diff options
| author | Naveed Massjouni <naveedm9@gmail.com> | 2011-05-23 17:25:59 -0400 |
|---|---|---|
| committer | Naveed Massjouni <naveedm9@gmail.com> | 2011-05-23 17:25:59 -0400 |
| commit | bac28418b7b92aa2654fad39d0240a85aa637488 (patch) | |
| tree | 4ca55fabe94f3f4166e6891432868c391fc3db0a | |
| parent | fe92b867a876086636c4d84a103876b1568a74bc (diff) | |
Removing code duplication between parse_image_ref and get_image service.
Made parse_image_ref private.
| -rw-r--r-- | nova/image/__init__.py | 14 |
1 files changed, 4 insertions, 10 deletions
diff --git a/nova/image/__init__.py b/nova/image/__init__.py index be692680a..d957c38fe 100644 --- a/nova/image/__init__.py +++ b/nova/image/__init__.py @@ -28,19 +28,13 @@ from nova import flags FLAGS = flags.FLAGS -def parse_image_ref(image_ref): +def _parse_image_ref(image_ref): """Parse an image href into composite parts. - If the image_ref passed in is an integer, it will - return (image_ref, None, None), otherwise it will - return (image_id, host, port) - - :param image_ref: href or id of an image + :param image_ref: href of an image + :returns: a tuple of the form (image_id, host, port) """ - if str(image_ref).isdigit(): - return (int(image_ref), None, None) - o = urlparse(image_ref) port = o.port or 80 host = o.netloc.split(':', 1)[0] @@ -69,7 +63,7 @@ def get_image_service(image_ref): return (get_default_image_service(), int(image_ref)) try: - (image_id, host, port) = parse_image_ref(image_ref) + (image_id, host, port) = _parse_image_ref(image_ref) except: raise exception.InvalidImageRef(image_ref=image_ref) glance_client = nova.image.glance.GlanceClient(host, port) |
