summaryrefslogtreecommitdiffstats
path: root/nova/compute
diff options
context:
space:
mode:
authorJason Koelker <jason@koelker.net>2011-09-19 09:35:08 -0500
committerJason Koelker <jason@koelker.net>2011-09-19 09:35:08 -0500
commit041b4a64b09941c7168cc5ef0e348a68a2cdab0e (patch)
tree54774fb7141bba92fea9d44185f127c4ca5a4bcb /nova/compute
parentbd8133c8a9ca39ae3bb66499975462ccec5f8ca8 (diff)
parent0561c0e01822d81fc90fed00f41b8d469c6c7808 (diff)
merge the sknurt
Diffstat (limited to 'nova/compute')
-rw-r--r--nova/compute/api.py46
-rw-r--r--nova/compute/manager.py22
2 files changed, 39 insertions, 29 deletions
diff --git a/nova/compute/api.py b/nova/compute/api.py
index 9c3cc934e..853e6ef9e 100644
--- a/nova/compute/api.py
+++ b/nova/compute/api.py
@@ -287,18 +287,24 @@ class API(base.Base):
return (num_instances, base_options, image)
@staticmethod
- def _ephemeral_size(instance_type, ephemeral_name):
- num = block_device.ephemeral_num(ephemeral_name)
+ def _volume_size(instance_type, virtual_name):
+ size = 0
+ if virtual_name == 'swap':
+ size = instance_type.get('swap', 0)
+ elif block_device.is_ephemeral(virtual_name):
+ num = block_device.ephemeral_num(virtual_name)
- # TODO(yamahata): ephemeralN where N > 0
- # Only ephemeral0 is allowed for now because InstanceTypes
- # table only allows single local disk, local_gb.
- # In order to enhance it, we need to add a new columns to
- # instance_types table.
- if num > 0:
- return 0
+ # TODO(yamahata): ephemeralN where N > 0
+ # Only ephemeral0 is allowed for now because InstanceTypes
+ # table only allows single local disk, local_gb.
+ # In order to enhance it, we need to add a new columns to
+ # instance_types table.
+ if num > 0:
+ return 0
- return instance_type.get('local_gb')
+ size = instance_type.get('local_gb')
+
+ return size
def _update_image_block_device_mapping(self, elevated_context,
instance_type, instance_id,
@@ -319,12 +325,7 @@ class API(base.Base):
if not block_device.is_swap_or_ephemeral(virtual_name):
continue
- size = 0
- if virtual_name == 'swap':
- size = instance_type.get('swap', 0)
- elif block_device.is_ephemeral(virtual_name):
- size = self._ephemeral_size(instance_type, virtual_name)
-
+ size = self._volume_size(instance_type, virtual_name)
if size == 0:
continue
@@ -354,8 +355,8 @@ class API(base.Base):
virtual_name = bdm.get('virtual_name')
if (virtual_name is not None and
- block_device.is_ephemeral(virtual_name)):
- size = self._ephemeral_size(instance_type, virtual_name)
+ block_device.is_swap_or_ephemeral(virtual_name)):
+ size = self._volume_size(instance_type, virtual_name)
if size == 0:
continue
values['volume_size'] = size
@@ -1285,13 +1286,18 @@ class API(base.Base):
self._cast_compute_message('resume_instance', context, instance_id)
@scheduler_api.reroute_compute("rescue")
- def rescue(self, context, instance_id):
+ def rescue(self, context, instance_id, rescue_password=None):
"""Rescue the given instance."""
self.update(context,
instance_id,
vm_state=vm_states.ACTIVE,
task_state=task_states.RESCUING)
- self._cast_compute_message('rescue_instance', context, instance_id)
+
+ rescue_params = {
+ "rescue_password": rescue_password
+ }
+ self._cast_compute_message('rescue_instance', context, instance_id,
+ params=rescue_params)
@scheduler_api.reroute_compute("unrescue")
def unrescue(self, context, instance_id):
diff --git a/nova/compute/manager.py b/nova/compute/manager.py
index 7915830ec..46c643aee 100644
--- a/nova/compute/manager.py
+++ b/nova/compute/manager.py
@@ -70,8 +70,6 @@ flags.DEFINE_string('compute_driver', 'nova.virt.connection.get_connection',
'Driver to use for controlling virtualization')
flags.DEFINE_string('stub_network', False,
'Stub network related code')
-flags.DEFINE_integer('password_length', 12,
- 'Length of generated admin passwords')
flags.DEFINE_string('console_host', socket.gethostname(),
'Console proxy host to use to connect to instances on'
'this host.')
@@ -797,12 +795,18 @@ class ComputeManager(manager.SchedulerDependentManager):
@exception.wrap_exception(notifier=notifier, publisher_id=publisher_id())
@checks_instance_lock
- def rescue_instance(self, context, instance_id):
- """Rescue an instance on this host."""
+ def rescue_instance(self, context, instance_id, **kwargs):
+ """
+ Rescue an instance on this host.
+ :param rescue_password: password to set on rescue instance
+ """
+
LOG.audit(_('instance %s: rescuing'), instance_id, context=context)
context = context.elevated()
instance_ref = self.db.instance_get(context, instance_id)
+ instance_ref.admin_pass = kwargs.get('rescue_password',
+ utils.generate_password(FLAGS.password_length))
network_info = self._get_instance_nw_info(context, instance_ref)
# NOTE(blamar): None of the virt drivers use the 'callback' param
@@ -1388,11 +1392,6 @@ class ComputeManager(manager.SchedulerDependentManager):
instance_ref = self.db.instance_get(context, instance_id)
hostname = instance_ref['hostname']
- # Getting fixed ips
- fixed_ips = self.db.instance_get_fixed_addresses(context, instance_id)
- if not fixed_ips:
- raise exception.FixedIpNotFoundForInstance(instance_id=instance_id)
-
# If any volume is mounted, prepare here.
if not instance_ref['volumes']:
LOG.info(_("%s has no volume."), hostname)
@@ -1408,6 +1407,11 @@ class ComputeManager(manager.SchedulerDependentManager):
# Retry operation is necessary because continuously request comes,
# concorrent request occurs to iptables, then it complains.
network_info = self._get_instance_nw_info(context, instance_ref)
+
+ fixed_ips = [nw_info[1]['ips'] for nw_info in network_info]
+ if not fixed_ips:
+ raise exception.FixedIpNotFoundForInstance(instance_id=instance_id)
+
max_retry = FLAGS.live_migration_retry_count
for cnt in range(max_retry):
try: