---
src/amf/amfnd/avnd_comp.h | 77 ++++++++++++++++---------------
src/amf/amfnd/avnd_err.h | 1 +
src/amf/amfnd/avnd_hc.h | 1 +
src/amf/amfnd/avnd_proc.h | 1 +
src/amf/amfnd/avnd_su.h | 1 +
src/amf/amfnd/avnd_tmr.h | 7 +--
src/amf/amfnd/avnd_util.h | 1 +
src/amf/amfnd/cam.cc | 3 +-
src/amf/amfnd/chc.cc | 3 +-
src/amf/amfnd/clc.cc | 35 ++++++++------
src/amf/amfnd/comp.cc | 51 ++++++++++++++++++++-
src/amf/amfnd/compdb.cc | 113 +++++++++++++++-------------------------------
src/amf/amfnd/err.cc | 1 +
src/amf/amfnd/proxydb.cc | 1 +
src/amf/amfnd/su.cc | 1 +
src/amf/amfnd/sudb.cc | 3 +-
src/amf/amfnd/susm.cc | 2 +-
src/amf/amfnd/tmr.cc | 1 +
src/amf/amfnd/util.cc | 1 +
19 files changed, 167 insertions(+), 137 deletions(-)
diff --git a/src/amf/amfnd/avnd_comp.h b/src/amf/amfnd/avnd_comp.h
index a2fc22691..4b735138e 100644
--- a/src/amf/amfnd/avnd_comp.h
+++ b/src/amf/amfnd/avnd_comp.h
@@ -1,6 +1,7 @@
/* -*- OpenSAF -*-
*
* (C) Copyright 2008 The OpenSAF Foundation
+ * (C) Copyright 2017 Ericsson AB - All Rights Reserved.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
@@ -33,11 +34,14 @@
#include <bitset>
#include <string>
#include <map>
+#include <vector>
+#include "avnd_tmr.h"
struct avnd_cb_tag;
struct avnd_su_si_rec;
class AVND_SU;
struct avnd_srm_req_tag;
+class AVND_COMP;
/***************************************************************************
********** S T R U C T U R E / E N U M D E F I N I T I O N S ***********
@@ -90,16 +94,42 @@ typedef enum avnd_comp_clc_cmd_type {
} AVND_COMP_CLC_CMD_TYPE;
/* clc command parameter definition */
-typedef struct avnd_comp_clc_param {
- char cmd[SAAMF_CLC_LEN]; /* cmd ascii string */
- SaTimeT timeout; /* cmd timeout value */
- uint32_t len; /* cmd len */
-} AVND_COMP_CLC_CMD_PARAM;
+struct CompClcCmdParam {
+ void init_clc_cli_command(const char *clc_cmd, char **clc_cmd_argv,
+ const SaImmAttrValuesT_2 **attributes,
+ const char *attr_name);
+ std::string cmd;
+ std::vector<std::string> cmd_argv; /* cmd argv */
+ SaTimeT timeout; /* cmd timeout value */
+};
/* clc info definition (top level wrapper structure) */
-typedef struct avnd_comp_clc_info {
- /* clc commands (indexed by cmd type) */
- AVND_COMP_CLC_CMD_PARAM cmds[AVND_COMP_CLC_CMD_TYPE_MAX - 1];
+struct CompClcInfo {
+ std::map<AVND_COMP_CLC_CMD_TYPE, CompClcCmdParam> cmds;
+ std::string get_cmd(AVND_COMP_CLC_CMD_TYPE cmd_type);
+
+ template<std::size_t Size>
+ void create_argv(std::array<char*, Size> &argv, uint32_t &argc,
AVND_COMP_CLC_CMD_TYPE cmd_type) {
+ std::string delimiter {' '};
+ argc = 0;
+ std::string str = saAmfNodeSwBundlePathPrefix + cmds[cmd_type].cmd;
+ size_t start = 0;
+ size_t end = 0;
+
+ while (end != std::string::npos) {
+ if (argc >= argv.size()) {
+ LOG_WA("Too many arguments given, max %zu arguments are supported",
argv.size());
+ break;
+ }
+
+ end = str.find(delimiter, start);
+ std::string tmp = str.substr(start, (end == std::string::npos) ?
std::string::npos : end - start);
+ argv[argc++] = strdup(tmp.data());
+ start = ((end > (std::string::npos - delimiter.size())) ?
std::string::npos : end + delimiter.size());
+ }
+ }
+
+ std::string saAmfNodeSwBundlePathPrefix;
uint32_t inst_retry_max; /* configured no of instantiate retry attempts */
uint32_t inst_retry_cnt; /* curr no of instantiate retry attempts */
@@ -123,7 +153,7 @@ typedef struct avnd_comp_clc_info {
uint32_t inst_code_rcvd; /* Store the error value
received from the instantiate script */
-} AVND_COMP_CLC_INFO;
+};
/*##########################################################################
COMPONENT CALLBACK DEFINITIONS
@@ -341,7 +371,7 @@ class AVND_COMP {
bool is_hc_cmd_configured {};
/* clc info */
- AVND_COMP_CLC_INFO clc_info {};
+ CompClcInfo clc_info {};
/* Update received flag, which will normally be false and will be
* true if updates are received from the AVD on fail-over.*/
@@ -684,33 +714,6 @@ class AVND_COMP {
void m_AVND_COMP_OPER_STATE_AVD_SYNC(struct avnd_cb_tag *cb,
const AVND_COMP *comp, uint32_t &o_rc);
-/* macro to parse the clc cmd string */
-#define m_AVND_COMP_CLC_STR_PARSE(st, sc, ac, av, tav) \
- { \
- char str[SAAMF_CLC_LEN], *tok = nullptr; \
- /* copy the str as strtok modifies the original str */ \
- strcpy(str, st); \
- ac = 0; \
- if (nullptr != (tok = strtok(str, " "))) { \
- strncpy(sc, tok, SAAMF_CLC_LEN - 1); \
- av[ac] = sc; \
- } \
- ac++; \
- while ((nullptr != (tok = strtok(nullptr, " "))) && \
- (ac < (AVND_COMP_CLC_PARAM_MAX + 1))) { \
- if (strlen(tok) > AVND_COMP_CLC_PARAM_SIZE_MAX) break; \
- strcpy(tav[ac], tok); \
- av[ac] = tav[ac]; \
- ac++; \
- } \
- if (nullptr != tok) { \
- sc[0] = (char)(long)nullptr; \
- av[0] = nullptr; \
- ac = 0; \
- } else \
- av[ac] = nullptr; \
- }
-
/* macros for comp proxy status */
#define m_AVND_COMP_PROXY_STATUS_SET(x, val) (((x)->proxy_status = val))
diff --git a/src/amf/amfnd/avnd_err.h b/src/amf/amfnd/avnd_err.h
index 76f968927..321bb28d8 100644
--- a/src/amf/amfnd/avnd_err.h
+++ b/src/amf/amfnd/avnd_err.h
@@ -1,6 +1,7 @@
/* -*- OpenSAF -*-
*
* (C) Copyright 2008 The OpenSAF Foundation
+ * (C) Copyright 2017 Ericsson AB - All Rights Reserved.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
diff --git a/src/amf/amfnd/avnd_hc.h b/src/amf/amfnd/avnd_hc.h
index cc51304b5..0369cbdc8 100644
--- a/src/amf/amfnd/avnd_hc.h
+++ b/src/amf/amfnd/avnd_hc.h
@@ -1,6 +1,7 @@
/* -*- OpenSAF -*-
*
* (C) Copyright 2008 The OpenSAF Foundation
+ * (C) Copyright 2017 Ericsson AB - All Rights Reserved.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
diff --git a/src/amf/amfnd/avnd_proc.h b/src/amf/amfnd/avnd_proc.h
index a65ae948f..3adf47ba0 100644
--- a/src/amf/amfnd/avnd_proc.h
+++ b/src/amf/amfnd/avnd_proc.h
@@ -1,6 +1,7 @@
/* -*- OpenSAF -*-
*
* (C) Copyright 2008 The OpenSAF Foundation
+ * (C) Copyright 2017 Ericsson AB - All Rights Reserved.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
diff --git a/src/amf/amfnd/avnd_su.h b/src/amf/amfnd/avnd_su.h
index c7ba25718..e66109e5c 100644
--- a/src/amf/amfnd/avnd_su.h
+++ b/src/amf/amfnd/avnd_su.h
@@ -1,6 +1,7 @@
/* -*- OpenSAF -*-
*
* (C) Copyright 2008 The OpenSAF Foundation
+ * (C) Copyright 2017 Ericsson AB - All Rights Reserved.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
diff --git a/src/amf/amfnd/avnd_tmr.h b/src/amf/amfnd/avnd_tmr.h
index 400b44c70..ce7e2869c 100644
--- a/src/amf/amfnd/avnd_tmr.h
+++ b/src/amf/amfnd/avnd_tmr.h
@@ -1,6 +1,7 @@
/* -*- OpenSAF -*-
*
* (C) Copyright 2008 The OpenSAF Foundation
+ * (C) Copyright 2017 Ericsson AB - All Rights Reserved.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
@@ -96,7 +97,7 @@ typedef struct avnd_tmr {
start = (comp).clc_info.inst_cmd_ts;
\
m_GET_TIME_STAMP(curr);
\
per =
\
- (comp).clc_info.cmds[AVND_COMP_CLC_CMD_TYPE_INSTANTIATE - 1].timeout -
\
+ (comp).clc_info.cmds[AVND_COMP_CLC_CMD_TYPE_INSTANTIATE].timeout - \
(curr - start);
\
(rc) = avnd_start_tmr((cb), &(comp).clc_info.clc_reg_tmr,
\
AVND_TMR_CLC_COMP_REG, per, (comp).comp_hdl);
\
@@ -137,7 +138,7 @@ void tmr_node_err_esc_stop(avnd_cb_tag *cb);
{
\
SaTimeT per = 0;
\
per =
\
- (comp).clc_info.cmds[AVND_COMP_CLC_CMD_TYPE_INSTANTIATE - 1].timeout;
\
+ (comp).clc_info.cmds[AVND_COMP_CLC_CMD_TYPE_INSTANTIATE].timeout; \
(rc) = avnd_start_tmr((cb), &(comp).clc_info.clc_reg_tmr,
\
AVND_TMR_CLC_PXIED_COMP_INST, per, (comp).comp_hdl);
\
};
@@ -151,7 +152,7 @@ void tmr_node_err_esc_stop(avnd_cb_tag *cb);
{
\
SaTimeT per = 0;
\
per =
\
- (comp).clc_info.cmds[AVND_COMP_CLC_CMD_TYPE_INSTANTIATE - 1].timeout;
\
+ (comp).clc_info.cmds[AVND_COMP_CLC_CMD_TYPE_INSTANTIATE].timeout; \
(rc) = avnd_start_tmr((cb), &(comp).orph_tmr, AVND_TMR_CLC_PXIED_COMP_REG,
\
per, (comp).comp_hdl);
\
};
diff --git a/src/amf/amfnd/avnd_util.h b/src/amf/amfnd/avnd_util.h
index 687e69d54..cff33a789 100644
--- a/src/amf/amfnd/avnd_util.h
+++ b/src/amf/amfnd/avnd_util.h
@@ -1,6 +1,7 @@
/* -*- OpenSAF -*-
*
* (C) Copyright 2008 The OpenSAF Foundation
+ * (C) Copyright 2017 Ericsson AB - All Rights Reserved.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
diff --git a/src/amf/amfnd/cam.cc b/src/amf/amfnd/cam.cc
index 7c7a13d4c..21253d714 100644
--- a/src/amf/amfnd/cam.cc
+++ b/src/amf/amfnd/cam.cc
@@ -1,6 +1,7 @@
/* -*- OpenSAF -*-
*
* (C) Copyright 2008 The OpenSAF Foundation
+ * (C) Copyright 2017 Ericsson AB - All Rights Reserved.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
@@ -49,7 +50,7 @@
Notes : None.
******************************************************************************/
uint32_t avnd_comp_am_start(AVND_CB *cb, AVND_COMP *comp) {
- AVND_COMP_CLC_INFO *clc_info = &comp->clc_info;
+ CompClcInfo *clc_info = &comp->clc_info;
AVND_ERR_INFO err;
uint32_t rc = NCSCC_RC_SUCCESS;
diff --git a/src/amf/amfnd/chc.cc b/src/amf/amfnd/chc.cc
index 3cae877c1..7c1d93632 100644
--- a/src/amf/amfnd/chc.cc
+++ b/src/amf/amfnd/chc.cc
@@ -1,6 +1,7 @@
/* -*- OpenSAF -*-
*
* (C) Copyright 2008 The OpenSAF Foundation
+ * (C) Copyright 2017 Ericsson AB - All Rights Reserved.
* Copyright (C) 2017, Oracle and/or its affiliates. All rights reserved.
*
* This program is distributed in the hope that it will be useful, but
@@ -767,7 +768,7 @@ uint32_t avnd_comp_hc_cmd_start(AVND_CB *cb, AVND_COMP
*comp) {
if (rec) {
// timeout for the HC cmd is HC duration
- comp->clc_info.cmds[AVND_COMP_CLC_CMD_TYPE_HC - 1].timeout = rec->max_dur;
+ comp->clc_info.cmds[AVND_COMP_CLC_CMD_TYPE_HC].timeout = rec->max_dur;
// be nice and allow the component to start properly by just starting the
// timer here and do first health check at timeout instead
diff --git a/src/amf/amfnd/clc.cc b/src/amf/amfnd/clc.cc
index b6db14ac8..43f3bec39 100644
--- a/src/amf/amfnd/clc.cc
+++ b/src/amf/amfnd/clc.cc
@@ -1,6 +1,7 @@
/* -*- OpenSAF -*-
*
* (C) Copyright 2008 The OpenSAF Foundation
+ * (C) Copyright 2017 Ericsson AB - All Rights Reserved.
* Copyright (C) 2017, Oracle and/or its affiliates. All rights reserved.
*
* This program is distributed in the hope that it will be useful, but
@@ -35,6 +36,7 @@
#include <cinttypes>
#include <string.h>
+#include <array>
#include "base/logtrace.h"
#include "base/daemon.h"
@@ -271,20 +273,18 @@ static const char
*str_exec_status(NCS_OS_PROC_EXEC_STATUS status) {
*/
static void log_failed_exec(NCS_OS_PROC_EXEC_STATUS_INFO *exec_stat,
AVND_COMP *comp, AVND_COMP_CLC_CMD_TYPE exec_cmd) {
- osafassert(exec_cmd <= AVND_COMP_CLC_CMD_TYPE_MAX);
-
LOG_NO("Reason:'%s'", str_exec_status(exec_stat->value));
if (NCS_OS_PROC_EXIT_WITH_CODE == exec_stat->value)
LOG_NO("Exit code: %u", exec_stat->info.exit_with_code.exit_code);
if (NCS_OS_PROC_EXEC_FAIL == exec_stat->value)
- LOG_NO("CLC CLI script:'%s'", comp->clc_info.cmds[exec_cmd - 1].cmd);
+ LOG_NO("CLC CLI script:'%s'", comp->clc_info.get_cmd(exec_cmd).data());
if (NCS_OS_PROC_EXIT_ON_SIGNAL == exec_stat->value)
LOG_NO("Signal: %u, CLC CLI script:'%s'",
exec_stat->info.exit_on_signal.signal_num,
- comp->clc_info.cmds[exec_cmd - 1].cmd);
+ comp->clc_info.get_cmd(exec_cmd).data());
}
/****************************************************************************
@@ -1416,7 +1416,7 @@ uint32_t avnd_comp_clc_st_chng_prc(AVND_CB *cb, AVND_COMP
*comp,
/* mds dest & hdl might have changed */
curr_rec->dest = comp->reg_dest;
curr_rec->timeout =
- comp->clc_info.cmds[AVND_COMP_CLC_CMD_TYPE_INSTANTIATE -
1].timeout;
+ comp->clc_info.cmds[AVND_COMP_CLC_CMD_TYPE_INSTANTIATE].timeout;
curr_rec->cbk_info->hdl = comp->reg_hdl;
/* send it */
@@ -1870,7 +1870,7 @@ static bool
is_failed_comp_eligible_for_instantiation(AVND_COMP *comp) {
Notes : None.
******************************************************************************/
uint32_t avnd_comp_clc_xxxing_cleansucc_hdler(AVND_CB *cb, AVND_COMP *comp) {
- AVND_COMP_CLC_INFO *clc_info = &comp->clc_info;
+ CompClcInfo *clc_info = &comp->clc_info;
uint32_t rc = NCSCC_RC_SUCCESS;
TRACE_ENTER2(
"'%s': Cleanup success event in the instantiating/restarting state",
@@ -2936,10 +2936,11 @@ uint32_t avnd_comp_clc_cmd_execute(AVND_CB *cb,
AVND_COMP *comp,
AVND_CLC_EVT *clc_evt;
AVND_EVT *evt = 0;
- AVND_COMP_CLC_INFO *clc_info = &comp->clc_info;
- char scr[SAAMF_CLC_LEN];
- char *argv[AVND_COMP_CLC_PARAM_MAX + 2];
- char tmp_argv[AVND_COMP_CLC_PARAM_MAX + 2][AVND_COMP_CLC_PARAM_SIZE_MAX];
+ CompClcInfo *clc_info = &comp->clc_info;
+ std::array<char*, AVND_COMP_CLC_PARAM_MAX + 2> argv_arr {};
+
+ char **argv;
+
uint32_t argc = 0, rc = NCSCC_RC_SUCCESS, count = 0;
TRACE_ENTER2("'%s':CLC CLI command type:'%s'", comp->name.c_str(),
@@ -3036,15 +3037,14 @@ uint32_t avnd_comp_clc_cmd_execute(AVND_CB *cb,
AVND_COMP *comp,
}
comp->create_ncs_env_arg(&arg);
+ comp->clc_info.create_argv(argv_arr, argc, cmd_type);
- /* tokenize the cmd */
- m_AVND_COMP_CLC_STR_PARSE(clc_info->cmds[cmd_type - 1].cmd, scr, argc, argv,
- tmp_argv);
+ argv = argv_arr.data();
/* populate the cmd-info */
cmd_info.i_script = argv[0];
cmd_info.i_argv = argv;
- cmd_info.i_timeout_in_ms = ((clc_info->cmds[cmd_type - 1].timeout) /
1000000);
+ cmd_info.i_timeout_in_ms = ((clc_info->cmds[cmd_type].timeout) / 1000000);
cmd_info.i_cb = comp_clc_resp_callback;
cmd_info.i_set_env_args = &arg;
cmd_info.i_usr_hdl = (NCS_EXEC_USR_HDL)clc_evt;
@@ -3056,7 +3056,7 @@ uint32_t avnd_comp_clc_cmd_execute(AVND_CB *cb, AVND_COMP
*comp,
TRACE_1("CLC CLI command timeout: In nano secs:%lld In milli secs: %" PRId64
"",
- clc_info->cmds[cmd_type - 1].timeout, cmd_info.i_timeout_in_ms);
+ clc_info->cmds[cmd_type].timeout, cmd_info.i_timeout_in_ms);
for (count = 0; count < cmd_info.i_set_env_args->num_args; count++)
TRACE_1("CLC CLI command env variable name = '%s': value ='%s'",
@@ -3066,6 +3066,11 @@ uint32_t avnd_comp_clc_cmd_execute(AVND_CB *cb,
AVND_COMP *comp,
/* finally execute the command */
rc = ncs_os_process_execute_timed(&cmd_info);
+ // Free argv data
+ for (char **p = argv_arr.data(); *p != nullptr; ++p) {
+ delete [] *p;
+ }
+
/* Remove the env_set structure */
for (unsigned int i = 0; i < arg.num_args; i++) {
free(arg.env_arg[i].name);
diff --git a/src/amf/amfnd/comp.cc b/src/amf/amfnd/comp.cc
index f052f9992..b04d9b0c7 100644
--- a/src/amf/amfnd/comp.cc
+++ b/src/amf/amfnd/comp.cc
@@ -1,6 +1,7 @@
/* -*- OpenSAF -*-
*
* (C) Copyright 2008 The OpenSAF Foundation
+ * (C) Copyright 2017 Ericsson AB - All Rights Reserved.
* Copyright (C) 2017, Oracle and/or its affiliates. All rights reserved.
*
* This program is distributed in the hope that it will be useful, but
@@ -3091,7 +3092,7 @@ void AVND_COMP::add_cmd_env(const std::string &key_value)
{
pos = key_value.find('=');
if (pos != std::string::npos) {
- add_cmd_env(key_value.substr(0, pos - 1), key_value.substr(pos + 1));
+ add_cmd_env(key_value.substr(0, pos), key_value.substr(pos + 1));
} else {
LOG_ER("Unknown environment variable format '%s'. Should be 'var=value'",
key_value.c_str());
@@ -3119,3 +3120,51 @@ void AVND_COMP::create_ncs_env_arg(NCS_OS_ENVIRON_ARGS*
args) {
}
args->env_arg = env;
}
+
+/**
+ * Initializes a single CLC-CLI command for a component.
+ *
+ * If path in comptype is absolute it is used, else (it is relative) it is
+ * prepended with path prefix.
+ *
+ * @param cmd
+ * @param clc_cmd
+ * @param type_cmd_argv
+ * @param path_prefix
+ * @param attributes
+ * @param attr_name
+ */
+void CompClcCmdParam::init_clc_cli_command(const char *clc_cmd, char
**clc_cmd_argv,
+ const SaImmAttrValuesT_2
**attributes,
+ const char *attr_name) {
+ const std::string space {' '};
+ const char *argv;
+
+ cmd = clc_cmd;
+
+ // append argv from comp type
+ int j = 0;
+ while ((argv = clc_cmd_argv[j++]) != nullptr)
+ cmd.append(space + argv);
+
+ // append argv from comp instance
+ j = 0;
+ while ((argv = immutil_getStringAttr(attributes, attr_name, j++)) != nullptr)
+ cmd.append(space + argv);
+
+ TRACE("cmd=%s", cmd.c_str());
+}
+
+//
+std::string CompClcInfo::get_cmd(AVND_COMP_CLC_CMD_TYPE cmd_type) {
+ std::string tmp = saAmfNodeSwBundlePathPrefix + cmds[cmd_type].cmd;
+
+ if (cmds[cmd_type].cmd_argv.empty() != true) {
+ tmp += " ";
+ }
+
+ for (auto argv : cmds[cmd_type].cmd_argv) {
+ tmp += argv;
+ }
+ return tmp;
+}
diff --git a/src/amf/amfnd/compdb.cc b/src/amf/amfnd/compdb.cc
index 2d1ce2736..90ab6da39 100644
--- a/src/amf/amfnd/compdb.cc
+++ b/src/amf/amfnd/compdb.cc
@@ -375,7 +375,7 @@ uint32_t avnd_comp_oper_req(AVND_CB *cb, AVSV_PARAM_INFO
*param) {
break;
case saAmfCompInstantiateTimeout_ID:
osafassert(sizeof(SaTimeT) == param->value_len);
- comp->clc_info.cmds[AVND_COMP_CLC_CMD_TYPE_INSTANTIATE - 1].timeout =
+ comp->clc_info.cmds[AVND_COMP_CLC_CMD_TYPE_INSTANTIATE].timeout =
m_NCS_OS_NTOHLL_P(param->value);
break;
@@ -384,25 +384,25 @@ uint32_t avnd_comp_oper_req(AVND_CB *cb, AVSV_PARAM_INFO
*param) {
case saAmfCompTerminateTimeout_ID:
osafassert(sizeof(SaTimeT) == param->value_len);
- comp->clc_info.cmds[AVND_COMP_CLC_CMD_TYPE_TERMINATE - 1].timeout =
+ comp->clc_info.cmds[AVND_COMP_CLC_CMD_TYPE_TERMINATE].timeout =
m_NCS_OS_NTOHLL_P(param->value);
break;
case saAmfCompCleanupTimeout_ID:
osafassert(sizeof(SaTimeT) == param->value_len);
- comp->clc_info.cmds[AVND_COMP_CLC_CMD_TYPE_CLEANUP - 1].timeout =
+ comp->clc_info.cmds[AVND_COMP_CLC_CMD_TYPE_CLEANUP].timeout =
m_NCS_OS_NTOHLL_P(param->value);
break;
case saAmfCompAmStartTimeout_ID:
osafassert(sizeof(SaTimeT) == param->value_len);
- comp->clc_info.cmds[AVND_COMP_CLC_CMD_TYPE_AMSTART - 1].timeout =
+ comp->clc_info.cmds[AVND_COMP_CLC_CMD_TYPE_AMSTART].timeout =
m_NCS_OS_NTOHLL_P(param->value);
break;
case saAmfCompAmStopTimeout_ID:
osafassert(sizeof(SaTimeT) == param->value_len);
- comp->clc_info.cmds[AVND_COMP_CLC_CMD_TYPE_AMSTOP - 1].timeout =
+ comp->clc_info.cmds[AVND_COMP_CLC_CMD_TYPE_AMSTOP].timeout =
m_NCS_OS_NTOHLL_P(param->value);
break;
@@ -617,37 +617,37 @@ uint32_t avnd_comptype_oper_req(AVND_CB *cb,
AVSV_PARAM_INFO *param) {
break;
}
case saAmfCtDefClcCliTimeout_ID: {
- AVND_COMP_CLC_CMD_PARAM *cmd;
+ CompClcCmdParam *cmd;
SaTimeT saAmfCtDefClcCliTimeout = *((SaTimeT *)param->value);
osafassert(sizeof(SaTimeT) == param->value_len);
if (comp->use_comptype_attr->test(CompInstantiateTimeout)) {
cmd = &comp->clc_info
- .cmds[AVND_COMP_CLC_CMD_TYPE_INSTANTIATE - 1];
+ .cmds[AVND_COMP_CLC_CMD_TYPE_INSTANTIATE];
cmd->timeout = saAmfCtDefClcCliTimeout;
TRACE("cmd->timeout (Instantiate) modified to '%llu'",
cmd->timeout);
}
if (comp->use_comptype_attr->test(CompTerminateTimeout)) {
cmd =
- &comp->clc_info.cmds[AVND_COMP_CLC_CMD_TYPE_TERMINATE - 1];
+ &comp->clc_info.cmds[AVND_COMP_CLC_CMD_TYPE_TERMINATE];
cmd->timeout = saAmfCtDefClcCliTimeout;
TRACE("cmd->timeout (Terminate) modified to '%llu'",
cmd->timeout);
}
if (comp->use_comptype_attr->test(CompCleanupTimeout)) {
- cmd = &comp->clc_info.cmds[AVND_COMP_CLC_CMD_TYPE_CLEANUP - 1];
+ cmd = &comp->clc_info.cmds[AVND_COMP_CLC_CMD_TYPE_CLEANUP];
cmd->timeout = saAmfCtDefClcCliTimeout;
TRACE("cmd->timeout (Cleanup) modified to '%llu'",
cmd->timeout);
}
if (comp->use_comptype_attr->test(CompAmStartTimeout)) {
- cmd = &comp->clc_info.cmds[AVND_COMP_CLC_CMD_TYPE_AMSTART - 1];
+ cmd = &comp->clc_info.cmds[AVND_COMP_CLC_CMD_TYPE_AMSTART];
cmd->timeout = saAmfCtDefClcCliTimeout;
TRACE("cmd->timeout (AM Start) modified to '%llu'",
cmd->timeout);
}
if (comp->use_comptype_attr->test(CompAmStopTimeout)) {
- cmd = &comp->clc_info.cmds[AVND_COMP_CLC_CMD_TYPE_AMSTOP - 1];
+ cmd = &comp->clc_info.cmds[AVND_COMP_CLC_CMD_TYPE_AMSTOP];
cmd->timeout = saAmfCtDefClcCliTimeout;
TRACE("cmd->timeout (AM Stop) modified to '%llu'",
cmd->timeout);
@@ -1079,51 +1079,6 @@ done:
}
/**
- * Initializes a single CLC-CLI command for a component.
- *
- * If path in comptype is absolute it is used, else (it is relative) it is
- * prepended with path prefix.
- *
- * @param cmd
- * @param clc_cmd
- * @param type_cmd_argv
- * @param path_prefix
- * @param attributes
- * @param attr_name
- */
-static void init_clc_cli_command(AVND_COMP_CLC_CMD_PARAM *cmd,
- const char *clc_cmd, char **clc_cmd_argv,
- const char *path_prefix,
- const SaImmAttrValuesT_2 **attributes,
- const char *attr_name) {
- char *buf = cmd->cmd;
- int i, j;
- const char *argv;
-
- // prepend with path prefix if available
- if (path_prefix == nullptr)
- i = snprintf(buf, sizeof(cmd->cmd), "%s", clc_cmd);
- else
- i = snprintf(buf, sizeof(cmd->cmd), "%s/%s", path_prefix, clc_cmd);
-
- // append argv from comp type
- j = 0;
- while ((argv = clc_cmd_argv[j++]) != nullptr)
- i += snprintf(&buf[i], sizeof(cmd->cmd) - i, " %s", argv);
-
- // append argv from comp instance
- j = 0;
- while ((argv = immutil_getStringAttr(attributes, attr_name, j++)) != nullptr)
- i += snprintf(&buf[i], sizeof(cmd->cmd) - i, " %s", argv);
-
- cmd->len = i;
-
- /* Check for truncation, should alloc these strings dynamically instead */
- osafassert((cmd->len > 0) && (cmd->len < sizeof(cmd->cmd)));
- TRACE("cmd=%s", cmd->cmd);
-}
-
-/**
* Initializes the CLC-CLI attributes (commands and timeout) for a component.
*
* @param comp
@@ -1133,16 +1088,15 @@ static void
init_clc_cli_command(AVND_COMP_CLC_CMD_PARAM *cmd,
*/
static void init_clc_cli_attributes(AVND_COMP *comp,
const amf_comp_type_t *comptype,
- const char *path_prefix,
const SaImmAttrValuesT_2 **attributes) {
- AVND_COMP_CLC_CMD_PARAM *cmd;
+ CompClcCmdParam *cmd;
TRACE_ENTER();
- cmd = &comp->clc_info.cmds[AVND_COMP_CLC_CMD_TYPE_INSTANTIATE - 1];
+ cmd = &comp->clc_info.cmds[AVND_COMP_CLC_CMD_TYPE_INSTANTIATE];
if (comptype->saAmfCtRelPathInstantiateCmd != nullptr) {
- init_clc_cli_command(cmd, comptype->saAmfCtRelPathInstantiateCmd,
- comptype->saAmfCtDefInstantiateCmdArgv, path_prefix,
+ cmd->init_clc_cli_command(comptype->saAmfCtRelPathInstantiateCmd,
+ comptype->saAmfCtDefInstantiateCmdArgv,
attributes, "saAmfCompInstantiateCmdArgv");
}
@@ -1156,10 +1110,10 @@ static void init_clc_cli_attributes(AVND_COMP *comp,
comp->pxied_inst_cbk_timeout = cmd->timeout;
}
- cmd = &comp->clc_info.cmds[AVND_COMP_CLC_CMD_TYPE_TERMINATE - 1];
+ cmd = &comp->clc_info.cmds[AVND_COMP_CLC_CMD_TYPE_TERMINATE];
if (comptype->saAmfCtRelPathTerminateCmd != nullptr) {
- init_clc_cli_command(cmd, comptype->saAmfCtRelPathTerminateCmd,
- comptype->saAmfCtDefTerminateCmdArgv, path_prefix,
+ cmd->init_clc_cli_command(comptype->saAmfCtRelPathTerminateCmd,
+ comptype->saAmfCtDefTerminateCmdArgv,
attributes, "saAmfCompTerminateCmdArgv");
}
@@ -1174,10 +1128,10 @@ static void init_clc_cli_attributes(AVND_COMP *comp,
cmd->timeout = comptype->saAmfCtDefClcCliTimeout;
}
- cmd = &comp->clc_info.cmds[AVND_COMP_CLC_CMD_TYPE_CLEANUP - 1];
+ cmd = &comp->clc_info.cmds[AVND_COMP_CLC_CMD_TYPE_CLEANUP];
if (comptype->saAmfCtRelPathCleanupCmd != nullptr) {
- init_clc_cli_command(cmd, comptype->saAmfCtRelPathCleanupCmd,
- comptype->saAmfCtDefCleanupCmdArgv, path_prefix,
+ cmd->init_clc_cli_command(comptype->saAmfCtRelPathCleanupCmd,
+ comptype->saAmfCtDefCleanupCmdArgv,
attributes, "saAmfCompCleanupCmdArgv");
}
@@ -1191,10 +1145,10 @@ static void init_clc_cli_attributes(AVND_COMP *comp,
comp->pxied_clean_cbk_timeout = cmd->timeout;
}
- cmd = &comp->clc_info.cmds[AVND_COMP_CLC_CMD_TYPE_AMSTART - 1];
+ cmd = &comp->clc_info.cmds[AVND_COMP_CLC_CMD_TYPE_AMSTART];
if (comptype->saAmfCtRelPathAmStartCmd != nullptr) {
- init_clc_cli_command(cmd, comptype->saAmfCtRelPathAmStartCmd,
- comptype->saAmfCtDefAmStartCmdArgv, path_prefix,
+ cmd->init_clc_cli_command(comptype->saAmfCtRelPathAmStartCmd,
+ comptype->saAmfCtDefAmStartCmdArgv,
attributes, "saAmfCompAmStartCmdArgv");
comp->is_am_en = true;
}
@@ -1205,10 +1159,10 @@ static void init_clc_cli_attributes(AVND_COMP *comp,
comp->use_comptype_attr->set(CompAmStartTimeout);
}
- cmd = &comp->clc_info.cmds[AVND_COMP_CLC_CMD_TYPE_AMSTOP - 1];
+ cmd = &comp->clc_info.cmds[AVND_COMP_CLC_CMD_TYPE_AMSTOP];
if (comptype->saAmfCtRelPathAmStopCmd != nullptr) {
- init_clc_cli_command(cmd, comptype->saAmfCtRelPathAmStopCmd,
- comptype->saAmfCtDefAmStopCmdArgv, path_prefix,
+ cmd->init_clc_cli_command(comptype->saAmfCtRelPathAmStopCmd,
+ comptype->saAmfCtDefAmStopCmdArgv,
attributes, "saAmfCompAmStopCmdArgv");
}
@@ -1218,10 +1172,10 @@ static void init_clc_cli_attributes(AVND_COMP *comp,
comp->use_comptype_attr->set(CompAmStopTimeout);
}
- cmd = &comp->clc_info.cmds[AVND_COMP_CLC_CMD_TYPE_HC - 1];
+ cmd = &comp->clc_info.cmds[AVND_COMP_CLC_CMD_TYPE_HC];
if (comptype->osafAmfCtRelPathHcCmd != nullptr) {
- init_clc_cli_command(cmd, comptype->osafAmfCtRelPathHcCmd,
- comptype->osafAmfCtDefHcCmdArgv, path_prefix,
+ cmd->init_clc_cli_command(comptype->osafAmfCtRelPathHcCmd,
+ comptype->osafAmfCtDefHcCmdArgv,
attributes, "osafAmfCompHcCmdArgv");
comp->is_hc_cmd_configured = true;
}
@@ -1280,6 +1234,11 @@ static int comp_init(AVND_COMP *comp, const
SaImmAttrValuesT_2 **attributes) {
immOmHandle, const_cast<SaImmAttrNameT>("saAmfNodeSwBundlePathPrefix"),
Amf::to_string(&nodeswbundle_name), &path_prefix);
+ if (path_prefix != nullptr) {
+ std::string slash = "/";
+ comp->clc_info.saAmfNodeSwBundlePathPrefix = path_prefix + slash;
+ }
+
if
(immutil_getAttr(const_cast<SaImmAttrNameT>("saAmfCompInstantiationLevel"),
attributes, 0, &comp->inst_level) != SA_AIS_OK) {
comp->inst_level = comptype->saAmfCtDefInstantiationLevel;
@@ -1362,7 +1321,7 @@ static int comp_init(AVND_COMP *comp, const
SaImmAttrValuesT_2 **attributes) {
comp->is_restart_en = (disable_restart == true) ? false : true;
init_comp_category(comp, comptype->saAmfCtCompCategory);
- init_clc_cli_attributes(comp, comptype, path_prefix, attributes);
+ init_clc_cli_attributes(comp, comptype, attributes);
/* Set oper status to enable irrespective of comp category PI or NPI. */
m_AVND_COMP_OPER_STATE_SET(comp, SA_AMF_OPERATIONAL_ENABLED);
diff --git a/src/amf/amfnd/err.cc b/src/amf/amfnd/err.cc
index cc43c2c54..d3f33b272 100644
--- a/src/amf/amfnd/err.cc
+++ b/src/amf/amfnd/err.cc
@@ -1,6 +1,7 @@
/* -*- OpenSAF -*-
*
* (C) Copyright 2008 The OpenSAF Foundation
+ * (C) Copyright 2017 Ericsson AB - All Rights Reserved.
* Copyright (C) 2017, Oracle and/or its affiliates. All rights reserved.
*
* This program is distributed in the hope that it will be useful, but
diff --git a/src/amf/amfnd/proxydb.cc b/src/amf/amfnd/proxydb.cc
index 69f2f4e52..576108625 100644
--- a/src/amf/amfnd/proxydb.cc
+++ b/src/amf/amfnd/proxydb.cc
@@ -2,6 +2,7 @@
*
* (C) Copyright 2008 The OpenSAF Foundation
* Copyright (C) 2017, Oracle and/or its affiliates. All rights reserved.
+ * (C) Copyright 2017 Ericsson AB - All Rights Reserved.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
diff --git a/src/amf/amfnd/su.cc b/src/amf/amfnd/su.cc
index a1fc4e4d1..c016c214d 100644
--- a/src/amf/amfnd/su.cc
+++ b/src/amf/amfnd/su.cc
@@ -1,6 +1,7 @@
/* -*- OpenSAF -*-
*
* (C) Copyright 2008 The OpenSAF Foundation
+ * (C) Copyright 2017 Ericsson AB - All Rights Reserved.
* Copyright (C) 2017, Oracle and/or its affiliates. All rights reserved.
*
* This program is distributed in the hope that it will be useful, but
diff --git a/src/amf/amfnd/sudb.cc b/src/amf/amfnd/sudb.cc
index 5323acc0f..0951233f7 100644
--- a/src/amf/amfnd/sudb.cc
+++ b/src/amf/amfnd/sudb.cc
@@ -1,7 +1,8 @@
/* -*- OpenSAF -*-
*
* (C) Copyright 2008 The OpenSAF Foundation
- * Copyright (C) 2017, Oracle and/or its affiliates. All rights reserved.
+ * (C) Copyright 2017 Ericsson AB - All Rights Reserved.
+ * * Copyright (C) 2017, Oracle and/or its affiliates. All rights reserved.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
diff --git a/src/amf/amfnd/susm.cc b/src/amf/amfnd/susm.cc
index d38a12d04..8864fb517 100644
--- a/src/amf/amfnd/susm.cc
+++ b/src/amf/amfnd/susm.cc
@@ -4052,7 +4052,7 @@ uint32_t avnd_evt_ir_evh(struct avnd_cb_tag *cb, struct
avnd_evt_tag *evt) {
// If SU has been already instantiated, inform amfd
if ((cb->led_state == AVND_LED_STATE_RED) &&
(su->pres == SA_AMF_PRESENCE_INSTANTIATED) &&
- (su_all_pi_comps_instantiated(su) == true) &&
+ (su->all_pi_comps_instantiated() == true) &&
(m_AVND_SU_OPER_STATE_IS_ENABLED(su))) {
TRACE("SU oper state is enabled and pres state is instantiated.");
rc = avnd_di_oper_send(cb, su, 0);
diff --git a/src/amf/amfnd/tmr.cc b/src/amf/amfnd/tmr.cc
index 0e0e8e341..0efe66cd3 100644
--- a/src/amf/amfnd/tmr.cc
+++ b/src/amf/amfnd/tmr.cc
@@ -1,6 +1,7 @@
/* -*- OpenSAF -*-
*
* (C) Copyright 2008 The OpenSAF Foundation
+ * (C) Copyright 2017 Ericsson AB - All Rights Reserved.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
diff --git a/src/amf/amfnd/util.cc b/src/amf/amfnd/util.cc
index 1b348177e..d51e4d65c 100644
--- a/src/amf/amfnd/util.cc
+++ b/src/amf/amfnd/util.cc
@@ -1,6 +1,7 @@
/* -*- OpenSAF -*-
*
* (C) Copyright 2008 The OpenSAF Foundation
+ * (C) Copyright 2017 Ericsson AB - All Rights Reserved.
* Copyright (C) 2017, Oracle and/or its affiliates. All rights reserved.
*
* This program is distributed in the hope that it will be useful, but
--
2.13.0
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Opensaf-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/opensaf-devel