diff --git a/neutronclient/neutron/v2_0/lb/v2/healthmonitor.py b/neutronclient/neutron/v2_0/lb/v2/healthmonitor.py index 23136f74f..ff1c11e3c 100644 --- a/neutronclient/neutron/v2_0/lb/v2/healthmonitor.py +++ b/neutronclient/neutron/v2_0/lb/v2/healthmonitor.py @@ -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], diff --git a/neutronclient/neutron/v2_0/lb/v2/pool.py b/neutronclient/neutron/v2_0/lb/v2/pool.py index 11644be45..7182171b3 100644 --- a/neutronclient/neutron/v2_0/lb/v2/pool.py +++ b/neutronclient/neutron/v2_0/lb/v2/pool.py @@ -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 diff --git a/neutronclient/tests/unit/lb/v2/test_cli20_healthmonitor.py b/neutronclient/tests/unit/lb/v2/test_cli20_healthmonitor.py index 20af12762..96f96a68f 100644 --- a/neutronclient/tests/unit/lb/v2/test_cli20_healthmonitor.py +++ b/neutronclient/tests/unit/lb/v2/test_cli20_healthmonitor.py @@ -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) diff --git a/neutronclient/tests/unit/lb/v2/test_cli20_pool.py b/neutronclient/tests/unit/lb/v2/test_cli20_pool.py index daf3e5292..77b565562 100644 --- a/neutronclient/tests/unit/lb/v2/test_cli20_pool.py +++ b/neutronclient/tests/unit/lb/v2/test_cli20_pool.py @@ -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)