Sfoglia il codice sorgente

- (Re-)introduction of event based multicast messages (not all yet)
- Use of Distinguished Names (DN) in API and multicast messages
- CSI resassignment properly handled (by using restarting state)
- State 'setter' functions with uniform printouts
- Simple 'assign SU to host' algorithm:
- based on saAmfSUHostedByNode config attribute
- see config file for example
- Debug print runtime attributes upon user request:
$ pkill -USR2 aisexec
- Object-oriented naming of functions started (but not finished)
- testamf1.c updated with some new tests
- Minor fix in print.h and print.c
- AMF can be started on two nodes (example config file needs
modification for this)



git-svn-id: http://svn.fedorahosted.org/svn/corosync/trunk@1058 fd59a12c-fef9-0310-b244-a6a79926bd2f

Hans Feldt 19 anni fa
parent
commit
ef284f2b30
10 ha cambiato i file con 543 aggiunte e 485 eliminazioni
  1. 40 34
      conf/amf.conf
  2. 381 336
      exec/amf.c
  3. 54 36
      exec/amfconfig.c
  4. 4 4
      exec/amfconfig.h
  5. 3 7
      exec/main.c
  6. 1 1
      exec/print.c
  7. 1 1
      exec/print.h
  8. 2 0
      include/ipc_amf.h
  9. 3 7
      test/clc_cli_script
  10. 54 59
      test/testamf1.c

+ 40 - 34
conf/amf.conf

@@ -3,16 +3,16 @@
 # - clccli_path can be set on any level from application and down and will be
 # added to the CLI commands if they are not already specified with an absolute
 # path (begins with /).
+# WL - WorkLoad
 
