[sdc] docker file fix for cassandra
[sdc.git] / openecomp-be / lib / openecomp-sdc-translator-lib / openecomp-sdc-translator-core / src / main / java / org / openecomp / sdc / translator / services / heattotosca / globaltypes / ContrailV2VirtualMachineInterfaceGlobalType.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * SDC
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
10  * 
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  * 
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=========================================================
19  */
20
21 package org.openecomp.sdc.translator.services.heattotosca.globaltypes;
22
23 import org.openecomp.sdc.tosca.datatypes.ToscaDataType;
24 import org.openecomp.sdc.tosca.datatypes.ToscaNodeType;
25 import org.openecomp.sdc.tosca.datatypes.model.AttributeDefinition;
26 import org.openecomp.sdc.tosca.datatypes.model.DataType;
27 import org.openecomp.sdc.tosca.datatypes.model.NodeType;
28 import org.openecomp.sdc.tosca.datatypes.model.PropertyDefinition;
29 import org.openecomp.sdc.tosca.datatypes.model.PropertyType;
30 import org.openecomp.sdc.tosca.datatypes.model.ServiceTemplate;
31 import org.openecomp.sdc.tosca.services.DataModelUtil;
32 import org.openecomp.sdc.tosca.services.ToscaConstants;
33 import org.openecomp.sdc.translator.services.heattotosca.Constants;
34
35 import java.util.HashMap;
36 import java.util.Map;
37
38 class ContrailV2VirtualMachineInterfaceGlobalType {
39   private ContrailV2VirtualMachineInterfaceGlobalType() {
40   }
41
42   public static ServiceTemplate createServiceTemplate() {
43     ServiceTemplate contrailVirtualMachineInterface = new ServiceTemplate();
44     contrailVirtualMachineInterface
45         .setTosca_definitions_version(ToscaConstants.TOSCA_DEFINITIONS_VERSION);
46     contrailVirtualMachineInterface.setMetadata(DataModelUtil
47         .createMetadata(Constants.CONTRAILV2_VIRTUAL_MACHINE_INTERFACE_TEMPLATE_NAME, "1.0.0",
48             null));
49     contrailVirtualMachineInterface.setImports(GlobalTypesUtil.createCommonImportList());
50     contrailVirtualMachineInterface
51         .setDescription("Contrail Virtual Machine Interface TOSCA Global Types");
52     contrailVirtualMachineInterface.setNode_types(createGlobalNodeTypes());
53     contrailVirtualMachineInterface.setData_types(createGlobalDataTypes());
54     return contrailVirtualMachineInterface;
55   }
56
57   private static Map<String, DataType> createGlobalDataTypes() {
58     Map<String, DataType> globalDataTypes = new HashMap<>();
59     globalDataTypes
60         .put(ToscaDataType.CONTRAILV2_VIRTUAL_MACHINE_INTERFACE_PROPERTIES.getDisplayName(),
61             createVmiPropertiesDataType());
62     return globalDataTypes;
63   }
64
65   private static DataType createVmiPropertiesDataType() {
66     DataType dataType = new DataType();
67     dataType.setDerived_from(ToscaDataType.ROOT.getDisplayName());
68     dataType.setDescription("Virtual Machine Interface Properties.");
69     Map<String, PropertyDefinition> properties = new HashMap<>();
70
71     properties.put("virtual_machine_interface_properties_service_interface_type", DataModelUtil
72         .createPropertyDefinition(PropertyType.STRING.getDisplayName(), "Service Interface Type.",
73             false, null, null, null, null));
74     dataType.setProperties(properties);
75     return dataType;
76   }
77
78   private static Map<String, NodeType> createGlobalNodeTypes() {
79     Map<String, NodeType> globalNodeTypes = new HashMap<>();
80     globalNodeTypes.put(ToscaNodeType.CONTRAILV2_VIRTUAL_MACHINE_INTERFACE.getDisplayName(),
81         createVmiNodeType());
82     return globalNodeTypes;
83   }
84
85   private static NodeType createVmiNodeType() {
86     NodeType nodeType = new NodeType();
87     nodeType.setDerived_from(ToscaNodeType.NETWORK_PORT.getDisplayName());
88     nodeType.setProperties(createVmiProperties());
89     nodeType.setAttributes(createVmiAttributes());
90     return nodeType;
91   }
92
93   private static Map<String, AttributeDefinition> createVmiAttributes() {
94     Map<String, AttributeDefinition> vmiAttributesDefMap = new HashMap<>();
95     vmiAttributesDefMap.put("fq_name", DataModelUtil
96         .createAttributeDefinition(PropertyType.STRING.getDisplayName(),
97             "The FQ name of the Virtual Network.", null, null, null));
98     vmiAttributesDefMap.put("show", DataModelUtil
99         .createAttributeDefinition(PropertyType.STRING.getDisplayName(), "All attributes.", null,
100             null, null));
101     return vmiAttributesDefMap;
102   }
103
104   private static Map<String, PropertyDefinition> createVmiProperties() {
105     Map<String, PropertyDefinition> virtualMachineInterfacePropertyDefMap = new HashMap<>();
106     virtualMachineInterfacePropertyDefMap.put(Constants.NAME_PROPERTY_NAME, DataModelUtil
107         .createPropertyDefinition(PropertyType.STRING.getDisplayName(),
108             "Virtual Machine Interface name", false, null, null, null, null));
109     virtualMachineInterfacePropertyDefMap.put("virtual_machine_intefrace_mac_addresses",
110         DataModelUtil
111             .createPropertyDefinition(PropertyType.LIST.getDisplayName(), "List of mac addresses.",
112                 false, null, null,
113                 DataModelUtil.createEntrySchema(PropertyType.STRING.getDisplayName(), null, null),
114                 null));
115     virtualMachineInterfacePropertyDefMap.put("virtual_network_refs", DataModelUtil
116         .createPropertyDefinition(PropertyType.LIST.getDisplayName(), "List of virtual networks.",
117             false, null, null,
118             DataModelUtil.createEntrySchema(PropertyType.STRING.getDisplayName(), null, null),
119             null));
120     virtualMachineInterfacePropertyDefMap.put("port_tuple_refs", DataModelUtil
121         .createPropertyDefinition(PropertyType.LIST.getDisplayName(), "List of port tuples.", false,
122             null, null,
123             DataModelUtil.createEntrySchema(PropertyType.STRING.getDisplayName(), null, null),
124             null));
125     virtualMachineInterfacePropertyDefMap.put("security_group_refs", DataModelUtil
126         .createPropertyDefinition(PropertyType.LIST.getDisplayName(), "List of security groups.",
127             false, null, null,
128             DataModelUtil.createEntrySchema(PropertyType.STRING.getDisplayName(), null, null),
129             null));
130     virtualMachineInterfacePropertyDefMap.put("virtual_machine_interface_properties", DataModelUtil
131         .createPropertyDefinition(
132             ToscaDataType.CONTRAILV2_VIRTUAL_MACHINE_INTERFACE_PROPERTIES.getDisplayName(),
133             "virtual machine interface properties.", false, null, null, null, null));
134     return virtualMachineInterfacePropertyDefMap;
135   }
136 }