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
This commit is contained in:
Mark McLoughlin
2012-11-04 21:32:45 +00:00
parent 8ce58defbe
commit 637e805634
28 changed files with 231 additions and 216 deletions

View File

@@ -19,6 +19,7 @@
the system.
"""
from nova import config
import nova.context
from nova import db
from nova import exception
@@ -50,16 +51,16 @@ notify_api_faults = cfg.BoolOpt('notify_api_faults', default=False,
'in the API service.')
FLAGS = flags.FLAGS
FLAGS.register_opt(notify_state_opt)
FLAGS.register_opt(notify_any_opt)
FLAGS.register_opt(notify_api_faults)
CONF = config.CONF
CONF.register_opt(notify_state_opt)
CONF.register_opt(notify_any_opt)
CONF.register_opt(notify_api_faults)
def send_api_fault(url, status, exception):
"""Send an api.fault notification."""
if not FLAGS.notify_api_faults:
if not CONF.notify_api_faults:
return
payload = {'url': url, 'exception': str(exception), 'status': status}
@@ -75,7 +76,7 @@ def send_update(context, old_instance, new_instance, service=None, host=None):
in that instance
"""
if not FLAGS.notify_on_any_change and not FLAGS.notify_on_state_change:
if not CONF.notify_on_any_change and not CONF.notify_on_state_change:
# skip all this if updates are disabled
return
@@ -91,8 +92,8 @@ def send_update(context, old_instance, new_instance, service=None, host=None):
if old_vm_state != new_vm_state:
# yes, the vm state is changing:
update_with_state_change = True
elif FLAGS.notify_on_state_change:
if (FLAGS.notify_on_state_change.lower() == "vm_and_task_state" and
elif CONF.notify_on_state_change:
if (CONF.notify_on_state_change.lower() == "vm_and_task_state" and
old_task_state != new_task_state):
# yes, the task state is changing:
update_with_state_change = True
@@ -120,7 +121,7 @@ def send_update_with_states(context, instance, old_vm_state, new_vm_state,
are any, in the instance
"""
if not FLAGS.notify_on_state_change:
if not CONF.notify_on_state_change:
# skip all this if updates are disabled
return
@@ -135,8 +136,8 @@ def send_update_with_states(context, instance, old_vm_state, new_vm_state,
if old_vm_state != new_vm_state:
# yes, the vm state is changing:
fire_update = True
elif FLAGS.notify_on_state_change:
if (FLAGS.notify_on_state_change.lower() == "vm_and_task_state" and
elif CONF.notify_on_state_change:
if (CONF.notify_on_state_change.lower() == "vm_and_task_state" and
old_task_state != new_task_state):
# yes, the task state is changing:
fire_update = True