Merge "Import only once in nova_notifier"
This commit is contained in:
commit
652bd9822d
@ -22,6 +22,12 @@ from ceilometer.openstack.common import log as logging
|
|||||||
from nova import db
|
from nova import db
|
||||||
from ceilometer.compute.manager import AgentManager
|
from ceilometer.compute.manager import AgentManager
|
||||||
|
|
||||||
|
try:
|
||||||
|
from nova.conductor import api
|
||||||
|
instance_info_source = api.API()
|
||||||
|
except ImportError:
|
||||||
|
from nova import db as instance_info_source
|
||||||
|
|
||||||
# This module runs inside the nova compute
|
# This module runs inside the nova compute
|
||||||
# agent, which only configures the "nova" logger.
|
# agent, which only configures the "nova" logger.
|
||||||
# We use a fake logger name in that namespace
|
# We use a fake logger name in that namespace
|
||||||
@ -59,14 +65,5 @@ def notify(context, message):
|
|||||||
if message['event_type'] == 'compute.instance.delete.start':
|
if message['event_type'] == 'compute.instance.delete.start':
|
||||||
instance_id = message['payload']['instance_id']
|
instance_id = message['payload']['instance_id']
|
||||||
LOG.debug('polling final stats for %r', instance_id)
|
LOG.debug('polling final stats for %r', instance_id)
|
||||||
try:
|
|
||||||
from nova.conductor import api
|
|
||||||
except ImportError:
|
|
||||||
# Keep compatibility with folsom.
|
|
||||||
_agent_manager.poll_instance(context,
|
_agent_manager.poll_instance(context,
|
||||||
db.instance_get_by_uuid(context, instance_id))
|
instance_info_source.instance_get_by_uuid(context, instance_id))
|
||||||
else:
|
|
||||||
conductor_api = api.API()
|
|
||||||
_agent_manager.poll_instance(context,
|
|
||||||
conductor_api.instance_get_by_uuid(context, instance_id))
|
|
||||||
return
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user