diff options
| author | Rick Harris <rick.harris@rackspace.com> | 2011-06-09 21:36:20 +0000 |
|---|---|---|
| committer | Rick Harris <rick.harris@rackspace.com> | 2011-06-09 21:36:20 +0000 |
| commit | e307bf5dd60dc84587f76d88956499ee1f1013fb (patch) | |
| tree | 5fed05d4909c947e6fb3650a1042f6639f46171c | |
| parent | be9b25b225d2b4c25e1b977e1e4b8166b3dacaf4 (diff) | |
| download | nova-e307bf5dd60dc84587f76d88956499ee1f1013fb.tar.gz nova-e307bf5dd60dc84587f76d88956499ee1f1013fb.tar.xz nova-e307bf5dd60dc84587f76d88956499ee1f1013fb.zip | |
Fixing code per review comments
| -rw-r--r-- | nova/flags.py | 4 | ||||
| -rw-r--r-- | nova/image/glance.py | 7 | ||||
| -rw-r--r-- | nova/tests/image/test_glance.py | 9 | ||||
| -rw-r--r-- | nova/virt/images.py | 12 | ||||
| -rw-r--r-- | nova/virt/xenapi/vm_utils.py | 3 |
5 files changed, 10 insertions, 25 deletions
diff --git a/nova/flags.py b/nova/flags.py index 545cf90fe..acfcf8d68 100644 --- a/nova/flags.py +++ b/nova/flags.py @@ -272,8 +272,8 @@ DEFINE_string('aws_access_key_id', 'admin', 'AWS Access ID') DEFINE_string('aws_secret_access_key', 'admin', 'AWS Access Key') # NOTE(sirp): my_ip interpolation doesn't work within nested structures DEFINE_list('glance_api_servers', - [('127.0.0.1', 9292)], - 'list of glance servers available to nova') + ['127.0.0.1:9292'], + 'list of glance api servers available to nova (host:port)') DEFINE_integer('s3_port', 3333, 's3 port') DEFINE_string('s3_host', '$my_ip', 's3 host (for infrastructure)') DEFINE_string('s3_dmz', '$my_ip', 's3 dmz ip (for instances)') diff --git a/nova/image/glance.py b/nova/image/glance.py index f82c0f4a3..5712215bb 100644 --- a/nova/image/glance.py +++ b/nova/image/glance.py @@ -45,7 +45,9 @@ def pick_glance_api_server(): Returns (host, port) """ - host, port = random.choice(FLAGS.glance_api_servers) + host_port = random.choice(FLAGS.glance_api_servers) + host, port_str = host_port.split(':') + port = int(port_str) return host, port @@ -60,7 +62,8 @@ class GlanceImageService(service.BaseImageService): SERVICE_IMAGE_ATTRS = service.BaseImageService.BASE_IMAGE_ATTRS +\ GLANCE_ONLY_ATTRS - _client = None + def __init__(self, client=None): + self._client = client def _get_client(self): # NOTE(sirp): we want to load balance each request across glance diff --git a/nova/tests/image/test_glance.py b/nova/tests/image/test_glance.py index 033b8389c..223e7ae57 100644 --- a/nova/tests/image/test_glance.py +++ b/nova/tests/image/test_glance.py @@ -17,7 +17,6 @@ import datetime -import stubout import unittest from nova import context @@ -61,16 +60,10 @@ class BaseGlanceTest(unittest.TestCase): NOW_DATETIME = datetime.datetime(2010, 10, 11, 10, 30, 22) def setUp(self): - self.stubs = stubout.StubOutForTesting() self.client = StubGlanceClient(None) - self.service = glance.GlanceImageService() - self.stubs.Set(self.service, 'client', self.client) + self.service = glance.GlanceImageService(client=self.client) self.context = context.RequestContext(None, None) - def tearDown(self): - self.stubs.UnsetAll() - super(BaseGlanceTest, self).tearDown() - def assertDateTimesFilled(self, image_meta): self.assertEqual(image_meta['created_at'], self.NOW_DATETIME) self.assertEqual(image_meta['updated_at'], self.NOW_DATETIME) diff --git a/nova/virt/images.py b/nova/virt/images.py index e6f3d3c9e..40bf6107c 100644 --- a/nova/virt/images.py +++ b/nova/virt/images.py @@ -43,15 +43,3 @@ def fetch(image_href, path, _user, _project): elevated = context.get_admin_context() metadata = image_service.get(elevated, image_id, image_file) return metadata - - -# TODO(vish): xenapi should use the glance client code directly instead -# of retrieving the image using this method. -def image_url(image): - if FLAGS.image_service == "nova.image.glance.GlanceImageService": - glance_host, glance_port = \ - glance_image_service.pick_glance_api_server() - return "http://%s:%s/images/%s" % (glance_host, glance_port, image) - - return "http://%s:%s/_images/%s/image" % (FLAGS.s3_host, FLAGS.s3_port, - image) diff --git a/nova/virt/xenapi/vm_utils.py b/nova/virt/xenapi/vm_utils.py index ccde6cbfe..b9d4346e4 100644 --- a/nova/virt/xenapi/vm_utils.py +++ b/nova/virt/xenapi/vm_utils.py @@ -581,7 +581,8 @@ class VMHelper(HelperBase): Returns: A single filename if image_type is KERNEL_RAMDISK A list of dictionaries that describe VDIs, otherwise """ - url = images.image_url(image) + url = "http://%s:%s/_images/%s/image" % (FLAGS.s3_host, FLAGS.s3_port, + image) LOG.debug(_("Asking xapi to fetch %(url)s as %(access)s") % locals()) if image_type == ImageType.KERNEL_RAMDISK: fn = 'get_kernel' |
