[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 / ContrailV2VirtualNetworkGlobalType.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.CapabilityDefinition;
27 import org.openecomp.sdc.tosca.datatypes.model.DataType;
28 import org.openecomp.sdc.tosca.datatypes.model.NodeType;
29 import org.openecomp.sdc.tosca.datatypes.model.PropertyDefinition;
30 import org.openecomp.sdc.tosca.datatypes.model.PropertyType;
31 import org.openecomp.sdc.tosca.datatypes.model.ServiceTemplate;
32 import org.openecomp.sdc.tosca.services.DataModelUtil;
33 import org.openecomp.sdc.tosca.services.ToscaConstants;
34 import org.openecomp.sdc.translator.services.heattotosca.Constants;
35
36 import java.util.HashMap;
37 import java.util.Map;
38
39 public class ContrailV2VirtualNetworkGlobalType {
40
41   /**
42    * Create service template service template.
43    *
44    * @return the service template
45    */
46   public static ServiceTemplate createServiceTemplate() {
47     ServiceTemplate contrailVirtualNetworkServiceTemplate = new ServiceTemplate();
48     contrailVirtualNetworkServiceTemplate
49         .setTosca_definitions_version(ToscaConstants.TOSCA_DEFINITIONS_VERSION);
50     contrailVirtualNetworkServiceTemplate.setMetadata(DataModelUtil
51         .createMetadata(Constants.CONTRAILV2_VIRTUAL_NETWORK_TEMPLATE_NAME, "1.0.0", null));
52     contrailVirtualNetworkServiceTemplate
53         .setDescription("Contrail V2 Virtual Network Global Types");
54     contrailVirtualNetworkServiceTemplate.setImports(GlobalTypesUtil.createCommonImportList());
55     contrailVirtualNetworkServiceTemplate.setNode_types(createGlobalNodeTypes());
56     contrailVirtualNetworkServiceTemplate.setData_types(createGlobalDataTypes());
57     return contrailVirtualNetworkServiceTemplate;
58   }
59
60   private static Map<String, NodeType> createGlobalNodeTypes() {
61     Map<String, NodeType> globalNodeTypes = new HashMap<>();
62     globalNodeTypes.put(ToscaNodeType.CONTRAILV2_VIRTUAL_NETWORK.getDisplayName(),
63         createContrailVirtualNetworkNodeType());
64     return globalNodeTypes;
65   }
66
67   private static NodeType createContrailVirtualNetworkNodeType() {
68     NodeType contrailV2VirtualNetworkNodeType = new NodeType();
69     contrailV2VirtualNetworkNodeType.setDerived_from(ToscaNodeType.NETWORK.getDisplayName());
70     contrailV2VirtualNetworkNodeType.setProperties(createContrailVirtualNetworkProperties());
71     contrailV2VirtualNetworkNodeType.setAttributes(createContrailVirtualNetworkAttributes());
72     contrailV2VirtualNetworkNodeType.setCapabilities(createContrailVirtualNetworkCapabilities());
73     return contrailV2VirtualNetworkNodeType;
74   }
75
76   private static Map<String, CapabilityDefinition> createContrailVirtualNetworkCapabilities() {
77     Map<String, CapabilityDefinition> capabilities = new HashMap<>();
78     capabilities.put("attachment", GlobalTypesUtil.createAttachmentCapability());
79     return capabilities;
80   }
81
82   private static Map<String, PropertyDefinition> createContrailVirtualNetworkProperties() {
83     Map<String, PropertyDefinition> contrailVirtualNetworkPropertyDefMap = new HashMap<>();
84     //contrailVirtualNetworkPropertyDefMap.put("name", DataModelUtil.
85     // createPropertyDefinition(PropertyType.STRING.getDisplayName()
86     // , "Name", false, null, null, null, null));
87     contrailVirtualNetworkPropertyDefMap.put("network_ipam_refs", DataModelUtil
88         .createPropertyDefinition(PropertyType.LIST.getDisplayName(), "IPAM references", false,
89             null, null,
90             DataModelUtil.createEntrySchema(PropertyType.STRING.getDisplayName(), null, null),
91             null));
92     contrailVirtualNetworkPropertyDefMap.put("network_ipam_refs_data", DataModelUtil
93         .createPropertyDefinition(PropertyType.LIST.getDisplayName(), "IPAM references Data", false,
94             null, null, DataModelUtil.createEntrySchema(
95                 ToscaDataType.CONTRAILV2_VIRTUAL_NETWORK_IPAM_REF_DATA.getDisplayName(), null,
96                 null), null));
97     contrailVirtualNetworkPropertyDefMap.put("network_policy_refs", DataModelUtil
98         .createPropertyDefinition(PropertyType.LIST.getDisplayName(), "Policy references", false,
99             null, null,
100             DataModelUtil.createEntrySchema(PropertyType.STRING.getDisplayName(), null, null),
101             null));
102     contrailVirtualNetworkPropertyDefMap.put("network_policy_refs_data", DataModelUtil
103         .createPropertyDefinition(PropertyType.LIST.getDisplayName(), "Policy references data",
104             false, null, null, DataModelUtil.createEntrySchema(
105                 ToscaDataType.CONTRAILV2_VIRTUAL_NETWORK_POLICY_REF_DATA.getDisplayName(), null,
106                 null), null));
107     contrailVirtualNetworkPropertyDefMap.put("subnets", DataModelUtil
108         .createPropertyDefinition(PropertyType.MAP.getDisplayName(), "Network related subnets",
109             false, null, null, DataModelUtil
110                 .createEntrySchema(ToscaDataType.NEUTRON_SUBNET.getDisplayName(), null, null),
111             null));
112     return contrailVirtualNetworkPropertyDefMap;
113   }
114
115   private static Map<String, DataType> createGlobalDataTypes() {
116     Map<String, DataType> globalDataTypes = new HashMap<>();
117     globalDataTypes.put(ToscaDataType.CONTRAILV2_VIRTUAL_NETWORK_IPAM_REF_DATA.getDisplayName(),
118         createVirtualNetworkIpamRefDataDataType());
119     globalDataTypes.put(
120         ToscaDataType.CONTRAILV2_VIRTUAL_NETWORK_IPAM_REF_DATA_IPAM_SUBNET_LIST.getDisplayName(),
121         createVirtualNetworkIpamRefDataIpanSubnetListDataType());
122     globalDataTypes
123         .put(ToscaDataType.CONTRAILV2_VIRTUAL_NETWORK_IPAM_REF_DATA_IPAM_SUBNET.getDisplayName(),
124             createVirtualNetworkIpamRefDataIpanSubnetDataType());
125     globalDataTypes.put(ToscaDataType.CONTRAILV2_VIRTUAL_NETWORK_POLICY_REF_DATA.getDisplayName(),
126         createVirtualNetworkPolicyRefDataDataType());
127     globalDataTypes
128         .put(ToscaDataType.CONTRAILV2_VIRTUAL_NETWORK_POLICY_REF_DATA_SEQUENCE.getDisplayName(),
129             createVirtualNetworkPolicyRefSequenceDataDataType());
130     return globalDataTypes;
131   }
132
133   private static DataType createVirtualNetworkIpamRefDataDataType() {
134     DataType dataType = new DataType();
135     dataType.setDerived_from(ToscaDataType.ROOT.getDisplayName());
136     dataType.setDescription("Network Ipam Ref Data");
137     Map<String, PropertyDefinition> properties = new HashMap<>();
138
139     properties.put("network_ipam_refs_data_ipam_subnets", DataModelUtil
140         .createPropertyDefinition(PropertyType.LIST.getDisplayName(),
141             "Network ipam refs data ipam subnets", false, null, null, DataModelUtil
142                 .createEntrySchema(
143                     ToscaDataType.CONTRAILV2_VIRTUAL_NETWORK_IPAM_REF_DATA_IPAM_SUBNET_LIST
144                         .getDisplayName(), null, null), null));
145     dataType.setProperties(properties);
146     return dataType;
147   }
148
149   private static DataType createVirtualNetworkIpamRefDataIpanSubnetListDataType() {
150     DataType dataType = new DataType();
151     dataType.setDerived_from(ToscaDataType.ROOT.getDisplayName());
152     dataType.setDescription("Network Ipam Ref Data Subnet List");
153     Map<String, PropertyDefinition> properties = new HashMap<>();
154
155     properties.put("network_ipam_refs_data_ipam_subnets_subnet", DataModelUtil
156         .createPropertyDefinition(
157             ToscaDataType.CONTRAILV2_VIRTUAL_NETWORK_IPAM_REF_DATA_IPAM_SUBNET.getDisplayName(),
158             "Network ipam refs data ipam subnets", false, null, null, null, null));
159     properties.put("network_ipam_refs_data_ipam_subnets_addr_from_start", DataModelUtil
160         .createPropertyDefinition(PropertyType.STRING.getDisplayName(),
161             "Network ipam refs data ipam subnets addr from start", false, null, null, null, null));
162
163     dataType.setProperties(properties);
164     return dataType;
165   }
166
167   private static DataType createVirtualNetworkIpamRefDataIpanSubnetDataType() {
168     DataType dataType = new DataType();
169     dataType.setDerived_from(ToscaDataType.ROOT.getDisplayName());
170     dataType.setDescription("Network Ipam Ref Data Subnet");
171     Map<String, PropertyDefinition> properties = new HashMap<>();
172
173     properties.put("network_ipam_refs_data_ipam_subnets_subnet_ip_prefix", DataModelUtil
174         .createPropertyDefinition(PropertyType.STRING.getDisplayName(),
175             "Network ipam refs data ipam subnets ip prefix", false, null, null, null, null));
176     properties.put("network_ipam_refs_data_ipam_subnets_subnet_ip_prefix_len", DataModelUtil
177         .createPropertyDefinition(PropertyType.STRING.getDisplayName(),
178             "Network ipam refs data ipam subnets ip prefix len", false, null, null, null, null));
179     dataType.setProperties(properties);
180     return dataType;
181   }
182
183
184   private static DataType createVirtualNetworkPolicyRefDataDataType() {
185     DataType dataType = new DataType();
186     dataType.setDerived_from(ToscaDataType.ROOT.getDisplayName());
187     dataType.setDescription("network policy refs data");
188     Map<String, PropertyDefinition> properties = new HashMap<>();
189
190     properties.put("network_policy_refs_data_sequence", DataModelUtil.createPropertyDefinition(
191         ToscaDataType.CONTRAILV2_VIRTUAL_NETWORK_POLICY_REF_DATA_SEQUENCE.getDisplayName(),
192         "Network Policy ref data sequence", false, null, null, null, null));
193
194
195     dataType.setProperties(properties);
196     return dataType;
197   }
198
199
200   private static DataType createVirtualNetworkPolicyRefSequenceDataDataType() {
201     DataType dataType = new DataType();
202     dataType.setDerived_from(ToscaDataType.ROOT.getDisplayName());
203     dataType.setDescription("network policy refs data sequence");
204     Map<String, PropertyDefinition> properties = new HashMap<>();
205
206     properties.put("network_policy_refs_data_sequence_major", DataModelUtil
207         .createPropertyDefinition(PropertyType.INTEGER.getDisplayName(),
208             "Network Policy ref data sequence Major", false, null, null, null, null));
209     properties.put("network_policy_refs_data_sequence_minor", DataModelUtil
210         .createPropertyDefinition(PropertyType.INTEGER.getDisplayName(),
211             "Network Policy ref data sequence Minor", false, null, null, null, null));
212
213     dataType.setProperties(properties);
214     return dataType;
215   }
216
217   private static Map<String, AttributeDefinition> createContrailVirtualNetworkAttributes() {
218     Map<String, AttributeDefinition> contrailVirtualNetworkAttributesDefMap = new HashMap<>();
219     contrailVirtualNetworkAttributesDefMap.put("subnets_name", DataModelUtil
220         .createAttributeDefinition(PropertyType.LIST.getDisplayName(),
221             "Subnets name of this network", null,
222             DataModelUtil.createEntrySchema(PropertyType.STRING.getDisplayName(), null, null),
223             null));
224     contrailVirtualNetworkAttributesDefMap.put("subnets", DataModelUtil
225         .createAttributeDefinition(PropertyType.MAP.getDisplayName(), "Network related subnets",
226             null, DataModelUtil
227                 .createEntrySchema(ToscaDataType.NEUTRON_SUBNET.getDisplayName(), null, null),
228             null));
229     contrailVirtualNetworkAttributesDefMap.put("subnets_show", DataModelUtil
230         .createAttributeDefinition(PropertyType.MAP.getDisplayName(),
231             "Detailed information about each subnet", null,
232             DataModelUtil.createEntrySchema(PropertyType.STRING.getDisplayName(), null, null),
233             null));
234     contrailVirtualNetworkAttributesDefMap.put("fq_name", DataModelUtil
235         .createAttributeDefinition(PropertyType.STRING.getDisplayName(), "fq_name", null, null,
236             null));
237     return contrailVirtualNetworkAttributesDefMap;
238   }
239 }