osaf/services/saf/amf/amfnd/compdb.cc |  52 ++++++++++++++++++++++------------
 1 files changed, 34 insertions(+), 18 deletions(-)


diff --git a/osaf/services/saf/amf/amfnd/compdb.cc 
b/osaf/services/saf/amf/amfnd/compdb.cc
--- a/osaf/services/saf/amf/amfnd/compdb.cc
+++ b/osaf/services/saf/amf/amfnd/compdb.cc
@@ -956,10 +956,10 @@ static amf_comp_type_t *avnd_comptype_cr
        if (immutil_getAttr(const_cast<SaImmAttrNameT>("saAmfCtCompCategory"), 
attributes, 0, &compt->saAmfCtCompCategory) != SA_AIS_OK)
                osafassert(0);
 
-       if (IS_COMP_LOCAL(compt->saAmfCtCompCategory) && 
-           immutil_getAttr(const_cast<SaImmAttrNameT>("saAmfCtSwBundle"), 
attributes, 0, &compt->saAmfCtSwBundle) != SA_AIS_OK) {
-               osafassert(0);
-               return NULL;    
+       if (IS_COMP_LOCAL(compt->saAmfCtCompCategory)) {
+               // Ignore if not found, commands can be specified with absolute 
path
+               immutil_getAttr(const_cast<SaImmAttrNameT>("saAmfCtSwBundle"),
+                       attributes, 0, &compt->saAmfCtSwBundle);
        }
 
         
immutil_getAttrValuesNumber(const_cast<SaImmAttrNameT>("saAmfCtDefCmdEnv"), 
attributes, &j);
@@ -1170,18 +1170,17 @@ done:
 }
 
 /**
- * Initialize the bundle dependent attributes in comp (the
- * CLC-CLI commands).
+ * Initializes the CLC-CLI commands in a component.
  * 
- * If path in comptype for AM & HC scripts is absolute it is
- * used, else (it is relative) it is prepended with path prefix.
+ * If path in comptype is absolute it is used, else (it is relative) it is
+ * prepended with path prefix.
  * 
  * @param comp
  * @param comptype
  * @param path_prefix
  * @param attributes
  */
-static void init_bundle_dependent_attributes(AVND_COMP *comp,
+static void init_clc_cli_commands(AVND_COMP *comp,
                                const amf_comp_type_t *comptype,
                                const char *path_prefix,
                                const SaImmAttrValuesT_2 **attributes)
@@ -1194,8 +1193,13 @@ static void init_bundle_dependent_attrib
        cmd = &comp->clc_info.cmds[AVND_COMP_CLC_CMD_TYPE_INSTANTIATE - 1];
        if (comptype->saAmfCtRelPathInstantiateCmd != NULL) {
                i = 0;
-               i += snprintf(&cmd->cmd[i], sizeof(cmd->cmd) - i, "%s/%s",
-                       path_prefix, comptype->saAmfCtRelPathInstantiateCmd);
+
+               if (comptype->saAmfCtRelPathInstantiateCmd[0] == '/')
+                       i += snprintf(&cmd->cmd[i], sizeof(cmd->cmd) - i, "%s",
+                               comptype->saAmfCtRelPathInstantiateCmd);
+               else
+                       i += snprintf(&cmd->cmd[i], sizeof(cmd->cmd) - i, 
"%s/%s",
+                               path_prefix, 
comptype->saAmfCtRelPathInstantiateCmd);
 
                j = 0;
                while ((argv = comptype->saAmfCtDefInstantiateCmdArgv[j++]) != 
NULL)
@@ -1215,8 +1219,13 @@ static void init_bundle_dependent_attrib
        cmd = &comp->clc_info.cmds[AVND_COMP_CLC_CMD_TYPE_TERMINATE - 1];
        if (comptype->saAmfCtRelPathTerminateCmd != NULL) {
                i = 0;
-               i += snprintf(&cmd->cmd[i], sizeof(cmd->cmd) - i, "%s/%s",
-                       path_prefix, comptype->saAmfCtRelPathTerminateCmd);
+
+               if (comptype->saAmfCtRelPathTerminateCmd[0] == '/')
+                       i += snprintf(&cmd->cmd[i], sizeof(cmd->cmd) - i, "%s",
+                               comptype->saAmfCtRelPathTerminateCmd);
+               else
+                       i += snprintf(&cmd->cmd[i], sizeof(cmd->cmd) - i, 
"%s/%s",
+                               path_prefix, 
comptype->saAmfCtRelPathTerminateCmd);
 
                j = 0;
                while ((argv = comptype->saAmfCtDefTerminateCmdArgv[j++]) != 
NULL)
@@ -1236,8 +1245,13 @@ static void init_bundle_dependent_attrib
        cmd = &comp->clc_info.cmds[AVND_COMP_CLC_CMD_TYPE_CLEANUP - 1];
        if (comptype->saAmfCtRelPathCleanupCmd != NULL) {
                i = 0;
-               i += snprintf(&cmd->cmd[i], sizeof(cmd->cmd) - i, "%s/%s",
-                       path_prefix, comptype->saAmfCtRelPathCleanupCmd);
+
+               if (comptype->saAmfCtRelPathCleanupCmd[0] == '/')
+                       i += snprintf(&cmd->cmd[i], sizeof(cmd->cmd) - i, "%s",
+                               comptype->saAmfCtRelPathCleanupCmd);
+               else
+                       i += snprintf(&cmd->cmd[i], sizeof(cmd->cmd) - i, 
"%s/%s",
+                               path_prefix, 
comptype->saAmfCtRelPathCleanupCmd);
 
                j = 0;
                while ((argv = comptype->saAmfCtDefCleanupCmdArgv[j++]) != NULL)
@@ -1383,9 +1397,11 @@ static int comp_init(AVND_COMP *comp, co
        res = get_string_attr_from_imm(immOmHandle, 
const_cast<SaImmAttrNameT>("saAmfNodeSwBundlePathPrefix"),
                &nodeswbundle_name, &path_prefix);
 
-       if (res == 0) {
-               init_bundle_dependent_attributes(comp, comptype, path_prefix, 
attributes);
-       } else {
+       // Initialize commands also when path prefix is not found
+       init_clc_cli_commands(comp, comptype, path_prefix, attributes);
+
+       // Treat missing path prefix as an error only if command is not absolute
+       if ((res != 0) && (comptype->saAmfCtRelPathCleanupCmd[0] != '/')) {
                if (bundle_missing_is_error) {
                        LOG_NO("%s: '%s'", __FUNCTION__, comp->name.value);
                        LOG_ER("%s: FAILED to read '%s'", __FUNCTION__, 
nodeswbundle_name.value);

------------------------------------------------------------------------------
Rapidly troubleshoot problems before they affect your business. Most IT 
organizations don't have a clear picture of how application performance 
affects their revenue. With AppDynamics, you get 100% visibility into your 
Java,.NET, & PHP application. Start your 15-day FREE TRIAL of AppDynamics Pro!
http://pubads.g.doubleclick.net/gampad/clk?id=84349831&iu=/4140/ostg.clktrk
_______________________________________________
Opensaf-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/opensaf-devel

Reply via email to