diff options
| author | Jenkins <jenkins@review.openstack.org> | 2012-11-07 05:41:57 +0000 |
|---|---|---|
| committer | Gerrit Code Review <review@openstack.org> | 2012-11-07 05:41:57 +0000 |
| commit | ee3d2a190844b7b0493545c6e6967cfdf520a67d (patch) | |
| tree | 5ada6a336288e02f6d70495128cad7434e943976 /nova/image | |
| parent | d4dd0842b63ff3bbe0f51f3e222c0d852df79f9c (diff) | |
| parent | 637e805634b5179ffacad57ee26d4175449537f5 (diff) | |
Merge "Switch from FLAGS to CONF in misc modules"
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] |
