From d41e3952d24c788dbac7f21389c3c145d366d252 Mon Sep 17 00:00:00 2001 From: Terry Howe Date: Wed, 2 Jul 2014 09:00:23 -0600 Subject: [PATCH] Allow --data option to pass UUID instead of json Allow the user to pass UUID only instead of full json. This will be handy for get and delete. For example: python -m examples.get openstack/network/v2/network.py \ --data ab13c9e7-3f30-4eee-9f96-41deb0223183 Change-Id: I12f15728b908d21110e9dead857d24d903bf17a9 --- examples/common.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/examples/common.py b/examples/common.py index 909fcf18..cde20e7f 100755 --- a/examples/common.py +++ b/examples/common.py @@ -39,6 +39,7 @@ import os import subprocess import sys import traceback +import uuid CONSOLE_MESSAGE_FORMAT = '%(levelname)s: %(name)s %(message)s' _logger = logging.getLogger(__name__) @@ -63,7 +64,11 @@ def find_resource_cls(opts): def get_data_option(opts): - return json.loads(opts.data) + try: + iddy = uuid.UUID(opts.data) + return {'id': iddy} + except ValueError: + return json.loads(opts.data) def get_open_fds():