AdminUtils: NSX-V3: Show and update the NSX rate limit
Usage: nsxadmin -r rate-limit -o show nsxadmin -r rate-limit -o nsx-update --property rate_limit=45 Change-Id: I0b08cd42be61158a1358479d8f0cae271e26541f Depends-on: I35a05f9810832e9a22ec9db43f167f13df0744a4
This commit is contained in:
parent
108a706d92
commit
0edcfacc69
@ -471,6 +471,16 @@ LBaaS
|
||||
|
||||
nsxadmin -r lb-monitors -o list
|
||||
|
||||
Rate Limit
|
||||
~~~~~~~~~~
|
||||
- Show the current NSX rate limit:
|
||||
|
||||
nsxadmin -r rate-limit -o show
|
||||
|
||||
- Update the NSX rate limit:
|
||||
|
||||
nsxadmin -r rate-limit -o nsx-update --property value=<>
|
||||
|
||||
|
||||
NSXtvd
|
||||
------
|
||||
|
@ -44,6 +44,7 @@ LB_SERVICES = 'lb-services'
|
||||
LB_VIRTUAL_SERVERS = 'lb-virtual-servers'
|
||||
LB_POOLS = 'lb-pools'
|
||||
LB_MONITORS = 'lb-monitors'
|
||||
RATE_LIMIT = 'rate-limit'
|
||||
|
||||
# NSXV only Resource Constants
|
||||
EDGES = 'edges'
|
||||
|
@ -0,0 +1,74 @@
|
||||
# Copyright 2016 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
|
||||
import vmware_nsx.shell.resources as shell
|
||||
from vmware_nsxlib.v3 import nsx_constants
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
neutron_client = utils.NeutronDbClient()
|
||||
|
||||
|
||||
@admin_utils.output_header
|
||||
def nsx_rate_limit_show(resource, event, trigger, **kwargs):
|
||||
"""Show the current NSX rate limit."""
|
||||
|
||||
nsxlib = utils.get_connected_nsxlib()
|
||||
if not nsxlib.feature_supported(nsx_constants.FEATURE_RATE_LIMIT):
|
||||
LOG.error("This utility is not available for NSX version %s",
|
||||
nsxlib.get_version())
|
||||
return
|
||||
|
||||
rate_limit = nsxlib.http_services.get_rate_limit()
|
||||
LOG.info("Current NSX rate limit is %s", rate_limit)
|
||||
|
||||
|
||||
@admin_utils.output_header
|
||||
def nsx_rate_limit_update(resource, event, trigger, **kwargs):
|
||||
"""Set the NSX rate limit
|
||||
|
||||
The default value is 40. 0 means no limit
|
||||
"""
|
||||
nsxlib = utils.get_connected_nsxlib()
|
||||
if not nsxlib.feature_supported(nsx_constants.FEATURE_RATE_LIMIT):
|
||||
LOG.error("This utility is not available for NSX version %s",
|
||||
nsxlib.get_version())
|
||||
return
|
||||
|
||||
rate_limit = None
|
||||
if kwargs.get('property'):
|
||||
properties = admin_utils.parse_multi_keyval_opt(kwargs['property'])
|
||||
rate_limit = properties.get('value', None)
|
||||
if rate_limit is None:
|
||||
usage = ("nsxadmin -r rate-limit -o nsx-update "
|
||||
"--property value=<new limit>")
|
||||
LOG.error("Missing parameters. Usage: %s", usage)
|
||||
return
|
||||
|
||||
nsxlib.http_services.update_rate_limit(rate_limit)
|
||||
LOG.info("NSX rate limit was updated to %s", rate_limit)
|
||||
|
||||
|
||||
registry.subscribe(nsx_rate_limit_show,
|
||||
constants.RATE_LIMIT,
|
||||
shell.Operations.SHOW.value)
|
||||
|
||||
registry.subscribe(nsx_rate_limit_update,
|
||||
constants.RATE_LIMIT,
|
||||
shell.Operations.NSX_UPDATE.value)
|
@ -130,7 +130,10 @@ nsxv3_resources = {
|
||||
constants.LB_POOLS: Resource(constants.LB_POOLS,
|
||||
[Operations.LIST.value]),
|
||||
constants.LB_MONITORS: Resource(constants.LB_MONITORS,
|
||||
[Operations.LIST.value])
|
||||
[Operations.LIST.value]),
|
||||
constants.RATE_LIMIT: Resource(constants.RATE_LIMIT,
|
||||
[Operations.SHOW.value,
|
||||
Operations.NSX_UPDATE.value])
|
||||
}
|
||||
|
||||
# Add supported NSX-V resources in this dictionary
|
||||
|
Loading…
x
Reference in New Issue
Block a user