def test_attach(self): ctx = self.get_mock_ctx("PublicIp") self.elasticip.resource_id = 'elasticip' config = {ALLOCATION_ID: 'elasticip-attach'} iface = MagicMock() iface.attach = self.mock_return(config) elasticip.attach(ctx, iface, config) self.assertEqual(self.elasticip.resource_id, 'elasticip') ctx.instance.runtime_properties['allocation_id'] = 'elasticip-attach' iface.attach = self.mock_return(config) elasticip.attach(ctx, iface, config) self.assertEqual(self.elasticip.resource_id, 'elasticip')
def test_attach(self): ctx = self.get_mock_ctx("InternetGateway") self.internet_gateway.resource_id = 'internet gateway' config = {VPC_ID: 'vpc'} iface = MagicMock() iface.attach = self.mock_return(config) internet_gateway.attach(ctx, iface, config) self.assertEqual(self.internet_gateway.resource_id, 'internet gateway')
def test_attach(self): ctx = self.get_mock_ctx("NetworkAcl") self.networkacl.resource_id = 'network acl' config = {NETWORKACL_ID: 'network acl', SUBNET_ID: 'subnet'} iface = MagicMock() iface.attach = self.mock_return(config) networkacl.attach(ctx, iface, config) self.assertEqual(self.networkacl.resource_id, 'network acl')
def test_attach(self): ctx = self.get_mock_ctx("RouteTable") self.routetable.resource_id = 'route table' config = {ROUTETABLE_ID: 'route table', SUBNET_ID: 'subnet'} iface = MagicMock() iface.attach = self.mock_return(config) routetable.attach(ctx, iface, config) self.assertEqual(self.routetable.resource_id, 'route table')
def _stub_volume_client(self): self.instance_task._volume_client = MagicMock(spec=cinderclient.Client) stub_volume_mgr = MagicMock(spec=cinderclient.volumes.VolumeManager) self.instance_task.volume_client.volumes = stub_volume_mgr stub_volume_mgr.extend = MagicMock(return_value=None) stub_new_volume = cinderclient.volumes.Volume(stub_volume_mgr, {"status": "available", "size": 2}, True) stub_volume_mgr.get = MagicMock(return_value=stub_new_volume) stub_volume_mgr.attach = MagicMock(return_value=None)
def test_attach(self): ctx = self.get_mock_ctx("NetworkInterface") self.eni.resource_id = 'eni' config = {ATTACHMENT_ID: 'eni-attach'} iface = MagicMock() iface.attach = self.mock_return(config) eni.attach(ctx, iface, config) self.assertEqual(self.eni.resource_id, 'eni')
def test_attach(self): ctx = self.get_mock_ctx("VpnGateway") self.vpn_gateway.resource_id = 'vpn gateway' config = {VPC_ID: 'vpc', 'Type': type} iface = MagicMock() iface.attach = self.mock_return(config) vpn_gateway.attach(ctx, iface, config) self.assertEqual(self.vpn_gateway.resource_id, 'vpn gateway')
def _stub_volume_client(self): self.instance_task._volume_client = MagicMock(spec=cinderclient.Client) stub_volume_mgr = MagicMock(spec=cinderclient.volumes.VolumeManager) self.instance_task.volume_client.volumes = stub_volume_mgr stub_volume_mgr.extend = MagicMock(return_value=None) stub_new_volume = cinderclient.volumes.Volume( stub_volume_mgr, {'status': 'available', 'size': 2}, True) stub_volume_mgr.get = MagicMock(return_value=stub_new_volume) stub_volume_mgr.attach = MagicMock(return_value=None)
def test_attach_with_relationships(self): ctx = self.get_mock_ctx("VpnGateway", type_hierarchy=[VPC_TYPE]) config = {VPNGATEWAY_ID: 'vpn gateway', 'Type': type} self.vpn_gateway.resource_id = config[VPNGATEWAY_ID] iface = MagicMock() iface.attach = self.mock_return(config) with patch('cloudify_aws.common.utils.find_rel_by_node_type'): vpn_gateway.attach(ctx, iface, config) self.assertEqual(self.vpn_gateway.resource_id, 'vpn gateway')
def test_attach_with_relationships(self): ctx = self.get_mock_ctx("InternetGateway", type_hierarchy=[VPC_TYPE]) config = {INTERNETGATEWAY_ID: 'internet gateway'} self.internet_gateway.resource_id = config[INTERNETGATEWAY_ID] iface = MagicMock() iface.attach = self.mock_return(config) with patch('cloudify_aws.common.utils.find_rel_by_node_type'): internet_gateway.attach(ctx, iface, config) self.assertEqual(self.internet_gateway.resource_id, 'internet gateway')
def test_attach_with_relationships(self): ctx = self.get_mock_ctx("RouteTable", type_hierarchy=[SUBNET_TYPE]) config = {} self.routetable.resource_id = 'route table' iface = MagicMock() iface.attach = self.mock_return(config) iface.resource_id = self.mock_return('route table') with patch('cloudify_aws.common.utils.find_rels_by_node_type'): routetable.attach(ctx, iface, config) self.assertEqual(self.routetable.resource_id, 'route table')
def test_attach_with_relationships(self): ctx = self.get_mock_ctx("PublicIp", type_hierarchy=[INSTANCE_TYPE_DEPRECATED]) config = {ALLOCATION_ID: 'elasticip-attach'} self.elasticip.resource_id = 'elasticip' iface = MagicMock() iface.attach = self.mock_return(config) with patch('cloudify_awssdk.common.utils.find_rel_by_node_type'): elasticip.attach(ctx, iface, config) self.assertEqual(self.elasticip.resource_id, 'elasticip')
def test_attach_with_relationships(self): ctx = self.get_mock_ctx("NetworkInterface", type_hierarchy=[INSTANCE_TYPE_DEPRECATED]) config = {ATTACHMENT_ID: 'eni-attach'} self.eni.resource_id = 'eni' iface = MagicMock() iface.attach = self.mock_return(config) with patch('cloudify_awssdk.common.utils.find_rel_by_node_type'): eni.attach(ctx, iface, config) self.assertEqual(self.eni.resource_id, 'eni')
def test_attach_with_relationships(self): ctx = self.get_mock_ctx("InternetGateway", type_hierarchy=[VPC_TYPE]) config = {INTERNETGATEWAY_ID: 'internet gateway'} self.internet_gateway.resource_id = config[INTERNETGATEWAY_ID] iface = MagicMock() iface.attach = self.mock_return(config) with patch('cloudify_awssdk.common.utils.find_rel_by_node_type'): internet_gateway.attach(ctx, iface, config) self.assertEqual(self.internet_gateway.resource_id, 'internet gateway')
def test_attach_with_relationships(self): ctx = self.get_mock_ctx("NetworkAcl", type_hierarchy=[SUBNET_TYPE]) config = {} self.networkacl.resource_id = 'network acl' iface = MagicMock() iface.attach = self.mock_return(config) iface.resource_id = self.mock_return('network acl') with patch('cloudify_awssdk.common.utils.find_rel_by_node_type'): networkacl.attach(ctx, iface, config) self.assertEqual(self.networkacl.resource_id, 'network acl')
def test_attach(self): ctx = self.get_mock_ctx(DHCPOPTIONS) self.dhcp.resource_id = 'dhcp' config = {VPC_ID: 'vpc', 'DhcpConfigurations': {'Key': 'domain-name', 'Value': ['example.com']}} iface = MagicMock() iface.attach = self.mock_return(config) dhcp.attach(ctx, iface, config) self.assertEqual(self.dhcp.resource_id, 'dhcp')
def test_attach_with_relationships(self): ctx = self.get_mock_ctx("NetworkInterface", type_hierarchy=[INSTANCE_TYPE_DEPRECATED]) config = {ATTACHMENT_ID: 'eni-attach'} self.eni.resource_id = 'eni' iface = MagicMock() iface.attach = self.mock_return(config) with patch('cloudify_aws.common.utils.find_rel_by_node_type'): eni.attach(ctx, iface, config) self.assertEqual(self.eni.resource_id, 'eni')
def test_attach_with_relationships(self): ctx = self.get_mock_ctx("PublicIp", type_hierarchy=[INSTANCE_TYPE_DEPRECATED]) config = {ALLOCATION_ID: 'elasticip-attach'} self.elasticip.resource_id = 'elasticip' iface = MagicMock() iface.attach = self.mock_return(config) with patch('cloudify_aws.common.utils.find_rel_by_node_type'): elasticip.attach(ctx, iface, config) self.assertEqual(self.elasticip.resource_id, 'elasticip')
def test_attach_with_relationships(self): ctx = self.get_mock_ctx(DHCPOPTIONS, type_hierarchy=[VPC_TYPE]) config = {DHCPOPTIONS_ID: 'dhcp', 'DhcpConfigurations': {'Key': 'domain-name', 'Value': ['example.com']}} self.dhcp.resource_id = config[DHCPOPTIONS_ID] iface = MagicMock() iface.attach = self.mock_return(config) with patch('cloudify_aws.common.utils.find_rel_by_node_type'): dhcp.attach(ctx, iface, config) self.assertEqual(self.dhcp.resource_id, 'dhcp')
def test_attach_with_relationships(self): ctx = self.get_mock_ctx(DHCPOPTIONS, type_hierarchy=[VPC_TYPE]) config = {DHCPOPTIONS_ID: 'dhcp', 'DhcpConfigurations': {'Key': 'domain-name', 'Value': ['example.com']}} self.dhcp.resource_id = config[DHCPOPTIONS_ID] iface = MagicMock() iface.attach = self.mock_return(config) with patch('cloudify_awssdk.common.utils.find_rel_by_node_type'): dhcp.attach(ctx, iface, config) self.assertEqual(self.dhcp.resource_id, 'dhcp')
def test_attach_with_relationships(self): ctx = self.get_mock_ctx( "NetworkAcl", type_hierarchy=[SUBNET_TYPE]) config = {'NewAssociationId': 'foo'} self.networkacl.resource_id = 'network acl' iface = MagicMock() iface.attach = self.mock_return(config) iface.resource_id = self.mock_return('network acl') with patch('cloudify_aws.common.utils.find_rel_by_node_type'): networkacl.attach(ctx, iface, config) self.assertEqual(self.networkacl.resource_id, 'network acl')
def test_attach_with_relationships_eni(self): ctx = \ self.get_mock_ctx("PublicIp", type_hierarchy=[NETWORKINTERFACE_TYPE, NETWORKINTERFACE_TYPE_DEPRECATED] ) value = {'AssociationId': 'elasticip-assos'} config = {ALLOCATION_ID: 'elasticip-attach', 'Domain': 'vpc'} ctx.instance.runtime_properties['allocation_id'] = 'elasticip-attach' iface = MagicMock() iface.attach = self.mock_return(value) with patch('cloudify_awssdk.common.utils.find_rel_by_node_type'): elasticip.attach(ctx, iface, config) self.assertEqual(config['Domain'], 'vpc')
def test_attach_with_relationships_eni(self): ctx = \ self.get_mock_ctx("PublicIp", type_hierarchy=[NETWORKINTERFACE_TYPE, NETWORKINTERFACE_TYPE_DEPRECATED] ) value = {'AssociationId': 'elasticip-assos'} config = {ALLOCATION_ID: 'elasticip-attach', 'Domain': 'vpc'} ctx.instance.runtime_properties['allocation_id'] = 'elasticip-attach' iface = MagicMock() iface.attach = self.mock_return(value) with patch('cloudify_aws.common.utils.find_rel_by_node_type'): elasticip.attach(ctx, iface, config) self.assertEqual(config['Domain'], 'vpc')