diff options
author | Peter Stachowski <peter@tesora.com> | 2016-11-05 20:08:53 -0400 |
---|---|---|
committer | Peter Stachowski <peter@tesora.com> | 2017-01-05 00:12:32 +0000 |
commit | 7c0d2c23c36a8379d09f551c013c20e9a62e519f (patch) | |
tree | 25e29a67c89a2f444c27be5a5926bc88b9c91f4a /troveclient/v1 | |
parent | 714c6e781c0bf6ad84015061c397bedce8eccd1e (diff) | |
download | python-troveclient-7c0d2c23c36a8379d09f551c013c20e9a62e519f.tar.gz |
Add support for module-reapply command
To facilitate the concept of live-update, a new command
'reapply' has been added to reapply a given module
to all instances that it had previously been applied to.
Originally, a module designated live-update would automatically
be re-applied whenever it was updated. Adding a specific
command however, allows operators/users more control over
how the new payload would be distributed. Old 'modules'
could be left if desired, or updated with the new command.
Change-Id: Ic4cc9e9085cb40f1afbec05caeb04886137027a4
Partial-Bug: #1554903
Depends-On: I4caf4a57226dd711575cde766076fa25d16792e2
Diffstat (limited to 'troveclient/v1')
-rw-r--r-- | troveclient/v1/modules.py | 21 | ||||
-rw-r--r-- | troveclient/v1/shell.py | 34 |
2 files changed, 50 insertions, 5 deletions
diff --git a/troveclient/v1/modules.py b/troveclient/v1/modules.py index 9508608..36b8a1e 100644 --- a/troveclient/v1/modules.py +++ b/troveclient/v1/modules.py @@ -167,3 +167,24 @@ class Modules(base.ManagerWithFind): query_strings['count_only'] = count_only return self._paginated(url, "instances", limit, marker, query_strings=query_strings) + + def reapply(self, module, md5=None, include_clustered=None, + batch_size=None, delay=None, force=None): + """Reapplies the specified module.""" + url = "/modules/%s/instances" % base.getid(module) + body = { + "reapply": { + } + } + if md5: + body["reapply"]["md5"] = md5 + if include_clustered is not None: + body["reapply"]["include_clustered"] = int(include_clustered) + if batch_size is not None: + body["reapply"]["batch_size"] = batch_size + if delay is not None: + body["reapply"]["batch_delay"] = delay + if force is not None: + body["reapply"]["force"] = int(force) + resp, body = self.api.client.put(url, body=body) + common.check_for_exceptions(resp, body, url) diff --git a/troveclient/v1/shell.py b/troveclient/v1/shell.py index 9131ff3..a9761d5 100644 --- a/troveclient/v1/shell.py +++ b/troveclient/v1/shell.py @@ -1799,8 +1799,7 @@ def do_module_show(cs, args): 'Admin only.')) @utils.arg('--live_update', action='store_true', default=False, help=_('Allow module to be updated even if it is already applied ' - 'to a current instance or cluster. Automatically attempt to ' - 'reapply this module if the contents change.')) + 'to a current instance or cluster.')) @utils.arg('--priority_apply', action='store_true', default=False, help=_('Sets a priority for applying the module. All priority ' 'modules will be applied before non-priority ones. ' @@ -1880,9 +1879,7 @@ def do_module_create(cs, args): help=_('Allow all users to see this module. Admin only.')) @utils.arg('--live_update', action='store_true', default=None, help=_('Allow module to be updated or deleted even if it is ' - 'already applied to a current instance or cluster. ' - 'Automatically attempt to reapply this module if the ' - 'contents change.')) + 'already applied to a current instance or cluster.')) @utils.arg('--no_live_update', dest='live_update', action='store_false', default=None, help=_('Restricts a module from being updated or deleted if it is ' @@ -1925,6 +1922,33 @@ def do_module_update(cs, args): _print_object(updated_module) +@utils.arg('module', metavar='<module>', type=str, + help=_('Name or ID of the module.')) +@utils.arg('--md5', metavar='<md5>', type=str, + default=None, + help=_('Reapply the module only to instances applied ' + 'with the specific md5.')) +@utils.arg('--include_clustered', action='store_true', default=False, + help=_('Include instances that are part of a cluster ' + '(default %(default)s).')) +@utils.arg('--batch_size', metavar='<batch_size>', type=int, + default=None, + help=_('Number of instances to reapply the module to before ' + 'sleeping.')) +@utils.arg('--delay', metavar='<delay>', type=int, + default=None, + help=_('Time to sleep in seconds between applying batches.')) +@utils.arg('--force', action='store_true', default=False, + help=_('Force reapply even on modules already having the ' + 'current MD5')) +@utils.service_type('database') +def do_module_reapply(cs, args): + """Reapply a module.""" + module = _find_module(cs, args.module) + cs.modules.reapply(module, args.md5, args.include_clustered, + args.batch_size, args.delay, args.force) + + @utils.arg('module', metavar='<module>', help=_('ID or name of the module.')) @utils.service_type('database') |