Пример #1
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.instance.runtime_properties['placement'] = \
            TEST_ZONE
        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.VolumeInstanceConnection().disassociated(args)
        self.assertNotIn('instance_id', ctx.source.instance.runtime_properties)
Пример #2
0
    def test_good_volume_attach(self):
        """ Tests that attach runs when clean. """

        ctx = self.mock_relationship_context('test_good_volume_attach')
        current_ctx.set(ctx=ctx)
        volume = self.get_volume()
        instance_id = self.get_instance_id()
        ctx.source.instance.runtime_properties['aws_resource_id'] = \
            volume.id
        ctx.target.instance.runtime_properties['placement'] = \
            TEST_ZONE
        ctx.target.instance.runtime_properties['aws_resource_id'] = \
            instance_id
        ebs.VolumeInstanceConnection().associate(ctx=ctx)
Пример #3
0
    def test_bad_volume_attach(self):
        """ Tests that NonRecoverableError: Invalid Address is
            raised when an address that is not in the user's
            EC2 account is provided to the detach function
        """

        ctx = self.mock_relationship_context('test_bad_volume_detach')
        current_ctx.set(ctx=ctx)
        ctx.source.instance.runtime_properties['aws_resource_id'] = \
            BAD_VOLUME_ID
        ctx.source.instance.runtime_properties['instance_id'] = \
            BAD_INSTANCE_ID
        ctx.target.instance.runtime_properties['placement'] = \
            TEST_ZONE
        ex = self.assertRaises(NonRecoverableError,
                               ebs.VolumeInstanceConnection().associate,
                               ctx=ctx)
        self.assertIn('not found in account', ex.message)
Пример #4
0
 def create_volumeinstanceconn_for_checking(self):
     return ebs.VolumeInstanceConnection()