def test_existing_detach(self):
        """ Tests that when an address that is in the user's
            EC2 account is provided to the disassociate function
            no errors are raised
        """

        ctx = self.mock_relationship_context(
            'test_existing_detach')
        current_ctx.set(ctx=ctx)
        volume = self.get_volume()
        instance_id = self.get_instance_id()
        ctx.source.node.properties['use_external_resource'] = True
        ctx.source.node.properties['resource_id'] = volume.id
        ctx.source.instance.runtime_properties['aws_resource_id'] = \
            volume.id
        ctx.target.node.properties['use_external_resource'] = True
        ctx.target.node.properties['resource_id'] = volume.id
        ctx.target.instance.runtime_properties['aws_resource_id'] = \
            instance_id
        ctx.source.instance.runtime_properties['instance_id'] = \
            instance_id
        args = dict(force=True)
        ebs.detach(args, ctx=ctx)
        self.assertNotIn(
            'instance_id', ctx.source.instance.runtime_properties)
    def test_good_volume_detach(self):
        """ Tests that detach runs when clean. """

        ctx = self.mock_relationship_context("test_good_address_detach")
        current_ctx.set(ctx=ctx)
        volume = self.get_volume()
        instance_id = self.get_instance_id()
        volume.attach(instance_id, TEST_DEVICE)
        ctx.source.instance.runtime_properties["aws_resource_id"] = volume.id
        ctx.source.instance.runtime_properties["instance_id"] = instance_id
        ctx.target.instance.runtime_properties["aws_resource_id"] = instance_id
        args = dict(force=True)
        ebs.detach(args, ctx=ctx)
Exemplo n.º 3
0
    def test_good_volume_detach(self):
        """ Tests that detach runs when clean. """

        ctx = self.mock_relationship_context('test_good_address_detach')
        current_ctx.set(ctx=ctx)
        volume = self.get_volume()
        instance_id = self.get_instance_id()
        volume.attach(instance_id, TEST_DEVICE)
        ctx.source.instance.runtime_properties['aws_resource_id'] = \
            volume.id
        ctx.source.instance.runtime_properties['instance_id'] = \
            instance_id
        ctx.target.instance.runtime_properties['aws_resource_id'] = \
            instance_id
        args = dict(force=True)
        ebs.detach(args, ctx=ctx)
Exemplo n.º 4
0
    def test_existing_detach(self):
        """ Tests that when an address that is in the user's
            EC2 account is provided to the disassociate function
            no errors are raised
        """

        ctx = self.mock_relationship_context('test_existing_detach')
        current_ctx.set(ctx=ctx)
        volume = self.get_volume()
        instance_id = self.get_instance_id()
        ctx.source.node.properties['use_external_resource'] = True
        ctx.source.node.properties['resource_id'] = volume.id
        ctx.source.instance.runtime_properties['aws_resource_id'] = \
            volume.id
        ctx.target.node.properties['use_external_resource'] = True
        ctx.target.node.properties['resource_id'] = volume.id
        ctx.target.instance.runtime_properties['aws_resource_id'] = \
            instance_id
        ctx.source.instance.runtime_properties['instance_id'] = \
            instance_id
        args = dict(force=True)
        ebs.detach(args, ctx=ctx)
        self.assertNotIn('instance_id', ctx.source.instance.runtime_properties)