def destroy(self, context, instance, network_info, block_device_info=None, destroy_disks=True, migrate_data=None): """Destroy the specified instance from the Hypervisor. If the instance is not found (for example if networking failed), this function should still succeed. It's probably a good idea to log a warning in that case. :param context: security context :param instance: Instance object as returned by DB layer. :param network_info: :py:meth:`~nova.network.manager.NetworkManager.get_instance_nw_info` :param block_device_info: Information about block devices that should be detached from the instance. :param destroy_disks: Indicates if disks should be destroyed :param migrate_data: implementation specific params """ compute, project, zone = self.gce_svc, self.gce_project, self.gce_zone gce_id = self._get_gce_id_from_instance(instance) LOG.info(_LI('Deleting instance %s') % instance.uuid) operation = gceutils.delete_instance(compute, project, zone, gce_id) gceutils.wait_for_operation(compute, project, zone, operation) LOG.info(_LI("Destroy Complete %s") % instance.uuid)
def destroy(self, context, instance, network_info, block_device_info=None, destroy_disks=True, migrate_data=None): """Destroy the specified instance from the Hypervisor. If the instance is not found (for example if networking failed), this function should still succeed. It's probably a good idea to log a warning in that case. :param context: security context :param instance: Instance object as returned by DB layer. :param network_info: :py:meth:`~nova.network.manager.NetworkManager.get_instance_nw_info` :param block_device_info: Information about block devices that should be detached from the instance. :param destroy_disks: Indicates if disks should be destroyed :param migrate_data: implementation specific params """ compute, project, zone = self.gce_svc, self.gce_project, self.gce_zone LOG.info('Deleting instance %s' % instance.uuid) try: gce_id = self._get_gce_name_from_instance(instance) except exception.InstanceNotFound: LOG.error("Unable to find GCE mapping for instance %s" % instance.uuid) return try: operation = gceutils.delete_instance(compute, project, zone, gce_id) except HttpError: # Sometimes instance may not exist in GCE, in that case we just # allow deleting VM from openstack LOG.error( "Instance {0} not found in GCE, removing from openstack.". format(instance.uuid)) return gceutils.wait_for_operation(compute, project, operation, interval=5, timeout=300) LOG.info("Destroy Complete %s" % instance.uuid)