Skip to content

Commit

Permalink
Fixed old libvirt semantics, added resume_guests_state_on_host_boot f…
Browse files Browse the repository at this point in the history
…lag.
  • Loading branch information
chemikadze committed Jul 25, 2011
1 parent 9c88bbe commit ba4946d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
9 changes: 4 additions & 5 deletions nova/compute/manager.py
Expand Up @@ -146,9 +146,7 @@ def __init__(self, compute_driver=None, *args, **kwargs):
*args, **kwargs)

def init_host(self):
"""Initialization for a standalone compute service.
Reboots instances marked as running in DB if they is not running."""
"""Initialization for a standalone compute service."""
self.driver.init_host(host=self.host)
context = nova.context.get_admin_context()
instances = self.db.instance_get_all_by_host(context, self.host)
Expand All @@ -157,12 +155,13 @@ def init_host(self):
db_state = instance['state']
drv_state = self._update_state(context, instance['id'])

expect_running = db_state == power_state.RUNNING != drv_state
expect_running = (db_state == power_state.RUNNING != drv_state)

LOG.debug(_('Current state of %(inst_name)s is %(drv_state)s, '
'state in DB is %(db_state)s.'), locals())

if expect_running and FLAGS.start_guests_on_host_boot:
if (expect_running and FLAGS.resume_guests_state_on_host_boot)\
or FLAGS.start_guests_on_host_boot:
LOG.info(_('Rebooting instance %(inst_name)s after '
'nova-compute restart.'), locals())
self.reboot_instance(context, instance['id'])
Expand Down
2 changes: 2 additions & 0 deletions nova/flags.py
Expand Up @@ -390,3 +390,5 @@ def _get_my_ip():

DEFINE_bool('start_guests_on_host_boot', False,
'Whether to restart guests when the host reboots')
DEFINE_bool('resume_guests_state_on_host_boot', False,
'Whether to start guests, that was running before the host reboot')

0 comments on commit ba4946d

Please sign in to comment.