Merge "Fixed pool and health monitor create bugs"
This commit is contained in:
@@ -86,8 +86,15 @@ class CreateHealthMonitor(neutronV20.CreateCommand):
|
|||||||
'--type',
|
'--type',
|
||||||
required=True, choices=['PING', 'TCP', 'HTTP', 'HTTPS'],
|
required=True, choices=['PING', 'TCP', 'HTTP', 'HTTPS'],
|
||||||
help=_('One of the predefined health monitor types.'))
|
help=_('One of the predefined health monitor types.'))
|
||||||
|
parser.add_argument(
|
||||||
|
'--pool', required=True,
|
||||||
|
help=_('ID or name of the pool that this healthmonitor will '
|
||||||
|
'monitor.'))
|
||||||
|
|
||||||
def args2body(self, parsed_args):
|
def args2body(self, parsed_args):
|
||||||
|
pool_id = neutronV20.find_resourceid_by_name_or_id(
|
||||||
|
self.get_client(), 'pool', parsed_args.pool,
|
||||||
|
cmd_resource='lbaas_pool')
|
||||||
body = {
|
body = {
|
||||||
self.resource: {
|
self.resource: {
|
||||||
'admin_state_up': parsed_args.admin_state,
|
'admin_state_up': parsed_args.admin_state,
|
||||||
@@ -95,6 +102,7 @@ class CreateHealthMonitor(neutronV20.CreateCommand):
|
|||||||
'max_retries': parsed_args.max_retries,
|
'max_retries': parsed_args.max_retries,
|
||||||
'timeout': parsed_args.timeout,
|
'timeout': parsed_args.timeout,
|
||||||
'type': parsed_args.type,
|
'type': parsed_args.type,
|
||||||
|
'pool_id': pool_id
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
neutronV20.update_dict(parsed_args, body[self.resource],
|
neutronV20.update_dict(parsed_args, body[self.resource],
|
||||||
|
@@ -75,12 +75,11 @@ class CreatePool(neutronV20.CreateCommand):
|
|||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
'--description',
|
'--description',
|
||||||
help=_('Description of the pool.'))
|
help=_('Description of the pool.'))
|
||||||
parser.add_argument(
|
|
||||||
'--healthmonitor-id',
|
|
||||||
help=_('ID of the health monitor to use.'))
|
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
'--session-persistence', metavar='TYPE:VALUE',
|
'--session-persistence', metavar='TYPE:VALUE',
|
||||||
help=_('The type of session persistence to use.'))
|
help=_('The type of session persistence to use.'))
|
||||||
|
parser.add_argument(
|
||||||
|
'--name', help=_('The name of the pool.'))
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
'--lb-algorithm',
|
'--lb-algorithm',
|
||||||
required=True,
|
required=True,
|
||||||
@@ -96,9 +95,6 @@ class CreatePool(neutronV20.CreateCommand):
|
|||||||
required=True,
|
required=True,
|
||||||
choices=['HTTP', 'HTTPS', 'TCP'],
|
choices=['HTTP', 'HTTPS', 'TCP'],
|
||||||
help=_('Protocol for balancing.'))
|
help=_('Protocol for balancing.'))
|
||||||
parser.add_argument(
|
|
||||||
'name', metavar='NAME',
|
|
||||||
help=_('The name of the pool.'))
|
|
||||||
|
|
||||||
def args2body(self, parsed_args):
|
def args2body(self, parsed_args):
|
||||||
if parsed_args.session_persistence:
|
if parsed_args.session_persistence:
|
||||||
@@ -107,7 +103,6 @@ class CreatePool(neutronV20.CreateCommand):
|
|||||||
self.get_client(), 'listener', parsed_args.listener)
|
self.get_client(), 'listener', parsed_args.listener)
|
||||||
body = {
|
body = {
|
||||||
self.resource: {
|
self.resource: {
|
||||||
'name': parsed_args.name,
|
|
||||||
'admin_state_up': parsed_args.admin_state,
|
'admin_state_up': parsed_args.admin_state,
|
||||||
'protocol': parsed_args.protocol,
|
'protocol': parsed_args.protocol,
|
||||||
'lb_algorithm': parsed_args.lb_algorithm,
|
'lb_algorithm': parsed_args.lb_algorithm,
|
||||||
@@ -115,7 +110,7 @@ class CreatePool(neutronV20.CreateCommand):
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
neutronV20.update_dict(parsed_args, body[self.resource],
|
neutronV20.update_dict(parsed_args, body[self.resource],
|
||||||
['description', 'healthmonitor_id',
|
['description', 'name',
|
||||||
'session_persistence'])
|
'session_persistence'])
|
||||||
return body
|
return body
|
||||||
|
|
||||||
|
@@ -35,10 +35,11 @@ class CLITestV20LbHealthMonitorJSON(test_cli20.CLITestV20Base):
|
|||||||
max_retries = '3'
|
max_retries = '3'
|
||||||
delay = '10'
|
delay = '10'
|
||||||
timeout = '60'
|
timeout = '60'
|
||||||
|
pool = 'pool1'
|
||||||
args = ['--type', type, '--max-retries', max_retries,
|
args = ['--type', type, '--max-retries', max_retries,
|
||||||
'--delay', delay, '--timeout', timeout]
|
'--delay', delay, '--timeout', timeout, '--pool', pool]
|
||||||
position_names = ['type', 'max_retries', 'delay', 'timeout']
|
position_names = ['type', 'max_retries', 'delay', 'timeout', 'pool_id']
|
||||||
position_values = [type, max_retries, delay, timeout]
|
position_values = [type, max_retries, delay, timeout, pool]
|
||||||
self._test_create_resource(resource, cmd, '', my_id, args,
|
self._test_create_resource(resource, cmd, '', my_id, args,
|
||||||
position_names, position_values,
|
position_names, position_values,
|
||||||
cmd_resource=cmd_resource)
|
cmd_resource=cmd_resource)
|
||||||
@@ -57,15 +58,16 @@ class CLITestV20LbHealthMonitorJSON(test_cli20.CLITestV20Base):
|
|||||||
http_method = 'GET'
|
http_method = 'GET'
|
||||||
expected_codes = '201'
|
expected_codes = '201'
|
||||||
url_path = '/somepath'
|
url_path = '/somepath'
|
||||||
|
pool = 'pool1'
|
||||||
args = ['--admin-state-down', '--http-method', http_method,
|
args = ['--admin-state-down', '--http-method', http_method,
|
||||||
'--expected-codes', expected_codes, '--url-path', url_path,
|
'--expected-codes', expected_codes, '--url-path', url_path,
|
||||||
'--type', type, '--max-retries', max_retries,
|
'--type', type, '--max-retries', max_retries,
|
||||||
'--delay', delay, '--timeout', timeout]
|
'--delay', delay, '--timeout', timeout, '--pool', pool]
|
||||||
position_names = ['admin_state_up', 'http_method', 'expected_codes',
|
position_names = ['admin_state_up', 'http_method', 'expected_codes',
|
||||||
'url_path', 'type', 'max_retries', 'delay',
|
'url_path', 'type', 'max_retries', 'delay',
|
||||||
'timeout']
|
'timeout', 'pool_id']
|
||||||
position_values = [False, http_method, expected_codes, url_path,
|
position_values = [False, http_method, expected_codes, url_path,
|
||||||
type, max_retries, delay, timeout]
|
type, max_retries, delay, timeout, pool]
|
||||||
self._test_create_resource(resource, cmd, '', my_id, args,
|
self._test_create_resource(resource, cmd, '', my_id, args,
|
||||||
position_names, position_values,
|
position_names, position_values,
|
||||||
cmd_resource=cmd_resource)
|
cmd_resource=cmd_resource)
|
||||||
|
@@ -33,12 +33,11 @@ class CLITestV20LbPoolJSON(test_cli20.CLITestV20Base):
|
|||||||
lb_algorithm = 'ROUND_ROBIN'
|
lb_algorithm = 'ROUND_ROBIN'
|
||||||
listener = 'listener'
|
listener = 'listener'
|
||||||
protocol = 'TCP'
|
protocol = 'TCP'
|
||||||
name = 'my-pool'
|
|
||||||
args = ['--lb-algorithm', lb_algorithm, '--protocol', protocol,
|
args = ['--lb-algorithm', lb_algorithm, '--protocol', protocol,
|
||||||
'--listener', listener, name]
|
'--listener', listener]
|
||||||
position_names = ['admin_state_up', 'lb_algorithm', 'protocol',
|
position_names = ['admin_state_up', 'lb_algorithm', 'protocol',
|
||||||
'listener_id', 'name']
|
'listener_id']
|
||||||
position_values = [True, lb_algorithm, protocol, listener, name]
|
position_values = [True, lb_algorithm, protocol, listener]
|
||||||
self._test_create_resource(resource, cmd, '', my_id, args,
|
self._test_create_resource(resource, cmd, '', my_id, args,
|
||||||
position_names, position_values,
|
position_names, position_values,
|
||||||
cmd_resource=cmd_resource)
|
cmd_resource=cmd_resource)
|
||||||
@@ -56,19 +55,16 @@ class CLITestV20LbPoolJSON(test_cli20.CLITestV20Base):
|
|||||||
session_persistence_str = 'HTTP_COOKIE:1234'
|
session_persistence_str = 'HTTP_COOKIE:1234'
|
||||||
session_persistence = {'type': 'HTTP_COOKIE',
|
session_persistence = {'type': 'HTTP_COOKIE',
|
||||||
'cookie_name': '1234'}
|
'cookie_name': '1234'}
|
||||||
healthmon_id = 'healthmon-id'
|
|
||||||
name = 'my-pool'
|
name = 'my-pool'
|
||||||
args = ['--lb-algorithm', lb_algorithm, '--protocol', protocol,
|
args = ['--lb-algorithm', lb_algorithm, '--protocol', protocol,
|
||||||
'--description', description, '--session-persistence',
|
'--description', description, '--session-persistence',
|
||||||
session_persistence_str, '--healthmonitor-id',
|
session_persistence_str, '--admin-state-down', '--name', name,
|
||||||
healthmon_id, '--admin-state-down', name,
|
|
||||||
'--listener', listener]
|
'--listener', listener]
|
||||||
position_names = ['lb_algorithm', 'protocol', 'description',
|
position_names = ['lb_algorithm', 'protocol', 'description',
|
||||||
'session_persistence', 'healthmonitor_id',
|
'session_persistence', 'admin_state_up', 'name',
|
||||||
'admin_state_up', 'listener_id', 'name']
|
'listener_id']
|
||||||
position_values = [lb_algorithm, protocol, description,
|
position_values = [lb_algorithm, protocol, description,
|
||||||
session_persistence, healthmon_id,
|
session_persistence, False, name, listener]
|
||||||
False, listener, name]
|
|
||||||
self._test_create_resource(resource, cmd, '', my_id, args,
|
self._test_create_resource(resource, cmd, '', my_id, args,
|
||||||
position_names, position_values,
|
position_names, position_values,
|
||||||
cmd_resource=cmd_resource)
|
cmd_resource=cmd_resource)
|
||||||
|
Reference in New Issue
Block a user