2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ============LICENSE_END=========================================================
21 package org.openecomp.sdc.translator.services.heattotosca;
24 import org.openecomp.sdc.heat.datatypes.model.HeatResourcesTypes;
25 import org.openecomp.sdc.heat.datatypes.model.Resource;
27 import org.openecomp.sdc.translator.services.heattotosca.impl.ResourceTranslationBase;
28 import org.openecomp.sdc.translator.services.heattotosca.impl.ResourceTranslationCinderVolumeAttachmentImpl;
29 import org.openecomp.sdc.translator.services.heattotosca.impl.ResourceTranslationCinderVolumeImpl;
30 import org.openecomp.sdc.translator.services.heattotosca.impl.ResourceTranslationContrailAttachPolicyImpl;
31 import org.openecomp.sdc.translator.services.heattotosca.impl.ResourceTranslationContrailNetworkPolicyImpl;
32 import org.openecomp.sdc.translator.services.heattotosca.impl.ResourceTranslationContrailServiceInstanceImpl;
33 import org.openecomp.sdc.translator.services.heattotosca.impl.ResourceTranslationContrailServiceTemplateImpl;
34 import org.openecomp.sdc.translator.services.heattotosca.impl.ResourceTranslationContrailV2NetworkPolicyImpl;
35 import org.openecomp.sdc.translator.services.heattotosca.impl.ResourceTranslationContrailV2VirtualNetworkImpl;
36 import org.openecomp.sdc.translator.services.heattotosca.impl.ResourceTranslationContrailV2VmInterfaceImpl;
37 import org.openecomp.sdc.translator.services.heattotosca.impl.ResourceTranslationContrailVirtualNetworkImpl;
38 import org.openecomp.sdc.translator.services.heattotosca.impl.ResourceTranslationDefaultImpl;
39 import org.openecomp.sdc.translator.services.heattotosca.impl.ResourceTranslationNestedImpl;
40 import org.openecomp.sdc.translator.services.heattotosca.impl.ResourceTranslationNeutronNetImpl;
41 import org.openecomp.sdc.translator.services.heattotosca.impl.ResourceTranslationNeutronPortImpl;
42 import org.openecomp.sdc.translator.services.heattotosca.impl.ResourceTranslationNeutronSecurityGroupImpl;
43 import org.openecomp.sdc.translator.services.heattotosca.impl.ResourceTranslationNeutronSubnetImpl;
44 import org.openecomp.sdc.translator.services.heattotosca.impl.ResourceTranslationNovaServerGroupsImpl;
45 import org.openecomp.sdc.translator.services.heattotosca.impl.ResourceTranslationNovaServerImpl;
46 import org.openecomp.sdc.translator.services.heattotosca.impl.ResourceTranslationResourceGroupImpl;
48 import java.util.Objects;
50 public class ResourceTranslationFactory {
55 * @param resource the resource
56 * @return the instance
58 public static ResourceTranslationBase getInstance(Resource resource) {
59 HeatResourcesTypes heatResource = HeatResourcesTypes.findByHeatResource(resource.getType());
60 if (Objects.isNull(heatResource)) {
61 if (HeatToToscaUtil.isYmlFileType(resource.getType())) {
62 return new ResourceTranslationNestedImpl();
64 return new ResourceTranslationDefaultImpl();
66 switch (heatResource) {
67 case NOVA_SERVER_RESOURCE_TYPE:
68 return new ResourceTranslationNovaServerImpl();
69 case NOVA_SERVER_GROUP_RESOURCE_TYPE:
70 return new ResourceTranslationNovaServerGroupsImpl();
71 case NEUTRON_SECURITY_GROUP_RESOURCE_TYPE:
72 return new ResourceTranslationNeutronSecurityGroupImpl();
73 case NEUTRON_PORT_RESOURCE_TYPE:
74 return new ResourceTranslationNeutronPortImpl();
75 case CONTRAIL_VIRTUAL_NETWORK_RESOURCE_TYPE:
76 return new ResourceTranslationContrailVirtualNetworkImpl();
77 case CONTRAIL_V2_VIRTUAL_NETWORK_RESOURCE_TYPE:
78 return new ResourceTranslationContrailV2VirtualNetworkImpl();
79 case CONTRAIL_V2_VIRTUAL_MACHINE_INTERFACE_RESOURCE_TYPE:
80 return new ResourceTranslationContrailV2VmInterfaceImpl();
81 case CINDER_VOLUME_RESOURCE_TYPE:
82 return new ResourceTranslationCinderVolumeImpl();
83 case CINDER_VOLUME_ATTACHMENT_RESOURCE_TYPE:
84 return new ResourceTranslationCinderVolumeAttachmentImpl();
85 case NEUTRON_NET_RESOURCE_TYPE:
86 return new ResourceTranslationNeutronNetImpl();
87 case NEUTRON_SUBNET_RESOURCE_TYPE:
88 return new ResourceTranslationNeutronSubnetImpl();
89 case CONTRAIL_NETWORK_RULE_RESOURCE_TYPE:
90 return new ResourceTranslationContrailNetworkPolicyImpl();
91 case CONTRAIL_V2_NETWORK_RULE_RESOURCE_TYPE:
92 return new ResourceTranslationContrailV2NetworkPolicyImpl();
93 case CONTRAIL_NETWORK_ATTACH_RULE_RESOURCE_TYPE:
94 return new ResourceTranslationContrailAttachPolicyImpl();
95 case RESOURCE_GROUP_RESOURCE_TYPE:
96 return new ResourceTranslationResourceGroupImpl();
97 case CONTRAIL_SERVICE_TEMPLATE:
98 return new ResourceTranslationContrailServiceTemplateImpl();
99 case CONTRAIL_SERVICE_INSTANCE:
100 return new ResourceTranslationContrailServiceInstanceImpl();
102 return new ResourceTranslationDefaultImpl();