Example #1
0
    def test_prepare_assoc_Role_NonRecoverableError(self):
        _source_ctx, _target_ctx, _ctx = self._create_instance_relationships(
            'test_prepare_assoc',
            ['cloudify.nodes.Root', 'cloudify.nodes.aws.iam.Role'])
        current_ctx.set(_ctx)

        with self.assertRaises(NonRecoverableError) as error:
            instance.prepare_assoc(ctx=_ctx, resource_config=None, iface=None)
        self.assertEqual(str(error.exception),
                         ('Missing required relationship inputs ' +
                          '"iam_role_type_key" and/or "iam_role_id_key".'))
Example #2
0
    def test_prepare_assoc_SecurityGroup(self):
        _source_ctx, _target_ctx, _ctx = self._create_instance_relationships(
            'test_prepare_assoc',
            ['cloudify.nodes.Root', 'cloudify.aws.nodes.SecurityGroup'])
        current_ctx.set(_ctx)

        instance.prepare_assoc(ctx=_ctx, resource_config=None, iface=None)
        self.assertEqual(
            _source_ctx.instance.runtime_properties, {
                '_set_changed': True,
                'aws_resource_id': 'aws_resource_mock_id',
                'resource_config': {
                    'VpcSecurityGroupIds': ['aws_target_mock_id']
                },
                'resource_id': 'prepare_attach_source'
            })
Example #3
0
    def test_prepare_assoc_Role(self):
        _source_ctx, _target_ctx, _ctx = self._create_instance_relationships(
            'test_prepare_assoc',
            ['cloudify.nodes.Root', 'cloudify.nodes.aws.iam.Role'])
        current_ctx.set(_ctx)

        _target_ctx.instance.runtime_properties[
            'iam_role_id_key'] = 'role_field'
        instance.prepare_assoc(ctx=_ctx,
                               resource_config=None,
                               iface=None,
                               iam_role_type_key='iam_role_type_key',
                               iam_role_id_key='iam_role_id_key')
        self.assertEqual(
            _source_ctx.instance.runtime_properties, {
                '_set_changed': True,
                'aws_resource_id': 'aws_resource_mock_id',
                'resource_config': {
                    'iam_role_type_key': 'role_field'
                },
                'resource_id': 'prepare_attach_source'
            })