Juan Hernandez has uploaded a new change for review. Change subject: cli: Allow identifiers that aren't UUIDs ......................................................................
cli: Allow identifiers that aren't UUIDs Currently we assume that the identifiers of objects are always UUIDs, but this isn't true, as some objects like network labels use arbitrary strings as identifiers, and the show commands doesn't work with them: [oVirt shell (connected)]# list labels \ --network-identifier ovirtmgmt \ --datacenter-identifier mydc id : mylabel [oVirt shell (connected)]# show label \ --network-identifier ovirtmgmt \ --datacenter-identifier mydc \ mylabel ============ ERROR ============ label mylabel does not exist. =============================== This patch removes that limitation so that the show command works correctly: [oVirt shell (connected)]# show label \ --network-identifier ovirtmgmt \ --datacenter-identifier mydc \ mylabel id : mylabel network-id: 4e31cd25-501e-47e4-a8b2-96b57a96a7e3 Change-Id: I2f3da6c3fd307ce9933c9d11d9ada4c4ff772e88 Bug-Url: https://bugzilla.redhat.com/1148941 Signed-off-by: Juan Hernandez <juan.hernan...@redhat.com> --- M src/ovirtcli/command/command.py 1 file changed, 1 insertion(+), 21 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine-cli refs/changes/07/34207/1 diff --git a/src/ovirtcli/command/command.py b/src/ovirtcli/command/command.py index 5c972a9..1ccedca 100644 --- a/src/ovirtcli/command/command.py +++ b/src/ovirtcli/command/command.py @@ -27,7 +27,6 @@ import itertools from cli.messages import Messages import types -import re import keyword import __builtin__ @@ -346,9 +345,8 @@ self.error(err_str % candidate) if obj_id is not None: - obj_uuid = self.__produce_identifier(obj_id) _, kwargs = self._get_query_params(opts) - if obj_uuid is not None and 'id' in options: + if 'id' in options: return self.__get_by_id(coll, obj_id, kwargs) if 'name' in options: return self.__get_by_name(coll, obj_id, kwargs) @@ -396,24 +394,6 @@ return coll.get(id=id, **kwargs) else: return coll.get(id=id) - - 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: -- To view, visit http://gerrit.ovirt.org/34207 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I2f3da6c3fd307ce9933c9d11d9ada4c4ff772e88 Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine-cli Gerrit-Branch: master Gerrit-Owner: Juan Hernandez <juan.hernan...@redhat.com> _______________________________________________ Engine-patches mailing list Engine-patches@ovirt.org http://lists.ovirt.org/mailman/listinfo/engine-patches