def destroy_instance(self, ctx, instance): nova = self._get_nova_client(ctx) quantum = self._get_quantum_client(ctx) for device in instance['devices']: try: nova.servers.delete(device['instance_id']) except Exception as e: logging.error("Can not delete server", e) device['status'] = DELETED_STATE for wire in instance['wires']: try: quantum.delete_port(wire['left']['quantum_id']) except Exception as e: logging.error("Can not delete left wire side", e) try: quantum.delete_port(wire['right']['quantum_id']) except Exception as e: logging.error("Can not delete right wire side", e) try: quantum.delete_network(wire['quantum_id']) except Exception as e: logging.error("Can not delete wire side", e) db.delete_instance(instance['_id']) return instance
def destroy_instance(self, ctx, instance): for device in instance['devices']: device['instance_id'] = 'nova-123' device['status'] = 'stopped' db.delete_instance(instance['_id']) return instance