Merge reconnect_instance into after_reboot.

There was no need to have reconnect_instance. It's only called once,
and isn't a very long function.

Change-Id: Ib26b0cdd044aa808afaeeb8f04816f5b1759f972
This commit is contained in:
Paul Hummer 2016-11-24 06:53:59 +00:00
parent 9bf9db7e52
commit e40795cb03
1 changed files with 14 additions and 21 deletions

View File

@ -1493,33 +1493,26 @@ class LXDDriver(driver.ComputeDriver):
{'instance': instance.name, 'ex': ex},
instance=instance)
def _reconnect_instance(self, context, instance):
'''Reconnect instance ports.'''
# Check instance state
if (instance.vm_state != vm_states.STOPPED):
return
try:
network_info = self.network_api.get_instance_nw_info(
context, instance)
except exception.InstanceNotFound:
network_info = network_model.NetworkInfo()
# Plug in the network
self.plug_vifs(instance, network_info)
self.firewall_driver.setup_basic_filtering(instance, network_info)
self.firewall_driver.prepare_instance_filter(instance, network_info)
self.firewall_driver.apply_instance_filter(instance, network_info)
def _after_reboot(self):
'''Actions to take after the host has been rebooted.'''
"""Perform sync operation after host reboot."""
context = nova.context.get_admin_context()
instances = objects.InstanceList.get_by_host(
context, self.host, expected_attrs=['info_cache', 'metadata'])
for instance in instances:
self._reconnect_instance(context, instance)
if (instance.vm_state != vm_states.STOPPED):
continue
try:
network_info = self.network_api.get_instance_nw_info(
context, instance)
except exception.InstanceNotFound:
network_info = network_model.NetworkInfo()
self.plug_vifs(instance, network_info)
self.firewall_driver.setup_basic_filtering(instance, network_info)
self.firewall_driver.prepare_instance_filter(
instance, network_info)
self.firewall_driver.apply_instance_filter(instance, network_info)
def _container_init(self, host, instance):
(state, data) = (self.session.container_migrate(instance.name,