Support for Name field in Members and HMs
This patch adds support to enable naming LBaasV2 Members and Health Monitors(HMs) in python-neutronclient. Closes-Bug: #1515506 Change-Id: I27ac48953bb09841234fce6d852f062e2030284e
This commit is contained in:
parent
2ccf62fc44
commit
b779855629
|
@ -24,7 +24,7 @@ class ListHealthMonitor(neutronV20.ListCommand):
|
|||
|
||||
resource = 'healthmonitor'
|
||||
shadow_resource = 'lbaas_healthmonitor'
|
||||
list_columns = ['id', 'type', 'admin_state_up']
|
||||
list_columns = ['id', 'name', 'type', 'admin_state_up']
|
||||
pagination_support = True
|
||||
sorting_support = True
|
||||
|
||||
|
@ -43,6 +43,9 @@ class CreateHealthMonitor(neutronV20.CreateCommand):
|
|||
shadow_resource = 'lbaas_healthmonitor'
|
||||
|
||||
def add_known_arguments(self, parser):
|
||||
parser.add_argument(
|
||||
'--name',
|
||||
help=_('Name of the health monitor to be created.'))
|
||||
parser.add_argument(
|
||||
'--admin-state-down',
|
||||
dest='admin_state', action='store_false',
|
||||
|
@ -100,7 +103,7 @@ class CreateHealthMonitor(neutronV20.CreateCommand):
|
|||
'pool_id': pool_id}
|
||||
neutronV20.update_dict(parsed_args, body,
|
||||
['expected_codes', 'http_method', 'url_path',
|
||||
'tenant_id'])
|
||||
'tenant_id', 'name'])
|
||||
return {self.resource: body}
|
||||
|
||||
|
||||
|
@ -109,7 +112,16 @@ class UpdateHealthMonitor(neutronV20.UpdateCommand):
|
|||
|
||||
resource = 'healthmonitor'
|
||||
shadow_resource = 'lbaas_healthmonitor'
|
||||
allow_names = False
|
||||
|
||||
def add_known_arguments(self, parser):
|
||||
parser.add_argument(
|
||||
'--name',
|
||||
help=_('Updated name of the health monitor.'))
|
||||
|
||||
def args2body(self, parsed_args):
|
||||
body = {}
|
||||
neutronV20.update_dict(parsed_args, body, ['name'])
|
||||
return {self.resource: body}
|
||||
|
||||
|
||||
class DeleteHealthMonitor(neutronV20.DeleteCommand):
|
||||
|
|
|
@ -43,7 +43,7 @@ class ListMember(LbaasMemberMixin, neutronV20.ListCommand):
|
|||
resource = 'member'
|
||||
shadow_resource = 'lbaas_member'
|
||||
list_columns = [
|
||||
'id', 'address', 'protocol_port', 'weight',
|
||||
'id', 'name', 'address', 'protocol_port', 'weight',
|
||||
'subnet_id', 'admin_state_up', 'status'
|
||||
]
|
||||
pagination_support = True
|
||||
|
@ -76,6 +76,9 @@ class CreateMember(neutronV20.CreateCommand):
|
|||
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(
|
||||
'--subnet',
|
||||
required=True,
|
||||
|
@ -102,7 +105,7 @@ class CreateMember(neutronV20.CreateCommand):
|
|||
'protocol_port': parsed_args.protocol_port,
|
||||
'address': parsed_args.address}
|
||||
neutronV20.update_dict(parsed_args, body,
|
||||
['weight', 'subnet_id', 'tenant_id'])
|
||||
['weight', 'subnet_id', 'tenant_id', 'name'])
|
||||
return {self.resource: body}
|
||||
|
||||
|
||||
|
@ -123,12 +126,15 @@ class UpdateMember(neutronV20.UpdateCommand):
|
|||
parser.add_argument(
|
||||
'pool', metavar='POOL',
|
||||
help=_('ID or name of the pool that this member belongs to'))
|
||||
parser.add_argument(
|
||||
'--name',
|
||||
help=_('Updated name of the member.'))
|
||||
|
||||
def args2body(self, parsed_args):
|
||||
self.parent_id = _get_pool_id(self.get_client(), parsed_args.pool)
|
||||
body = {}
|
||||
neutronV20.update_dict(parsed_args, body,
|
||||
['admin_state_up', 'weight'])
|
||||
['admin_state_up', 'weight', 'name'])
|
||||
return {self.resource: body}
|
||||
|
||||
|
||||
|
|
|
@ -57,15 +57,17 @@ class CLITestV20LbHealthMonitorJSON(test_cli20.CLITestV20Base):
|
|||
expected_codes = '201'
|
||||
url_path = '/somepath'
|
||||
pool = 'pool1'
|
||||
name = 'healthmonitor1'
|
||||
args = ['--admin-state-down', '--http-method', http_method,
|
||||
'--expected-codes', expected_codes, '--url-path', url_path,
|
||||
'--type', type, '--max-retries', max_retries,
|
||||
'--delay', delay, '--timeout', timeout, '--pool', pool]
|
||||
'--delay', delay, '--timeout', timeout, '--pool', pool,
|
||||
'--name', name]
|
||||
position_names = ['admin_state_up', 'http_method', 'expected_codes',
|
||||
'url_path', 'type', 'max_retries', 'delay',
|
||||
'timeout', 'pool_id']
|
||||
'timeout', 'pool_id', 'name']
|
||||
position_values = [False, http_method, expected_codes, url_path,
|
||||
type, max_retries, delay, timeout, pool]
|
||||
type, max_retries, delay, timeout, pool, name]
|
||||
self._test_create_resource(resource, cmd, '', my_id, args,
|
||||
position_names, position_values,
|
||||
cmd_resource=cmd_resource)
|
||||
|
|
|
@ -53,12 +53,14 @@ class CLITestV20LbMemberJSON(test_cli20.CLITestV20Base):
|
|||
pool_id = 'pool-id'
|
||||
subnet_id = 'subnet-id'
|
||||
weight = '100'
|
||||
name = 'member1'
|
||||
args = ['--address', address, '--protocol-port', protocol_port,
|
||||
'--subnet', subnet_id, pool_id, '--weight', weight,
|
||||
'--admin-state-down']
|
||||
'--admin-state-down', '--name', name]
|
||||
position_names = ['admin_state_up', 'address', 'protocol_port',
|
||||
'subnet_id', 'weight']
|
||||
position_values = [False, address, protocol_port, subnet_id, weight]
|
||||
'subnet_id', 'weight', 'name']
|
||||
position_values = [False, address, protocol_port,
|
||||
subnet_id, weight, name]
|
||||
self._test_create_resource(resource, cmd, '', my_id, args,
|
||||
position_names, position_values,
|
||||
cmd_resource=cmd_resource,
|
||||
|
|
Loading…
Reference in New Issue