Ravi Nori has uploaded a new change for review.

Change subject: cli: moving vm from one cluster to another, using name doesn't 
work
......................................................................

cli: moving vm from one cluster to another, using name doesn't work

When a vm is down, cluster can be moved between different
clusters under the same datacenter.

using CLI this action works using cluster-id but has no
affect using cluster-name.

Change-Id: I6274b7070fa5ec0c0b5403dc9b2addfc8553c651
Bug-Url: https://bugzilla.redhat.com/950684
Signed-off-by: Ravi Nori <[email protected]>
---
M src/ovirtcli/command/command.py
1 file changed, 13 insertions(+), 1 deletion(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine-cli refs/changes/48/13848/1

diff --git a/src/ovirtcli/command/command.py b/src/ovirtcli/command/command.py
index 76b10d3..e10133d 100644
--- a/src/ovirtcli/command/command.py
+++ b/src/ovirtcli/command/command.py
@@ -197,15 +197,27 @@
         for key in options.keys():
             prop = key.replace('--', '')
             val = options[key]
-            if not prop.endswith('-id') and prop.endswith('-identifier'): 
continue
+            if not prop.endswith('-id') and not prop.endswith('-name') and 
prop.endswith('-identifier'): continue
             if type(val) == types.ListType:
                 for item in val:
                     self.__do_set_data(obj=obj, prop=prop, fq_prop=key, 
val=item)
             else:
+                if prop.endswith('-name'):
+                    self.__do_set_data_id_from_name(obj, prop, key, val)
                 self.__do_set_data(obj=obj, prop=prop, fq_prop=key, val=val)
 
         return obj
 
+    def __do_set_data_id_from_name(self, obj, prop, key, val):
+        index = prop.rfind('-name')
+        prop_obj = self.get_object(prop[:index], val)
+        if prop_obj:
+            id_val = str(getattr(prop_obj, 'id'))
+            if id_val:
+                id_prop = prop[:index]+'-id'
+                id_key = key[:key.rfind('-name')]+'-id'
+                self.__do_set_data(obj=obj, prop=id_prop, fq_prop=id_key, 
val=id_val)
+
     def read_object(self):
         """If input was provided via stdin, then parse it and return a binding
         instance."""


--
To view, visit http://gerrit.ovirt.org/13848
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I6274b7070fa5ec0c0b5403dc9b2addfc8553c651
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-engine-cli
Gerrit-Branch: master
Gerrit-Owner: Ravi Nori <[email protected]>
_______________________________________________
Engine-patches mailing list
[email protected]
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to