def rebuild(self, context, instance, image_meta, injected_files, admin_password, bdms, detach_block_devices, attach_block_devices, network_info=None, recreate=False, block_device_info=None, preserve_ephemeral=False): """Destroy and re-make this instance. A 'rebuild' effectively purges all existing data from the system and remakes the VM with given 'metadata' and 'personalities'. :param context: Security context. :param instance: Instance object. :param image_meta: Image object returned by nova.image.glance that defines the image from which to boot this instance. :param injected_files: User files to inject into instance. :param admin_password: Administrator password to set in instance. :param bdms: block-device-mappings to use for rebuild :param detach_block_devices: function to detach block devices. See nova.compute.manager.ComputeManager:_rebuild_default_impl for usage. :param attach_block_devices: function to attach block devices. See nova.compute.manager.ComputeManager:_rebuild_default_impl for usage. :param network_info: :py:meth:`~nova.network.manager.NetworkManager.get_instance_nw_info` :param block_device_info: Information about block devices to be attached to the instance. :param recreate: True if instance should be recreated with same disk. :param preserve_ephemeral: True if the default ephemeral storage partition must be preserved on rebuild. """ instance.task_state = task_states.REBUILD_SPAWNING instance.save(expected_task_state=[task_states.REBUILDING]) node_uuid = self._require_node(instance) node = db.bm_node_get_by_node_uuid(context, node_uuid) db.bm_node_update( context, node['id'], { 'task_state': baremetal_states.BUILDING, 'preserve_ephemeral': preserve_ephemeral }) self._spawn(node, context, instance, image_meta, injected_files, admin_password, network_info=network_info, block_device_info=block_device_info)
def get_available_resource(self, nodename): context = nova_context.get_admin_context() resource = {} try: node = db.bm_node_get_by_node_uuid(context, nodename) resource = self._node_resource(node) except exception.NodeNotFoundByUUID: pass return resource
def show(self, req, id): context = req.environ['nova.context'] authorize(context) try: node = db.bm_node_get_by_node_uuid(context, id) except exception.NodeNotFound: raise webob.exc.HTTPNotFound() try: ifs = db.bm_interface_get_all_by_bm_node_id(context, node.id) except exception.NodeNotFound: ifs = [] node = _node_dict(node) node['interfaces'] = [_interface_dict(i) for i in ifs] return {'node': node}
def rebuild(self, context, instance, image_meta, injected_files, admin_password, bdms, detach_block_devices, attach_block_devices, network_info=None, recreate=False, block_device_info=None, preserve_ephemeral=False): """Destroy and re-make this instance. A 'rebuild' effectively purges all existing data from the system and remakes the VM with given 'metadata' and 'personalities'. :param context: Security context. :param instance: Instance object. :param image_meta: Image object returned by nova.image.glance that defines the image from which to boot this instance. :param injected_files: User files to inject into instance. :param admin_password: Administrator password to set in instance. :param bdms: block-device-mappings to use for rebuild :param detach_block_devices: function to detach block devices. See nova.compute.manager.ComputeManager:_rebuild_default_impl for usage. :param attach_block_devices: function to attach block devices. See nova.compute.manager.ComputeManager:_rebuild_default_impl for usage. :param network_info: :py:meth:`~nova.network.manager.NetworkManager.get_instance_nw_info` :param block_device_info: Information about block devices to be attached to the instance. :param recreate: True if instance should be recreated with same disk. :param preserve_ephemeral: True if the default ephemeral storage partition must be preserved on rebuild. """ instance.task_state = task_states.REBUILD_SPAWNING instance.save(expected_task_state=[task_states.REBUILDING]) node_uuid = self._require_node(instance) node = db.bm_node_get_by_node_uuid(context, node_uuid) db.bm_node_update( context, node['id'], {'task_state': baremetal_states.BUILDING, 'preserve_ephemeral': preserve_ephemeral} ) self._spawn(node, context, instance, image_meta, injected_files, admin_password, network_info=network_info, block_device_info=block_device_info)
def macs_for_instance(self, instance): context = nova_context.get_admin_context() node_uuid = self._require_node(instance) node = db.bm_node_get_by_node_uuid(context, node_uuid) ifaces = db.bm_interface_get_all_by_bm_node_id(context, node['id']) return set(iface['address'] for iface in ifaces)
def get_available_resource(self, nodename): context = nova_context.get_admin_context() node = db.bm_node_get_by_node_uuid(context, nodename) dic = self._node_resource(node) return dic