예제 #1
0
    def _shutdown_instance(self, instance):
        ctx = context.ctx()

        if instance.node_group.floating_ip_pool:
            try:
                networks.delete_floating_ip(instance.instance_id)
            except nova_exceptions.NotFound:
                LOG.warn(_LW("Attempted to delete non-existent floating IP in "
                         "pool %(pool)s from instance %(instance)s"),
                         {'pool': instance.node_group.floating_ip_pool,
                          'instance': instance.instance_id})

        try:
            volumes.detach_from_instance(instance)
        except Exception:
            LOG.warn(_LW("Detaching volumes from instance %s failed"),
                     instance.instance_id)

        try:
            nova.client().servers.delete(instance.instance_id)
        except nova_exceptions.NotFound:
            LOG.warn(_LW("Attempted to delete non-existent instance %s"),
                     instance.instance_id)

        conductor.instance_remove(ctx, instance)
예제 #2
0
    def _shutdown_instance(self, instance):
        ctx = context.ctx()

        if instance.node_group.floating_ip_pool:
            try:
                networks.delete_floating_ip(instance.instance_id)
            except nova_exceptions.NotFound:
                LOG.warn(
                    _LW("Attempted to delete non-existent floating IP in "
                        "pool %(pool)s from instance %(instance)s"), {
                            'pool': instance.node_group.floating_ip_pool,
                            'instance': instance.instance_id
                        })

        try:
            volumes.detach_from_instance(instance)
        except Exception:
            LOG.warn(_LW("Detaching volumes from instance %s failed"),
                     instance.instance_id)

        try:
            nova.client().servers.delete(instance.instance_id)
        except nova_exceptions.NotFound:
            LOG.warn(_LW("Attempted to delete non-existent instance %s"),
                     instance.instance_id)

        conductor.instance_remove(ctx, instance)
예제 #3
0
    def _shutdown_instance(self, instance):
        ctx = context.ctx()

        if instance.node_group.floating_ip_pool:
            try:
                networks.delete_floating_ip(instance.instance_id)
            except nova_exceptions.NotFound:
                LOG.warning(
                    _LW("Attempted to delete non-existent floating IP "
                        "in pool {pool} from instance {instance}").format(
                            pool=instance.node_group.floating_ip_pool,
                            instance=instance.instance_id))

        try:
            volumes.detach_from_instance(instance)
        except Exception:
            LOG.warning(
                _LW("Detaching volumes from instance {id} failed").format(
                    id=instance.instance_id))

        try:
            nova.client().servers.delete(instance.instance_id)
        except nova_exceptions.NotFound:
            LOG.warning(
                _LW("Attempted to delete non-existent instance {id}").format(
                    id=instance.instance_id))

        conductor.instance_remove(ctx, instance)
예제 #4
0
    def _shutdown_instance(self, instance):
        ctx = context.ctx()

        if instance.node_group.floating_ip_pool:
            try:
                networks.delete_floating_ip(instance.instance_id)
            except nova_exceptions.NotFound:
                LOG.warning(_LW("Attempted to delete non-existent floating IP "
                                "in pool {pool} from instance {instance}")
                            .format(pool=instance.node_group.floating_ip_pool,
                                    instance=instance.instance_id))

        try:
            volumes.detach_from_instance(instance)
        except Exception:
            LOG.warning(_LW("Detaching volumes from instance {id} failed")
                        .format(id=instance.instance_id))

        try:
            nova.client().servers.delete(instance.instance_id)
        except nova_exceptions.NotFound:
            LOG.warning(_LW("Attempted to delete non-existent instance {id}")
                        .format(id=instance.instance_id))

        conductor.instance_remove(ctx, instance)
예제 #5
0
    def _shutdown_instance(self, instance):
        # Heat dissociates and deletes upon deletion of resources
        # See OS::Neutron::FloatingIP and OS::Neutron::FloatingIPAssociation
        if instance.node_group.floating_ip_pool:
            pass

        try:
            volumes.detach_from_instance(instance)
        except Exception:
            LOG.warning("Detaching volumes from instance failed")

        try:
            b.execute_with_retries(nova.client().servers.delete,
                                   instance.instance_id)
        except nova_exceptions.NotFound:
            LOG.warning("Attempted to delete non-existent instance")

        conductor.instance_remove(context.ctx(), instance)
