summaryrefslogtreecommitdiffstats
path: root/nova/compute
diff options
context:
space:
mode:
Diffstat (limited to 'nova/compute')
-rw-r--r--nova/compute/api.py60
-rw-r--r--nova/compute/manager.py38
2 files changed, 66 insertions, 32 deletions
diff --git a/nova/compute/api.py b/nova/compute/api.py
index 2a65ff042..e7afceb0b 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
@@ -904,7 +905,7 @@ class API(base.Base):
if 'reservation_id' in filters:
recurse_zones = True
- instances = self.db.instance_get_all_by_filters(context, filters)
+ instances = self._get_instances_by_filters(context, filters)
if not recurse_zones:
return instances
@@ -927,6 +928,18 @@ class API(base.Base):
return instances
+ def _get_instances_by_filters(self, context, filters):
+ ids = None
+ if 'ip6' in filters or 'ip' in filters:
+ res = self.network_api.get_instance_uuids_by_ip_filter(context,
+ filters)
+ # NOTE(jkoelker) It is possible that we will get the same
+ # instance uuid twice (one for ipv4 and ipv6)
+ uuids = set([r['instance_uuid'] for r in res])
+ filters['uuid'] = uuids
+
+ return self.db.instance_get_all_by_filters(context, filters)
+
def _cast_compute_message(self, method, context, instance_id, host=None,
params=None):
"""Generic handler for RPC casts to compute.
@@ -1272,13 +1285,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..cb5d10f83 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.')
@@ -81,6 +79,9 @@ flags.DEFINE_integer('live_migration_retry_count', 30,
flags.DEFINE_integer("rescue_timeout", 0,
"Automatically unrescue an instance after N seconds."
" Set to 0 to disable.")
+flags.DEFINE_integer("resize_confirm_window", 0,
+ "Automatically confirm resizes after N seconds."
+ " Set to 0 to disable.")
flags.DEFINE_integer('host_state_interval', 120,
'Interval in seconds for querying the host status')
@@ -797,12 +798,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 +1395,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 +1410,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:
@@ -1644,14 +1651,23 @@ class ComputeManager(manager.SchedulerDependentManager):
self.driver.poll_rescued_instances(FLAGS.rescue_timeout)
except Exception as ex:
LOG.warning(_("Error during poll_rescued_instances: %s"),
- unicode(ex))
+ unicode(ex))
+ error_list.append(ex)
+
+ try:
+ if FLAGS.resize_confirm_window > 0:
+ self.driver.poll_unconfirmed_resizes(
+ FLAGS.resize_confirm_window)
+ except Exception as ex:
+ LOG.warning(_("Error during poll_unconfirmed_resizes: %s"),
+ unicode(ex))
error_list.append(ex)
try:
self._report_driver_status()
except Exception as ex:
LOG.warning(_("Error during report_driver_status(): %s"),
- unicode(ex))
+ unicode(ex))
error_list.append(ex)
try: