Merge "Fixed pool and health monitor create bugs"

This commit is contained in:
Jenkins
2015-03-05 19:07:44 +00:00
committed by Gerrit Code Review
4 changed files with 26 additions and 25 deletions

View File

@@ -86,8 +86,15 @@ class CreateHealthMonitor(neutronV20.CreateCommand):
'--type',
required=True, choices=['PING', 'TCP', 'HTTP', 'HTTPS'],
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):
pool_id = neutronV20.find_resourceid_by_name_or_id(
self.get_client(), 'pool', parsed_args.pool,
cmd_resource='lbaas_pool')
body = {
self.resource: {
'admin_state_up': parsed_args.admin_state,
@@ -95,6 +102,7 @@ class CreateHealthMonitor(neutronV20.CreateCommand):
'max_retries': parsed_args.max_retries,
'timeout': parsed_args.timeout,
'type': parsed_args.type,
'pool_id': pool_id
},
}
neutronV20.update_dict(parsed_args, body[self.resource],

View File

@@ -75,12 +75,11 @@ class CreatePool(neutronV20.CreateCommand):
parser.add_argument(
'--description',
help=_('Description of the pool.'))
parser.add_argument(
'--healthmonitor-id',
help=_('ID of the health monitor to use.'))
parser.add_argument(
'--session-persistence', metavar='TYPE:VALUE',
help=_('The type of session persistence to use.'))
parser.add_argument(
'--name', help=_('The name of the pool.'))
parser.add_argument(
'--lb-algorithm',
required=True,
@@ -96,9 +95,6 @@ class CreatePool(neutronV20.CreateCommand):
required=True,
choices=['HTTP', 'HTTPS', 'TCP'],
help=_('Protocol for balancing.'))
parser.add_argument(
'name', metavar='NAME',
help=_('The name of the pool.'))
def args2body(self, parsed_args):
if parsed_args.session_persistence:
@@ -107,7 +103,6 @@ class CreatePool(neutronV20.CreateCommand):
self.get_client(), 'listener', parsed_args.listener)
body = {
self.resource: {
'name': parsed_args.name,
'admin_state_up': parsed_args.admin_state,
'protocol': parsed_args.protocol,
'lb_algorithm': parsed_args.lb_algorithm,
@@ -115,7 +110,7 @@ class CreatePool(neutronV20.CreateCommand):
},
}
neutronV20.update_dict(parsed_args, body[self.resource],
['description', 'healthmonitor_id',
['description', 'name',
'session_persistence'])
return body

View File

@@ -35,10 +35,11 @@ class CLITestV20LbHealthMonitorJSON(test_cli20.CLITestV20Base):
max_retries = '3'
delay = '10'
timeout = '60'
pool = 'pool1'
args = ['--type', type, '--max-retries', max_retries,
'--delay', delay, '--timeout', timeout]
position_names = ['type', 'max_retries', 'delay', 'timeout']
position_values = [type, max_retries, delay, timeout]
'--delay', delay, '--timeout', timeout, '--pool', pool]
position_names = ['type', 'max_retries', 'delay', 'timeout', 'pool_id']
position_values = [type, max_retries, delay, timeout, pool]
self._test_create_resource(resource, cmd, '', my_id, args,
position_names, position_values,
cmd_resource=cmd_resource)
@@ -57,15 +58,16 @@ class CLITestV20LbHealthMonitorJSON(test_cli20.CLITestV20Base):
http_method = 'GET'
expected_codes = '201'
url_path = '/somepath'
pool = 'pool1'
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]
'--delay', delay, '--timeout', timeout, '--pool', pool]
position_names = ['admin_state_up', 'http_method', 'expected_codes',
'url_path', 'type', 'max_retries', 'delay',
'timeout']
'timeout', 'pool_id']
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,
position_names, position_values,
cmd_resource=cmd_resource)

View File

@@ -33,12 +33,11 @@ class CLITestV20LbPoolJSON(test_cli20.CLITestV20Base):
lb_algorithm = 'ROUND_ROBIN'
listener = 'listener'
protocol = 'TCP'
name = 'my-pool'
args = ['--lb-algorithm', lb_algorithm, '--protocol', protocol,
'--listener', listener, name]
'--listener', listener]
position_names = ['admin_state_up', 'lb_algorithm', 'protocol',
'listener_id', 'name']
position_values = [True, lb_algorithm, protocol, listener, name]
'listener_id']
position_values = [True, lb_algorithm, protocol, listener]
self._test_create_resource(resource, cmd, '', my_id, args,
position_names, position_values,
cmd_resource=cmd_resource)
@@ -56,19 +55,16 @@ class CLITestV20LbPoolJSON(test_cli20.CLITestV20Base):
session_persistence_str = 'HTTP_COOKIE:1234'
session_persistence = {'type': 'HTTP_COOKIE',
'cookie_name': '1234'}
healthmon_id = 'healthmon-id'
name = 'my-pool'
args = ['--lb-algorithm', lb_algorithm, '--protocol', protocol,
'--description', description, '--session-persistence',
session_persistence_str, '--healthmonitor-id',
healthmon_id, '--admin-state-down', name,
session_persistence_str, '--admin-state-down', '--name', name,
'--listener', listener]
position_names = ['lb_algorithm', 'protocol', 'description',
'session_persistence', 'healthmonitor_id',
'admin_state_up', 'listener_id', 'name']
'session_persistence', 'admin_state_up', 'name',
'listener_id']
position_values = [lb_algorithm, protocol, description,
session_persistence, healthmon_id,
False, listener, name]
session_persistence, False, name, listener]
self._test_create_resource(resource, cmd, '', my_id, args,
position_names, position_values,
cmd_resource=cmd_resource)