From 5755c6d71c51763cb6145b9c70de5170a761e6f5 Mon Sep 17 00:00:00 2001 From: Christophe Varoqui Date: Tue, 16 Jul 2019 12:33:52 +0200 Subject: [PATCH] Change the internal --to arg name to "to" So the api call using that option is more intuitive: POST /service_action { "path": "test/svc/c1", "action": "scale", "options": { "to": 2 } } --- lib/resContainerHpVm.py | 2 +- lib/resContainerLxd.py | 2 +- lib/resContainerOvm.py | 2 +- lib/svc.py | 8 ++++---- lib/svcmgr_parser.py | 2 +- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/lib/resContainerHpVm.py b/lib/resContainerHpVm.py index c26903b6ae..64446e06ca 100644 --- a/lib/resContainerHpVm.py +++ b/lib/resContainerHpVm.py @@ -109,7 +109,7 @@ def check_capabilities(self): return False def _migrate(self): - cmd = ['hpvmmigrate', '-o', '-P', self.name, '-h', self.svc.options.destination_node] + cmd = ['hpvmmigrate', '-o', '-P', self.name, '-h', self.svc.options.to] (ret, buff, err) = self.vcall(cmd) if ret != 0: raise ex.excError diff --git a/lib/resContainerLxd.py b/lib/resContainerLxd.py index d11aa92411..67110cf76a 100644 --- a/lib/resContainerLxd.py +++ b/lib/resContainerLxd.py @@ -136,7 +136,7 @@ def cleanup_cgroup(self, t="*"): self.log.debug("failed to remove leftover cgroup %s: %s" % (p, str(e))) def _migrate(self): - cmd = [lxc, 'move', self.name, self.svc.options.destination_node+":"+self.name] + cmd = [lxc, 'move', self.name, self.svc.options.to+":"+self.name] (ret, buff, err) = self.vcall(cmd) if ret != 0: raise ex.excError diff --git a/lib/resContainerOvm.py b/lib/resContainerOvm.py index 35a1107e3f..6a53169419 100644 --- a/lib/resContainerOvm.py +++ b/lib/resContainerOvm.py @@ -59,7 +59,7 @@ def find_vmcf(self): return l[0] def _migrate(self): - cmd = ['xm', 'migrate', '-l', self.uuid, self.svc.options.destination_node] + cmd = ['xm', 'migrate', '-l', self.uuid, self.svc.options.to] (ret, buff, err) = self.vcall(cmd) if ret != 0: raise ex.excError diff --git a/lib/svc.py b/lib/svc.py index 1fb8d46aa4..ed35fde762 100644 --- a/lib/svc.py +++ b/lib/svc.py @@ -1365,9 +1365,9 @@ def prepare_global_expect(self, action): global_expect = "purged" action = "purge" elif action == "move": - if self.options.destination_node is None: + if self.options.to is None: raise ex.excError("the --to [,,...] option is required") - global_expect += self.options.destination_node + global_expect += self.options.to elif action == "switch": dst = self.destination_node_sanity_checks() # pylint: disable=assignment-from-none if dst is None: @@ -5033,7 +5033,7 @@ def destination_node_sanity_checks(self, destination_node=None): Return the validated destination node name. """ if destination_node is None: - destination_node = self.options.destination_node + destination_node = self.options.to if destination_node is None: destination_node = "" return destination_node @@ -5082,7 +5082,7 @@ def scale(self): if self.scale_target is None: raise ex.excError("can't scale: not a scaler") try: - value = int(self.options.destination_node) + value = int(self.options.to) assert value >= 0 except Exception: raise ex.excError("invalid scale target: set '--to ' where n>=0") diff --git a/lib/svcmgr_parser.py b/lib/svcmgr_parser.py index 30ef046feb..3124ab45d2 100644 --- a/lib/svcmgr_parser.py +++ b/lib/svcmgr_parser.py @@ -105,7 +105,7 @@ help="The tag name, as shown by :cmd:`svcmgr collector list tags`."), "to": Option( "--to", default=None, - action="store", dest="parm_destination_node", + action="store", dest="to", help="The remote node to start or migrate the service to. Or the " "target number of instance to scale to."), "upto": Option(