summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--nova/flags.py4
-rw-r--r--nova/image/glance.py7
-rw-r--r--nova/tests/image/test_glance.py11
3 files changed, 21 insertions, 1 deletions
diff --git a/nova/flags.py b/nova/flags.py
index 971e78807..ffb313cec 100644
--- a/nova/flags.py
+++ b/nova/flags.py
@@ -271,8 +271,10 @@ DEFINE_string('connection_type', 'libvirt', 'libvirt, xenapi or fake')
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_string('glance_host', _get_my_ip(), 'default glance host')
+DEFINE_integer('glance_port', 9292, 'default glance port')
DEFINE_list('glance_api_servers',
- ['%s:9292' % _get_my_ip()],
+ ['%s:%d' % (FLAGS.glance_host, FLAGS.glance_port)],
'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)')
diff --git a/nova/image/glance.py b/nova/image/glance.py
index 5ee1d2b8a..e4d9edc93 100644
--- a/nova/image/glance.py
+++ b/nova/image/glance.py
@@ -42,6 +42,13 @@ FLAGS = flags.FLAGS
GlanceClient = utils.import_class('glance.client.Client')
+def _construct_glance_url():
+ """Generate the default URL to glance."""
+ # TODO(jk0): This will eventually need to take SSL into consideration
+ # when supported in glance.
+ return "http://%s:%d" % (FLAGS.glance_host, FLAGS.glance_port)
+
+
def _parse_image_ref(image_href):
"""Parse an image href into composite parts.
diff --git a/nova/tests/image/test_glance.py b/nova/tests/image/test_glance.py
index 290c9a04a..9f866d790 100644
--- a/nova/tests/image/test_glance.py
+++ b/nova/tests/image/test_glance.py
@@ -22,11 +22,15 @@ import stubout
from nova.tests.api.openstack import fakes
from nova import context
from nova import exception
+from nova import flags
from nova.image import glance
from nova import test
from nova.tests.glance import stubs as glance_stubs
+FLAGS = flags.FLAGS
+
+
class NullWriter(object):
"""Used to test ImageService.get which takes a writer object"""
@@ -451,3 +455,10 @@ class TestGlanceImageService(test.TestCase):
image_meta = self.service.get(self.context, image_id, writer)
self.assertEqual(image_meta['created_at'], self.NOW_DATETIME)
self.assertEqual(image_meta['updated_at'], self.NOW_DATETIME)
+
+ def test_contruct_glance_url(self):
+ # TODO(jk0): This will eventually need to take SSL into consideration
+ # when supported in glance.
+ generated_url = glance._construct_glance_url()
+ actual_url = "http://%s:%d" % (FLAGS.glance_host, FLAGS.glance_port)
+ self.assertEqual(generated_url, actual_url)