From 87c40e8d5bd0d7fb80fe361bfa56adf5c50d5119 Mon Sep 17 00:00:00 2001 From: ashok2988 Date: Fri, 17 Nov 2017 15:19:09 +0530 Subject: [PATCH] NSX|V: add HA status to admin list of edges Enahnce the output of the edges. This will now habe the HA status of the edges. Change-Id: Ieadcf0cd5bb9609c1d76948f2eadf054dc3d27cf --- .../shell/admin/plugins/nsxv/resources/edges.py | 2 +- .../shell/admin/plugins/nsxv/resources/utils.py | 12 +++++++++--- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/vmware_nsx/shell/admin/plugins/nsxv/resources/edges.py b/vmware_nsx/shell/admin/plugins/nsxv/resources/edges.py index 2904101022..26cbef8dfa 100644 --- a/vmware_nsx/shell/admin/plugins/nsxv/resources/edges.py +++ b/vmware_nsx/shell/admin/plugins/nsxv/resources/edges.py @@ -49,7 +49,7 @@ nsxv = utils.get_nsxv_client() def nsx_list_edges(resource, event, trigger, **kwargs): """List edges from NSXv backend""" - headers = ['id', 'name', 'type', 'size'] + headers = ['id', 'name', 'type', 'size', 'ha'] edges = utils.get_nsxv_backend_edges() if (kwargs.get('verbose')): headers += ['syslog'] diff --git a/vmware_nsx/shell/admin/plugins/nsxv/resources/utils.py b/vmware_nsx/shell/admin/plugins/nsxv/resources/utils.py index d842d1a03f..f3b25170b0 100644 --- a/vmware_nsx/shell/admin/plugins/nsxv/resources/utils.py +++ b/vmware_nsx/shell/admin/plugins/nsxv/resources/utils.py @@ -106,13 +106,19 @@ def get_nsxv_backend_edges(): edges = nsxv.get_edges() backend_edges = [] for edge in edges: + summary = edge.get('appliancesSummary') + size = ha = None + if summary: + size = summary.get('applianceSize') + deployed_vms = summary.get('numberOfDeployedVms', 1) + ha = 'Enabled' if deployed_vms > 1 else 'Disabled' # get all the relevant backend information for this edge edge_data = { 'id': edge.get('id'), 'name': edge.get('name'), - 'size': edge['appliancesSummary'].get( - 'applianceSize') if edge.get('appliancesSummary') else None, - 'type': edge.get('edgeType') + 'size': size, + 'type': edge.get('edgeType'), + 'ha': ha, } backend_edges.append(edge_data) return backend_edges