-safAmfCluster = test_cluster {
-	saAmfClusterStartupTimeout=10000
+safAmfCluster = TEST_CLUSTER {
+	saAmfClusterStartupTimeout=3000
 	safAmfNode = seasc0036 {
 		saAmfNodeSuFailOverProb=2000
 		saAmfNodeSuFailoverMax=2
 	}
-	safApp = test_app1 {
-		clccli_path=/tmp/ais/test
-		safSg = raid {
+	safApp = APP-1 {
+		safSg = RAID {
 			saAmfSGRedundancyModel=nplusm	
 			saAmfSGNumPrefActiveSUs=1
 			saAmfSGMaxActiveSIsperSUs=2
@@ -23,24 +23,25 @@ safAmfCluster = test_cluster {
 			saAmfSGSuRestartProb=20000	
 			saAmfSGSuRestartMax=6
 			saAmfSGAutoAdjustProb=5000
-			safSu = SU_1 {
+			safSu = SERVICE_X_1 {
+				saAmfSUHostedByNode=seasc0036
 				saAmfSUNumComponents=1
-				safComp = comp_a_in_su_1 {
+				safComp = A {
 					saAmfCompCategory=sa_aware
 					saAmfCompCapability=x_active_or_y_standby
 					saAmfCompNumMaxActiveCsi=1
 					saAmfCompNumMaxStandbyCsi=1
 					saAmfCompDefaultClcCliTimeout = 500
 					saAmfCompDefaultCallbackTimeOut = 500
-					saAmfCompInstantiateCmd = /tmp/ais/test/clc_cli_script
-					saAmfCompInstantiateCmdArgv= instantiate /tmp/ais/test/testamf1
-					saAmfCompTerminateCmd = /tmp/ais/test/clc_cli_script
+					saAmfCompInstantiateCmd = /tmp/aistest/clc_cli_script
+					saAmfCompInstantiateCmdArgv= instantiate /tmp/aistest/testamf1
+					saAmfCompTerminateCmd = /tmp/aistest/clc_cli_script
 					saAmfCompTerminateCmdArgv = terminate
-					saAmfCompCleanupCmd = /tmp/ais/test/clc_cli_script
+					saAmfCompCleanupCmd = /tmp/aistest/clc_cli_script
 					saAmfCompCleanupCmdArgv = cleanup
 					saAmfCompCsTypes {
-						for_comp_a_x
-						for_comp_a_y
+						A-1
+						A-2
 					}
 					saAmfCompCmdEnv {
 						var1=val1
@@ -53,28 +54,30 @@ safAmfCluster = test_cluster {
 					}
 				}
 			}
-			safSu = SU_2 {
+			safSu = SERVICE_X_2 {
+				clccli_path=/tmp/aistest
+				saAmfSUHostedByNode=seasc0036
 				saAmfSUNumComponents=1
-				safComp = comp_a_in_su_2 {
+				safComp = A {
 					saAmfCompCategory=sa_aware
 					saAmfCompCapability=x_active_or_y_standby
 					saAmfCompNumMaxActiveCsi=1
 					saAmfCompNumMaxStandbyCsi=1
 					saAmfCompDefaultClcCliTimeout = 500
 					saAmfCompDefaultCallbackTimeOut = 500
-					saAmfCompInstantiateCmd = /tmp/ais/test/clc_cli_script
+					saAmfCompInstantiateCmd = clc_cli_script
 					saAmfCompInstantiateCmdArgv= instantiate
-					saAmfCompTerminateCmd = /tmp/ais/test/clc_cli_script
+					saAmfCompTerminateCmd = clc_cli_script
 					saAmfCompTerminateCmdArgv = terminate
-					saAmfCompCleanupCmd = /tmp/ais/test/clc_cli_script
+					saAmfCompCleanupCmd = clc_cli_script
 					saAmfCompCleanupCmdArgv = cleanup
 					saAmfCompCsTypes {
-						for_comp_a_x
-						for_comp_a_y
+						A-1
+						A-2
 					}
 					saAmfCompCmdEnv {
-                        COMP_BINARY_PATH=/tmp/ais/test
-                        COMP_BINARY_NAME=testamf1
+						COMP_BINARY_PATH=/tmp/aistest
+						COMP_BINARY_NAME=testamf1
 					}
 					saAmfCompRecoveryOnError=component_restart
 					safHealthcheckKey = key1 {
@@ -88,15 +91,15 @@ safAmfCluster = test_cluster {
 				}
 			}
 		}
-		safSi = SI_1 {
+		safSi = WL1 {
 			saAmfSINumCSIs=2
-			safCsi = csi_ax_in_si_1 {
-				saAmfCSTypeName=for_comp_a_x
+			safCsi = WL1-1 {
+				saAmfCSTypeName = A-1
 			}
-			safCsi = csi_ay_in_si_1 {
-				saAmfCSTypeName = for_comp_a_y
+			safCsi = WL1-2 {
+				saAmfCSTypeName = A-2
 				saAmfCsiDependencies {
-					saAmfCSIDependency = csi_ax_in_si_1
+					saAmfCSIDependency = WL1-1
 				}
 				safCSIAttr = attr1 {
 					val1
@@ -113,20 +116,23 @@ safAmfCluster = test_cluster {
 				saAmfRank = 2
 			}
 		}
-		safSi = SI_2 {
+		safSi = WL2 {
 			saAmfSINumCSIs=1
-			safCsi = csi_b_in_si_2 {
-				saAmfCSTypeName=for_comp_a_x
+			safCsi = WL2-1 {
+				saAmfCSTypeName = A-1
 			}
-			safDepend = SI_1 {
+			safCsi = WL2-2 {
+				saAmfCSTypeName = A-2
+			}
+			safDepend = WL1 {
 				saAmfToleranceTime=10000
 			}
 		}
-		safCSType = for_comp_a_y {
+		safCSType = A-1 {
 			safAmfCSAttrName = attr1
 			safAmfCSAttrName = good_health_limit
 		}
-		safCSType = for_comp_a_x {
+		safCSType = A-2 {
 		}
 	}
 }

File diff suppressed because it is too large
+ 381 - 336
exec/amf.c


+ 54 - 36
exec/amfconfig.c

@@ -102,50 +102,55 @@ struct amf_healthcheck *amf_find_healthcheck (struct amf_comp *comp, SaAmfHealth
 struct amf_comp *amf_find_comp (struct amf_cluster *cluster, SaNameT *name)
 {
 	struct amf_application *app;
-	struct amf_sg *group;
-	struct amf_su *unit;
-	struct amf_comp *comp;
-
-	for (app = cluster->application_head; app != NULL; app = app->next) {
-		for (group = app->sg_head; group != NULL; group = group->next) {
-			for (unit = group->su_head; unit != NULL; unit = unit->next) {
-				for (comp = unit->comp_head; comp != NULL; comp = comp->next) {
-					if (name_match (name, &comp->name)) {
-						return comp;
-					}
-				}
-			}
-		}
+	struct amf_sg *sg;
+	struct amf_su *su;
+	struct amf_comp *comp = NULL;
+	char *app_name;
+	char *sg_name;
+	char *su_name;
+	char *comp_name;
+	char *ptrptr;
+	char *buf;
+
+	/* malloc new buffer since strtok_r writes to its first argument */
+	buf = malloc (name->length);
+	memcpy (buf, name->value,name ->length);
+
+	comp_name = strtok_r(buf, ",", &ptrptr);
+	su_name = strtok_r(NULL, ",", &ptrptr);
+	sg_name = strtok_r(NULL, ",", &ptrptr);
+	app_name = strtok_r(NULL, ",", &ptrptr);
+
+	if (comp_name == NULL || su_name == NULL || sg_name == NULL || app_name == NULL) {
+		goto end;
 	}
 
-	return (0);
-}
+	comp_name +=  8;
+	su_name += 6;
+	sg_name += 6;
+	app_name += 7;
 
-struct amf_su *amf_find_unit (struct amf_cluster *cluster, SaNameT *name)
-{
-	struct amf_application *app;
-	struct amf_sg *group;
-	struct amf_su *unit = 0;
-	int found = 0;
-
-	for (app = cluster->application_head;
-		  app != NULL && found == 0; app = app->next) {
-		for (group = app->sg_head;
-			  group != NULL && found == 0; group = group->next) {
-			for (unit = group->su_head;
-				  unit != NULL && found == 0; unit = unit->next) {
-				if (name_match (name, &unit->name)) {
-					found = 1;
+	for (app = cluster->application_head; app != NULL; app = app->next) {
+		if (strncmp (app_name, (char*)app->name.value, app->name.length) == 0) {
+			for (sg = app->sg_head; sg != NULL; sg = sg->next) {
+				if (strncmp (sg_name, (char*)sg->name.value, sg->name.length) == 0) {
+					for (su = sg->su_head; su != NULL; su = su->next) {
+						if (strncmp (su_name, (char*)su->name.value, su->name.length) == 0) {
+							for (comp = su->comp_head; comp != NULL; comp = comp->next) {
+								if (strncmp (comp_name, (char*)comp->name.value, comp->name.length) == 0) {
+									goto end;
+								}
+							}
+						}
+					}
 				}
 			}
 		}
 	}
 
-	if (found) {
-		return (unit);
-	} else {
-		return (0);
-	}
+end:
+	free (buf);
+	return comp;
 }
 
 static int init_category (struct amf_comp *comp, char *loc)
@@ -326,6 +331,7 @@ int amf_config_read (struct amf_cluster *cluster, char **error_string)
 	}
 
 	cluster->saAmfClusterStartupTimeout = -1;
+	cluster->saAmfClusterAdminState = SA_AMF_ADMIN_UNLOCKED;
 
 	while (fgets (buf, 255, fp)) {
 		line_number += 1;
@@ -372,6 +378,7 @@ int amf_config_read (struct amf_cluster *cluster, char **error_string)
 				node = calloc (1, sizeof (struct amf_node));
 				node->next = cluster->node_head;
 				cluster->node_head = node;
+				node->saAmfNodeAdminState = SA_AMF_ADMIN_UNLOCKED;
 				node->saAmfNodeAutoRepair = SA_TRUE;
 				node->cluster = cluster;
 				node->saAmfNodeSuFailOverProb = -1;
@@ -383,6 +390,7 @@ int amf_config_read (struct amf_cluster *cluster, char **error_string)
 				app->next = cluster->application_head;
 				cluster->application_head = app;
 				app->cluster = cluster;
+				app->saAmfApplicationAdminState = SA_AMF_ADMIN_UNLOCKED;
 				setSaNameT (&app->name, trim_str (loc));
 				current_parse = AMF_APPLICATION;
 			} else if (strstr_rs (line, "}")) {
@@ -451,6 +459,7 @@ int amf_config_read (struct amf_cluster *cluster, char **error_string)
 				sg = calloc (1, sizeof (struct amf_sg));
 				sg->next = app->sg_head;
 				app->sg_head = sg;
+				sg->saAmfSGAdminState = SA_AMF_ADMIN_UNLOCKED;
 				sg->saAmfSGNumPrefActiveSUs = 1;
 				sg->saAmfSGNumPrefStandbySUs = 1;
 				sg->saAmfSGCompRestartProb = -1;
@@ -470,6 +479,8 @@ int amf_config_read (struct amf_cluster *cluster, char **error_string)
 				si->saAmfSIPrefActiveAssignments = 1;
 				si->saAmfSIPrefStandbyAssignments = 1;
 				setSaNameT (&si->name, trim_str (loc));
+				si->saAmfSIAdminState = SA_AMF_ADMIN_UNLOCKED;
+				si->saAmfSIAssignmentState = SA_AMF_ASSIGNMENT_UNASSIGNED;
 				current_parse = AMF_SI;
 			} else if ((loc = strstr_rs (line, "safCSType=")) != 0) {
 				current_parse = AMF_CS_TYPE;
@@ -524,6 +535,7 @@ int amf_config_read (struct amf_cluster *cluster, char **error_string)
 				su->next = sg->su_head;
 				sg->su_head = su;
 				su->sg = sg;
+				su->saAmfSUAdminState = SA_AMF_ADMIN_UNLOCKED;
 				su->saAmfSUOperState = SA_AMF_OPERATIONAL_DISABLED;
 				su->saAmfSUPresenceState = SA_AMF_PRESENCE_UNINSTANTIATED;
 				su->escalation_level = ESCALATION_LEVEL_NO_ESCALATION;
@@ -574,6 +586,8 @@ int amf_config_read (struct amf_cluster *cluster, char **error_string)
 				su->saAmfSUFailover = atoi (loc);
 			} else if ((loc = strstr_rs (line, "clccli_path=")) != 0) {
 				strcpy (su->clccli_path, loc);
+			} else if ((loc = strstr_rs (line, "saAmfSUHostedByNode=")) != 0) {
+				setSaNameT (&su->saAmfSUHostedByNode, loc);
 			} else if ((loc = strstr_rs (line, "safComp=")) != 0) {
 				comp = new_comp (su);
 				comp_env_var_cnt = 0;
@@ -593,6 +607,10 @@ int amf_config_read (struct amf_cluster *cluster, char **error_string)
 					error_reason = "saAmfSUFailover erroneous";
 					goto parse_error;
 				}
+				if (strcmp ((char*)su->saAmfSUHostedByNode.value, "") == 0) {
+					error_reason = "saAmfSUHostedByNode missing";
+					goto parse_error;
+				}
 				current_parse = AMF_SG;
 			} else {
 				goto parse_error;

+ 4 - 4
exec/amfconfig.h

@@ -179,11 +179,11 @@ struct amf_su {
 	struct amf_si_assignment *assigned_sis;
 
 	/* Implementation */
+	int is_local;
 	char clccli_path[PATH_MAX];
 	char binary_path[PATH_MAX];
 	SaUint32T              su_failover_cnt; /* missing in SAF specs? */
 	enum escalation_levels escalation_level;
-	SaAmfHAStateT          requested_ha_state;
 	struct amf_su         *next;
 };
 
@@ -282,11 +282,10 @@ struct amf_si {
 	SaAmfAdminStateT saAmfSIAdminState;
 	SaAmfAssignmentStateT saAmfSIAssignmentState;
 	SaUint32T saAmfSINumCurrActiveAssignments;
-	SaUint32T saAmfSINumICurrStandbyAssignments;
+	SaUint32T saAmfSINumCurrStandbyAssignments;
 
 	/* Relations */
 	struct amf_application   *application;
-	struct amf_sg            *protects_sg;
 	struct amf_csi           *csi_head;
 	struct amf_si_assignment *si_assignments;
 	struct amf_si_dependency *depends_on;
@@ -327,8 +326,10 @@ struct amf_si_assignment {
 	SaAmfHAStateT saAmfSISUHAState;
 
 	/* Relations */
+	struct amf_si *si;
 
 	/* Implementation */
+	struct amf_si_assignment *next;
 };
 
 struct amf_csi {
@@ -371,7 +372,6 @@ struct amf_csi_assignment {
 };
 
 extern struct amf_comp *amf_find_comp (struct amf_cluster *cluster, SaNameT *name);
-extern struct amf_su *amf_find_unit (struct amf_cluster *cluster, SaNameT *name);
 extern struct amf_healthcheck *amf_find_healthcheck (struct amf_comp *comp, SaAmfHealthcheckKeyT *key);
 extern int amf_config_read (struct amf_cluster *cluster, char **error_string);
 

+ 3 - 7
exec/main.c

@@ -91,21 +91,16 @@ static char delivery_data[MESSAGE_SIZE_MAX];
 
 SaClmClusterNodeT *(*main_clm_get_by_nodeid) (unsigned int node_id);
 
-#ifdef COMPILE_OUT
 static void sigusr2_handler (int num)
 {
 	int i;
 
-	for (i = 0; i < AIS_SERVICE_HANDLERS_COUNT; i++) {
+	for (i = 0; ais_service[i]; i++) {
 		if (ais_service[i]->exec_dump_fn) {
 			ais_service[i]->exec_dump_fn ();
-		 }
+		}
 	}
-
-	signal (SIGUSR2 ,sigusr2_handler);
-	return;
 }
-#endif
 
 struct totem_ip_address *this_ip;
 struct totem_ip_address this_non_loopback_ip;
@@ -531,6 +526,7 @@ int main (int argc, char **argv)
 	aisexec_mempool_init ();
 
 	signal (SIGINT, sigintr_handler);
+	signal (SIGUSR2, sigusr2_handler);
 
 	openais_ipc_init (aisexec_poll_handle, gid_valid, &this_non_loopback_ip);
 

+ 1 - 1
exec/print.c

@@ -160,7 +160,7 @@ static void _log_printf (char *file, int line,
 	}
 
 	if ((level == LOG_LEVEL_DEBUG) || (logmode & LOG_MODE_FILELINE)) {
-		sprintf (&newstring[i], "[%s:%u] %s", file, line, format);
+		sprintf (&newstring[i], "[%s:%04u] %s", file, line, format);
 	} else {	
 		sprintf (&newstring[i], "[%-5s] %s", loggers[id].ident, format);
 	}

+ 1 - 1
exec/print.h

@@ -151,7 +151,7 @@ static inline void log_init (const char *ident)
 
 #define LEAVE(format, args...) do { \
     if (LOG_LEVEL_DEBUG <= loggers[logger_identifier].level)  { \
-		trace (__FILE__, __LINE__, TAG_LEAVE, logger_identifier, ">%s: " format, __FUNCTION__, ##args); \
+		trace (__FILE__, __LINE__, TAG_LEAVE, logger_identifier, "<%s: " format, __FUNCTION__, ##args); \
     } \
 } while(0)
 

+ 2 - 0
include/ipc_amf.h

@@ -202,6 +202,8 @@ struct req_lib_amf_componenterrorreport {
 	SaNameT reportingComponent;
 	SaNameT erroneousComponent;
 	SaTimeT errorDetectionTime;
+	SaAmfRecommendedRecoveryT recommendedRecovery;
+	SaNtfIdentifierT ntfIdentifier;
 };
 
 struct res_lib_amf_componenterrorreport {

+ 3 - 7
test/clc_cli_script

@@ -35,8 +35,7 @@
 instantiate() {
 	echo clc_cli_script instantiating component $SA_AMF_COMPONENT_NAME $1
 	./openais-instantiate $1
-	RETVAL=$?
-	return $RETVAL
+	exit $?
 }
 
 terminate() {
@@ -47,8 +46,7 @@ terminate() {
 	fi
 	echo clc_cli_script terminating up component $SA_AMF_COMPONENT_NAME on PID `cat $PIDFILEPATH/openais_cleanup_$SA_AMF_COMPONENT_NAME`
 	kill -15 `cat $PIDFILEPATH/openais_cleanup_$SA_AMF_COMPONENT_NAME`
-	RETVAL=$?
-	return $RETVAL
+	exit $?
 }
 
 cleanup() {
@@ -59,8 +57,7 @@ cleanup() {
 	fi
 	echo clc_cli_script cleaning up component $SA_AMF_COMPONENT_NAME on PID `cat $PIDFILEPATH/openais_cleanup_$SA_AMF_COMPONENT_NAME`
 	kill -9 `cat $PIDFILEPATH/openais_cleanup_$SA_AMF_COMPONENT_NAME`
-	RETVAL=$?
-	return $RETVAL
+	exit $?
 }
 
 usage() {
@@ -73,7 +70,6 @@ case "$1" in
 			instantiate $2
 		else 
 			instantiate $COMP_BINARY_PATH/$COMP_BINARY_NAME
-			exit 1
 		fi
 		;;
 

+ 54 - 59
test/testamf1.c

@@ -84,34 +84,19 @@ void HealthcheckCallback (SaInvocationT invocation,
 
 	if( !good_health && healthcheck_no++);
 
-
-/*
-	printf ("Healthcheck %u for key '%s' for component ",
-		healthcheck_no, healthcheckKey->key);
-
-	printSaNameT ((SaNameT *)compName);
-	printf ("\n");
-*/
 	if (healthcheck_no == good_health_limit ) {
-printf ("COMPONENT REPORTING ERROR %s\n", compNameGlobal.value);
+        res = saAmfResponse (handle, invocation, SA_AIS_OK);
+        res = saAmfHealthcheckStop (handle,
+                                       &compNameGlobal,
+                                       &key0);
+        printf ("healthcheck stop result %d (should be %d)\n", res, SA_AIS_OK);
+
+        printf ("COMPONENT REPORTING ERROR %s\n", compNameGlobal.value);
 		saAmfComponentErrorReport (handle, compName, 0, SA_AMF_COMPONENT_RESTART, 0);
-		res = saAmfResponse (handle, invocation, SA_AIS_OK);
-printf ("COMPONENT DONE REPORTING ERROR\n");
+        printf ("COMPONENT DONE REPORTING ERROR\n");
 	} else {
 		res = saAmfResponse (handle, invocation, SA_AIS_OK);
 	}
-
-/*
-	if (healthcheck_no < good_health_limit) {
-		res = saAmfResponse (handle, invocation, SA_AIS_OK);
-	}
-*/
-/*
-	if (healthcheck_no == good_health_limit) {
-		res = saAmfHealthcheckStop (handle, &compNameGlobal, &key0);
-		stop = 1;
-	}
-*/
 }
 
 void ComponentTerminateCallback (
@@ -123,7 +108,7 @@ void ComponentTerminateCallback (
 	exit (0);
 }
 
-#if 1
+#if 0
     #include <sys/time.h>
     #define TRU "%d"
     #define TRS "%s" 
@@ -150,28 +135,22 @@ void CSISetCallback (
 	int res;
 	switch (haState) {
 	case SA_AMF_HA_ACTIVE:
-		printf ("CSISetCallback:"); 
-		printf ("for CSI '");
-		printSaNameT ((SaNameT *)&csiDescriptor->csiName);
-		printf ("' for component ");
-		printSaNameT ((SaNameT *)compName);
-		printf ("'");
- 		printf (" requested to enter hastate SA_AMF_ACTIVE for CSI %s\n",
-				csiDescriptor->csiName.value);
+		printf ("Component '%s' requested to enter hastate SA_AMF_ACTIVE for \n\tCSI '%s'\n",
+			compName->value, csiDescriptor->csiName.value);
 		res = saAmfResponse (handle, invocation, SA_AIS_OK);
 		int i;
 		TR(TRU, csiDescriptor->csiAttr.number);
 		for(i=0; i<csiDescriptor->csiAttr.number; i++) {
 
 		    if( strcmp((char*)csiDescriptor->csiAttr.attr[i].attrName, "good_health_limit") == 0){
-			good_health = strcmp((char*)csiDescriptor->csiAttr.attr[i].attrValue, "0") ? 0 : 1;
-			good_health_limit = atoi((char*)csiDescriptor->csiAttr.attr[i].attrValue);
+				good_health = strcmp((char*)csiDescriptor->csiAttr.attr[i].attrValue, "0") ? 0 : 1;
+				good_health_limit = atoi((char*)csiDescriptor->csiAttr.attr[i].attrValue);
 			
 		    }
-
- 
+#if 0
 		    TR(TRS,csiDescriptor->csiAttr.attr[i].attrName);
 		    TR(TRS, csiDescriptor->csiAttr.attr[i].attrValue);
+#endif
 		} 
 
 		TR(TRU, csiDescriptor->csiFlags);
@@ -183,14 +162,8 @@ void CSISetCallback (
 		break;  
          
 	case SA_AMF_HA_STANDBY:
-		printf ("CSISetCallback:"); 
-		printf ("for CSI '");
-		printSaNameT ((SaNameT *)&csiDescriptor->csiName);
-		printf ("' for component ");
-		printSaNameT ((SaNameT *)compName);
-		printf ("'");
-		printf (" requested to enter hastate SA_AMF_STANDBY for CSI %s\n",
-				csiDescriptor->csiName.value);
+		printf ("Component '%s' requested to enter hastate SA_AMF_STANDBY for \n\tCSI '%s'\n",
+			compName->value, csiDescriptor->csiName.value);
 		res = saAmfResponse (handle, invocation, SA_AIS_OK);
 		
 		TR(TRU,csiDescriptor->csiAttr.number);
@@ -302,6 +275,21 @@ int main (int argc, char **argv) {
 	fd_set read_fds;
 	extern char *optarg;
 	extern int optind;
+	char *name = getenv ("SA_AMF_COMPONENT_NAME");
+
+	/* test that it exist */
+	if (name == NULL) {
+		fprintf(stderr, "SA_AMF_COMPONENT_NAME missing\n");
+		exit (-1);
+	}
+
+	/* test for correct value */
+	if (strstr (name, "safComp=A,safSu=SERVICE_X_") == NULL) {
+		fprintf(stderr, "SA_AMF_COMPONENT_NAME value wrong\n");
+		exit (-2);
+	}
+
+	printf("Hello world from %s\n", name);
 
 	signal (SIGINT, sigintr_handler);
 #if defined(OPENAIS_BSD) || defined(OPENAIS_LINUX)
@@ -323,26 +311,33 @@ int main (int argc, char **argv) {
 	saAmfComponentNameGet (handle, &compNameGlobal);
 	write_pid ();
 	
-
 	result = saAmfHealthcheckStart (handle,
 		&compNameGlobal,
 		&key0,
 		SA_AMF_HEALTHCHECK_AMF_INVOKED,
 		SA_AMF_COMPONENT_FAILOVER);
-	printf ("healthcheck start result %d (should be 1)\n", result);
-
-	/*
-	 * Test already started healthcheck
-	 */
-	result = saAmfHealthcheckStart (handle,
-		&compNameGlobal,
-		&key0,
-		SA_AMF_HEALTHCHECK_AMF_INVOKED,
-		SA_AMF_COMPONENT_FAILOVER);
-	printf ("healthcheck start result %d (should be 14)\n", result);
-
-	result = saAmfComponentRegister (handle, &compNameGlobal, NULL);
-	printf ("register result is %d (should be 1)\n", result);
+    printf ("healthcheck start result %d (should be %d)\n", result, SA_AIS_OK);
+
+    {
+        SaNameT badname;
+        strcpy (badname.value, "badname");
+        badname.length = 7;
+        result = saAmfComponentRegister (handle, &badname, NULL);
+        printf ("register result is %d (should be %d)\n", result, SA_AIS_ERR_INVALID_PARAM);
+    }
+
+    result = saAmfComponentRegister (handle, &compNameGlobal, NULL);
+    printf ("register result is %d (should be %d)\n", result, SA_AIS_OK);
+
+    /*
+     * Test already started healthcheck
+     */
+    result = saAmfHealthcheckStart (handle,
+        &compNameGlobal,
+        &key0,
+        SA_AMF_HEALTHCHECK_AMF_INVOKED,
+        SA_AMF_COMPONENT_FAILOVER);
+    printf ("healthcheck start result %d (should be %d)\n", result, SA_AIS_ERR_EXIST);
 
 	do {
 		select (select_fd + 1, &read_fds, 0, 0, 0);

Some files were not shown because too many files changed in this diff