Пример #1
0
 def test_create_with_relationships(self):
     ctx = self.get_mock_ctx(
         "EC2Instances",
         test_properties={'os_family': 'linux'},
         type_hierarchy=['cloudify.nodes.Root', 'cloudify.nodes.Compute'])
     current_ctx.set(ctx=ctx)
     params = {'ImageId': 'test image', 'InstanceType': 'test type'}
     self.instances.resource_id = 'test_name'
     iface = MagicMock()
     with patch('cloudify_awssdk.common.utils.find_rel_by_node_type'):
         instances.create(ctx=ctx, iface=iface, resource_config=params)
         self.assertEqual(self.instances.resource_id, 'test_name')
Пример #2
0
 def test_create(self):
     ctx = self.get_mock_ctx(
         "EC2Instances",
         test_properties={'os_family': 'linux'},
         type_hierarchy=['cloudify.nodes.Root', 'cloudify.nodes.Compute'])
     current_ctx.set(ctx=ctx)
     params = {'ImageId': 'test image', 'InstanceType': 'test type'}
     self.instances.resource_id = 'test_name'
     iface = MagicMock()
     value = {INSTANCES: [{INSTANCE_ID: 'test_name'}]}
     iface.create = self.mock_return(value)
     instances.create(ctx=ctx, iface=iface, resource_config=params)
     self.assertEqual(self.instances.resource_id, 'test_name')
Пример #3
0
    def test_multiple_nics(self):

        _source_ctx1, _target_ctx1, _nic_type1 = \
            self._create_common_relationships(
                'test_node',
                source_type_hierarchy=['cloudify.nodes.Root',
                                       'cloudify.nodes.Compute',
                                       'cloudify.nodes.aws.ec2.Instances'],
                target_type_hierarchy=['cloudify.nodes.Root',
                                       NETWORK_INTERFACE_TYPE])
        _target_ctx1.instance.runtime_properties['aws_resource_id'] = 'eni-0'

        _source_ctx2, _target_ctx2, _nic_type2 = \
            self._create_common_relationships(
                'test_node',
                source_type_hierarchy=['cloudify.nodes.Root',
                                       'cloudify.nodes.Compute',
                                       'cloudify.nodes.aws.ec2.Instances'],
                target_type_hierarchy=['cloudify.nodes.Root',
                                       NETWORK_INTERFACE_TYPE])
        _target_ctx2.instance.runtime_properties['aws_resource_id'] = 'eni-1'

        _ctx = self.get_mock_ctx("EC2Instances",
                                 test_properties={'os_family': 'linux'},
                                 type_hierarchy=[
                                     'cloudify.nodes.Root',
                                     'cloudify.nodes.Compute',
                                     'cloudify.nodes.aws.ec2.Instances'
                                 ],
                                 test_relationships=[_nic_type1, _nic_type2])

        current_ctx.set(_ctx)
        params = {
            'ImageId':
            'test image',
            'InstanceType':
            'test type',
            'NetworkInterfaces': [{
                'NetworkInterfaceId': 'eni-2',
                'DeviceIndex': 2
            }]
        }
        iface = MagicMock()
        value = {INSTANCES: [{INSTANCE_ID: 'test_name'}]}
        iface.create = self.mock_return(value)
        instances.create(ctx=_ctx, iface=iface, resource_config=params)
Пример #4
0
    def test_create_relatonships(self):
        _source_ctx, _target_ctx, _group_rel = \
            self._create_common_relationships(
                'test_node',
                source_type_hierarchy=['cloudify.nodes.Root',
                                       'cloudify.nodes.Compute'],
                target_type_hierarchy=['cloudify.nodes.Root',
                                       GROUP_TYPE])

        _source_ctx, _target_ctx, _subnet_type = \
            self._create_common_relationships(
                'test_node',
                source_type_hierarchy=['cloudify.nodes.Root',
                                       'cloudify.nodes.Compute'],
                target_type_hierarchy=['cloudify.nodes.Root',
                                       SUBNET_TYPE])

        _source_ctx, _target_ctx, _nic_type = \
            self._create_common_relationships(
                'test_node',
                source_type_hierarchy=['cloudify.nodes.Root',
                                       'cloudify.nodes.Compute'],
                target_type_hierarchy=['cloudify.nodes.Root',
                                       NETWORK_INTERFACE_TYPE])

        _ctx = self.get_mock_ctx(
            "EC2Instances",
            test_properties={'os_family': 'linux'},
            type_hierarchy=['cloudify.nodes.Root', 'cloudify.nodes.Compute'],
            test_relationships=[_group_rel, _subnet_type, _nic_type])
        current_ctx.set(_ctx)
        params = {'ImageId': 'test image', 'InstanceType': 'test type'}
        iface = MagicMock()
        self.instances.resource_id = 'test_name'
        with patch('cloudify_awssdk.common.utils.find_rels_by_node_type'):
            instances.create(ctx=_ctx, iface=iface, resource_config=params)
            self.assertEqual(self.instances.resource_id, 'test_name')