NSX|V3: New admin utility to show MP cluster managers IPs

Usage:
nsxadmin -r cluster -o show

Output example:
NSX Cluster has 3 manager nodes:
10.192.210.183
10.192.210.184
10.192.210.185

Change-Id: I1a138c759c52e25481fdf34f1ed3d861470adf3e
This commit is contained in:
Adit Sarfaty 2018-08-02 11:54:17 +03:00
parent 61599c7cb2
commit caa451920b
4 changed files with 49 additions and 1 deletions

View File

@ -544,6 +544,12 @@ Rate Limit
nsxadmin -r rate-limit -o nsx-update --property value=<> nsxadmin -r rate-limit -o nsx-update --property value=<>
Cluster
~~~~~~~
- Show the NSX cluster managers ips:
nsxadmin -r cluster -o show
Config Config
~~~~~~ ~~~~~~

View File

@ -45,6 +45,7 @@ LB_VIRTUAL_SERVERS = 'lb-virtual-servers'
LB_POOLS = 'lb-pools' LB_POOLS = 'lb-pools'
LB_MONITORS = 'lb-monitors' LB_MONITORS = 'lb-monitors'
RATE_LIMIT = 'rate-limit' RATE_LIMIT = 'rate-limit'
CLUSTER = 'cluster'
ORPHANED_FIREWALL_SECTIONS = 'orphaned-firewall-sections' ORPHANED_FIREWALL_SECTIONS = 'orphaned-firewall-sections'
# NSXV only Resource Constants # NSXV only Resource Constants

View File

@ -0,0 +1,39 @@
# Copyright 2018 VMware, Inc. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
from neutron_lib.callbacks import registry
from oslo_log import log as logging
from vmware_nsx.shell.admin.plugins.common import constants
from vmware_nsx.shell.admin.plugins.common import utils as admin_utils
from vmware_nsx.shell.admin.plugins.nsxv3.resources import utils
from vmware_nsx.shell import resources as shell
LOG = logging.getLogger(__name__)
@admin_utils.output_header
def find_cluster_managers_ips(resource, event, trigger, **kwargs):
"""Show the current NSX rate limit."""
nsxlib = utils.get_connected_nsxlib()
manager_ips = nsxlib.cluster_nodes.get_managers_ips()
LOG.info("NSX Cluster has %s manager nodes:", len(manager_ips))
for ip in manager_ips:
LOG.info("%s", str(ip))
registry.subscribe(find_cluster_managers_ips,
constants.CLUSTER,
shell.Operations.SHOW.value)

View File

@ -141,7 +141,9 @@ nsxv3_resources = {
[Operations.LIST.value]), [Operations.LIST.value]),
constants.RATE_LIMIT: Resource(constants.RATE_LIMIT, constants.RATE_LIMIT: Resource(constants.RATE_LIMIT,
[Operations.SHOW.value, [Operations.SHOW.value,
Operations.NSX_UPDATE.value]) Operations.NSX_UPDATE.value]),
constants.CLUSTER: Resource(constants.CLUSTER,
[Operations.SHOW.value])
} }
# Add supported NSX-V resources in this dictionary # Add supported NSX-V resources in this dictionary