module-update with --all_datastores doesn't work
In writing the scenario tests for the fix for https://launchpad.net/bugs/1611525 (see https://review.openstack.org/#/c/353118/ ) it became evident that the --all_datastores and --all_datastore_versions options weren't functioning correctly. These options are now handled in the right way. Change-Id: I0f226f09db08f635c542b27d8d2f898050d327fa Partial-Bug: #1612430
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
---
|
||||
fixes:
|
||||
- Updating a module with all_datastores and
|
||||
all_datastore_versions now works correctly.
|
||||
Bug 1612430
|
@@ -21,7 +21,6 @@ from troveclient import utils
|
||||
|
||||
class Module(base.Resource):
|
||||
|
||||
NO_CHANGE_TO_ARG = 'no_change_to_argument'
|
||||
ALL_KEYWORD = 'all'
|
||||
|
||||
def __repr__(self):
|
||||
@@ -75,9 +74,10 @@ class Modules(base.ManagerWithFind):
|
||||
|
||||
def update(self, module, name=None, module_type=None,
|
||||
contents=None, description=None,
|
||||
all_tenants=None, datastore=Module.NO_CHANGE_TO_ARG,
|
||||
datastore_version=Module.NO_CHANGE_TO_ARG, auto_apply=None,
|
||||
visible=None, live_update=None):
|
||||
all_tenants=None, datastore=None,
|
||||
datastore_version=None, auto_apply=None,
|
||||
visible=None, live_update=None,
|
||||
all_datastores=None, all_datastore_versions=None):
|
||||
"""Update an existing module. Passing in
|
||||
datastore=None or datastore_version=None has the effect of
|
||||
making it available for all datastores/versions.
|
||||
@@ -96,13 +96,17 @@ class Modules(base.ManagerWithFind):
|
||||
if description is not None:
|
||||
body["module"]["description"] = description
|
||||
datastore_obj = {}
|
||||
if datastore is None or datastore != Module.NO_CHANGE_TO_ARG:
|
||||
if datastore:
|
||||
datastore_obj["type"] = datastore
|
||||
if (datastore_version is None or
|
||||
datastore_version != Module.NO_CHANGE_TO_ARG):
|
||||
if datastore_version:
|
||||
datastore_obj["version"] = datastore_version
|
||||
if datastore_obj:
|
||||
body["module"]["datastore"] = datastore_obj
|
||||
if all_datastores:
|
||||
body["module"]["all_datastores"] = int(all_datastores)
|
||||
if all_datastore_versions:
|
||||
body["module"]["all_datastore_versions"] = int(
|
||||
all_datastore_versions)
|
||||
if all_tenants is not None:
|
||||
body["module"]["all_tenants"] = int(all_tenants)
|
||||
if auto_apply is not None:
|
||||
|
@@ -1631,17 +1631,18 @@ def do_module_create(cs, args):
|
||||
@utils.arg('--description', metavar='<description>', type=str, default=None,
|
||||
help='Description of the module.')
|
||||
@utils.arg('--datastore', metavar='<datastore>',
|
||||
default=None,
|
||||
help='Name or ID of datastore this module can be applied to. '
|
||||
'If not specified, module can be applied to all datastores.')
|
||||
@utils.arg('--all_datastores', dest='datastore', action='store_const',
|
||||
const=None,
|
||||
@utils.arg('--all_datastores', default=None, action='store_const', const=True,
|
||||
help='Module is valid for all datastores.')
|
||||
@utils.arg('--datastore_version', metavar='<version>',
|
||||
default=None,
|
||||
help='Name or ID of datastore version this module can be applied '
|
||||
'to. If not specified, module can be applied to all versions.')
|
||||
@utils.arg('--all_datastore_versions', dest='datastore_version',
|
||||
action='store_const', const=None,
|
||||
help='Module is valid for all datastore version.')
|
||||
@utils.arg('--all_datastore_versions', default=None,
|
||||
action='store_const', const=True,
|
||||
help='Module is valid for all datastore versions.')
|
||||
@utils.arg('--auto_apply', action='store_true', default=None,
|
||||
help='Automatically apply this module when creating an instance '
|
||||
'or cluster.')
|
||||
@@ -1674,16 +1675,14 @@ def do_module_update(cs, args):
|
||||
module = _find_module(cs, args.module)
|
||||
contents = args.file.read() if args.file else None
|
||||
visible = not args.hidden if args.hidden is not None else None
|
||||
datastore_args = {}
|
||||
if args.datastore:
|
||||
datastore_args['datastore'] = args.datastore
|
||||
if args.datastore_version:
|
||||
datastore_args['datastore_version'] = args.datastore_version
|
||||
datastore_args = {'datastore': args.datastore,
|
||||
'datastore_version': args.datastore_version}
|
||||
updated_module = cs.modules.update(
|
||||
module, name=args.name, module_type=args.type, contents=contents,
|
||||
description=args.description, all_tenants=args.all_tenants,
|
||||
auto_apply=args.auto_apply, visible=visible,
|
||||
live_update=args.live_update, **datastore_args)
|
||||
live_update=args.live_update, all_datastores=args.all_datastores,
|
||||
all_datastore_versions=args.all_datastore_versions, **datastore_args)
|
||||
_print_object(updated_module)
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user