예제 #6
0
    def test_detach_volumes_v2(self, p_get_volume, p_detach, p_delete, p_cond):
        class Instance(object):
            def __init__(self):
                self.instance_id = "123454321"
                self.volumes = [123]
                self.instance_name = "spam"

        instance = Instance()
        p_get_volume.return_value = vol_v2.Volume(None, {"id": "123", "status": "available"})
        p_detach.return_value = None
        p_delete.return_value = None
        self.assertIsNone(volumes.detach_from_instance(instance))
예제 #7
0
    def _shutdown_instance(self, instance):
        if instance.node_group.floating_ip_pool:
            try:
                b.execute_with_retries(networks.delete_floating_ip,
                                       instance.instance_id)
            except nova_exceptions.NotFound:
                LOG.warning(_LW("Attempted to delete non-existent floating IP "
                                "in pool {pool} from instance")
                            .format(pool=instance.node_group.floating_ip_pool))

        try:
            volumes.detach_from_instance(instance)
        except Exception:
            LOG.warning(_LW("Detaching volumes from instance failed"))

        try:
            b.execute_with_retries(nova.client().servers.delete,
                                   instance.instance_id)
        except nova_exceptions.NotFound:
            LOG.warning(_LW("Attempted to delete non-existent instance"))

        conductor.instance_remove(context.ctx(), instance)
예제 #8
0
파일: engine.py 프로젝트: uladz/sahara
    def _shutdown_instance(self, instance):
        if instance.node_group.floating_ip_pool:
            try:
                b.execute_with_retries(networks.delete_floating_ip,
                                       instance.instance_id)
            except nova_exceptions.NotFound:
                LOG.warning(_LW("Attempted to delete non-existent floating IP "
                                "in pool {pool} from instance")
                            .format(pool=instance.node_group.floating_ip_pool))

        try:
            volumes.detach_from_instance(instance)
        except Exception:
            LOG.warning(_LW("Detaching volumes from instance failed"))

        try:
            b.execute_with_retries(nova.client().servers.delete,
                                   instance.instance_id)
        except nova_exceptions.NotFound:
            LOG.warning(_LW("Attempted to delete non-existent instance"))

        conductor.instance_remove(context.ctx(), instance)
예제 #9
0
    def test_detach_volumes(self, p_get_volume, p_detach, p_delete, p_cond):
        class Instance:
            def __init__(self):
                self.instance_id = '123454321'
                self.volumes = [123]
                self.instance_name = 'spam'

        instance = Instance()
        p_get_volume.return_value = v.Volume(None, {'id': '123',
                                                    'status': 'available'})
        p_detach.return_value = None
        p_delete.return_value = None
        self.assertIsNone(
            volumes.detach_from_instance(instance))
예제 #10
0
    def test_detach_volumes(self, p_get_volume, p_detach, p_delete, p_cond):
        class Instance:
            def __init__(self):
                self.instance_id = '123454321'
                self.volumes = [123]
                self.instance_name = 'spam'

        instance = Instance()
        p_get_volume.return_value = v.Volume(None, {'id': '123',
                                                    'status': 'available'})
        p_detach.return_value = None
        p_delete.return_value = None
        self.assertIsNone(
            volumes.detach_from_instance(instance))
예제 #11
0
    def test_detach_volumes(self, p_get_volume, p_detach, p_delete, p_cond):
        class Instance:
            def __init__(self):
                self.instance_id = '123454321'
                self.volumes = [123]

        instance = Instance()
        p_get_volume.return_value = v.Volume(None, {'id': '123'})
        p_detach.return_value = None
        p_delete.return_value = None
        self.assertIsNone(volumes.detach_from_instance(instance))

        p_delete.side_effect = RuntimeError
        self.assertRaises(RuntimeError, volumes.detach_from_instance, instance)
예제 #12
0
    def test_detach_volumes(self, p_get_volume, p_detach, p_delete, p_cond):
        class Instance:
            def __init__(self):
                self.instance_id = "123454321"
                self.volumes = [123]

        instance = Instance()
        p_get_volume.return_value = v.Volume(None, {"id": "123"})
        p_detach.return_value = None
        p_delete.return_value = None
        self.assertIsNone(volumes.detach_from_instance(instance))

        p_delete.side_effect = RuntimeError
        self.assertRaises(RuntimeError, volumes.detach_from_instance, instance)