def test_create_external_securitygroup_external_bad_id(self):

        ctx = self.mock_cloudify_context(
            'test_create_external_securitygroup_external_bad_id')
        current_ctx.set(ctx=ctx)

        ctx.node.properties['use_external_resource'] = True
        ctx.node.properties['resource_id'] = 'sg-73cd3f1e'

        with self.assertRaisesRegexp(NonRecoverableError,
                                     'security group does not exist'):
            securitygroup._create_external_securitygroup('sg-73cd3f1e')
    def test_create_external_securitygroup_external_bad_id(self):

        ctx = self.mock_cloudify_context(
            'test_create_external_securitygroup_external_bad_id')
        current_ctx.set(ctx=ctx)

        ctx.node.properties['use_external_resource'] = True
        ctx.node.properties['resource_id'] = 'sg-73cd3f1e'

        with self.assertRaisesRegexp(
                NonRecoverableError,
                'security group does not exist'):
            securitygroup._create_external_securitygroup(
                'sg-73cd3f1e')
Example #3
0
    def test_create_external_securitygroup_not_external(self):
        """ This checks that _create_external_securitygroup
        returns false when use_external_resource is false.
        """

        test_properties = self.get_mock_properties()
        ctx = self.security_group_mock(
            'test_create_external_securitygroup_not_external', test_properties)
        current_ctx.set(ctx=ctx)

        name = ctx.node.properties['resource_id']
        ctx.node.properties['use_external_resource'] = False

        output = securitygroup._create_external_securitygroup(name)
        self.assertEqual(False, output)
    def test_create_external_securitygroup_external(self):

        ctx = self.mock_cloudify_context(
            'test_create_external_securitygroup_external')
        current_ctx.set(ctx=ctx)

        client = self._get_ec2_client()
        group = client.create_security_group(
            'test_create_external_securitygroup_external', 'some description')
        self.addCleanup(group.delete)
        ctx.node.properties['use_external_resource'] = True
        ctx.node.properties['resource_id'] = group.id

        output = securitygroup._create_external_securitygroup(group.name)
        self.assertEqual(True, output)
        self.assertEqual(ctx.instance.runtime_properties[EXTERNAL_RESOURCE_ID],
                         group.id)
    def test_create_external_securitygroup_not_external(self):
        """ This checks that _create_external_securitygroup
        returns false when use_external_resource is false.
        """

        test_properties = self.get_mock_properties()
        ctx = self.security_group_mock(
            'test_create_external_securitygroup_not_external',
            test_properties)
        current_ctx.set(ctx=ctx)

        name = ctx.node.properties['resource_id']
        ctx.node.properties['use_external_resource'] = False

        output = securitygroup._create_external_securitygroup(
            name)
        self.assertEqual(False, output)
    def test_create_external_securitygroup_external(self):

        ctx = self.mock_cloudify_context(
            'test_create_external_securitygroup_external')
        current_ctx.set(ctx=ctx)

        client = self._get_ec2_client()
        group = client.create_security_group(
            'test_create_external_securitygroup_external',
            'some description')
        self.addCleanup(group.delete)
        ctx.node.properties['use_external_resource'] = True
        ctx.node.properties['resource_id'] = group.id

        output = securitygroup._create_external_securitygroup(group.name)
        self.assertEqual(True, output)
        self.assertEqual(
            ctx.instance.runtime_properties[EXTERNAL_RESOURCE_ID],
            group.id)