Michael Pasternak has uploaded a new change for review. Change subject: cli: "remove permit" command doesnt work by-id #887805 ......................................................................
cli: "remove permit" command doesnt work by-id #887805 https://bugzilla.redhat.com/show_bug.cgi?id=887805 Change-Id: I34954f9560f98707e10310cd0d343052f586c316 Signed-off-by: Michael Pasternak <[email protected]> --- M src/ovirtcli/command/command.py 1 file changed, 23 insertions(+), 4 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine-cli refs/changes/66/10366/1 diff --git a/src/ovirtcli/command/command.py b/src/ovirtcli/command/command.py index 8ee11cb..84f348a 100644 --- a/src/ovirtcli/command/command.py +++ b/src/ovirtcli/command/command.py @@ -27,6 +27,7 @@ import itertools from cli.messages import Messages import types +import re class OvirtCommand(Command): @@ -314,9 +315,9 @@ if kwargs and kwargs.has_key('id'): return coll.get(id=kwargs['id']) else: - uuid_cand = self._toUUID(obj_id) - if uuid_cand != None: - return coll.get(id=obj_id) + identifier = self.__produce_identifier(obj_id) + if identifier: + return coll.get(id=str(obj_id)) else: return coll.get(name=obj_id) else: @@ -327,6 +328,24 @@ self.error(err_str % candidate) return None + + def __produce_identifier(self, candidate): + if type(candidate) == str: + match = re.search(r'[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}', candidate) + if match: + return self._toUUID(candidate) + match = re.search(r'[-+]?\d+', candidate) + if match: + return self._toLong(candidate) + elif type(candidate) == int or type(candidate) == long: + return candidate + return None + + def _toLong(self, string): + try: + return long(string) + except: + return None def _toUUID(self, string): try: @@ -425,7 +444,7 @@ elif opts.has_key('--' + arg): method_args[arg] = opts['--' + arg] else: - #TODO: throw error if param is mandatory + # TODO: throw error if param is mandatory pass result = method(**method_args) -- To view, visit http://gerrit.ovirt.org/10366 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I34954f9560f98707e10310cd0d343052f586c316 Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine-cli Gerrit-Branch: master Gerrit-Owner: Michael Pasternak <[email protected]> _______________________________________________ Engine-patches mailing list [email protected] http://lists.ovirt.org/mailman/listinfo/engine-patches
