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
This commit is contained in:
Terry Howe
2014-07-02 09:00:23 -06:00
parent 4544ec3b6a
commit d41e3952d2

View File

@@ -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():