Re: [devel] [PATCH 1/1] amf: add option for controller status in amfclusterstatus [#2536]

2017-08-08 Thread Hans Nordebäck

ack, code review only. Minor comments below marked with [HansN]

/Regards HansN


On 08/04/2017 11:18 AM, Praveen wrote:

---
  src/amf/tools/amf_cluster_status.cc | 190 +++-
  1 file changed, 167 insertions(+), 23 deletions(-)

diff --git a/src/amf/tools/amf_cluster_status.cc 
b/src/amf/tools/amf_cluster_status.cc
index 5a28315..2000bef 100644
--- a/src/amf/tools/amf_cluster_status.cc
+++ b/src/amf/tools/amf_cluster_status.cc
@@ -19,6 +19,7 @@
  #include 
  #include 
  #include 
+#include 
  
  #include "mds/mds_papi.h"

  #include "base/osaf_time.h"
@@ -29,7 +30,6 @@
  #include "osaf/immutil/immutil.h"
  
  enum { AMF_CLUSTER_MDS_VERSION = 1, AMF_CLUSTER_MDS_SVC_ID = 501 };

-
  class CLM_NODE {
   public:
std::string clm_rdn;
@@ -51,7 +51,9 @@ static std::vector avnd_up_db;
  static std::map clm_db;
  static std::map amf_db;
  static uint32_t width = strlen("NODE(AMF)");
-
+static NODE_ID scs_node_id[2];
+static uint32_t scs_count;
+static bool print_also = true;
  uint32_t mds_callback(struct ncsmds_callback_info *info) {
uint32_t rc = NCSCC_RC_SUCCESS;
if (info->i_op != MDS_CALLBACK_SVC_EVENT) {
@@ -67,7 +69,10 @@ uint32_t mds_callback(struct ncsmds_callback_info *info) {
  
if (info->info.svc_evt.i_change == NCSMDS_UP) {

  if (info->info.svc_evt.i_svc_id == NCSMDS_SVC_ID_AVD) {
-  if (m_MDS_DEST_IS_AN_ADEST(info->info.svc_evt.i_dest)) is_avd_up = true;
+  if (m_MDS_DEST_IS_AN_ADEST(info->info.svc_evt.i_dest)) {
+is_avd_up = true;
+scs_node_id[scs_count++] = info->info.svc_evt.i_node_id;
+  }
  } else if (info->info.svc_evt.i_svc_id == NCSMDS_SVC_ID_AVND) {
avnd_up_db.push_back(info->info.svc_evt.i_node_id);
  }
@@ -290,56 +295,195 @@ static void print_cluster_info() {
  
  static void usage(const char *prog_name) {

std::cout << std::endl << "NAME" << std::endl;
-  std::cout << "\t" << prog_name
-<< " - lists RDNs of AMF nodes with their status (UP, DOWN, SAM)"
-<< std::endl;
+  std::cout << "\t" << prog_name << std::endl;
std::cout << std::endl << "SYNOPSIS" << std::endl;
std::cout << "\t" << prog_name << " [option]" << std::endl;
  
std::cout << std::endl << "DESCRIPTION" << std::endl;

std::cout << "\t"
-<< "lists RDNs of AMF nodes with their status: " << std::endl;
+<< "Use this command:"<

[devel] [PATCH 1/1] amf: add option for controller status in amfclusterstatus [#2536]

2017-08-04 Thread Praveen
---
 src/amf/tools/amf_cluster_status.cc | 190 +++-
 1 file changed, 167 insertions(+), 23 deletions(-)

diff --git a/src/amf/tools/amf_cluster_status.cc 
b/src/amf/tools/amf_cluster_status.cc
index 5a28315..2000bef 100644
--- a/src/amf/tools/amf_cluster_status.cc
+++ b/src/amf/tools/amf_cluster_status.cc
@@ -19,6 +19,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include "mds/mds_papi.h"
 #include "base/osaf_time.h"
@@ -29,7 +30,6 @@
 #include "osaf/immutil/immutil.h"
 
 enum { AMF_CLUSTER_MDS_VERSION = 1, AMF_CLUSTER_MDS_SVC_ID = 501 };
-
 class CLM_NODE {
  public:
   std::string clm_rdn;
@@ -51,7 +51,9 @@ static std::vector avnd_up_db;
 static std::map clm_db;
 static std::map amf_db;
 static uint32_t width = strlen("NODE(AMF)");
-
+static NODE_ID scs_node_id[2];
+static uint32_t scs_count;
+static bool print_also = true;
 uint32_t mds_callback(struct ncsmds_callback_info *info) {
   uint32_t rc = NCSCC_RC_SUCCESS;
   if (info->i_op != MDS_CALLBACK_SVC_EVENT) {
@@ -67,7 +69,10 @@ uint32_t mds_callback(struct ncsmds_callback_info *info) {
 
   if (info->info.svc_evt.i_change == NCSMDS_UP) {
 if (info->info.svc_evt.i_svc_id == NCSMDS_SVC_ID_AVD) {
-  if (m_MDS_DEST_IS_AN_ADEST(info->info.svc_evt.i_dest)) is_avd_up = true;
+  if (m_MDS_DEST_IS_AN_ADEST(info->info.svc_evt.i_dest)) {
+is_avd_up = true;
+scs_node_id[scs_count++] = info->info.svc_evt.i_node_id;
+  }
 } else if (info->info.svc_evt.i_svc_id == NCSMDS_SVC_ID_AVND) {
   avnd_up_db.push_back(info->info.svc_evt.i_node_id);
 }
@@ -290,56 +295,195 @@ static void print_cluster_info() {
 
 static void usage(const char *prog_name) {
   std::cout << std::endl << "NAME" << std::endl;
-  std::cout << "\t" << prog_name
-<< " - lists RDNs of AMF nodes with their status (UP, DOWN, SAM)"
-<< std::endl;
+  std::cout << "\t" << prog_name << std::endl;
   std::cout << std::endl << "SYNOPSIS" << std::endl;
   std::cout << "\t" << prog_name << " [option]" << std::endl;
 
   std::cout << std::endl << "DESCRIPTION" << std::endl;
   std::cout << "\t"
-<< "lists RDNs of AMF nodes with their status: " << std::endl;
+<< "Use this command:"<