push addional code
[sdc.git] / openecomp-be / lib / openecomp-sdc-translator-lib / openecomp-sdc-translator-core / src / main / java / org / openecomp / sdc / translator / services / heattotosca / globaltypes / CommonGlobalTypes.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
24 import org.openecomp.sdc.tosca.datatypes.ToscaCapabilityType;
25 import org.openecomp.sdc.tosca.datatypes.ToscaDataType;
26 import org.openecomp.sdc.tosca.datatypes.ToscaGroupType;
27 import org.openecomp.sdc.tosca.datatypes.ToscaPolicyType;
28 import org.openecomp.sdc.tosca.datatypes.ToscaRelationshipType;
29 import org.openecomp.sdc.tosca.datatypes.model.AttributeDefinition;
30 import org.openecomp.sdc.tosca.datatypes.model.CapabilityType;
31 import org.openecomp.sdc.tosca.datatypes.model.Constraint;
32 import org.openecomp.sdc.tosca.datatypes.model.DataType;
33 import org.openecomp.sdc.tosca.datatypes.model.GroupType;
34 import org.openecomp.sdc.tosca.datatypes.model.Import;
35 import org.openecomp.sdc.tosca.datatypes.model.PolicyType;
36 import org.openecomp.sdc.tosca.datatypes.model.PropertyDefinition;
37 import org.openecomp.sdc.tosca.datatypes.model.PropertyType;
38 import org.openecomp.sdc.tosca.datatypes.model.RelationshipType;
39 import org.openecomp.sdc.tosca.datatypes.model.ServiceTemplate;
40 import org.openecomp.sdc.tosca.services.DataModelUtil;
41 import org.openecomp.sdc.tosca.services.ToscaConstants;
42 import org.openecomp.sdc.tosca.services.ToscaUtil;
43 import org.openecomp.sdc.translator.services.heattotosca.Constants;
44
45 import java.util.ArrayList;
46 import java.util.HashMap;
47 import java.util.List;
48 import java.util.Map;
49
50 public class CommonGlobalTypes {
51
52   /**
53    * Create service template service template.
54    *
55    * @return the service template
56    */
57   public static ServiceTemplate createServiceTemplate() {
58     ServiceTemplate serviceTemplate = new ServiceTemplate();
59     serviceTemplate.setTosca_definitions_version(ToscaConstants.TOSCA_DEFINITIONS_VERSION);
60     serviceTemplate.setMetadata(
61         DataModelUtil.createMetadata(Constants.COMMON_GLOBAL_TEMPLATE_NAME, "1.0.0", null));
62     serviceTemplate.setDescription("TOSCA Global Types");
63     serviceTemplate.setData_types(createGlobalDataTypes());
64     serviceTemplate.setGroup_types(createGroupTypes());
65     serviceTemplate.setPolicy_types(createPolicyTypes());
66     serviceTemplate.setRelationship_types(createRelationTypes());
67     serviceTemplate.setCapability_types(createCapabilityTypes());
68     serviceTemplate.setImports(createImportList());
69     return serviceTemplate;
70   }
71
72   private static Map<String, CapabilityType> createCapabilityTypes() {
73     Map<String, CapabilityType> capabilityMap = new HashMap<>();
74     capabilityMap.put(ToscaCapabilityType.METRIC.getDisplayName(), createMetricCapabilityType());
75     capabilityMap
76         .put(ToscaCapabilityType.METRIC_CEILOMETER.getDisplayName(), createMetricCeilometerType());
77     capabilityMap.put(ToscaCapabilityType.METRIC_SNMP_TRAP.getDisplayName(), createMetricSnmpType(
78         "A node type that includes the Metric capability"
79                 + " indicates that it can be monitored using snmp trap."));
80     capabilityMap.put(ToscaCapabilityType.METRIC_SNMP_POLLING.getDisplayName(),
81         createMetricSnmpType(
82             "A node type that includes the Metric capability indicates"
83                     + " that it can be monitored using snmp polling."));
84     return capabilityMap;
85   }
86
87
88   private static CapabilityType createMetricSnmpType(String description) {
89     CapabilityType capabilityType = new CapabilityType();
90     capabilityType.setDerived_from(ToscaCapabilityType.METRIC.getDisplayName());
91     capabilityType.setDescription(description);
92     capabilityType.setProperties(createCapabilityMetricSnmpProperties());
93
94     return capabilityType;
95   }
96
97
98   private static Map<String, PropertyDefinition> createCapabilityMetricSnmpProperties() {
99     Map<String, PropertyDefinition> propertyDefinitionMap = new HashMap<>();
100     propertyDefinitionMap.put("oid", DataModelUtil
101         .createPropertyDefinition(PropertyType.STRING.getDisplayName(), "Object Id of the metric",
102             true, null, null, null, null));
103     return propertyDefinitionMap;
104   }
105
106   private static CapabilityType createMetricCeilometerType() {
107     CapabilityType capabilityType = new CapabilityType();
108     capabilityType.setDerived_from(ToscaCapabilityType.METRIC.getDisplayName());
109     capabilityType.setDescription(
110         "A node type that includes the Metric capability"
111                 + " indicates that it can be monitored using ceilometer.");
112     capabilityType.setProperties(createCapabilityMetricCeilometerProperties());
113     return capabilityType;
114   }
115
116
117   private static Map<String, PropertyDefinition> createCapabilityMetricCeilometerProperties() {
118     Map<String, PropertyDefinition> propertyDefinitionMap = new HashMap<>();
119     propertyDefinitionMap.put(Constants.NAME_PROPERTY_NAME, DataModelUtil
120         .createPropertyDefinition(PropertyType.STRING.getDisplayName(),
121             "Ceilometer metric type name to monitor. (The name ceilometer is using)", true, null,
122             null, null, null));
123     return propertyDefinitionMap;
124   }
125
126   private static Map<String, Import> createImportList() {
127     Map<String, Import> importsMap = new HashMap<>();
128     importsMap.put(ToscaConstants.NATIVE_TYPES_SERVICE_TEMPLATE_NAME, GlobalTypesUtil
129         .createServiceTemplateImport(ToscaConstants.NATIVE_TYPES_SERVICE_TEMPLATE_NAME));
130     return importsMap;
131   }
132
133   /**
134    * Create metric capability type capability type.
135    *
136    * @return the capability type
137    */
138   public static CapabilityType createMetricCapabilityType() {
139     CapabilityType capabilityType = new CapabilityType();
140     capabilityType.setDerived_from(ToscaCapabilityType.NFV_METRIC.getDisplayName());
141     capabilityType.setDescription(
142         "A node type that includes the Metric capability indicates that it can be monitored.");
143     capabilityType.setProperties(createCapabilityMetricProperties());
144     capabilityType.setAttributes(createCapabilityMetricAttributes());
145     return capabilityType;
146   }
147
148   private static Map<String, AttributeDefinition> createCapabilityMetricAttributes() {
149     Map<String, AttributeDefinition> attributeDefinitionMap = new HashMap<>();
150
151     attributeDefinitionMap.put("value", DataModelUtil
152         .createAttributeDefinition(PropertyType.STRING.getDisplayName(), "Runtime monitored value",
153             null, null, null));
154     return attributeDefinitionMap;
155   }
156
157   private static Map<String, PropertyDefinition> createCapabilityMetricProperties() {
158     Map<String, PropertyDefinition> propertyDefinitionMap = new HashMap<>();
159     propertyDefinitionMap.put("type", DataModelUtil
160         .createPropertyDefinition(PropertyType.STRING.getDisplayName(),
161             "Type of the metric value, for an example, Cumulative, Delta, Gauge and etc.", true,
162             null, null, null, null));
163     propertyDefinitionMap.put("unit", DataModelUtil
164         .createPropertyDefinition(PropertyType.STRING.getDisplayName(), "Unit of the metric value",
165             true, null, null, null, null));
166     propertyDefinitionMap.put("category", DataModelUtil
167         .createPropertyDefinition(PropertyType.STRING.getDisplayName(),
168             "Category of the metric, for an example, compute, disk, network, storage and etc.",
169             false, null, null, null, null));
170     propertyDefinitionMap.put(Constants.DESCRIPTION_PROPERTY_NAME, DataModelUtil
171         .createPropertyDefinition(PropertyType.STRING.getDisplayName(), "Description of the metric",
172             false, null, null, null, null));
173     return propertyDefinitionMap;
174   }
175
176   private static Map<String, RelationshipType> createRelationTypes() {
177     Map<String, RelationshipType> globalRelationshipTypes = new HashMap<>();
178     globalRelationshipTypes.put(ToscaRelationshipType.ATTACHES_TO.getDisplayName(),
179         createAttachesToRelationshipType());
180     return globalRelationshipTypes;
181   }
182
183   private static RelationshipType createAttachesToRelationshipType() {
184     RelationshipType attachesToRelationType = new RelationshipType();
185     attachesToRelationType.setDerived_from(ToscaRelationshipType.ROOT.getDisplayName());
186     attachesToRelationType.setDescription("This type represents an attachment relationship");
187     return attachesToRelationType;
188   }
189
190   private static Map<String, PolicyType> createPolicyTypes() {
191     Map<String, PolicyType> globalPolicyTypes = new HashMap<>();
192     globalPolicyTypes
193         .put(ToscaPolicyType.PLACEMENT_ANTILOCATE.getDisplayName(), createAntilocatePolicyType());
194     globalPolicyTypes
195         .put(ToscaPolicyType.PLACEMENT_COLOCATE.getDisplayName(), createColocatePolicyType());
196     globalPolicyTypes.put(ToscaPolicyType.PLACEMENT_VALET_AFFINITY.getDisplayName(),
197         createValetAffinityPolicyType());
198     globalPolicyTypes.put(ToscaPolicyType.PLACEMENT_VALET_DIVERSITY.getDisplayName(),
199         createValetDiversityPolicyType());
200     globalPolicyTypes.put(ToscaPolicyType.PLACEMENT_VALET_EXCLUSIVITY.getDisplayName(),
201         createValetExclusivityPolicyType());
202     return globalPolicyTypes;
203   }
204
205   private static PolicyType createValetDiversityPolicyType() {
206     PolicyType policyType = new PolicyType();
207     policyType.setDerived_from(ToscaPolicyType.PLACEMENT.getDisplayName());
208     policyType.setDescription("Valet Diversity");
209     policyType.setProperties(new HashMap<>());
210     policyType.getProperties().put("level", DataModelUtil
211         .createPropertyDefinition(PropertyType.STRING.getDisplayName(), "diversity", false,
212             DataModelUtil.createValidValuesConstraintsList("host", "rack"), null, null, "host"));
213
214     return policyType;
215   }
216
217   private static PolicyType createValetExclusivityPolicyType() {
218     PolicyType policyType = new PolicyType();
219     policyType.setDerived_from(ToscaPolicyType.PLACEMENT.getDisplayName());
220     policyType.setDescription("Valet Exclusivity");
221     policyType.setProperties(addNamePropertyToPolicyType());
222     policyType.setProperties(new HashMap<>());
223     policyType.getProperties().put("level", DataModelUtil
224         .createPropertyDefinition(PropertyType.STRING.getDisplayName(), "exclusivity", false,
225             DataModelUtil.createValidValuesConstraintsList("host", "rack"), null, null, "host"));
226     return policyType;
227   }
228
229   private static PolicyType createValetAffinityPolicyType() {
230     PolicyType policyType = new PolicyType();
231     policyType.setDerived_from(ToscaPolicyType.PLACEMENT.getDisplayName());
232     policyType.setDescription("Valet Affinity");
233     policyType.setProperties(new HashMap<>());
234     policyType.getProperties().put("level", DataModelUtil
235         .createPropertyDefinition(PropertyType.STRING.getDisplayName(), "affinity", false,
236             DataModelUtil.createValidValuesConstraintsList("host", "rack"), null, null, "host"));
237
238     return policyType;
239   }
240
241
242   private static PolicyType createColocatePolicyType() {
243     PolicyType policyType = new PolicyType();
244     policyType.setDerived_from(ToscaPolicyType.PLACEMENT.getDisplayName());
245     policyType.setDescription("Keep associated nodes (groups of nodes) based upon affinity value");
246     policyType.setProperties(addNamePropertyToPolicyType());
247     policyType.getProperties().put("affinity", DataModelUtil
248         .createPropertyDefinition(PropertyType.STRING.getDisplayName(), "affinity", true,
249             DataModelUtil.createValidValuesConstraintsList("host", "region", "compute"), null, null,
250             null));
251
252     return policyType;
253   }
254
255   private static PolicyType createAntilocatePolicyType() {
256     PolicyType policyType = new PolicyType();
257     policyType.setDerived_from(ToscaPolicyType.PLACEMENT.getDisplayName());
258     policyType.setDescription("My placement policy for separation based upon container type value");
259     policyType.setProperties(addNamePropertyToPolicyType());
260     policyType.getProperties().put("container_type", DataModelUtil
261         .createPropertyDefinition(PropertyType.STRING.getDisplayName(), "container type", false,
262             DataModelUtil.createValidValuesConstraintsList("host", "region", "compute"), null, null,
263             null));
264     return policyType;
265   }
266
267   private static Map<String, PropertyDefinition> addNamePropertyToPolicyType() {
268     Map<String, PropertyDefinition> policyTypeProperties = new HashMap<>();
269     policyTypeProperties.put(Constants.NAME_PROPERTY_NAME, DataModelUtil
270         .createPropertyDefinition(PropertyType.STRING.getDisplayName(), "The name of the policy",
271             false, null, null, null, null));
272     return policyTypeProperties;
273   }
274
275   private static Map<String, GroupType> createGroupTypes() {
276     Map<String, GroupType> globalGroupTypes = new HashMap<>();
277     globalGroupTypes.put(ToscaGroupType.HEAT_STACK.getDisplayName(), createHeatStackGroupType());
278     return globalGroupTypes;
279   }
280
281   private static GroupType createHeatStackGroupType() {
282     GroupType heatStackGroupType = new GroupType();
283     heatStackGroupType.setDerived_from(ToscaGroupType.ROOT.getDisplayName());
284     heatStackGroupType
285         .setDescription("Grouped all heat resources which are in the same heat stack");
286     heatStackGroupType.setProperties(createHeatStackGroupProperties());
287
288     return heatStackGroupType;
289   }
290
291   private static Map<String, PropertyDefinition> createHeatStackGroupProperties() {
292     Map<String, PropertyDefinition> propertiesDef = new HashMap<>();
293     propertiesDef.put("heat_file", DataModelUtil
294         .createPropertyDefinition(PropertyType.STRING.getDisplayName(),
295             "Heat file which associate to this group/heat stack", true, null, null, null, null));
296     propertiesDef.put(Constants.DESCRIPTION_PROPERTY_NAME, DataModelUtil
297         .createPropertyDefinition(PropertyType.STRING.getDisplayName(), "Heat file description",
298             false, null, null, null, null));
299     return propertiesDef;
300   }
301
302
303   /**
304    * Create common service template import import.
305    *
306    * @return the import
307    */
308   public static Import createCommonServiceTemplateImport() {
309     Import commonServiceTemplateImport = new Import();
310     commonServiceTemplateImport
311         .setFile(ToscaUtil.getServiceTemplateFileName(Constants.COMMON_GLOBAL_TEMPLATE_NAME));
312     return commonServiceTemplateImport;
313   }
314
315   private static Map<String, DataType> createGlobalDataTypes() {
316     Map<String, DataType> globalDataTypes = new HashMap<>();
317     globalDataTypes.put(ToscaDataType.NETWORK_ALLOCATION_POOL.getDisplayName(),
318         createAllocationPoolDataType());
319     globalDataTypes
320         .put(ToscaDataType.NETWORK_HOST_ROUTE.getDisplayName(), createHostRouteDataType());
321     globalDataTypes.put(ToscaDataType.NEUTRON_SUBNET.getDisplayName(), createSubnetDataType());
322     globalDataTypes
323         .put(ToscaDataType.NETWORK_ADDRESS_PAIR.getDisplayName(), createAddressPairDataType());
324     globalDataTypes.put(ToscaDataType.CONTRAIL_STATIC_ROUTE.getDisplayName(),
325         createContrailStaticRouteDataType());
326     globalDataTypes.put(ToscaDataType.CONTRAIL_ADDRESS_PAIR.getDisplayName(),
327         createContrailAddressPairDataType());
328     return globalDataTypes;
329   }
330
331   private static DataType createContrailStaticRouteDataType() {
332     DataType dataType = new DataType();
333     dataType.setDerived_from(ToscaDataType.ROOT.getDisplayName());
334     dataType.setDescription("static route");
335     Map<String, PropertyDefinition> prop = new HashMap<>();
336
337     prop.put("prefix", DataModelUtil
338         .createPropertyDefinition(PropertyType.STRING.getDisplayName(), "Route prefix", false, null,
339             null, null, null));
340     prop.put("next_hop", DataModelUtil
341         .createPropertyDefinition(PropertyType.STRING.getDisplayName(), "Next hop", false, null,
342             null, null, null));
343     prop.put("next_hop_type", DataModelUtil
344         .createPropertyDefinition(PropertyType.STRING.getDisplayName(), "Next hop type", false,
345             null, null, null, null));
346
347     dataType.setProperties(prop);
348     return dataType;
349   }
350
351   private static DataType createContrailAddressPairDataType() {
352     DataType dataType = new DataType();
353     dataType.setDerived_from(ToscaDataType.ROOT.getDisplayName());
354     dataType.setDescription("Address Pair");
355     Map<String, PropertyDefinition> prop = new HashMap<>();
356
357     prop.put("prefix", DataModelUtil
358         .createPropertyDefinition(PropertyType.STRING.getDisplayName(), "IP address prefix", false,
359             null, null, null, null));
360     prop.put("mac_address", DataModelUtil
361         .createPropertyDefinition(PropertyType.STRING.getDisplayName(), "Mac address", false, null,
362             null, null, null));
363     prop.put("address_mode", DataModelUtil
364         .createPropertyDefinition(PropertyType.STRING.getDisplayName(),
365             "Address mode active-active or active-standy", false,
366             DataModelUtil.createValidValuesConstraintsList("active-active", "active-standby"), null,
367             null, null));
368
369     dataType.setProperties(prop);
370     return dataType;
371   }
372
373   private static DataType createAddressPairDataType() {
374     DataType addressPairDataType = new DataType();
375     addressPairDataType.setDerived_from(ToscaDataType.ROOT.getDisplayName());
376     addressPairDataType.setDescription("MAC/IP address pairs");
377     Map<String, PropertyDefinition> addressPairProp = new HashMap<>();
378
379     addressPairProp.put("ip_address", DataModelUtil
380         .createPropertyDefinition(PropertyType.STRING.getDisplayName(), "IP address", false, null,
381             null, null, null));
382     addressPairProp.put("mac_address", DataModelUtil
383         .createPropertyDefinition(PropertyType.STRING.getDisplayName(), "MAC address", false, null,
384             null, null, null));
385     addressPairDataType.setProperties(addressPairProp);
386
387     return addressPairDataType;
388   }
389
390   private static DataType createHostRouteDataType() {
391     DataType hostRouteDataType = new DataType();
392     hostRouteDataType.setDerived_from(ToscaDataType.ROOT.getDisplayName());
393     hostRouteDataType.setDescription("Host route info for the subnet");
394
395     Map<String, PropertyDefinition> hostRoutePoolProp = new HashMap<>();
396     hostRoutePoolProp.put("destination", DataModelUtil
397         .createPropertyDefinition(PropertyType.STRING.getDisplayName(),
398             "The destination for static route", false, null, null, null, null));
399     hostRoutePoolProp.put("nexthop", DataModelUtil
400         .createPropertyDefinition(PropertyType.STRING.getDisplayName(),
401             "The next hop for the destination", false, null, null, null, null));
402     hostRouteDataType.setProperties(hostRoutePoolProp);
403
404     return hostRouteDataType;
405   }
406
407   private static DataType createAllocationPoolDataType() {
408     DataType allocationPoolDataType = new DataType();
409     allocationPoolDataType.setDerived_from(ToscaDataType.ROOT.getDisplayName());
410     allocationPoolDataType.setDescription("The start and end addresses for the allocation pool");
411
412     Map<String, PropertyDefinition> allocationPoolProp = new HashMap<>();
413     allocationPoolProp.put("start", DataModelUtil
414         .createPropertyDefinition(PropertyType.STRING.getDisplayName(),
415             "Start address for the allocation pool", false, null, null, null, null));
416     allocationPoolProp.put("end", DataModelUtil
417         .createPropertyDefinition(PropertyType.STRING.getDisplayName(),
418             "End address for the allocation pool", false, null, null, null, null));
419     allocationPoolDataType.setProperties(allocationPoolProp);
420
421     return allocationPoolDataType;
422   }
423
424   private static DataType createSubnetDataType() {
425     DataType subnetDataType = new DataType();
426     subnetDataType.setDerived_from(ToscaDataType.ROOT.getDisplayName());
427     subnetDataType.setDescription(
428         "A subnet represents an IP address block that can "
429                 + "be used for assigning IP addresses to virtual instances");
430
431     Map<String, PropertyDefinition> subnetProp = new HashMap<>();
432     subnetProp.put("allocation_pools", DataModelUtil
433         .createPropertyDefinition(PropertyType.LIST.getDisplayName(),
434             "The start and end addresses for the allocation pools", false, null, null, DataModelUtil
435                 .createEntrySchema(ToscaDataType.NETWORK_ALLOCATION_POOL.getDisplayName(), null,
436                     null), null));
437     subnetProp.put("cidr", DataModelUtil
438         .createPropertyDefinition(PropertyType.STRING.getDisplayName(), "The CIDR", false, null,
439             null, null, null));
440     subnetProp.put("dns_nameservers", DataModelUtil
441         .createPropertyDefinition(PropertyType.LIST.getDisplayName(),
442             "A specified set of DNS name servers to be used", false, null, null,
443             DataModelUtil.createEntrySchema(PropertyType.STRING.getDisplayName(), null, null),
444             new ArrayList<String>()));
445     subnetProp.put("enable_dhcp", DataModelUtil
446         .createPropertyDefinition(PropertyType.BOOLEAN.getDisplayName(),
447             "Set to true if DHCP is enabled and false if DHCP is disabled", false, null, null, null,
448             true));
449     subnetProp.put("gateway_ip", DataModelUtil
450         .createPropertyDefinition(PropertyType.STRING.getDisplayName(), "The gateway IP address",
451             false, null, null, null, null));
452     subnetProp.put("host_routes", DataModelUtil
453         .createPropertyDefinition(PropertyType.LIST.getDisplayName(), "The gateway IP address",
454             false, null, null, DataModelUtil
455                 .createEntrySchema(ToscaDataType.NETWORK_HOST_ROUTE.getDisplayName(), null, null),
456             null));
457     subnetProp.put("ip_version", DataModelUtil
458         .createPropertyDefinition(PropertyType.INTEGER.getDisplayName(), "The gateway IP address",
459             false, DataModelUtil.createValidValuesConstraintsList("4", "6"), null, null, 4));
460     subnetProp.put("ipv6_address_mode", DataModelUtil
461         .createPropertyDefinition(PropertyType.STRING.getDisplayName(), "IPv6 address mode", false,
462             DataModelUtil
463                 .createValidValuesConstraintsList("dhcpv6-stateful", "dhcpv6-stateless", "slaac"),
464             null, null, null));
465     subnetProp.put("ipv6_ra_mode", DataModelUtil
466         .createPropertyDefinition(PropertyType.STRING.getDisplayName(),
467             "IPv6 RA (Router Advertisement) mode", false, DataModelUtil
468                 .createValidValuesConstraintsList("dhcpv6-stateful", "dhcpv6-stateless", "slaac"),
469             null, null, null));
470     subnetProp.put(Constants.NAME_PROPERTY_NAME, DataModelUtil
471         .createPropertyDefinition(PropertyType.STRING.getDisplayName(), "The name of the subnet",
472             false, null, null, null, null));
473     subnetProp.put("prefixlen", DataModelUtil
474         .createPropertyDefinition(PropertyType.INTEGER.getDisplayName(),
475             "Prefix length for subnet allocation from subnet pool", false,
476             createPrefixlenConstraint(), null, null, null));
477     subnetProp.put("subnetpool", DataModelUtil
478         .createPropertyDefinition(PropertyType.STRING.getDisplayName(),
479             "The name or ID of the subnet pool", false, null, null, null, null));
480     subnetProp.put("tenant_id", DataModelUtil
481         .createPropertyDefinition(PropertyType.STRING.getDisplayName(),
482             "The ID of the tenant who owns the network", false, null, null, null, null));
483     subnetProp.put("value_specs", DataModelUtil
484         .createPropertyDefinition(PropertyType.MAP.getDisplayName(),
485             "Extra parameters to include in the request", false, null, null,
486             DataModelUtil.createEntrySchema(PropertyType.STRING.getDisplayName(), null, null),
487             new HashMap<>()));
488     subnetDataType.setProperties(subnetProp);
489
490     return subnetDataType;
491   }
492
493   private static List<Constraint> createPrefixlenConstraint() {
494     List<Constraint> constraints = new ArrayList<>();
495     Constraint constraint = new Constraint();
496     constraint.setGreater_or_equal(0);
497     constraints.add(constraint);
498     return constraints;
499   }
500 }