Merge "module-update with --all_datastores doesn't work"
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):
|
class Module(base.Resource):
|
||||||
|
|
||||||
NO_CHANGE_TO_ARG = 'no_change_to_argument'
|
|
||||||
ALL_KEYWORD = 'all'
|
ALL_KEYWORD = 'all'
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
@@ -75,9 +74,10 @@ class Modules(base.ManagerWithFind):
|
|||||||
|
|
||||||
def update(self, module, name=None, module_type=None,
|
def update(self, module, name=None, module_type=None,
|
||||||
contents=None, description=None,
|
contents=None, description=None,
|
||||||
all_tenants=None, datastore=Module.NO_CHANGE_TO_ARG,
|
all_tenants=None, datastore=None,
|
||||||
datastore_version=Module.NO_CHANGE_TO_ARG, auto_apply=None,
|
datastore_version=None, auto_apply=None,
|
||||||
visible=None, live_update=None):
|
visible=None, live_update=None,
|
||||||
|
all_datastores=None, all_datastore_versions=None):
|
||||||
"""Update an existing module. Passing in
|
"""Update an existing module. Passing in
|
||||||
datastore=None or datastore_version=None has the effect of
|
datastore=None or datastore_version=None has the effect of
|
||||||
making it available for all datastores/versions.
|
making it available for all datastores/versions.
|
||||||
@@ -96,13 +96,17 @@ class Modules(base.ManagerWithFind):
|
|||||||
if description is not None:
|
if description is not None:
|
||||||
body["module"]["description"] = description
|
body["module"]["description"] = description
|
||||||
datastore_obj = {}
|
datastore_obj = {}
|
||||||
if datastore is None or datastore != Module.NO_CHANGE_TO_ARG:
|
if datastore:
|
||||||
datastore_obj["type"] = datastore
|
datastore_obj["type"] = datastore
|
||||||
if (datastore_version is None or
|
if datastore_version:
|
||||||
datastore_version != Module.NO_CHANGE_TO_ARG):
|
|
||||||
datastore_obj["version"] = datastore_version
|
datastore_obj["version"] = datastore_version
|
||||||
if datastore_obj:
|
if datastore_obj:
|
||||||
body["module"]["datastore"] = 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:
|
if all_tenants is not None:
|
||||||
body["module"]["all_tenants"] = int(all_tenants)
|
body["module"]["all_tenants"] = int(all_tenants)
|
||||||
if auto_apply is not None:
|
if auto_apply is not None:
|
||||||
|
@@ -1688,17 +1688,18 @@ def do_module_create(cs, args):
|
|||||||
@utils.arg('--description', metavar='<description>', type=str, default=None,
|
@utils.arg('--description', metavar='<description>', type=str, default=None,
|
||||||
help='Description of the module.')
|
help='Description of the module.')
|
||||||
@utils.arg('--datastore', metavar='<datastore>',
|
@utils.arg('--datastore', metavar='<datastore>',
|
||||||
|
default=None,
|
||||||
help='Name or ID of datastore this module can be applied to. '
|
help='Name or ID of datastore this module can be applied to. '
|
||||||
'If not specified, module can be applied to all datastores.')
|
'If not specified, module can be applied to all datastores.')
|
||||||
@utils.arg('--all_datastores', dest='datastore', action='store_const',
|
@utils.arg('--all_datastores', default=None, action='store_const', const=True,
|
||||||
const=None,
|
|
||||||
help='Module is valid for all datastores.')
|
help='Module is valid for all datastores.')
|
||||||
@utils.arg('--datastore_version', metavar='<version>',
|
@utils.arg('--datastore_version', metavar='<version>',
|
||||||
|
default=None,
|
||||||
help='Name or ID of datastore version this module can be applied '
|
help='Name or ID of datastore version this module can be applied '
|
||||||
'to. If not specified, module can be applied to all versions.')
|
'to. If not specified, module can be applied to all versions.')
|
||||||
@utils.arg('--all_datastore_versions', dest='datastore_version',
|
@utils.arg('--all_datastore_versions', default=None,
|
||||||
action='store_const', const=None,
|
action='store_const', const=True,
|
||||||
help='Module is valid for all datastore version.')
|
help='Module is valid for all datastore versions.')
|
||||||
@utils.arg('--auto_apply', action='store_true', default=None,
|
@utils.arg('--auto_apply', action='store_true', default=None,
|
||||||
help='Automatically apply this module when creating an instance '
|
help='Automatically apply this module when creating an instance '
|
||||||
'or cluster.')
|
'or cluster.')
|
||||||
@@ -1731,16 +1732,14 @@ def do_module_update(cs, args):
|
|||||||
module = _find_module(cs, args.module)
|
module = _find_module(cs, args.module)
|
||||||
contents = args.file.read() if args.file else None
|
contents = args.file.read() if args.file else None
|
||||||
visible = not args.hidden if args.hidden is not None else None
|
visible = not args.hidden if args.hidden is not None else None
|
||||||
datastore_args = {}
|
datastore_args = {'datastore': args.datastore,
|
||||||
if args.datastore:
|
'datastore_version': args.datastore_version}
|
||||||
datastore_args['datastore'] = args.datastore
|
|
||||||
if args.datastore_version:
|
|
||||||
datastore_args['datastore_version'] = args.datastore_version
|
|
||||||
updated_module = cs.modules.update(
|
updated_module = cs.modules.update(
|
||||||
module, name=args.name, module_type=args.type, contents=contents,
|
module, name=args.name, module_type=args.type, contents=contents,
|
||||||
description=args.description, all_tenants=args.all_tenants,
|
description=args.description, all_tenants=args.all_tenants,
|
||||||
auto_apply=args.auto_apply, visible=visible,
|
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)
|
_print_object(updated_module)
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user