Update help information for lbaasv2 CLIs
Help information for lbaasV2 Update CLIs lack several options ( Refer bug#1515111 ). This patch adds all the options which are missing in the "neutron lbaas-*-update " CLIs Also updated is the --http-method for HealthMonitor, making it case in-sensitive. This also adds update of --default-pool for L7 support. Change-Id: If859dc899efa92173c7a654e3f1481b35790faaa Closes-Bug: #1515111 Closes-Bug: #1523968
This commit is contained in:
@@ -14,11 +14,56 @@
|
|||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
#
|
#
|
||||||
|
|
||||||
from neutronclient._i18n import _
|
from neutronclient._i18n import _
|
||||||
|
from neutronclient.common import utils
|
||||||
from neutronclient.neutron import v2_0 as neutronV20
|
from neutronclient.neutron import v2_0 as neutronV20
|
||||||
|
|
||||||
|
|
||||||
|
def _add_common_args(parser, is_create=True):
|
||||||
|
parser.add_argument(
|
||||||
|
'--delay',
|
||||||
|
required=is_create,
|
||||||
|
help=_('The time in seconds between sending probes to members.'))
|
||||||
|
parser.add_argument(
|
||||||
|
'--name',
|
||||||
|
help=_('Name of the health monitor.'))
|
||||||
|
parser.add_argument(
|
||||||
|
'--timeout',
|
||||||
|
required=is_create,
|
||||||
|
help=_('Maximum number of seconds for a monitor to wait for a '
|
||||||
|
'connection to be established before it times out. The '
|
||||||
|
'value must be less than the delay value.'))
|
||||||
|
parser.add_argument(
|
||||||
|
'--http-method',
|
||||||
|
type=utils.convert_to_uppercase,
|
||||||
|
help=_('The HTTP method used for requests by the monitor of type '
|
||||||
|
'HTTP.'))
|
||||||
|
parser.add_argument(
|
||||||
|
'--url-path',
|
||||||
|
help=_('The HTTP path used in the HTTP request used by the monitor '
|
||||||
|
'to test a member health. This must be a string '
|
||||||
|
'beginning with a / (forward slash).'))
|
||||||
|
parser.add_argument(
|
||||||
|
'--max-retries',
|
||||||
|
required=is_create,
|
||||||
|
help=_('Number of permissible connection failures before changing '
|
||||||
|
'the member status to INACTIVE. [1..10].'))
|
||||||
|
parser.add_argument(
|
||||||
|
'--expected-codes',
|
||||||
|
help=_('The list of HTTP status codes expected in '
|
||||||
|
'response from the member to declare it healthy. This '
|
||||||
|
'attribute can contain one value, '
|
||||||
|
'or a list of values separated by comma, '
|
||||||
|
'or a range of values (e.g. "200-299"). If this attribute '
|
||||||
|
'is not specified, it defaults to "200".'))
|
||||||
|
|
||||||
|
|
||||||
|
def _parse_common_args(body, parsed_args):
|
||||||
|
neutronV20.update_dict(parsed_args, body,
|
||||||
|
['expected_codes', 'http_method', 'url_path',
|
||||||
|
'timeout', 'name', 'delay', 'max_retries'])
|
||||||
|
|
||||||
|
|
||||||
class ListHealthMonitor(neutronV20.ListCommand):
|
class ListHealthMonitor(neutronV20.ListCommand):
|
||||||
"""LBaaS v2 List healthmonitors that belong to a given tenant."""
|
"""LBaaS v2 List healthmonitors that belong to a given tenant."""
|
||||||
|
|
||||||
@@ -43,45 +88,11 @@ class CreateHealthMonitor(neutronV20.CreateCommand):
|
|||||||
shadow_resource = 'lbaas_healthmonitor'
|
shadow_resource = 'lbaas_healthmonitor'
|
||||||
|
|
||||||
def add_known_arguments(self, parser):
|
def add_known_arguments(self, parser):
|
||||||
parser.add_argument(
|
_add_common_args(parser)
|
||||||
'--name',
|
|
||||||
help=_('Name of the health monitor to be created.'))
|
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
'--admin-state-down',
|
'--admin-state-down',
|
||||||
dest='admin_state', action='store_false',
|
dest='admin_state', action='store_false',
|
||||||
help=_('Set admin state up to false.'))
|
help=_('Set admin state up to false.'))
|
||||||
parser.add_argument(
|
|
||||||
'--expected-codes',
|
|
||||||
help=_('The list of HTTP status codes expected in '
|
|
||||||
'response from the member to declare it healthy. This '
|
|
||||||
'attribute can contain one value, '
|
|
||||||
'or a list of values separated by comma, '
|
|
||||||
'or a range of values (e.g. "200-299"). If this attribute '
|
|
||||||
'is not specified, it defaults to "200".'))
|
|
||||||
parser.add_argument(
|
|
||||||
'--http-method',
|
|
||||||
help=_('The HTTP method used for requests by the monitor of type '
|
|
||||||
'HTTP.'))
|
|
||||||
parser.add_argument(
|
|
||||||
'--url-path',
|
|
||||||
help=_('The HTTP path used in the HTTP request used by the monitor'
|
|
||||||
' to test a member health. This must be a string '
|
|
||||||
'beginning with a / (forward slash).'))
|
|
||||||
parser.add_argument(
|
|
||||||
'--delay',
|
|
||||||
required=True,
|
|
||||||
help=_('The time in seconds between sending probes to members.'))
|
|
||||||
parser.add_argument(
|
|
||||||
'--max-retries',
|
|
||||||
required=True,
|
|
||||||
help=_('Number of permissible connection failures before changing '
|
|
||||||
'the member status to INACTIVE. [1..10].'))
|
|
||||||
parser.add_argument(
|
|
||||||
'--timeout',
|
|
||||||
required=True,
|
|
||||||
help=_('Maximum number of seconds for a monitor to wait for a '
|
|
||||||
'connection to be established before it times out. The '
|
|
||||||
'value must be less than the delay value.'))
|
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
'--type',
|
'--type',
|
||||||
required=True, choices=['PING', 'TCP', 'HTTP', 'HTTPS'],
|
required=True, choices=['PING', 'TCP', 'HTTP', 'HTTPS'],
|
||||||
@@ -96,14 +107,11 @@ class CreateHealthMonitor(neutronV20.CreateCommand):
|
|||||||
self.get_client(), 'pool', parsed_args.pool,
|
self.get_client(), 'pool', parsed_args.pool,
|
||||||
cmd_resource='lbaas_pool')
|
cmd_resource='lbaas_pool')
|
||||||
body = {'admin_state_up': parsed_args.admin_state,
|
body = {'admin_state_up': parsed_args.admin_state,
|
||||||
'delay': parsed_args.delay,
|
|
||||||
'max_retries': parsed_args.max_retries,
|
|
||||||
'timeout': parsed_args.timeout,
|
|
||||||
'type': parsed_args.type,
|
'type': parsed_args.type,
|
||||||
'pool_id': pool_id}
|
'pool_id': pool_id}
|
||||||
neutronV20.update_dict(parsed_args, body,
|
neutronV20.update_dict(parsed_args, body,
|
||||||
['expected_codes', 'http_method', 'url_path',
|
['tenant_id'])
|
||||||
'tenant_id', 'name'])
|
_parse_common_args(body, parsed_args)
|
||||||
return {self.resource: body}
|
return {self.resource: body}
|
||||||
|
|
||||||
|
|
||||||
@@ -114,13 +122,17 @@ class UpdateHealthMonitor(neutronV20.UpdateCommand):
|
|||||||
shadow_resource = 'lbaas_healthmonitor'
|
shadow_resource = 'lbaas_healthmonitor'
|
||||||
|
|
||||||
def add_known_arguments(self, parser):
|
def add_known_arguments(self, parser):
|
||||||
parser.add_argument(
|
_add_common_args(parser, is_create=False)
|
||||||
'--name',
|
utils.add_boolean_argument(
|
||||||
help=_('Updated name of the health monitor.'))
|
parser, '--admin-state-up',
|
||||||
|
help=_('Update the administrative state of '
|
||||||
|
'the health monitor (True meaning "Up").'))
|
||||||
|
|
||||||
def args2body(self, parsed_args):
|
def args2body(self, parsed_args):
|
||||||
body = {}
|
body = {}
|
||||||
neutronV20.update_dict(parsed_args, body, ['name'])
|
_parse_common_args(body, parsed_args)
|
||||||
|
neutronV20.update_dict(parsed_args, body,
|
||||||
|
['admin_state_up'])
|
||||||
return {self.resource: body}
|
return {self.resource: body}
|
||||||
|
|
||||||
|
|
||||||
|
@@ -37,6 +37,29 @@ def _get_pool_id(client, pool_id_or_name):
|
|||||||
client, 'pool', pool_id_or_name, cmd_resource='lbaas_pool')
|
client, 'pool', pool_id_or_name, cmd_resource='lbaas_pool')
|
||||||
|
|
||||||
|
|
||||||
|
def _add_common_args(parser):
|
||||||
|
parser.add_argument(
|
||||||
|
'--description',
|
||||||
|
help=_('Description of the listener.'))
|
||||||
|
parser.add_argument(
|
||||||
|
'--connection-limit',
|
||||||
|
type=int,
|
||||||
|
help=_('The maximum number of connections per second allowed for '
|
||||||
|
'the vip. Positive integer or -1 for unlimited (default).'))
|
||||||
|
parser.add_argument(
|
||||||
|
'--default-pool',
|
||||||
|
help=_('Default pool for the listener.'))
|
||||||
|
|
||||||
|
|
||||||
|
def _parse_common_args(body, parsed_args, client):
|
||||||
|
neutronV20.update_dict(parsed_args, body,
|
||||||
|
['name', 'description', 'connection_limit'])
|
||||||
|
if parsed_args.default_pool:
|
||||||
|
default_pool_id = _get_pool_id(
|
||||||
|
client, parsed_args.default_pool)
|
||||||
|
body['default_pool_id'] = default_pool_id
|
||||||
|
|
||||||
|
|
||||||
class ListListener(neutronV20.ListCommand):
|
class ListListener(neutronV20.ListCommand):
|
||||||
"""LBaaS v2 List listeners that belong to a given tenant."""
|
"""LBaaS v2 List listeners that belong to a given tenant."""
|
||||||
|
|
||||||
@@ -59,18 +82,11 @@ class CreateListener(neutronV20.CreateCommand):
|
|||||||
resource = 'listener'
|
resource = 'listener'
|
||||||
|
|
||||||
def add_known_arguments(self, parser):
|
def add_known_arguments(self, parser):
|
||||||
|
_add_common_args(parser)
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
'--admin-state-down',
|
'--admin-state-down',
|
||||||
dest='admin_state', action='store_false',
|
dest='admin_state', action='store_false',
|
||||||
help=_('Set admin state up to false.'))
|
help=_('Set admin state up to false.'))
|
||||||
parser.add_argument(
|
|
||||||
'--connection-limit',
|
|
||||||
help=_('The maximum number of connections per second allowed for '
|
|
||||||
'the vip. Positive integer or -1 for unlimited (default).'),
|
|
||||||
type=int)
|
|
||||||
parser.add_argument(
|
|
||||||
'--description',
|
|
||||||
help=_('Description of the listener.'))
|
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
'--name',
|
'--name',
|
||||||
help=_('The name of the listener. At least one of --default-pool '
|
help=_('The name of the listener. At least one of --default-pool '
|
||||||
@@ -85,9 +101,6 @@ class CreateListener(neutronV20.CreateCommand):
|
|||||||
dest='sni_container_refs',
|
dest='sni_container_refs',
|
||||||
nargs='+',
|
nargs='+',
|
||||||
help=_('List of TLS container references for SNI.'))
|
help=_('List of TLS container references for SNI.'))
|
||||||
parser.add_argument(
|
|
||||||
'--default-pool',
|
|
||||||
help=_('Default pool for the listener.'))
|
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
'--loadbalancer',
|
'--loadbalancer',
|
||||||
metavar='LOADBALANCER',
|
metavar='LOADBALANCER',
|
||||||
@@ -105,36 +118,48 @@ class CreateListener(neutronV20.CreateCommand):
|
|||||||
help=_('Protocol port for the listener.'))
|
help=_('Protocol port for the listener.'))
|
||||||
|
|
||||||
def args2body(self, parsed_args):
|
def args2body(self, parsed_args):
|
||||||
resource = {
|
|
||||||
'protocol': parsed_args.protocol,
|
|
||||||
'protocol_port': parsed_args.protocol_port,
|
|
||||||
'admin_state_up': parsed_args.admin_state
|
|
||||||
}
|
|
||||||
if not parsed_args.loadbalancer and not parsed_args.default_pool:
|
if not parsed_args.loadbalancer and not parsed_args.default_pool:
|
||||||
message = _('Either --default-pool or --loadbalancer must be '
|
message = _('Either --default-pool or --loadbalancer must be '
|
||||||
'specified.')
|
'specified.')
|
||||||
raise exceptions.CommandError(message)
|
raise exceptions.CommandError(message)
|
||||||
|
body = {
|
||||||
|
'protocol': parsed_args.protocol,
|
||||||
|
'protocol_port': parsed_args.protocol_port,
|
||||||
|
'admin_state_up': parsed_args.admin_state
|
||||||
|
}
|
||||||
if parsed_args.loadbalancer:
|
if parsed_args.loadbalancer:
|
||||||
loadbalancer_id = _get_loadbalancer_id(
|
loadbalancer_id = _get_loadbalancer_id(
|
||||||
self.get_client(), parsed_args.loadbalancer)
|
self.get_client(), parsed_args.loadbalancer)
|
||||||
resource['loadbalancer_id'] = loadbalancer_id
|
body['loadbalancer_id'] = loadbalancer_id
|
||||||
if parsed_args.default_pool:
|
|
||||||
default_pool_id = _get_pool_id(
|
|
||||||
self.get_client(), parsed_args.default_pool)
|
|
||||||
resource['default_pool_id'] = default_pool_id
|
|
||||||
|
|
||||||
neutronV20.update_dict(parsed_args, resource,
|
neutronV20.update_dict(parsed_args, body,
|
||||||
['connection_limit', 'description',
|
['default_tls_container_ref',
|
||||||
'name', 'default_tls_container_ref',
|
|
||||||
'sni_container_refs', 'tenant_id'])
|
'sni_container_refs', 'tenant_id'])
|
||||||
return {self.resource: resource}
|
_parse_common_args(body, parsed_args, self.get_client())
|
||||||
|
return {self.resource: body}
|
||||||
|
|
||||||
|
|
||||||
class UpdateListener(neutronV20.UpdateCommand):
|
class UpdateListener(neutronV20.UpdateCommand):
|
||||||
"""LBaaS v2 Update a given listener."""
|
"""LBaaS v2 Update a given listener."""
|
||||||
|
|
||||||
resource = 'listener'
|
resource = 'listener'
|
||||||
allow_names = False
|
|
||||||
|
def add_known_arguments(self, parser):
|
||||||
|
_add_common_args(parser)
|
||||||
|
parser.add_argument(
|
||||||
|
'--name',
|
||||||
|
help=_('Name of the listener.'))
|
||||||
|
utils.add_boolean_argument(
|
||||||
|
parser, '--admin-state-up', dest='admin_state_up',
|
||||||
|
help=_('Specify the administrative state of the listener. '
|
||||||
|
'(True meaning "Up")'))
|
||||||
|
|
||||||
|
def args2body(self, parsed_args):
|
||||||
|
body = {}
|
||||||
|
neutronV20.update_dict(parsed_args, body,
|
||||||
|
['admin_state_up'])
|
||||||
|
_parse_common_args(body, parsed_args, self.get_client())
|
||||||
|
return {self.resource: body}
|
||||||
|
|
||||||
|
|
||||||
class DeleteListener(neutronV20.DeleteCommand):
|
class DeleteListener(neutronV20.DeleteCommand):
|
||||||
|
@@ -17,9 +17,24 @@
|
|||||||
from oslo_serialization import jsonutils
|
from oslo_serialization import jsonutils
|
||||||
|
|
||||||
from neutronclient._i18n import _
|
from neutronclient._i18n import _
|
||||||
|
from neutronclient.common import utils
|
||||||
from neutronclient.neutron import v2_0 as neutronV20
|
from neutronclient.neutron import v2_0 as neutronV20
|
||||||
|
|
||||||
|
|
||||||
|
def _add_common_args(parser):
|
||||||
|
parser.add_argument(
|
||||||
|
'--description',
|
||||||
|
help=_('Description of the load balancer.'))
|
||||||
|
parser.add_argument(
|
||||||
|
'--name', metavar='NAME',
|
||||||
|
help=_('Name of the load balancer.'))
|
||||||
|
|
||||||
|
|
||||||
|
def _parse_common_args(body, parsed_args):
|
||||||
|
neutronV20.update_dict(parsed_args, body,
|
||||||
|
['name', 'description'])
|
||||||
|
|
||||||
|
|
||||||
class ListLoadBalancer(neutronV20.ListCommand):
|
class ListLoadBalancer(neutronV20.ListCommand):
|
||||||
"""LBaaS v2 List loadbalancers that belong to a given tenant."""
|
"""LBaaS v2 List loadbalancers that belong to a given tenant."""
|
||||||
|
|
||||||
@@ -40,19 +55,13 @@ class CreateLoadBalancer(neutronV20.CreateCommand):
|
|||||||
"""LBaaS v2 Create a loadbalancer."""
|
"""LBaaS v2 Create a loadbalancer."""
|
||||||
|
|
||||||
resource = 'loadbalancer'
|
resource = 'loadbalancer'
|
||||||
allow_names = True
|
|
||||||
|
|
||||||
def add_known_arguments(self, parser):
|
def add_known_arguments(self, parser):
|
||||||
parser.add_argument(
|
_add_common_args(parser)
|
||||||
'--description',
|
|
||||||
help=_('Description of the load balancer.'))
|
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
'--admin-state-down',
|
'--admin-state-down',
|
||||||
dest='admin_state', action='store_false',
|
dest='admin_state', action='store_false',
|
||||||
help=_('Set admin state up to false.'))
|
help=_('Set admin state up to false.'))
|
||||||
parser.add_argument(
|
|
||||||
'--name', metavar='NAME',
|
|
||||||
help=_('Name of the load balancer.'))
|
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
'--provider',
|
'--provider',
|
||||||
help=_('Provider name of load balancer service.'))
|
help=_('Provider name of load balancer service.'))
|
||||||
@@ -77,8 +86,8 @@ class CreateLoadBalancer(neutronV20.CreateCommand):
|
|||||||
body['flavor_id'] = _flavor_id
|
body['flavor_id'] = _flavor_id
|
||||||
|
|
||||||
neutronV20.update_dict(parsed_args, body,
|
neutronV20.update_dict(parsed_args, body,
|
||||||
['description', 'provider', 'vip_address',
|
['provider', 'vip_address', 'tenant_id'])
|
||||||
'tenant_id', 'name'])
|
_parse_common_args(body, parsed_args)
|
||||||
return {self.resource: body}
|
return {self.resource: body}
|
||||||
|
|
||||||
|
|
||||||
@@ -86,14 +95,26 @@ class UpdateLoadBalancer(neutronV20.UpdateCommand):
|
|||||||
"""LBaaS v2 Update a given loadbalancer."""
|
"""LBaaS v2 Update a given loadbalancer."""
|
||||||
|
|
||||||
resource = 'loadbalancer'
|
resource = 'loadbalancer'
|
||||||
allow_names = True
|
|
||||||
|
def add_known_arguments(self, parser):
|
||||||
|
utils.add_boolean_argument(
|
||||||
|
parser, '--admin-state-up',
|
||||||
|
help=_('Update the administrative state of '
|
||||||
|
'the load balancer (True meaning "Up").'))
|
||||||
|
_add_common_args(parser)
|
||||||
|
|
||||||
|
def args2body(self, parsed_args):
|
||||||
|
body = {}
|
||||||
|
_parse_common_args(body, parsed_args)
|
||||||
|
neutronV20.update_dict(parsed_args, body,
|
||||||
|
['admin_state_up'])
|
||||||
|
return {self.resource: body}
|
||||||
|
|
||||||
|
|
||||||
class DeleteLoadBalancer(neutronV20.DeleteCommand):
|
class DeleteLoadBalancer(neutronV20.DeleteCommand):
|
||||||
"""LBaaS v2 Delete a given loadbalancer."""
|
"""LBaaS v2 Delete a given loadbalancer."""
|
||||||
|
|
||||||
resource = 'loadbalancer'
|
resource = 'loadbalancer'
|
||||||
allow_names = True
|
|
||||||
|
|
||||||
|
|
||||||
class RetrieveLoadBalancerStats(neutronV20.ShowCommand):
|
class RetrieveLoadBalancerStats(neutronV20.ShowCommand):
|
||||||
|
@@ -15,8 +15,10 @@
|
|||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
#
|
#
|
||||||
|
import argparse
|
||||||
|
|
||||||
from neutronclient._i18n import _
|
from neutronclient._i18n import _
|
||||||
|
from neutronclient.common import utils
|
||||||
from neutronclient.neutron import v2_0 as neutronV20
|
from neutronclient.neutron import v2_0 as neutronV20
|
||||||
|
|
||||||
|
|
||||||
@@ -37,6 +39,20 @@ class LbaasMemberMixin(object):
|
|||||||
help=_('ID or name of the pool that this member belongs to.'))
|
help=_('ID or name of the pool that this member belongs to.'))
|
||||||
|
|
||||||
|
|
||||||
|
def _add_common_args(parser):
|
||||||
|
parser.add_argument(
|
||||||
|
'--name',
|
||||||
|
help=_('Name of the member.'))
|
||||||
|
parser.add_argument(
|
||||||
|
'--weight',
|
||||||
|
help=_('Weight of member in the pool (default:1, [0..256]).'))
|
||||||
|
|
||||||
|
|
||||||
|
def _parse_common_args(body, parsed_args):
|
||||||
|
neutronV20.update_dict(parsed_args, body,
|
||||||
|
['weight', 'name'])
|
||||||
|
|
||||||
|
|
||||||
class ListMember(LbaasMemberMixin, neutronV20.ListCommand):
|
class ListMember(LbaasMemberMixin, neutronV20.ListCommand):
|
||||||
"""LBaaS v2 List members that belong to a given pool."""
|
"""LBaaS v2 List members that belong to a given pool."""
|
||||||
|
|
||||||
@@ -69,16 +85,11 @@ class CreateMember(neutronV20.CreateCommand):
|
|||||||
shadow_resource = 'lbaas_member'
|
shadow_resource = 'lbaas_member'
|
||||||
|
|
||||||
def add_known_arguments(self, parser):
|
def add_known_arguments(self, parser):
|
||||||
|
_add_common_args(parser)
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
'--admin-state-down',
|
'--admin-state-down',
|
||||||
dest='admin_state', action='store_false',
|
dest='admin_state', action='store_false',
|
||||||
help=_('Set admin state up to false'))
|
help=_('Set admin state up to false.'))
|
||||||
parser.add_argument(
|
|
||||||
'--weight',
|
|
||||||
help=_('Weight of member in the pool (default:1, [0..256]).'))
|
|
||||||
parser.add_argument(
|
|
||||||
'--name',
|
|
||||||
help=_('Name of the member to be created.'))
|
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
'--subnet',
|
'--subnet',
|
||||||
required=True,
|
required=True,
|
||||||
@@ -105,7 +116,8 @@ class CreateMember(neutronV20.CreateCommand):
|
|||||||
'protocol_port': parsed_args.protocol_port,
|
'protocol_port': parsed_args.protocol_port,
|
||||||
'address': parsed_args.address}
|
'address': parsed_args.address}
|
||||||
neutronV20.update_dict(parsed_args, body,
|
neutronV20.update_dict(parsed_args, body,
|
||||||
['weight', 'subnet_id', 'tenant_id', 'name'])
|
['subnet_id', 'tenant_id'])
|
||||||
|
_parse_common_args(body, parsed_args)
|
||||||
return {self.resource: body}
|
return {self.resource: body}
|
||||||
|
|
||||||
|
|
||||||
@@ -119,22 +131,25 @@ class UpdateMember(neutronV20.UpdateCommand):
|
|||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
'--admin-state-down',
|
'--admin-state-down',
|
||||||
dest='admin_state', action='store_false',
|
dest='admin_state', action='store_false',
|
||||||
help=_('Set admin state up to false'))
|
default=argparse.SUPPRESS,
|
||||||
parser.add_argument(
|
help=_('[DEPRECATED in Mitaka] Set admin state up to false.'))
|
||||||
'--weight',
|
|
||||||
help=_('Weight of member in the pool (default:1, [0..256])'))
|
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
'pool', metavar='POOL',
|
'pool', metavar='POOL',
|
||||||
help=_('ID or name of the pool that this member belongs to'))
|
help=_('ID or name of the pool that this member belongs to.'))
|
||||||
parser.add_argument(
|
utils.add_boolean_argument(
|
||||||
'--name',
|
parser, '--admin-state-up',
|
||||||
help=_('Updated name of the member.'))
|
dest='admin_state',
|
||||||
|
help=_('Update the administrative state of '
|
||||||
|
'the member (True meaning "Up").'))
|
||||||
|
# ToDo(reedip): After Mitaka, remove admin-state-down
|
||||||
|
_add_common_args(parser)
|
||||||
|
|
||||||
def args2body(self, parsed_args):
|
def args2body(self, parsed_args):
|
||||||
self.parent_id = _get_pool_id(self.get_client(), parsed_args.pool)
|
self.parent_id = _get_pool_id(self.get_client(), parsed_args.pool)
|
||||||
body = {}
|
body = {}
|
||||||
neutronV20.update_dict(parsed_args, body,
|
if hasattr(parsed_args, 'admin_state'):
|
||||||
['admin_state_up', 'weight', 'name'])
|
body['admin_state_up'] = parsed_args.admin_state
|
||||||
|
_parse_common_args(body, parsed_args)
|
||||||
return {self.resource: body}
|
return {self.resource: body}
|
||||||
|
|
||||||
|
|
||||||
|
@@ -39,6 +39,29 @@ def _get_listener_id(client, listener_id_or_name):
|
|||||||
client, 'listener', listener_id_or_name)
|
client, 'listener', listener_id_or_name)
|
||||||
|
|
||||||
|
|
||||||
|
def _add_common_args(parser):
|
||||||
|
parser.add_argument(
|
||||||
|
'--description',
|
||||||
|
help=_('Description of the pool.'))
|
||||||
|
parser.add_argument(
|
||||||
|
'--name', help=_('The name of the pool.'))
|
||||||
|
parser.add_argument(
|
||||||
|
'--lb-algorithm',
|
||||||
|
required=True,
|
||||||
|
type=utils.convert_to_uppercase,
|
||||||
|
choices=['ROUND_ROBIN', 'LEAST_CONNECTIONS', 'SOURCE_IP'],
|
||||||
|
help=_('The algorithm used to distribute load between the members '
|
||||||
|
'of the pool.'))
|
||||||
|
|
||||||
|
|
||||||
|
def _parse_common_args(parsed_args):
|
||||||
|
body = {}
|
||||||
|
neutronV20.update_dict(parsed_args,
|
||||||
|
body, ['description', 'lb_algorithm', 'name',
|
||||||
|
'session_persistence'])
|
||||||
|
return body
|
||||||
|
|
||||||
|
|
||||||
class ListPool(neutronV20.ListCommand):
|
class ListPool(neutronV20.ListCommand):
|
||||||
"""LBaaS v2 List pools that belong to a given tenant."""
|
"""LBaaS v2 List pools that belong to a given tenant."""
|
||||||
|
|
||||||
@@ -72,22 +95,11 @@ class CreatePool(neutronV20.CreateCommand):
|
|||||||
shadow_resource = 'lbaas_pool'
|
shadow_resource = 'lbaas_pool'
|
||||||
|
|
||||||
def add_known_arguments(self, parser):
|
def add_known_arguments(self, parser):
|
||||||
|
_add_common_args(parser)
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
'--admin-state-down',
|
'--admin-state-down',
|
||||||
dest='admin_state', action='store_false',
|
dest='admin_state', action='store_false',
|
||||||
help=_('Set admin state up to false.'))
|
help=_('Set admin state up to false.'))
|
||||||
parser.add_argument(
|
|
||||||
'--description',
|
|
||||||
help=_('Description of the pool.'))
|
|
||||||
parser.add_argument(
|
|
||||||
'--session-persistence',
|
|
||||||
metavar='type=TYPE[,cookie_name=COOKIE_NAME]',
|
|
||||||
type=utils.str2dict_type(required_keys=['type'],
|
|
||||||
optional_keys=['cookie_name']),
|
|
||||||
help=_('The type of session persistence to use and associated '
|
|
||||||
'cookie name'))
|
|
||||||
parser.add_argument(
|
|
||||||
'--name', help=_('The name of the pool.'))
|
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
'--listener',
|
'--listener',
|
||||||
help=_('Listener whose default-pool should be set to this pool. '
|
help=_('Listener whose default-pool should be set to this pool. '
|
||||||
@@ -98,43 +110,40 @@ class CreatePool(neutronV20.CreateCommand):
|
|||||||
help=_('Loadbalancer with which this pool should be associated. '
|
help=_('Loadbalancer with which this pool should be associated. '
|
||||||
'At least one of --listener or --loadbalancer must be '
|
'At least one of --listener or --loadbalancer must be '
|
||||||
'specified.'))
|
'specified.'))
|
||||||
parser.add_argument(
|
|
||||||
'--lb-algorithm',
|
|
||||||
required=True,
|
|
||||||
choices=['ROUND_ROBIN', 'LEAST_CONNECTIONS', 'SOURCE_IP'],
|
|
||||||
help=_('The algorithm used to distribute load between the members '
|
|
||||||
'of the pool.'))
|
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
'--protocol',
|
'--protocol',
|
||||||
|
type=utils.convert_to_uppercase,
|
||||||
required=True,
|
required=True,
|
||||||
choices=['HTTP', 'HTTPS', 'TCP'],
|
choices=['HTTP', 'HTTPS', 'TCP'],
|
||||||
type=utils.convert_to_uppercase,
|
|
||||||
help=_('Protocol for balancing.'))
|
help=_('Protocol for balancing.'))
|
||||||
|
parser.add_argument(
|
||||||
|
'--session-persistence',
|
||||||
|
metavar='type=TYPE[,cookie_name=COOKIE_NAME]',
|
||||||
|
type=utils.str2dict_type(required_keys=['type'],
|
||||||
|
optional_keys=['cookie_name']),
|
||||||
|
help=_('The type of session persistence to use and associated '
|
||||||
|
'cookie name.'))
|
||||||
|
|
||||||
def args2body(self, parsed_args):
|
def args2body(self, parsed_args):
|
||||||
resource = {
|
|
||||||
'admin_state_up': parsed_args.admin_state,
|
|
||||||
'protocol': parsed_args.protocol,
|
|
||||||
'lb_algorithm': parsed_args.lb_algorithm
|
|
||||||
}
|
|
||||||
if not parsed_args.listener and not parsed_args.loadbalancer:
|
if not parsed_args.listener and not parsed_args.loadbalancer:
|
||||||
message = _('At least one of --listener or --loadbalancer must be '
|
message = _('At least one of --listener or --loadbalancer must be '
|
||||||
'specified.')
|
'specified.')
|
||||||
raise exceptions.CommandError(message)
|
raise exceptions.CommandError(message)
|
||||||
|
body = _parse_common_args(parsed_args)
|
||||||
if parsed_args.listener:
|
if parsed_args.listener:
|
||||||
listener_id = _get_listener_id(
|
listener_id = _get_listener_id(
|
||||||
self.get_client(),
|
self.get_client(),
|
||||||
parsed_args.listener)
|
parsed_args.listener)
|
||||||
resource['listener_id'] = listener_id
|
body['listener_id'] = listener_id
|
||||||
if parsed_args.loadbalancer:
|
if parsed_args.loadbalancer:
|
||||||
loadbalancer_id = _get_loadbalancer_id(
|
loadbalancer_id = _get_loadbalancer_id(
|
||||||
self.get_client(),
|
self.get_client(),
|
||||||
parsed_args.loadbalancer)
|
parsed_args.loadbalancer)
|
||||||
resource['loadbalancer_id'] = loadbalancer_id
|
body['loadbalancer_id'] = loadbalancer_id
|
||||||
neutronV20.update_dict(parsed_args, resource,
|
body['admin_state_up'] = parsed_args.admin_state
|
||||||
['description', 'name',
|
neutronV20.update_dict(parsed_args, body,
|
||||||
'session_persistence', 'tenant_id'])
|
['tenant_id', 'protocol'])
|
||||||
return {self.resource: resource}
|
return {self.resource: body}
|
||||||
|
|
||||||
|
|
||||||
class UpdatePool(neutronV20.UpdateCommand):
|
class UpdatePool(neutronV20.UpdateCommand):
|
||||||
@@ -143,6 +152,26 @@ class UpdatePool(neutronV20.UpdateCommand):
|
|||||||
resource = 'pool'
|
resource = 'pool'
|
||||||
shadow_resource = 'lbaas_pool'
|
shadow_resource = 'lbaas_pool'
|
||||||
|
|
||||||
|
def add_known_arguments(self, parser):
|
||||||
|
utils.add_boolean_argument(
|
||||||
|
parser, '--admin-state-up',
|
||||||
|
help=_('Update the administrative state of '
|
||||||
|
'the pool (True meaning "Up").'))
|
||||||
|
parser.add_argument(
|
||||||
|
'--session-persistence',
|
||||||
|
metavar='type=TYPE[,cookie_name=COOKIE_NAME]',
|
||||||
|
type=utils.str2dict_type(required_keys=['type'],
|
||||||
|
optional_keys=['cookie_name']),
|
||||||
|
help=_('The type of session persistence to use and associated '
|
||||||
|
'cookie name.'))
|
||||||
|
_add_common_args(parser)
|
||||||
|
|
||||||
|
def args2body(self, parsed_args):
|
||||||
|
body = _parse_common_args(parsed_args)
|
||||||
|
neutronV20.update_dict(parsed_args, body,
|
||||||
|
['admin_state_up'])
|
||||||
|
return {self.resource: body}
|
||||||
|
|
||||||
|
|
||||||
class DeletePool(neutronV20.DeleteCommand):
|
class DeletePool(neutronV20.DeleteCommand):
|
||||||
"""LBaaS v2 Delete a given pool."""
|
"""LBaaS v2 Delete a given pool."""
|
||||||
|
@@ -129,17 +129,40 @@ class CLITestV20LbHealthMonitorJSON(test_cli20.CLITestV20Base):
|
|||||||
args, ['id', 'name'],
|
args, ['id', 'name'],
|
||||||
cmd_resource=cmd_resource)
|
cmd_resource=cmd_resource)
|
||||||
|
|
||||||
def test_update_healthmonitor(self):
|
def _test_update_hm(self, args, expected_values):
|
||||||
# lbaas-healthmonitor-update myid --name newname.
|
|
||||||
resource = 'healthmonitor'
|
resource = 'healthmonitor'
|
||||||
cmd_resource = 'lbaas_healthmonitor'
|
cmd_resource = 'lbaas_healthmonitor'
|
||||||
|
my_id = 'myid'
|
||||||
cmd = healthmonitor.UpdateHealthMonitor(test_cli20.MyApp(sys.stdout),
|
cmd = healthmonitor.UpdateHealthMonitor(test_cli20.MyApp(sys.stdout),
|
||||||
None)
|
None)
|
||||||
self._test_update_resource(resource, cmd, 'myid',
|
args.insert(0, my_id)
|
||||||
['myid', '--name', 'newname'],
|
self._test_update_resource(resource, cmd, my_id,
|
||||||
{'name': 'newname', },
|
args,
|
||||||
|
expected_values,
|
||||||
cmd_resource=cmd_resource)
|
cmd_resource=cmd_resource)
|
||||||
|
|
||||||
|
def test_update_healthmonitor(self):
|
||||||
|
# lbaas-healthmonitor-update myid --name newname.
|
||||||
|
self._test_update_hm(['--name', 'newname'], {'name': 'newname', })
|
||||||
|
# lbaas-healthmonitor-update myid --delay 10.
|
||||||
|
self._test_update_hm(['--delay', '10'], {'delay': '10'})
|
||||||
|
# lbaas-healthmonitor-update myid --timeout 5.
|
||||||
|
self._test_update_hm(['--timeout', '5'], {'timeout': '5', })
|
||||||
|
# lbaas-healthmonitor-update myid --delay 10.
|
||||||
|
self._test_update_hm(['--http-method', 'OPTIONS'],
|
||||||
|
{'http_method': 'OPTIONS'})
|
||||||
|
# lbaas-healthmonitor-update myid --url-path /test/string .
|
||||||
|
self._test_update_hm(['--url-path', '/test/string'],
|
||||||
|
{'url_path': '/test/string', })
|
||||||
|
# lbaas-healthmonitor-update myid --max-retries 5
|
||||||
|
self._test_update_hm(['--max-retries', '5'], {'max_retries': '5'})
|
||||||
|
# lbaas-healthmonitor-update myid --expected-codes 201
|
||||||
|
self._test_update_hm(['--expected-codes', '201'],
|
||||||
|
{'expected_codes': '201'})
|
||||||
|
# lbaas-healthmonitor-update myid --admin-state-up False
|
||||||
|
self._test_update_hm(['--admin-state-up', 'False'],
|
||||||
|
{'admin_state_up': 'False'})
|
||||||
|
|
||||||
def test_delete_healthmonitor(self):
|
def test_delete_healthmonitor(self):
|
||||||
# lbaas-healthmonitor-delete my-id.
|
# lbaas-healthmonitor-delete my-id.
|
||||||
resource = 'healthmonitor'
|
resource = 'healthmonitor'
|
||||||
|
@@ -159,16 +159,30 @@ class CLITestV20LbListenerJSON(test_cli20.CLITestV20Base):
|
|||||||
args, ['id', 'name'],
|
args, ['id', 'name'],
|
||||||
cmd_resource=cmd_resource)
|
cmd_resource=cmd_resource)
|
||||||
|
|
||||||
def test_update_listener(self):
|
def _test_update_listener(self, args, expected_values):
|
||||||
# lbaas-listener-update myid --name newname.
|
|
||||||
resource = 'listener'
|
resource = 'listener'
|
||||||
cmd_resource = 'lbaas_listener'
|
cmd_resource = 'lbaas_listener'
|
||||||
|
my_id = 'myid'
|
||||||
|
args.insert(0, my_id)
|
||||||
cmd = listener.UpdateListener(test_cli20.MyApp(sys.stdout), None)
|
cmd = listener.UpdateListener(test_cli20.MyApp(sys.stdout), None)
|
||||||
self._test_update_resource(resource, cmd, 'myid',
|
self._test_update_resource(resource, cmd, my_id,
|
||||||
['myid', '--name', 'newname'],
|
args, expected_values,
|
||||||
{'name': 'newname', },
|
|
||||||
cmd_resource=cmd_resource)
|
cmd_resource=cmd_resource)
|
||||||
|
|
||||||
|
def test_update_listener(self):
|
||||||
|
# lbaas-listener-update myid --name newname.
|
||||||
|
self._test_update_listener(['--name', 'newname'],
|
||||||
|
{'name': 'newname', })
|
||||||
|
# lbaas-listener-update myid --description check.
|
||||||
|
self._test_update_listener(['--description', 'check'],
|
||||||
|
{'description': 'check', })
|
||||||
|
# lbaas-listener-update myid --connection-limit -1
|
||||||
|
self._test_update_listener(['--connection-limit', '-1'],
|
||||||
|
{'connection_limit': -1, })
|
||||||
|
# lbaas-listener-update myid --admin-state-up False.
|
||||||
|
self._test_update_listener(['--admin-state-up', 'False'],
|
||||||
|
{'admin_state_up': 'False', })
|
||||||
|
|
||||||
def test_delete_listener(self):
|
def test_delete_listener(self):
|
||||||
# lbaas-listener-delete my-id.
|
# lbaas-listener-delete my-id.
|
||||||
resource = 'listener'
|
resource = 'listener'
|
||||||
|
@@ -112,16 +112,26 @@ class CLITestV20LbLoadBalancerJSON(test_cli20.CLITestV20Base):
|
|||||||
args, ['id', 'name'],
|
args, ['id', 'name'],
|
||||||
cmd_resource=cmd_resource)
|
cmd_resource=cmd_resource)
|
||||||
|
|
||||||
def test_update_loadbalancer(self):
|
def _test_update_lb(self, args, expected_values):
|
||||||
# lbaas-loadbalancer-loadbalancer-update myid --name newname.
|
|
||||||
resource = 'loadbalancer'
|
resource = 'loadbalancer'
|
||||||
cmd_resource = 'lbaas_loadbalancer'
|
cmd_resource = 'lbaas_loadbalancer'
|
||||||
|
my_id = 'myid'
|
||||||
|
args.insert(0, my_id)
|
||||||
cmd = lb.UpdateLoadBalancer(test_cli20.MyApp(sys.stdout), None)
|
cmd = lb.UpdateLoadBalancer(test_cli20.MyApp(sys.stdout), None)
|
||||||
self._test_update_resource(resource, cmd, 'myid',
|
self._test_update_resource(resource, cmd, my_id,
|
||||||
['myid', '--name', 'newname'],
|
args, expected_values,
|
||||||
{'name': 'newname', },
|
|
||||||
cmd_resource=cmd_resource)
|
cmd_resource=cmd_resource)
|
||||||
|
|
||||||
|
def test_update_loadbalancer(self):
|
||||||
|
# lbaas-loadbalancer-update myid --name newname.
|
||||||
|
self._test_update_lb(['--name', 'newname'], {'name': 'newname', })
|
||||||
|
# lbaas-loadbalancer-update myid --description check.
|
||||||
|
self._test_update_lb(['--description', 'check'],
|
||||||
|
{'description': 'check', })
|
||||||
|
# lbaas-loadbalancer-update myid --admin-state-up False.
|
||||||
|
self._test_update_lb(['--admin-state-up', 'False'],
|
||||||
|
{'admin_state_up': 'False', })
|
||||||
|
|
||||||
def test_delete_loadbalancer(self):
|
def test_delete_loadbalancer(self):
|
||||||
# lbaas-loadbalancer-loadbalancer-delete my-id.
|
# lbaas-loadbalancer-loadbalancer-delete my-id.
|
||||||
resource = 'loadbalancer'
|
resource = 'loadbalancer'
|
||||||
|
@@ -61,7 +61,7 @@ class CLITestV20LbMemberJSON(test_cli20.CLITestV20Base):
|
|||||||
'subnet_id', 'weight', 'name']
|
'subnet_id', 'weight', 'name']
|
||||||
position_values = [False, address, protocol_port,
|
position_values = [False, address, protocol_port,
|
||||||
subnet_id, weight, name]
|
subnet_id, weight, name]
|
||||||
self._test_create_resource(resource, cmd, '', my_id, args,
|
self._test_create_resource(resource, cmd, name, my_id, args,
|
||||||
position_names, position_values,
|
position_names, position_values,
|
||||||
cmd_resource=cmd_resource,
|
cmd_resource=cmd_resource,
|
||||||
parent_id=pool_id)
|
parent_id=pool_id)
|
||||||
@@ -145,6 +145,18 @@ class CLITestV20LbMemberJSON(test_cli20.CLITestV20Base):
|
|||||||
{'name': 'newname', },
|
{'name': 'newname', },
|
||||||
cmd_resource=cmd_resource,
|
cmd_resource=cmd_resource,
|
||||||
parent_id=pool_id)
|
parent_id=pool_id)
|
||||||
|
# lbaas-member-update myid --weight 100.
|
||||||
|
args = [my_id, pool_id, '--weight', '100']
|
||||||
|
self._test_update_resource(resource, cmd, my_id, args,
|
||||||
|
{'weight': '100', },
|
||||||
|
cmd_resource=cmd_resource,
|
||||||
|
parent_id=pool_id)
|
||||||
|
# lbaas-member-update myid --admin-state-up False
|
||||||
|
args = [my_id, pool_id, '--admin-state-up', 'False']
|
||||||
|
self._test_update_resource(resource, cmd, my_id, args,
|
||||||
|
{'admin_state_up': 'False', },
|
||||||
|
cmd_resource=cmd_resource,
|
||||||
|
parent_id=pool_id)
|
||||||
|
|
||||||
def test_delete_member(self):
|
def test_delete_member(self):
|
||||||
# lbaas-member-delete my-id.
|
# lbaas-member-delete my-id.
|
||||||
|
@@ -157,13 +157,27 @@ class CLITestV20LbPoolJSON(test_cli20.CLITestV20Base):
|
|||||||
cmd_resource=cmd_resource)
|
cmd_resource=cmd_resource)
|
||||||
|
|
||||||
def test_update_pool(self):
|
def test_update_pool(self):
|
||||||
# lbaas-pool-update myid --name newname.
|
# lbaas-pool-update myid --name newname --description SuperPool
|
||||||
|
# --lb-algorithm SOURCE_IP --admin-state-up
|
||||||
|
# --session-persistence type=dict,type=HTTP_COOKIE,cookie_name=pie
|
||||||
|
|
||||||
resource = 'pool'
|
resource = 'pool'
|
||||||
cmd_resource = 'lbaas_pool'
|
cmd_resource = 'lbaas_pool'
|
||||||
cmd = pool.UpdatePool(test_cli20.MyApp(sys.stdout), None)
|
cmd = pool.UpdatePool(test_cli20.MyApp(sys.stdout), None)
|
||||||
self._test_update_resource(resource, cmd, 'myid',
|
args = ['myid', '--name', 'newname',
|
||||||
['myid', '--name', 'newname'],
|
'--description', 'SuperPool', '--lb-algorithm', "SOURCE_IP",
|
||||||
{'name': 'newname', },
|
'--admin-state-up', 'True',
|
||||||
|
'--session-persistence', 'type=dict,'
|
||||||
|
'type=HTTP_COOKIE,cookie_name=pie']
|
||||||
|
body = {'name': 'newname',
|
||||||
|
"description": "SuperPool",
|
||||||
|
"lb_algorithm": "SOURCE_IP",
|
||||||
|
"admin_state_up": 'True',
|
||||||
|
'session_persistence': {
|
||||||
|
'type': 'HTTP_COOKIE',
|
||||||
|
'cookie_name': 'pie',
|
||||||
|
}, }
|
||||||
|
self._test_update_resource(resource, cmd, 'myid', args, body,
|
||||||
cmd_resource=cmd_resource)
|
cmd_resource=cmd_resource)
|
||||||
|
|
||||||
def test_delete_pool(self):
|
def test_delete_pool(self):
|
||||||
|
Reference in New Issue
Block a user