diff options
| author | Mark McLoughlin <markmc@redhat.com> | 2012-11-04 21:32:45 +0000 |
|---|---|---|
| committer | Mark McLoughlin <markmc@redhat.com> | 2012-11-04 21:46:35 +0000 |
| commit | 637e805634b5179ffacad57ee26d4175449537f5 (patch) | |
| tree | c0ff2f32d3f2957ae7b96a2eedc35b0029917048 /nova/image | |
| parent | 8ce58defbe560b1da34d991b38ac64a9b4c8d654 (diff) | |
| download | nova-637e805634b5179ffacad57ee26d4175449537f5.tar.gz nova-637e805634b5179ffacad57ee26d4175449537f5.tar.xz nova-637e805634b5179ffacad57ee26d4175449537f5.zip | |
Switch from FLAGS to CONF in misc modules
Use the global CONF variable instead of FLAGS. This is purely a cleanup
since FLAGS is already just another reference to CONF.
We leave the nova.flags imports until a later cleanup commit since
removing them may cause unpredictable problems due to config options not
being registered.
Change-Id: Ib110ba8d1837780e90b0d3fe13f8e6b68ed15f65
Diffstat (limited to 'nova/image')
| -rw-r--r-- | nova/image/glance.py | 15 | ||||
| -rw-r--r-- | nova/image/s3.py | 19 |
2 files changed, 18 insertions, 16 deletions
diff --git a/nova/image/glance.py b/nova/image/glance.py index 4c77d1204..0cbc91531 100644 --- a/nova/image/glance.py +++ b/nova/image/glance.py @@ -29,6 +29,7 @@ import urlparse import glanceclient import glanceclient.exc +from nova import config from nova import exception from nova import flags from nova.openstack.common import jsonutils @@ -37,7 +38,7 @@ from nova.openstack.common import timeutils LOG = logging.getLogger(__name__) -FLAGS = flags.FLAGS +CONF = config.CONF def _parse_image_ref(image_href): @@ -63,8 +64,8 @@ def _create_glance_client(context, host, port, use_ssl, version=1): else: scheme = 'http' params = {} - params['insecure'] = FLAGS.glance_api_insecure - if FLAGS.auth_strategy == 'keystone': + params['insecure'] = CONF.glance_api_insecure + if CONF.auth_strategy == 'keystone': params['token'] = context.auth_token endpoint = '%s://%s:%s' % (scheme, host, port) return glanceclient.Client(str(version), endpoint, **params) @@ -72,12 +73,12 @@ def _create_glance_client(context, host, port, use_ssl, version=1): def get_api_servers(): """ - Shuffle a list of FLAGS.glance_api_servers and return an iterator + Shuffle a list of CONF.glance_api_servers and return an iterator that will cycle through the list, looping around to the beginning if necessary. """ api_servers = [] - for api_server in FLAGS.glance_api_servers: + for api_server in CONF.glance_api_servers: if '//' not in api_server: api_server = 'http://' + api_server o = urlparse.urlparse(api_server) @@ -124,12 +125,12 @@ class GlanceClientWrapper(object): def call(self, context, version, method, *args, **kwargs): """ Call a glance client method. If we get a connection error, - retry the request according to FLAGS.glance_num_retries. + retry the request according to CONF.glance_num_retries. """ retry_excs = (glanceclient.exc.ServiceUnavailable, glanceclient.exc.InvalidEndpoint, glanceclient.exc.CommunicationError) - num_attempts = 1 + FLAGS.glance_num_retries + num_attempts = 1 + CONF.glance_num_retries for attempt in xrange(1, num_attempts + 1): client = self.client or self._create_onetime_client(context, diff --git a/nova/image/s3.py b/nova/image/s3.py index 80f94484e..d252baba0 100644 --- a/nova/image/s3.py +++ b/nova/image/s3.py @@ -31,6 +31,7 @@ from lxml import etree from nova.api.ec2 import ec2utils import nova.cert.rpcapi +from nova import config from nova import exception from nova import flags from nova.image import glance @@ -60,8 +61,8 @@ s3_opts = [ 'when downloading from s3'), ] -FLAGS = flags.FLAGS -FLAGS.register_opts(s3_opts) +CONF = config.CONF +CONF.register_opts(s3_opts) class S3ImageService(object): @@ -152,17 +153,17 @@ class S3ImageService(object): def _conn(context): # NOTE(vish): access and secret keys for s3 server are not # checked in nova-objectstore - access = FLAGS.s3_access_key - if FLAGS.s3_affix_tenant: + access = CONF.s3_access_key + if CONF.s3_affix_tenant: access = '%s:%s' % (access, context.project_id) - secret = FLAGS.s3_secret_key + secret = CONF.s3_secret_key calling = boto.s3.connection.OrdinaryCallingFormat() return boto.s3.connection.S3Connection(aws_access_key_id=access, aws_secret_access_key=secret, - is_secure=FLAGS.s3_use_ssl, + is_secure=CONF.s3_use_ssl, calling_format=calling, - port=FLAGS.s3_port, - host=FLAGS.s3_host) + port=CONF.s3_port, + host=CONF.s3_host) @staticmethod def _download_file(bucket, filename, local_dir): @@ -260,7 +261,7 @@ class S3ImageService(object): def _s3_create(self, context, metadata): """Gets a manifest from s3 and makes an image.""" - image_path = tempfile.mkdtemp(dir=FLAGS.image_decryption_dir) + image_path = tempfile.mkdtemp(dir=CONF.image_decryption_dir) image_location = metadata['properties']['image_location'] bucket_name = image_location.split('/')[0] |
