NSXv3: Add admin utils for LBaaS resource
This initial version adds some basic admin utilities for Neutron LBaaS resources. - LB Services - Virtual Servers - Pools - Monitors Change-Id: I549dbdf47f92ffbcc1ad87e8734dc09dee4228fe
This commit is contained in:
parent
7a5246d1ed
commit
1daab3a424
@ -402,6 +402,26 @@ BGP GW edges
|
|||||||
|
|
||||||
nsxadmin -r bgp-neighbour -o delete --property gw-edge-ids=<edge_id>[,...] --property ip-address=<IP_ADDRESS>
|
nsxadmin -r bgp-neighbour -o delete --property gw-edge-ids=<edge_id>[,...] --property ip-address=<IP_ADDRESS>
|
||||||
|
|
||||||
|
|
||||||
|
LBaaS
|
||||||
|
~~~~~~~~~~~~
|
||||||
|
- List NSX LB services::
|
||||||
|
|
||||||
|
nsxadmin -r lb-services -o list
|
||||||
|
|
||||||
|
- List NSX LB virtual servers::
|
||||||
|
|
||||||
|
nsxadmin -r lb-virtual-servers -o list
|
||||||
|
|
||||||
|
- List NSX LB pools::
|
||||||
|
|
||||||
|
nsxadmin -r lb-pools -o list
|
||||||
|
|
||||||
|
- List NSX LB monitors::
|
||||||
|
|
||||||
|
nsxadmin -r lb-monitors -o list
|
||||||
|
|
||||||
|
|
||||||
Config
|
Config
|
||||||
~~~~~~
|
~~~~~~
|
||||||
|
|
||||||
|
@ -36,6 +36,10 @@ PORTS = 'ports'
|
|||||||
METADATA_PROXY = 'metadata-proxy'
|
METADATA_PROXY = 'metadata-proxy'
|
||||||
ORPHANED_DHCP_SERVERS = 'orphaned-dhcp-servers'
|
ORPHANED_DHCP_SERVERS = 'orphaned-dhcp-servers'
|
||||||
CERTIFICATE = 'certificate'
|
CERTIFICATE = 'certificate'
|
||||||
|
LB_SERVICES = 'lb-services'
|
||||||
|
LB_VIRTUAL_SERVERS = 'lb-virtual-servers'
|
||||||
|
LB_POOLS = 'lb-pools'
|
||||||
|
LB_MONITORS = 'lb-monitors'
|
||||||
|
|
||||||
# NSXV only Resource Constants
|
# NSXV only Resource Constants
|
||||||
EDGES = 'edges'
|
EDGES = 'edges'
|
||||||
|
@ -0,0 +1,90 @@
|
|||||||
|
# Copyright 2015 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 oslo_log import log as logging
|
||||||
|
|
||||||
|
from vmware_nsx.shell.admin.plugins.common import constants
|
||||||
|
from vmware_nsx.shell.admin.plugins.common import formatters
|
||||||
|
from vmware_nsx.shell.admin.plugins.common import utils as admin_utils
|
||||||
|
from vmware_nsx.shell.admin.plugins.nsxv3.resources import utils
|
||||||
|
from vmware_nsxlib.v3 import nsx_constants as consts
|
||||||
|
|
||||||
|
LOG = logging.getLogger(__name__)
|
||||||
|
nsxlib = utils.get_connected_nsxlib()
|
||||||
|
|
||||||
|
|
||||||
|
@admin_utils.list_handler(constants.LB_SERVICES)
|
||||||
|
@admin_utils.output_header
|
||||||
|
def nsx_list_lb_services(resource, event, trigger, **kwargs):
|
||||||
|
"""List LB services on NSX backend"""
|
||||||
|
|
||||||
|
if not nsxlib.feature_supported(consts.FEATURE_LOAD_BALANCER):
|
||||||
|
LOG.error("This utility is not available for NSX version %s",
|
||||||
|
nsxlib.get_version())
|
||||||
|
return
|
||||||
|
|
||||||
|
lb_services = nsxlib.load_balancer.service.list()
|
||||||
|
LOG.info(formatters.output_formatter(
|
||||||
|
constants.LB_SERVICES, lb_services,
|
||||||
|
['display_name', 'id', 'virtual_server_ids', 'attachment']))
|
||||||
|
return bool(lb_services)
|
||||||
|
|
||||||
|
|
||||||
|
@admin_utils.list_handler(constants.LB_VIRTUAL_SERVERS)
|
||||||
|
@admin_utils.output_header
|
||||||
|
def nsx_list_lb_virtual_servers(resource, event, trigger, **kwargs):
|
||||||
|
"""List LB virtual servers on NSX backend"""
|
||||||
|
|
||||||
|
if not nsxlib.feature_supported(consts.FEATURE_LOAD_BALANCER):
|
||||||
|
LOG.error("This utility is not available for NSX version %s",
|
||||||
|
nsxlib.get_version())
|
||||||
|
return
|
||||||
|
|
||||||
|
lb_virtual_servers = nsxlib.load_balancer.virtual_server.list()
|
||||||
|
LOG.info(formatters.output_formatter(
|
||||||
|
constants.LB_VIRTUAL_SERVERS, lb_virtual_servers,
|
||||||
|
['display_name', 'id', 'ip_address', 'pool_id']))
|
||||||
|
return bool(lb_virtual_servers)
|
||||||
|
|
||||||
|
|
||||||
|
@admin_utils.list_handler(constants.LB_POOLS)
|
||||||
|
@admin_utils.output_header
|
||||||
|
def nsx_list_lb_pools(resource, event, trigger, **kwargs):
|
||||||
|
|
||||||
|
if not nsxlib.feature_supported(consts.FEATURE_LOAD_BALANCER):
|
||||||
|
LOG.error("This utility is not available for NSX version %s",
|
||||||
|
nsxlib.get_version())
|
||||||
|
return
|
||||||
|
|
||||||
|
lb_pools = nsxlib.load_balancer.pool.list()
|
||||||
|
LOG.info(formatters.output_formatter(
|
||||||
|
constants.LB_POOLS, lb_pools,
|
||||||
|
['display_name', 'id', 'active_monitor_ids', 'members']))
|
||||||
|
return bool(lb_pools)
|
||||||
|
|
||||||
|
|
||||||
|
@admin_utils.list_handler(constants.LB_MONITORS)
|
||||||
|
@admin_utils.output_header
|
||||||
|
def nsx_list_lb_monitors(resource, event, trigger, **kwargs):
|
||||||
|
|
||||||
|
if not nsxlib.feature_supported(consts.FEATURE_LOAD_BALANCER):
|
||||||
|
LOG.error("This utility is not available for NSX version %s",
|
||||||
|
nsxlib.get_version())
|
||||||
|
return
|
||||||
|
|
||||||
|
lb_monitors = nsxlib.load_balancer.monitor.list()
|
||||||
|
LOG.info(formatters.output_formatter(
|
||||||
|
constants.LB_MONITORS, lb_monitors,
|
||||||
|
['display_name', 'id', 'resource_type']))
|
||||||
|
return bool(lb_monitors)
|
@ -115,6 +115,14 @@ nsxv3_resources = {
|
|||||||
constants.ORPHANED_NETWORKS: Resource(constants.ORPHANED_NETWORKS,
|
constants.ORPHANED_NETWORKS: Resource(constants.ORPHANED_NETWORKS,
|
||||||
[Operations.LIST.value,
|
[Operations.LIST.value,
|
||||||
Operations.NSX_CLEAN.value]),
|
Operations.NSX_CLEAN.value]),
|
||||||
|
constants.LB_SERVICES: Resource(constants.LB_SERVICES,
|
||||||
|
[Operations.LIST.value]),
|
||||||
|
constants.LB_VIRTUAL_SERVERS: Resource(constants.LB_VIRTUAL_SERVERS,
|
||||||
|
[Operations.LIST.value]),
|
||||||
|
constants.LB_POOLS: Resource(constants.LB_POOLS,
|
||||||
|
[Operations.LIST.value]),
|
||||||
|
constants.LB_MONITORS: Resource(constants.LB_MONITORS,
|
||||||
|
[Operations.LIST.value])
|
||||||
}
|
}
|
||||||
|
|
||||||
# Add supported NSX-V resources in this dictionary
|
# Add supported NSX-V resources in this dictionary
|
||||||
|
Loading…
Reference in New Issue
Block a user