Simplify clearing session-persistence
Currently Session Persistance for a pool can be cleared by "neutron lbaas-pool-update pool --session-persistence type=dict type=NONE" But this option seems to be a bit long and complicated, so therefore this patch tries to simplify it by adding a new option --no-session-persistence, which does the same job. Change-Id: Iacafe765a2f0f9537a4e4d01b9b8086a9e313b92 Depends-On: I654b172927e1d96677a7da9e0846231b0ac48aa9
This commit is contained in:
@@ -39,7 +39,7 @@ 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):
|
def _add_common_args(parser, is_create=True):
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
'--description',
|
'--description',
|
||||||
help=_('Description of the pool.'))
|
help=_('Description of the pool.'))
|
||||||
@@ -47,7 +47,7 @@ def _add_common_args(parser):
|
|||||||
'--name', help=_('The name of the pool.'))
|
'--name', help=_('The name of the pool.'))
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
'--lb-algorithm',
|
'--lb-algorithm',
|
||||||
required=True,
|
required=is_create,
|
||||||
type=utils.convert_to_uppercase,
|
type=utils.convert_to_uppercase,
|
||||||
choices=['ROUND_ROBIN', 'LEAST_CONNECTIONS', 'SOURCE_IP'],
|
choices=['ROUND_ROBIN', 'LEAST_CONNECTIONS', 'SOURCE_IP'],
|
||||||
help=_('The algorithm used to distribute load between the members '
|
help=_('The algorithm used to distribute load between the members '
|
||||||
@@ -57,8 +57,7 @@ def _add_common_args(parser):
|
|||||||
def _parse_common_args(parsed_args):
|
def _parse_common_args(parsed_args):
|
||||||
body = {}
|
body = {}
|
||||||
neutronV20.update_dict(parsed_args,
|
neutronV20.update_dict(parsed_args,
|
||||||
body, ['description', 'lb_algorithm', 'name',
|
body, ['description', 'lb_algorithm', 'name'])
|
||||||
'session_persistence'])
|
|
||||||
return body
|
return body
|
||||||
|
|
||||||
|
|
||||||
@@ -142,7 +141,8 @@ class CreatePool(neutronV20.CreateCommand):
|
|||||||
body['loadbalancer_id'] = loadbalancer_id
|
body['loadbalancer_id'] = loadbalancer_id
|
||||||
body['admin_state_up'] = parsed_args.admin_state
|
body['admin_state_up'] = parsed_args.admin_state
|
||||||
neutronV20.update_dict(parsed_args, body,
|
neutronV20.update_dict(parsed_args, body,
|
||||||
['tenant_id', 'protocol'])
|
['tenant_id', 'protocol',
|
||||||
|
'session_persistence'])
|
||||||
return {self.resource: body}
|
return {self.resource: body}
|
||||||
|
|
||||||
|
|
||||||
@@ -157,17 +157,26 @@ class UpdatePool(neutronV20.UpdateCommand):
|
|||||||
parser, '--admin-state-up',
|
parser, '--admin-state-up',
|
||||||
help=_('Update the administrative state of '
|
help=_('Update the administrative state of '
|
||||||
'the pool (True meaning "Up").'))
|
'the pool (True meaning "Up").'))
|
||||||
parser.add_argument(
|
session_group = parser.add_mutually_exclusive_group()
|
||||||
|
session_group.add_argument(
|
||||||
'--session-persistence',
|
'--session-persistence',
|
||||||
metavar='type=TYPE[,cookie_name=COOKIE_NAME]',
|
metavar='type=TYPE[,cookie_name=COOKIE_NAME]',
|
||||||
type=utils.str2dict_type(required_keys=['type'],
|
type=utils.str2dict_type(required_keys=['type'],
|
||||||
optional_keys=['cookie_name']),
|
optional_keys=['cookie_name']),
|
||||||
help=_('The type of session persistence to use and associated '
|
help=_('The type of session persistence to use and associated '
|
||||||
'cookie name.'))
|
'cookie name.'))
|
||||||
_add_common_args(parser)
|
session_group.add_argument(
|
||||||
|
'--no-session-persistence',
|
||||||
|
action='store_true',
|
||||||
|
help=_('Clear session persistence for the pool.'))
|
||||||
|
_add_common_args(parser, False)
|
||||||
|
|
||||||
def args2body(self, parsed_args):
|
def args2body(self, parsed_args):
|
||||||
body = _parse_common_args(parsed_args)
|
body = _parse_common_args(parsed_args)
|
||||||
|
if parsed_args.no_session_persistence:
|
||||||
|
body['session_persistence'] = None
|
||||||
|
elif parsed_args.session_persistence:
|
||||||
|
body['session_persistence'] = parsed_args.session_persistence
|
||||||
neutronV20.update_dict(parsed_args, body,
|
neutronV20.update_dict(parsed_args, body,
|
||||||
['admin_state_up'])
|
['admin_state_up'])
|
||||||
return {self.resource: body}
|
return {self.resource: body}
|
||||||
|
@@ -179,6 +179,17 @@ class CLITestV20LbPoolJSON(test_cli20.CLITestV20Base):
|
|||||||
}, }
|
}, }
|
||||||
self._test_update_resource(resource, cmd, 'myid', args, body,
|
self._test_update_resource(resource, cmd, 'myid', args, body,
|
||||||
cmd_resource=cmd_resource)
|
cmd_resource=cmd_resource)
|
||||||
|
# lbaas-pool-update myid --name Name
|
||||||
|
# --no-session-persistence
|
||||||
|
|
||||||
|
resource = 'pool'
|
||||||
|
cmd_resource = 'lbaas_pool'
|
||||||
|
cmd = pool.UpdatePool(test_cli20.MyApp(sys.stdout), None)
|
||||||
|
args = ['myid', '--name', 'Name', '--no-session-persistence']
|
||||||
|
body = {'name': "Name",
|
||||||
|
"session_persistence": None, }
|
||||||
|
self._test_update_resource(resource, cmd, 'myid', args, body,
|
||||||
|
cmd_resource=cmd_resource)
|
||||||
|
|
||||||
def test_delete_pool(self):
|
def test_delete_pool(self):
|
||||||
# lbaas-pool-delete my-id.
|
# lbaas-pool-delete my-id.
|
||||||
|
@@ -0,0 +1,6 @@
|
|||||||
|
---
|
||||||
|
features:
|
||||||
|
- |
|
||||||
|
A new option ``--no-session-persistence`` has been added to
|
||||||
|
the ``neutron lbaas-pool-update`` CLI to clear the session persistence
|
||||||
|
with which the current pool is associated.
|
Reference in New Issue
Block a user