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/utils.py | |
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/utils.py')
-rw-r--r-- | nova/utils.py | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/nova/utils.py b/nova/utils.py index 284d72b55..5d3caecab 100644 --- a/nova/utils.py +++ b/nova/utils.py @@ -47,6 +47,7 @@ from eventlet import greenthread from eventlet import semaphore import netaddr +from nova import config from nova import exception from nova import flags from nova.openstack.common import cfg @@ -57,9 +58,8 @@ from nova.openstack.common import timeutils LOG = logging.getLogger(__name__) -FLAGS = flags.FLAGS - -FLAGS.register_opt( +CONF = config.CONF +CONF.register_opt( cfg.BoolOpt('disable_process_locking', default=False, help='Whether to disable inter-process locks')) @@ -171,7 +171,7 @@ def execute(*cmd, **kwargs): 'to utils.execute: %r') % kwargs) if run_as_root and os.geteuid() != 0: - cmd = ['sudo', 'nova-rootwrap', FLAGS.rootwrap_config] + list(cmd) + cmd = ['sudo', 'nova-rootwrap', CONF.rootwrap_config] + list(cmd) cmd = map(str, cmd) @@ -330,7 +330,7 @@ def last_completed_audit_period(unit=None, before=None): The begin timestamp of this audit period is the same as the end of the previous.""" if not unit: - unit = FLAGS.instance_usage_audit_period + unit = CONF.instance_usage_audit_period offset = 0 if '@' in unit: @@ -483,7 +483,7 @@ class LazyPluggable(object): def __get_backend(self): if not self.__backend: - backend_name = FLAGS[self.__pivot] + backend_name = CONF[self.__pivot] if backend_name not in self.__backends: msg = _('Invalid backend: %s') % backend_name raise exception.NovaException(msg) @@ -851,7 +851,7 @@ def monkey_patch(): this function patches a decorator for all functions in specified modules. You can set decorators for each modules - using FLAGS.monkey_patch_modules. + using CONF.monkey_patch_modules. The format is "Module path:Decorator function". Example: 'nova.api.ec2.cloud:nova.notifier.api.notify_decorator' @@ -861,11 +861,11 @@ def monkey_patch(): name - name of the function function - object of the function """ - # If FLAGS.monkey_patch is not True, this function do nothing. - if not FLAGS.monkey_patch: + # If CONF.monkey_patch is not True, this function do nothing. + if not CONF.monkey_patch: return # Get list of modules and decorators - for module_and_decorator in FLAGS.monkey_patch_modules: + for module_and_decorator in CONF.monkey_patch_modules: module, decorator_name = module_and_decorator.split(':') # import decorator function decorator = importutils.import_class(decorator_name) @@ -913,7 +913,7 @@ def generate_glance_url(): """Generate the 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) + return "http://%s:%d" % (CONF.glance_host, CONF.glance_port) def generate_image_url(image_ref): @@ -1044,7 +1044,7 @@ def service_is_up(service): last_heartbeat = service['updated_at'] or service['created_at'] # Timestamps in DB are UTC. elapsed = total_seconds(timeutils.utcnow() - last_heartbeat) - return abs(elapsed) <= FLAGS.service_down_time + return abs(elapsed) <= CONF.service_down_time def generate_mac_address(): |