diff options
| author | William Wolf <throughnothing@gmail.com> | 2011-05-17 19:30:29 -0400 |
|---|---|---|
| committer | William Wolf <throughnothing@gmail.com> | 2011-05-17 19:30:29 -0400 |
| commit | d24f59a251173826817e5f5c53a4f54dfe927f2d (patch) | |
| tree | e68592bd5c223613500ec9e63388f8c2349cb57e /nova/utils.py | |
| parent | eacb354c159aeb8f428232eb7d678ffb60bb73cd (diff) | |
added is_int function to utils
Diffstat (limited to 'nova/utils.py')
| -rw-r--r-- | nova/utils.py | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/nova/utils.py b/nova/utils.py index c7da95a97..fff916527 100644 --- a/nova/utils.py +++ b/nova/utils.py @@ -726,6 +726,11 @@ def parse_server_string(server_str): return ('', '') +def is_int(x): + """ Return if passed in variable is integer or not """ + return re.match(r'\d+$', str(x)) + + def parse_image_ref(image_ref): """ Parse an imageRef and return (id, host, port) @@ -757,18 +762,18 @@ def get_image_service(image_ref=None): image_ref - image ref/id for an image """ - ImageService = utils.import_class(FLAGS.image_service) + ImageService = import_class(FLAGS.image_service) if not image_ref: - return (ImageService(), -1) + return (ImageService(), None) (image_id, host, port) = parse_image_ref(image_ref) image_service = None if host: - GlanceImageService = utils.import_class(FLAGS.glance_image_service) - GlanceClient = utils.import_class('glance.client.Client') + GlanceImageService = import_class(FLAGS.glance_image_service) + GlanceClient = import_class('glance.client.Client') glance_client = GlanceClient(host, port) image_service = GlanceImageService(glance_client) |
