Lines Matching refs:instance
109 help='Allow kernel boot options to be set in instance '
160 # Required in order to create a zone VNC console SMF service instance
356 LOG.exception(_("Unable to initialize editing of instance '%s' "
377 "instance '%s' via zonemgr(3RAD): %s")
404 "instance '%s' via zonemgr(3RAD): %s")
429 LOG.exception(_("Unable to create new resource '%s' for instance "
445 LOG.exception(_("Unable to remove resource '%s' for instance '%s' "
459 "for instance '%s' via zonemgr(3RAD): %s")
471 An instance has an ID, which is the identifier chosen by Nova to represent
472 the instance further up the stack. This is unfortunately also called a
473 'name' elsewhere. As far as this layer is concerned, 'instance ID' and
474 'instance name' are synonyms.
476 Note that the instance ID or name is not human-readable or
484 platform-specific layer is responsible for keeping track of which instance
487 Some methods here take an instance of nova.compute.service.Instance. This
489 instance, and pass them into this layer. This layer is responsible for
828 def get_info(self, instance):
829 """Get the current status of an instance, by name (not ID!)
831 :param instance: nova.objects.instance.Instance object
836 name = instance['name']
861 def instance_exists(self, instance):
862 """Checks existence of an instance on the host.
864 :param instance: The instance to lookup
866 Returns True if an instance with the supplied ID exists on
877 return instance.uuid in self.list_instance_uuids()
879 return instance.name in self.list_instances()
882 """Estimate the virtualization overhead required to build an instance
885 Defaults to zero, drivers should override if per-instance overhead
913 def _rebuild_block_devices(self, context, instance, bdms, recreate):
915 rootmp = instance['root_device_name']
936 "for instance '%s'") % instance['name'])
943 self.detach_volume(ci, instance, entry['device_name'])
946 msg = (_("Unable to find the root device for instance '%s'.")
947 % instance['name'])
952 def _set_instance_metahostid(self, instance):
955 the instance
957 hostid = instance.system_metadata.get('hostid')
961 zone = self._get_zone_by_name(instance['name'])
967 instance.system_metadata['hostid'] = hostid
971 def rebuild(self, context, instance, image_meta, injected_files,
976 """Destroy and re-make this instance.
988 :param instance: nova.objects.instance.Instance
990 the creation of the new instance.
992 The metadata of the image of the instance.
993 :param injected_files: User files to inject into instance.
994 :param admin_password: Administrator password to set in instance.
1004 :param recreate: True if the instance is being recreated on a new
1007 attached to the instance.
1012 instance.system_metadata['evac_from'] = instance['launched_on']
1013 instance.save()
1014 extra_specs = self._get_flavor(instance)['extra_specs'].copy()
1021 self._power_off(instance, "HALT")
1023 instance.task_state = task_states.REBUILD_BLOCK_DEVICE_MAPPING
1024 instance.save(expected_task_state=[task_states.REBUILDING])
1025 root_ci = self._rebuild_block_devices(context, instance, bdms,
1034 msg = (_("Root device is not on shared storage for instance "
1035 "'%s'.") % instance['name'])
1039 self.destroy(context, instance, network_info, block_device_info)
1056 instance.task_state = task_states.REBUILD_SPAWNING
1057 instance.save(
1063 extra_specs = self._get_flavor(instance)['extra_specs'].copy()
1065 instance.system_metadata['rebuilding'] = 'false'
1066 self._create_config(context, instance, network_info, root_ci, None)
1067 del instance.system_metadata['evac_from']
1068 instance.save()
1070 instance.system_metadata['rebuilding'] = 'true'
1071 self.spawn(context, instance, image_meta, injected_files,
1074 del instance.system_metadata['rebuilding']
1075 name = instance['name']
1083 rootmp = instance['root_device_name']
1091 self.attach_volume(context, connection_info, instance, mount)
1093 self._power_on(instance, network_info)
1100 self.set_admin_password(instance, admin_password)
1102 def _get_flavor(self, instance):
1103 """Retrieve the flavor object as specified in the instance object"""
1106 instance['instance_type_id'])
1108 def _fetch_image(self, context, instance):
1109 """Fetch an image using Glance given the instance's image_ref."""
1112 iref = instance['image_ref']
1132 images.fetch(context, iref, image, instance['user_id'],
1133 instance['project_id'])
1142 def _validate_image(self, context, image, instance):
1143 """Validate a glance image for compatibility with the instance."""
1145 if instance['image_ref'] in self._validated_archives:
1155 raise exception.ImageUnacceptable(image_id=instance['image_ref'],
1163 raise exception.ImageUnacceptable(image_id=instance['image_ref'],
1178 image_meta = glanceapi.get(context, instance['image_ref'])
1184 raise exception.ImageUnacceptable(image_id=instance['image_ref'],
1189 raise exception.ImageUnacceptable(image_id=instance['image_ref'],
1192 self._validated_archives.append(instance['image_ref'])
1194 def _validate_flavor(self, instance):
1196 flavor = self._get_flavor(instance)
1203 instance_size = Size('%sMB' % instance['memory_mb'])
1209 memsize=str(instance['memory_mb']),
1345 "set on flavor for instance '%s'")
1350 def _create_boot_volume(self, context, instance):
1356 context, instance['root_gb'],
1357 instance['hostname'] + "-" + self._rootzpool_suffix,
1358 "Boot volume for instance '%s' (%s)"
1359 % (instance['name'], instance['uuid']),
1370 LOG.exception(_("Unable to create root zpool volume for instance "
1371 "'%s': %s") % (instance['name'], reason))
1374 def _connect_boot_volume(self, volume, mountpoint, context, instance):
1376 instance_uuid = instance['uuid']
1379 connector = self.get_volume_connector(instance)
1389 extra_specs = self._get_flavor(instance)['extra_specs'].copy()
1411 # iSCSI LUN is on the same host as the instance.
1485 def _ovs_add_port(self, instance, vif, port):
1501 'external-ids:vm-uuid=%s' % instance['uuid']
1530 def _plug_vifs(self, instance, network_info):
1535 # first find out all the anets for a given instance
1538 '-z', instance['name'],
1541 msg = (_("Unable to get interfaces for instance '%s': %s")
1542 % (instance['name'], reason))
1552 LOG.debug(_("List of instance %s's anets: %s")
1553 % (instance['name'], anetdict))
1562 'to instance %s')
1564 instance['name']))
1566 self._ovs_add_port(instance, vif, anet)
1568 def _unplug_vifs(self, instance):
1576 msg = (_("Unable to get interfaces for instance '%s': %s")
1577 % (instance['name'], reason))
1581 if port.split('/')[0] != instance['name']:
1607 "lower-link can be determined for the instance's "
1616 "can be determined for the instance's interface."))
1661 def _set_network(self, context, name, instance, network_info, brand,
1699 tstate = instance['task_state']
1705 instance.system_metadata['rebuilding'] == 'true'):
1722 def _set_suspend(self, instance):
1723 """Use the instance name to specify the pathname for the suspend image.
1725 name = instance['name']
1735 def _verify_sysconfig(self, sc_dir, instance, admin_password=None):
1745 sshkey = instance.get('key_data')
1746 name = instance.get('hostname')
1783 instance.system_metadata.update(
1785 instance.save()
1808 def _create_config(self, context, instance, network_info, connection_info,
1811 name = instance['name']
1815 flavor = self._get_flavor(instance)
1830 msg = (_("Invalid brand '%s' specified for instance '%s'"
1834 tstate = instance['task_state']
1840 instance.system_metadata['rebuilding'] == 'true'):
1849 self._verify_sysconfig(sc_dir, instance, admin_password)
1852 % (name, instance['display_name']))
1856 hostid = instance.system_metadata.get('hostid')
1864 self._set_num_cpu(name, instance['vcpus'], brand)
1865 self._set_memory_cap(name, instance['memory_mb'], brand)
1866 self._set_network(context, name, instance, network_info, brand,
1870 LOG.exception(_("Unable to create configuration for instance '%s' "
1874 def _create_vnc_console_service(self, instance):
1889 name = instance['name']
1895 if self._has_vnc_console_service(instance):
1897 "console SMF service for instance '%s'") % name)
1905 def _delete_vnc_console_service(self, instance):
1907 name = instance['name']
1908 self._disable_vnc_console_service(instance)
1915 if not self._has_vnc_console_service(instance):
1917 "VNC console SMF service for instance '%s'")
1926 def _enable_vnc_console_service(self, instance):
1928 name = instance['name']
1943 if not self._has_vnc_console_service(instance):
1945 "VNC console SMF service for instance '%s'")
1967 instance_uuid=instance['uuid'])
1991 def _disable_vnc_console_service(self, instance):
1993 name = instance['name']
1994 if not self._has_vnc_console_service(instance):
1996 "console SMF service for instance '%s'") % name)
2007 # The console service sets a SMF instance property for the port
2018 def _get_vnc_console_service_state(self, instance):
2019 """Returns state of the instance zone VNC console SMF service"""
2020 name = instance['name']
2021 if not self._has_vnc_console_service(instance):
2023 "VNC console SMF service for instance '%s'")
2035 "console SMF service for instance '%s': %s")
2039 def _has_vnc_console_service(self, instance):
2040 """Returns True if the instance has a zone VNC console SMF service"""
2041 name = instance['name']
2050 def _install(self, instance, image, sc_dir):
2052 name = instance['name']
2070 LOG.debug(_("Installing instance '%s' (%s)") %
2071 (name, instance['display_name']))
2075 LOG.exception(_("Unable to install root file system for instance "
2079 self._set_instance_metahostid(instance)
2081 LOG.debug(_("Installation of instance '%s' (%s) complete") %
2082 (name, instance['display_name']))
2084 def _power_on(self, instance, network_info):
2086 name = instance['name']
2091 # Attempt to update the zones hostid in the instance data, to catch
2093 self._set_instance_metahostid(instance)
2103 # Get any bootargs set in the instance metadata by the user
2104 meta_bootargs = instance.metadata.get('bootargs')
2109 instance.metadata.get('bootargs_persist', 'False'))
2118 self._plug_vifs(instance, network_info)
2121 LOG.exception(_("Unable to power on instance '%s' via "
2130 instance.metadata.pop('bootargs', None)
2131 instance.metadata.pop('bootargs_persist', None)
2138 def _uninstall(self, instance):
2140 name = instance['name']
2154 "instance '%s' via zonemgr(3RAD): %s")
2158 def _delete_config(self, instance):
2160 name = instance['name']
2168 LOG.exception(_("Unable to delete configuration for instance '%s' "
2172 def spawn(self, context, instance, image_meta, injected_files,
2174 """Create a new instance/VM/domain on the virtualization platform.
2176 Once this successfully completes, the instance should be
2179 If this fails, any partial instance should be completely
2184 :param instance: nova.objects.instance.Instance
2186 the creation of the new instance.
2188 The metadata of the image of the instance.
2189 :param injected_files: User files to inject into instance.
2190 :param admin_password: Administrator password to set in instance.
2194 attached to the instance.
2196 image = self._fetch_image(context, instance)
2197 self._validate_image(context, image, instance)
2198 self._validate_flavor(instance)
2217 volume = self._create_boot_volume(context, instance)
2219 name = instance['name']
2222 context, instance)
2234 "instance %s: %s") % (volume['id'], name, reason))
2244 self._create_config(context, instance, network_info,
2246 self._install(instance, image, sc_dir)
2251 instance, entry['mount_device'])
2253 self._power_on(instance, network_info)
2256 LOG.exception(_("Unable to spawn instance '%s' via zonemgr(3RAD): "
2258 # At least attempt to uninstall the instance, depending on where
2262 self._uninstall(instance)
2265 LOG.debug(_("Unable to uninstall instance '%s' via "
2268 self._delete_config(instance)
2271 LOG.debug(_("Unable to unconfigure instance '%s' via "
2284 # there's only one bdm for this instance at this point
2286 context, instance.uuid).objects[0]
2295 bdm['volume_size'] = instance['root_gb']
2298 def _power_off(self, instance, halt_type):
2300 name = instance['name']
2305 # Attempt to update the zones hostid in the instance data, to catch
2307 self._set_instance_metahostid(instance)
2310 self._unplug_vifs(instance)
2322 "trying to power off instance '%s' via "
2326 LOG.exception(_("Unable to power off instance '%s' "
2330 def _samehost_revert_resize(self, context, instance, network_info,
2334 self.power_off(instance)
2336 extra_specs = self._get_flavor(instance)['extra_specs'].copy()
2339 name = instance['name']
2341 self._set_num_cpu(name, instance.vcpus, brand)
2342 self._set_memory_cap(name, instance.memory_mb, brand)
2344 rgb = instance.root_gb
2345 old_rvid = instance.system_metadata.get('old_instance_volid')
2347 new_rvid = instance.system_metadata.get('new_instance_volid')
2348 mount_dev = instance['root_device_name']
2349 del instance.system_metadata['old_instance_volid']
2351 self._resize_disk_migration(context, instance, new_rvid, old_rvid,
2354 def destroy(self, context, instance, network_info, block_device_info=None,
2356 """Destroy the specified instance from the Hypervisor.
2358 If the instance is not found (for example if networking failed), this
2363 :param instance: Instance object as returned by DB layer.
2367 be detached from the instance.
2371 if (instance['task_state'] == task_states.RESIZE_REVERTING and
2372 instance.system_metadata['old_vm_state'] == vm_states.RESIZED):
2378 evac_from = instance.system_metadata.get('evac_from')
2379 if evac_from is not None and instance['task_state'] is None:
2380 instance.host = evac_from
2381 instance.node = evac_from
2382 del instance.system_metadata['evac_from']
2383 instance.save()
2391 if self._has_vnc_console_service(instance):
2392 self._disable_vnc_console_service(instance)
2393 self._delete_vnc_console_service(instance)
2397 name = instance['name']
2399 # If instance cannot be found, just return.
2401 LOG.warning(_("Unable to find instance '%s' via zonemgr(3RAD)")
2407 self._power_off(instance, 'HARD')
2409 self._uninstall(instance)
2411 self._delete_config(instance)
2414 LOG.warning(_("Unable to destroy instance '%s' via zonemgr(3RAD): "
2417 # One last point of house keeping. If we are deleting the instance
2430 if instance['task_state'] == task_states.RESIZE_REVERTING:
2435 volid = instance.system_metadata.get(tag)
2440 del instance.system_metadata[tag]
2444 def cleanup(self, context, instance, network_info, block_device_info=None,
2446 """Cleanup the instance resources .
2452 :param instance: Instance object as returned by DB layer.
2456 be detached from the instance.
2462 def reboot(self, context, instance, network_info, reboot_type,
2464 """Reboot the specified instance.
2466 After this is called successfully, the instance's state
2472 :param instance: nova.objects.instance.Instance
2480 name = instance['name']
2486 self._power_on(instance, network_info)
2497 # Get any bootargs set in the instance metadata by the user
2498 meta_bootargs = instance.metadata.get('bootargs')
2503 instance.metadata.get('bootargs_persist', 'False'))
2511 self._unplug_vifs(instance)
2517 self._plug_vifs(instance, network_info)
2520 LOG.exception(_("Unable to reboot instance '%s' via "
2529 instance.metadata.pop('bootargs', None)
2530 instance.metadata.pop('bootargs_persist', None)
2541 def _get_console_output(self, instance):
2560 logfile_pattern = '/var/log/zones/%s.console*' % instance['name']
2580 def get_console_output(self, context, instance):
2581 """Get console output for an instance
2584 :param instance: nova.objects.instance.Instance
2586 return self._get_console_output(instance)
2588 def get_vnc_console(self, context, instance):
2592 :param instance: nova.objects.instance.Instance
2594 :returns an instance of console.type.ConsoleVNC
2599 name = instance['name']
2600 if instance['vm_state'] == vm_states.BUILDING:
2603 raise exception.InstanceNotReady(instance_id=instance['uuid'])
2605 if not self._has_vnc_console_service(instance):
2607 "instance '%s'") % name)
2608 self._create_vnc_console_service(instance)
2610 self._enable_vnc_console_service(instance)
2613 # The console service sets an SMF instance property for the port
2639 def get_spice_console(self, context, instance):
2643 :param instance: nova.objects.instance.Instance
2645 :returns an instance of console.type.ConsoleSpice
2649 def get_rdp_console(self, context, instance):
2653 :param instance: nova.objects.instance.Instance
2655 :returns an instance of console.type.ConsoleRDP
2659 def get_serial_console(self, context, instance):
2663 :param instance: nova.objects.instance.Instance
2665 :returns an instance of console.type.ConsoleSerial
2669 def get_mks_console(self, context, instance):
2673 :param instance: nova.objects.instance.Instance
2675 :returns an instance of console.type.ConsoleMKS
2721 reason = (_("Could not get diagnostic info for instance '%s' "
2728 def get_diagnostics(self, instance):
2729 """Return diagnostics data about the given instance.
2731 :param nova.objects.instance.Instance instance:
2732 The instance to which the diagnostic data should be returned.
2739 name = instance['name']
2745 def get_instance_diagnostics(self, instance):
2746 """Return diagnostics data about the given instance.
2748 :param nova.objects.instance.Instance instance:
2749 The instance to which the diagnostic data should be returned.
2761 :param instances: nova.objects.instance.InstanceList
2777 def attach_volume(self, context, connection_info, instance, mountpoint,
2779 """Attach the disk to the instance at mountpoint using info."""
2782 name = instance['name']
2787 extra_specs = self._get_flavor(instance)['extra_specs'].copy()
2812 LOG.exception(_("Unable to attach '%s' to instance '%s' via "
2818 def detach_volume(self, connection_info, instance, mountpoint,
2820 """Detach the disk attached to the instance."""
2821 name = instance['name']
2826 extra_specs = self._get_flavor(instance)['extra_specs'].copy()
2840 LOG.warning(_("Storage resource '%s' is not attached to instance "
2853 "to running instance '%s' because the "
2870 instance, mountpoint, resize_to):
2871 """Replace the volume attached to the given `instance`.
2875 `instance`.
2878 'instance'.
2879 :param nova.objects.instance.Instance instance:
2880 The instance whose volume gets replaced by another one.
2882 The mountpoint in the instance where the volume for
2892 def attach_interface(self, instance, image_meta, vif):
2893 """Use hotplug to add a network interface to a running instance.
2897 :param nova.objects.instance.Instance instance:
2898 The instance which will get an additional network interface.
2900 The metadata of the image of the instance.
2908 name = instance['name']
2914 extra_specs = self._get_flavor(instance)['extra_specs'].copy()
2919 if instance['vm_state'] == vm_states.ACTIVE:
2924 msg = (_("Unable to attach interface to instance '%s' via "
2934 self._ovs_add_port(instance, vif, anet)
2936 def detach_interface(self, instance, vif):
2937 """Use hotunplug to remove a network interface from a running instance.
2941 :param nova.objects.instance.Instance instance:
2942 The instance which gets a network interface removed.
2950 name = instance['name']
2961 "instance '%s'.") % (vif['address'], name))
2964 extra_specs = self._get_flavor(instance)['extra_specs'].copy()
2979 if instance['vm_state'] == vm_states.ACTIVE:
2984 "instance '%s' because the resource is most likely "
3003 def _cleanup_migrate_disk(self, context, instance, volume):
3008 :param instance: nova.objects.instance.Instance being migrated/resized
3016 def migrate_disk_and_power_off(self, context, instance, dest,
3020 """Transfers the disk of a running instance in multiple phases, turning
3021 off the instance before the end.
3023 :param nova.objects.instance.Instance instance:
3024 The instance whose disk should be migrated.
3028 The flavor of the instance whose disk get migrated.
3030 The network information of the given `instance`.
3041 LOG.debug("Starting migrate_disk_and_power_off", instance=instance)
3045 instance.system_metadata['resize_samehost'] = samehost
3047 extra_specs = self._get_flavor(instance)['extra_specs'].copy()
3058 orgb = instance['root_gb']
3064 self.power_off(instance, timeout, retry_interval)
3069 rootmp = instance.root_device_name
3099 instance.system_metadata['old_instance_volid'] = volume_id
3100 instance.system_metadata['new_instance_volid'] = newvolume['id']
3115 self._cleanup_migrate_disk(context, instance, newvolume)
3122 def snapshot(self, context, instance, image_id, update_task_state):
3123 """Snapshots the specified instance.
3126 :param instance: nova.objects.instance.Instance
3130 name = instance['name']
3137 extra_specs = self._get_flavor(instance)['extra_specs'].copy()
3145 context, instance['image_ref'])
3163 'owner_id': instance['project_id'],
3164 'instance_uuid': instance['uuid'],
3187 zone_name = instance['name']
3192 instance=instance)
3202 instance=instance)
3219 def post_interrupted_snapshot_cleanup(self, context, instance):
3223 :param instance: nova.objects.instance.Instance
3227 def _cleanup_finish_migration(self, context, instance, disk_info,
3237 old_rvid = instance.system_metadata.get('old_instance_volid')
3239 connector = self.get_volume_connector(instance)
3243 new_rvid = instance.system_metadata['new_instance_volid']
3245 rootmp = instance.root_device_name
3246 self._volume_api.attach(context, old_rvid, instance['uuid'],
3255 del instance.system_metadata['new_instance_volid']
3256 del instance.system_metadata['old_instance_volid']
3259 self.destroy(context, instance, network_info)
3260 instance['host'] = instance['launched_on']
3261 instance['node'] = instance['launched_on']
3263 def finish_migration(self, context, migration, instance, disk_info,
3270 :param instance: nova.objects.instance.Instance being migrated/resized
3275 The metadata of the image of the instance.
3276 :param resize_instance: True if the instance is being resized,
3278 :param block_device_info: instance volume block device info
3279 :param power_on: True if the instance should be powered on, False
3284 instance.system_metadata['old_vm_state'] = vm_states.RESIZED
3286 extra_specs = self._get_flavor(instance)['extra_specs'].copy()
3288 name = instance['name']
3292 rootmp = instance['root_device_name']
3301 cpu = instance.vcpus
3302 mem = instance.memory_mb
3309 rgb = instance.root_gb
3310 self._resize_disk_migration(context, instance,
3321 instance,
3327 self._create_config(context, instance, network_info,
3340 instance, entry['mount_device'])
3343 self._power_on(instance, network_info)
3364 self._cleanup_finish_migration(context, instance, disk_info,
3368 def confirm_migration(self, context, migration, instance, network_info):
3371 :param instance: nova.objects.instance.Instance
3374 old_rvid = instance.system_metadata.get('old_instance_volid')
3375 new_rvid = instance.system_metadata.get('new_instance_volid')
3377 new_vname = instance['display_name'] + "-" + self._rootzpool_suffix
3378 del instance.system_metadata['old_instance_volid']
3379 del instance.system_metadata['new_instance_volid']
3386 self.destroy(context, instance, network_info)
3388 del instance.system_metadata['resize_samehost']
3390 def _resize_disk_migration(self, context, instance, configured,
3398 :param instance: nova.objects.instance.Instance being resized
3405 connector = self.get_volume_connector(instance)
3410 rootmp = instance.root_device_name
3413 name = instance['name']
3437 self._volume_api.attach(context, replacement, instance['uuid'],
3452 def finish_revert_migration(self, context, instance, network_info,
3457 :param instance: nova.objects.instance.Instance being migrated/resized
3460 :param block_device_info: instance volume block device info
3461 :param power_on: True if the instance should be powered on, False
3465 # original volume to the instance. Otherwise we need to update the
3467 samehost = instance.system_metadata.get('resize_samehost')
3469 self._samehost_revert_resize(context, instance, network_info,
3471 del instance.system_metadata['resize_samehost']
3473 old_rvid = instance.system_metadata.get('old_instance_volid')
3475 connector = self.get_volume_connector(instance)
3480 new_rvid = instance.system_metadata['new_instance_volid']
3484 rootmp = instance.root_device_name
3485 self._volume_api.attach(context, old_rvid, instance['uuid'],
3494 del instance.system_metadata['new_instance_volid']
3495 del instance.system_metadata['old_instance_volid']
3497 new_rvid = instance.system_metadata.get('new_instance_volid')
3499 del instance.system_metadata['new_instance_volid']
3502 self._power_on(instance, network_info)
3504 def pause(self, instance):
3505 """Pause the given instance.
3507 A paused instance doesn't use CPU cycles of the host anymore. The
3513 :param nova.objects.instance.Instance instance:
3514 The instance which should be paused.
3521 def unpause(self, instance):
3522 """Unpause the given paused instance.
3524 The paused instance gets unpaused and will use CPU cycles of the
3529 :param nova.objects.instance.Instance instance:
3530 The instance which should be unpaused.
3537 def suspend(self, context, instance):
3538 """Suspend the specified instance.
3540 A suspended instance doesn't use CPU cycles or memory of the host
3541 anymore. The state of the instance could be persisted on the host
3547 :param nova.objects.instance.Instance instance:
3548 The instance to suspend.
3552 name = instance['name']
3561 "to reset instance state back to 'active'.")
3562 % (zone.brand, instance['display_name']))
3574 self._set_suspend(instance)
3579 self._set_suspend(instance)
3582 self._unplug_vifs(instance)
3585 LOG.exception(_("Unable to suspend instance '%s' via "
3589 def resume(self, context, instance, network_info, block_device_info=None):
3590 """resume the specified suspended instance.
3592 The suspended instance gets resumed and will use CPU cycles and memory
3599 :param nova.objects.instance.Instance instance:
3600 The suspended instance to resume.
3608 name = instance['name']
3619 # check that the instance is suspended
3626 self._plug_vifs(instance, network_info)
3629 LOG.exception(_("Unable to resume instance '%s' via "
3633 def resume_state_on_host_boot(self, context, instance, network_info,
3637 :param instance: nova.objects.instance.Instance
3639 name = instance['name']
3650 self._power_on(instance, network_info)
3652 def rescue(self, context, instance, network_info, image_meta,
3654 """Rescue the specified instance.
3658 :param nova.objects.instance.Instance instance:
3659 The instance being rescued.
3663 The metadata of the image of the instance.
3668 def set_bootable(self, instance, is_bootable):
3669 """Set the ability to power on/off an instance.
3671 :param instance: nova.objects.instance.Instance
3675 def unrescue(self, instance, network_info):
3676 """Unrescue the specified instance.
3678 :param instance: nova.objects.instance.Instance
3683 def power_off(self, instance, timeout=0, retry_interval=0):
3684 """Power off the specified instance.
3686 :param instance: nova.objects.instance.Instance
3691 self._power_off(instance, 'SOFT')
3693 def power_on(self, context, instance, network_info,
3695 """Power on the specified instance.
3697 :param instance: nova.objects.instance.Instance
3699 self._power_on(instance, network_info)
3701 def trigger_crash_dump(self, instance):
3702 """Trigger crash dump mechanism on the given instance.
3707 :param nova.objects.instance.Instance instance:
3708 The instance where the crash dump should be triggered.
3714 def soft_delete(self, instance):
3715 """Soft delete the specified instance.
3717 A soft-deleted instance doesn't allocate any resources anymore, but is
3719 uses the database entry to create a new instance based on that.
3721 :param nova.objects.instance.Instance instance:
3722 The instance to soft-delete.
3728 def restore(self, instance):
3729 """Restore the specified soft-deleted instance.
3731 The restored instance will be automatically booted. The counter action
3734 :param nova.objects.instance.Instance instance:
3735 The soft-deleted instance which should be restored from the
3854 def pre_live_migration(self, context, instance, block_device_info,
3856 """Prepare an instance for live migration
3859 :param instance: nova.objects.instance.Instance object
3860 :param block_device_info: instance block device information
3861 :param network_info: instance network information
3862 :param disk_info: instance disk information
3882 def live_migration(self, context, instance, dest,
3885 """Live migration of an instance to another host.
3888 :param instance:
3890 instance object that is migrated.
3902 name = instance['name']
3908 LOG.exception(_("Unable to live migrate instance '%s' to host "
3911 recover_method(context, instance, dest, block_migration)
3913 post_method(context, instance, dest, block_migration, migrate_data)
3915 def live_migration_force_complete(self, instance):
3918 :param instance: Instance being live migrated
3923 def live_migration_abort(self, instance):
3926 :param instance: instance that is live migrating
3931 def rollback_live_migration_at_destination(self, context, instance,
3939 :param instance: instance object that was being migrated
3940 :param network_info: instance network information
3941 :param block_device_info: instance block device information
3949 def post_live_migration(self, context, instance, block_device_info,
3954 :instance: instance object that was migrated
3955 :block_device_info: instance block device information
3962 if self._has_vnc_console_service(instance):
3963 self._disable_vnc_console_service(instance)
3964 self._delete_vnc_console_service(instance)
3968 name = instance['name']
3970 # If instance cannot be found, just return.
3972 LOG.warning(_("Unable to find instance '%s' via zonemgr(3RAD)")
3977 self._delete_config(instance)
3980 LOG.exception(_("Unable to delete configuration for instance '%s' "
3984 def post_live_migration_at_source(self, context, instance, network_info):
3988 :param instance: instance object reference
3989 :param network_info: instance network information
3991 self._unplug_vifs(instance)
3993 def post_live_migration_at_destination(self, context, instance,
4000 :param instance: instance object that is migrated
4001 :param network_info: instance network information
4004 self._plug_vifs(instance, network_info)
4006 def check_instance_shared_storage_local(self, context, instance):
4007 """Check if instance files located on shared storage.
4013 :param instance: nova.objects.instance.Instance object
4018 """Check if instance files located on shared storage.
4033 def check_can_live_migrate_destination(self, context, instance,
4043 :param instance: nova.db.sqlalchemy.models.Instance
4062 extra_specs = self._get_flavor(instance)['extra_specs'].copy()
4092 """Check if local volumes are attached to the instance."""
4102 def check_can_live_migrate_source(self, context, instance,
4110 :param instance: nova.db.sqlalchemy.models.Instance
4121 name = instance['name']
4130 def get_instance_disk_info(self, instance,
4132 """Retrieve information about actual disk sizes of an instance.
4134 :param instance: nova.objects.Instance
4164 def refresh_instance_security_rules(self, instance):
4167 Gets called when an instance gets added to or removed from
4168 the security group the instance is a member of or if the
4173 def reset_network(self, instance):
4174 """reset networking for specified instance."""
4178 def ensure_filtering_rules_for_instance(self, instance, network_info):
4181 To migrate an instance, filtering rules to hypervisors
4188 - prepare_instance_filter(for nova-instance-instance-xxx, etc.)
4198 :param instance: nova.objects.instance.Instance object
4212 def unfilter_instance(self, instance, network_info):
4213 """Stop filtering instance."""
4217 def set_admin_password(self, instance, new_pass):
4218 """Set the root password on the specified instance.
4220 :param instance: nova.objects.instance.Instance
4223 name = instance['name']
4235 def inject_file(self, instance, b64_path, b64_contents):
4236 """Writes a file on the specified instance.
4238 The first parameter is an instance of nova.compute.service.Instance,
4239 and so the instance is being specified as instance.name. The second
4241 written on the instance; the third is the contents of the file, also
4250 def change_instance_metadata(self, context, instance, diff):
4251 """Applies a diff to the instance metadata.
4254 changes to the instance's metadata to the hypervisor. If the
4255 hypervisor has no means of publishing the instance metadata to
4256 the instance, then this method should not be implemented.
4259 :param instance: nova.objects.instance.Instance
4263 def inject_network_info(self, instance, nw_info):
4264 """inject network info for specified instance."""
4278 A list of nova.objects.instance.Instance objects that have been
4344 def plug_vifs(self, instance, network_info):
4345 """Plug virtual interfaces (VIFs) into the given `instance` at
4346 instance boot time.
4350 :param nova.objects.instance.Instance instance:
4351 The instance which gets VIFs plugged.
4360 def unplug_vifs(self, instance, network_info):
4368 :param nova.objects.instance.Instance instance:
4369 The instance which gets VIFs unplugged.
4399 def block_stats(self, instance, disk_id):
4401 given instance. These are returned as [rd_req, rd_bytes, wr_req,
4414 Note that this function takes an instance ID.
4418 def deallocate_networks_on_reschedule(self, instance):
4422 def macs_for_instance(self, instance):
4423 """What MAC addresses must this instance have?
4427 addresses that the instance is to have. allocate_for_instance will take
4428 this into consideration when provisioning networking for the instance.
4431 freeform) is up to the network implementation layer. For instance,
4451 def dhcp_options_for_instance(self, instance):
4452 """Get DHCP options for this instance.
4485 :param all_instances: nova.objects.instance.InstanceList
4531 def get_volume_connector(self, instance):
4532 """Get connector information for the instance for attaching to volumes.
4559 instance=instance)
4566 instance=instance)
4573 instance=instance)
4603 """Get information about instance resource usage.
4609 def instance_on_disk(self, instance):
4610 """Checks access of instance files on the host.
4612 :param instance: nova.objects.instance.Instance to lookup
4614 Returns True if files of an instance with the supplied ID accessible on
4619 of access to instance shared disk files
4623 instance['uuid'])
4626 rootmp = instance['root_device_name']
4636 msg = (_("Unable to find the root device for instance '%s'.")
4637 % instance['name'])
4649 an instance of the nova.virt.event.Event class.
4668 _("Event must be an instance of nova.virt.event.Event"))
4677 def delete_instance_files(self, instance):
4678 """Delete any lingering instance files for an instance.
4680 :param instance: nova.objects.instance.Instance
4681 :returns: True if the instance was deleted from disk, False otherwise.
4683 # Delete the zone configuration for the instance using destroy, because
4686 LOG.debug(_("Cleaning up for instance %s"), instance['name'])
4688 self.destroy(None, instance, None)
4702 def volume_snapshot_create(self, context, instance, volume_id,
4704 """Snapshots volumes attached to a specified instance.
4710 :param nova.objects.instance.Instance instance:
4711 The instance that has the volume attached
4724 def volume_snapshot_delete(self, context, instance, volume_id,
4726 """Deletes a snapshot of a volume attached to a specified instance.
4732 :param nova.objects.instance.Instance instance:
4733 The instance that has the volume attached.
4748 def default_root_device_name(self, instance, image_meta, root_bdm):
4751 :param nova.objects.instance.Instance instance:
4752 The instance to get the root device for.
4754 The metadata of the image of the instance.
4760 def default_device_names_for_instance(self, instance, root_device_name,
4765 def get_device_name_for_instance(self, instance,
4769 :param instance: nova.objects.instance.Instance that volume is
4771 :param bdms: a nova.objects.BlockDeviceMappingList for the instance
4772 :param block_device_obj: A nova.objects.BlockDeviceMapping instance
4794 def quiesce(self, context, instance, image_meta):
4795 """Quiesce the specified instance to prepare for snapshots.
4797 If the specified instance doesn't support quiescing,
4802 :param instance: nova.objects.instance.Instance to be quiesced
4804 The metadata of the image of the instance.
4808 def unquiesce(self, context, instance, image_meta):
4809 """Unquiesce the specified instance after snapshots.
4811 If the specified instance doesn't support quiescing,
4816 :param instance: nova.objects.instance.Instance to be unquiesced
4818 The metadata of the image of the instance.
4822 def network_binding_host_id(self, context, instance):
4826 :param instance: nova.objects.instance.Instance that the network
4830 return instance.get('host')