summaryrefslogtreecommitdiffstats
path: root/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/globaltypes
diff options
context:
space:
mode:
Diffstat (limited to 'openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/globaltypes')
-rw-r--r--openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/globaltypes/AbstractSubstituteGlobalType.java167
-rw-r--r--openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/globaltypes/CinderVolumeGlobalType.java242
-rw-r--r--openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/globaltypes/CommonGlobalTypes.java500
-rw-r--r--openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/globaltypes/ContrailAbstractSubstituteGlobalType.java196
-rw-r--r--openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/globaltypes/ContrailComputeGlobalType.java128
-rw-r--r--openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/globaltypes/ContrailNetworkRuleGlobalType.java227
-rw-r--r--openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/globaltypes/ContrailPortGlobalType.java107
-rw-r--r--openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/globaltypes/ContrailV2NetworkRuleGlobalType.java274
-rw-r--r--openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/globaltypes/ContrailV2VirtualMachineInterfaceGlobalType.java136
-rw-r--r--openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/globaltypes/ContrailV2VirtualNetworkGlobalType.java239
-rw-r--r--openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/globaltypes/ContrailVirtualNetworkGlobalType.java134
-rw-r--r--openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/globaltypes/GlobalTypesGenerator.java128
-rw-r--r--openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/globaltypes/GlobalTypesUtil.java69
-rw-r--r--openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/globaltypes/NeutronNetGlobalType.java143
-rw-r--r--openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/globaltypes/NeutronPortGlobalType.java203
-rw-r--r--openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/globaltypes/NeutronSecurityRulesGlobalType.java175
-rw-r--r--openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/globaltypes/NovaServerGlobalType.java307
17 files changed, 3375 insertions, 0 deletions
diff --git a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/globaltypes/AbstractSubstituteGlobalType.java b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/globaltypes/AbstractSubstituteGlobalType.java
new file mode 100644
index 0000000000..221a9e522b
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/globaltypes/AbstractSubstituteGlobalType.java
@@ -0,0 +1,167 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * SDC
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.sdc.translator.services.heattotosca.globaltypes;
+
+import org.openecomp.sdc.tosca.datatypes.ToscaDataType;
+import org.openecomp.sdc.tosca.datatypes.ToscaNodeType;
+import org.openecomp.sdc.tosca.datatypes.model.Constraint;
+import org.openecomp.sdc.tosca.datatypes.model.DataType;
+import org.openecomp.sdc.tosca.datatypes.model.NodeType;
+import org.openecomp.sdc.tosca.datatypes.model.PropertyDefinition;
+import org.openecomp.sdc.tosca.datatypes.model.PropertyType;
+import org.openecomp.sdc.tosca.datatypes.model.ServiceTemplate;
+import org.openecomp.sdc.tosca.services.DataModelUtil;
+import org.openecomp.sdc.tosca.services.ToscaConstants;
+import org.openecomp.sdc.translator.services.heattotosca.Constants;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+
+public class AbstractSubstituteGlobalType {
+
+ private AbstractSubstituteGlobalType() {
+ }
+
+ /**
+ * Create service template service template.
+ *
+ * @return the service template
+ */
+ public static ServiceTemplate createServiceTemplate() {
+ ServiceTemplate serviceTemplate = new ServiceTemplate();
+ serviceTemplate.setTosca_definitions_version(ToscaConstants.TOSCA_DEFINITIONS_VERSION);
+ serviceTemplate.setMetadata(
+ DataModelUtil.createMetadata(Constants.ABSTRACT_SUBSTITUTE_TEMPLATE_NAME, "1.0.0", null));
+ serviceTemplate.setImports(GlobalTypesUtil.createCommonImportList());
+ serviceTemplate.setDescription("Abstract Substitute Global Types");
+ serviceTemplate.setData_types(createGlobalDataTypes());
+ serviceTemplate.setNode_types(createGlobalNodeTypes());
+ return serviceTemplate;
+ }
+
+ private static Map<String, NodeType> createGlobalNodeTypes() {
+ Map<String, NodeType> globalNodeTypes = new HashMap<>();
+ globalNodeTypes.put(ToscaNodeType.ABSTRACT_SUBSTITUTE.getDisplayName(),
+ createAbstractSubstituteNodeType());
+ return globalNodeTypes;
+ }
+
+ private static NodeType createAbstractSubstituteNodeType() {
+ NodeType nodeType = new NodeType();
+ nodeType.setDerived_from(ToscaNodeType.ROOT.getDisplayName());
+ nodeType.setProperties(createAbstractSubstituteProperties());
+ return nodeType;
+ }
+
+ private static Map<String, PropertyDefinition> createAbstractSubstituteProperties() {
+ Map<String, PropertyDefinition> props = new HashMap<>();
+ props.put(ToscaConstants.SERVICE_TEMPLATE_FILTER_PROPERTY_NAME, DataModelUtil
+ .createPropertyDefinition(ToscaDataType.SUBSTITUTION_FILTERING.getDisplayName(),
+ "Substitution Filter", true, null, null, null, null));
+
+ return props;
+ }
+
+
+ private static Map<String, DataType> createGlobalDataTypes() {
+ Map<String, DataType> globalDataTypes = new HashMap<>();
+ globalDataTypes.put(ToscaDataType.SUBSTITUTION_FILTER.getDisplayName(),
+ createSubstitutionFilterDataType());
+ globalDataTypes.put(ToscaDataType.SUBSTITUTION_FILTERING.getDisplayName(),
+ createSubstitutionFilteringDataType());
+ return globalDataTypes;
+ }
+
+ private static DataType createSubstitutionFilterDataType() {
+ DataType dataType = new DataType();
+ dataType.setDerived_from(ToscaDataType.ROOT.getDisplayName());
+ dataType.setDescription("Substitution Filter");
+ Map<String, PropertyDefinition> properties = new HashMap<>();
+ properties.put(ToscaConstants.COUNT_PROPERTY_NAME, DataModelUtil
+ .createPropertyDefinition(PropertyType.STRING.getDisplayName(), "Count", false, null, null,
+ null, 1));
+ properties.put(ToscaConstants.SCALING_ENABLED_PROPERTY_NAME, DataModelUtil
+ .createPropertyDefinition(PropertyType.BOOLEAN.getDisplayName(),
+ "Indicates whether service scaling is enabled", false, null, null, null, true));
+ properties.put(ToscaConstants.SUBSTITUTE_SERVICE_TEMPLATE_PROPERTY_NAME, DataModelUtil
+ .createPropertyDefinition(PropertyType.STRING.getDisplayName(),
+ "Substitute Service Template", true, null, null, null, null));
+ properties.put("mandatory", DataModelUtil
+ .createPropertyDefinition(PropertyType.BOOLEAN.getDisplayName(), "Mandatory", false, null,
+ null, null, true));
+ properties.put("index_variable", DataModelUtil
+ .createPropertyDefinition(PropertyType.STRING.getDisplayName(), "Index variable", false,
+ createMinLengthConstraint(), null, null, "%index%"));
+
+ dataType.setProperties(properties);
+ return dataType;
+ }
+
+ private static List<Constraint> createMinLengthConstraint() {
+ List<Constraint> constraints;
+ constraints = new ArrayList<>();
+ Constraint constraint = new Constraint();
+ constraint.setMin_length(3);
+ constraints.add(constraint);
+ return constraints;
+ }
+
+ private static DataType createSubstitutionFilteringDataType() {
+ DataType dataType = new DataType();
+ dataType.setDerived_from(ToscaDataType.ROOT.getDisplayName());
+ dataType.setDescription("Substitution Filter");
+ Map<String, PropertyDefinition> properties = new HashMap<>();
+ properties.put(ToscaConstants.COUNT_PROPERTY_NAME, DataModelUtil
+ .createPropertyDefinition(PropertyType.STRING.getDisplayName(), "Count", false, null, null,
+ null, 1));
+ properties.put(ToscaConstants.INDEX_VALUE_PROPERTY_NAME, DataModelUtil
+ .createPropertyDefinition(PropertyType.INTEGER.getDisplayName(),
+ "Index value of the substitution service template runtime instance", false,
+ createIndexValueConstraint(), null, null, 0));
+ properties.put(ToscaConstants.SCALING_ENABLED_PROPERTY_NAME, DataModelUtil
+ .createPropertyDefinition(PropertyType.BOOLEAN.getDisplayName(),
+ "Indicates whether service scaling is enabled", false, null, null, null, true));
+ properties.put(ToscaConstants.SUBSTITUTE_SERVICE_TEMPLATE_PROPERTY_NAME, DataModelUtil
+ .createPropertyDefinition(PropertyType.STRING.getDisplayName(),
+ "Substitute Service Template", true, null, null, null, null));
+ properties.put("mandatory", DataModelUtil
+ .createPropertyDefinition(PropertyType.BOOLEAN.getDisplayName(), "Mandatory", false, null,
+ null, null, true));
+
+
+ dataType.setProperties(properties);
+ return dataType;
+ }
+
+ private static List<Constraint> createIndexValueConstraint() {
+ List<Constraint> constraints;
+ constraints = new ArrayList<>();
+ Constraint constraint = new Constraint();
+ constraint.setGreater_or_equal(0);
+ constraints.add(constraint);
+ return constraints;
+ }
+
+
+}
diff --git a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/globaltypes/CinderVolumeGlobalType.java b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/globaltypes/CinderVolumeGlobalType.java
new file mode 100644
index 0000000000..72f3043225
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/globaltypes/CinderVolumeGlobalType.java
@@ -0,0 +1,242 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * SDC
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.sdc.translator.services.heattotosca.globaltypes;
+
+import org.openecomp.sdc.tosca.datatypes.ToscaNodeType;
+import org.openecomp.sdc.tosca.datatypes.ToscaRelationshipType;
+import org.openecomp.sdc.tosca.datatypes.model.AttributeDefinition;
+import org.openecomp.sdc.tosca.datatypes.model.Constraint;
+import org.openecomp.sdc.tosca.datatypes.model.NodeType;
+import org.openecomp.sdc.tosca.datatypes.model.PropertyDefinition;
+import org.openecomp.sdc.tosca.datatypes.model.PropertyType;
+import org.openecomp.sdc.tosca.datatypes.model.RelationshipType;
+import org.openecomp.sdc.tosca.datatypes.model.ServiceTemplate;
+import org.openecomp.sdc.tosca.services.DataModelUtil;
+import org.openecomp.sdc.tosca.services.ToscaConstants;
+import org.openecomp.sdc.translator.services.heattotosca.Constants;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+public class CinderVolumeGlobalType {
+
+ /**
+ * Create service template service template.
+ *
+ * @return the service template
+ */
+ public static ServiceTemplate createServiceTemplate() {
+ ServiceTemplate cinderVolumeServiceTemplate = new ServiceTemplate();
+ cinderVolumeServiceTemplate
+ .setTosca_definitions_version(ToscaConstants.TOSCA_DEFINITIONS_VERSION);
+ cinderVolumeServiceTemplate.setMetadata(
+ DataModelUtil.createMetadata(Constants.CINDER_VOLUME_TEMPLATE_NAME, "1.0.0", null));
+ cinderVolumeServiceTemplate.setDescription("Cinder Volume TOSCA Global Types");
+ cinderVolumeServiceTemplate.setRelationship_types(createGlobalRelationshipTypes());
+ cinderVolumeServiceTemplate.setNode_types(createGlobalNodeTypes());
+ return cinderVolumeServiceTemplate;
+ }
+
+ private static Map<String, NodeType> createGlobalNodeTypes() {
+ Map<String, NodeType> globalNodeTypes = new HashMap<>();
+ globalNodeTypes.put(ToscaNodeType.CINDER_VOLUME.getDisplayName(), createCinderVolumeNodeType());
+ return globalNodeTypes;
+ }
+
+ private static NodeType createCinderVolumeNodeType() {
+ NodeType cinderVolumeNodeType = new NodeType();
+ cinderVolumeNodeType.setDerived_from(ToscaNodeType.BLOCK_STORAGE.getDisplayName());
+ cinderVolumeNodeType.setProperties(createCinderVolumeProperties());
+ cinderVolumeNodeType.setAttributes(createCinderVolumeAttributes());
+ return cinderVolumeNodeType;
+ }
+
+ private static Map<String, RelationshipType> createGlobalRelationshipTypes() {
+ Map<String, RelationshipType> globalRelationshipTypes = new HashMap<>();
+ globalRelationshipTypes.put(ToscaRelationshipType.CINDER_VOLUME_ATTACHES_TO.getDisplayName(),
+ createCinderVolumeAttachesToRelationshipType());
+ return globalRelationshipTypes;
+ }
+
+ private static RelationshipType createCinderVolumeAttachesToRelationshipType() {
+ RelationshipType cinderVolumeAttachesToRelationType = new RelationshipType();
+ cinderVolumeAttachesToRelationType
+ .setDerived_from(ToscaRelationshipType.NATIVE_ATTACHES_TO.getDisplayName());
+ cinderVolumeAttachesToRelationType
+ .setDescription("This type represents an attachment relationship for associating volume");
+
+ Map<String, PropertyDefinition> cinderVolumeAttachesToProps = new HashMap<>();
+ cinderVolumeAttachesToProps.put("location", DataModelUtil
+ .createPropertyDefinition(PropertyType.STRING.getDisplayName(),
+ "The location where the volume is exposed on the instance, mountpoint", false, null,
+ null, null, null)); //overridden location prop from attachesTo
+ cinderVolumeAttachesToProps.put("instance_uuid", DataModelUtil
+ .createPropertyDefinition(PropertyType.STRING.getDisplayName(),
+ "The ID of the server to which the volume attaches", true, null, null, null, null));
+ cinderVolumeAttachesToProps.put("volume_id", DataModelUtil
+ .createPropertyDefinition(PropertyType.STRING.getDisplayName(),
+ "The ID of the volume to be attached", true, null, null, null, null));
+ cinderVolumeAttachesToRelationType.setProperties(cinderVolumeAttachesToProps);
+
+ Map<String, AttributeDefinition> cinderVolumeAttachesToAttributes = new HashMap<>();
+ cinderVolumeAttachesToAttributes.put("show", DataModelUtil
+ .createAttributeDefinition(PropertyType.STRING.getDisplayName(),
+ "Detailed information about resource", null, null, null));
+ cinderVolumeAttachesToRelationType.setAttributes(cinderVolumeAttachesToAttributes);
+
+ return cinderVolumeAttachesToRelationType;
+ }
+
+ private static Map<String, PropertyDefinition> createCinderVolumeProperties() {
+ Map<String, PropertyDefinition> cinderVolumePropertyDefMap = new HashMap<>();
+ cinderVolumePropertyDefMap.put("availability_zone", DataModelUtil
+ .createPropertyDefinition(PropertyType.STRING.getDisplayName(),
+ "The availability zone in which the volume will be created", false, null, null, null,
+ null));
+ cinderVolumePropertyDefMap.put("backup_id", DataModelUtil
+ .createPropertyDefinition(PropertyType.STRING.getDisplayName(),
+ "If specified, the backup to create the volume from", false, null, null, null, null));
+ cinderVolumePropertyDefMap.put(Constants.DESCRIPTION_PROPERTY_NAME, DataModelUtil
+ .createPropertyDefinition(PropertyType.STRING.getDisplayName(),
+ "A description of the volume", false, null, null, null, null));
+ cinderVolumePropertyDefMap.put("image", DataModelUtil
+ .createPropertyDefinition(PropertyType.STRING.getDisplayName(),
+ "If specified, the name or ID of the image to create the volume from", false, null,
+ null, null, null));
+ cinderVolumePropertyDefMap.put("metadata", DataModelUtil
+ .createPropertyDefinition(PropertyType.MAP.getDisplayName(),
+ "Key/value pairs to associate with the volume", false, null, null,
+ DataModelUtil.createEntrySchema(PropertyType.STRING.getDisplayName(), null, null),
+ null));
+ cinderVolumePropertyDefMap.put("multiattach", DataModelUtil
+ .createPropertyDefinition(PropertyType.BOOLEAN.getDisplayName(),
+ "Whether allow the volume to be attached more than once", false, null, null, null,
+ null));
+ cinderVolumePropertyDefMap.put(Constants.NAME_PROPERTY_NAME, DataModelUtil
+ .createPropertyDefinition(PropertyType.STRING.getDisplayName(),
+ "A name used to distinguish the volume", false, null, null, null, null));
+ cinderVolumePropertyDefMap.put("read_only", DataModelUtil
+ .createPropertyDefinition(PropertyType.BOOLEAN.getDisplayName(),
+ "Enables or disables read-only access mode of volume", false, null, null, null, null));
+ cinderVolumePropertyDefMap.put("scheduler_hints", DataModelUtil
+ .createPropertyDefinition(PropertyType.MAP.getDisplayName(),
+ "Arbitrary key-value pairs specified by the client "
+ + "to help the Cinder scheduler creating a volume",
+ false, null, null,
+ DataModelUtil.createEntrySchema(PropertyType.STRING.getDisplayName(), null, null),
+ null));
+ cinderVolumePropertyDefMap.put("size", DataModelUtil
+ .createPropertyDefinition(PropertyType.SCALAR_UNIT_SIZE.getDisplayName(),
+ "The requested storage size (default unit is MB)", false, getSizeConstraints(), null,
+ null, null));
+ cinderVolumePropertyDefMap.put("source_volid", DataModelUtil
+ .createPropertyDefinition(PropertyType.STRING.getDisplayName(),
+ "If specified, the volume to use as source", false, null, null, null, null));
+ cinderVolumePropertyDefMap.put("volume_type", DataModelUtil
+ .createPropertyDefinition(PropertyType.STRING.getDisplayName(),
+ "If specified, the type of volume to use, mapping to a specific backend", false, null,
+ null, null, null));
+ cinderVolumePropertyDefMap.put("delete_on_termination", DataModelUtil
+ .createPropertyDefinition(PropertyType.BOOLEAN.getDisplayName(),
+ "Indicate whether the volume should be deleted when the server is terminated", false,
+ null, null, null, null));
+ cinderVolumePropertyDefMap.put("boot_index", DataModelUtil
+ .createPropertyDefinition(PropertyType.INTEGER.getDisplayName(),
+ "Integer used for ordering the boot disks", false, null, null, null, null));
+ cinderVolumePropertyDefMap.put("device_type", DataModelUtil
+ .createPropertyDefinition(PropertyType.STRING.getDisplayName(), "Device type", false,
+ getDeviceTypeConstraints(), null, null, null));
+ cinderVolumePropertyDefMap.put("disk_bus", DataModelUtil
+ .createPropertyDefinition(PropertyType.STRING.getDisplayName(),
+ "Bus of the device: hypervisor driver chooses a suitable default if omitted", false,
+ getDiskBusConstraints(), null, null, null));
+ cinderVolumePropertyDefMap.put("swap_size", DataModelUtil
+ .createPropertyDefinition(PropertyType.SCALAR_UNIT_SIZE.getDisplayName(),
+ "The size of the swap, in MB", false, null, null, null, null));
+
+ return cinderVolumePropertyDefMap;
+ }
+
+ private static Map<String, AttributeDefinition> createCinderVolumeAttributes() {
+ Map<String, AttributeDefinition> cinderVolumeAttributesDefMap = new HashMap<>();
+ cinderVolumeAttributesDefMap.put("attachments", DataModelUtil
+ .createAttributeDefinition(PropertyType.STRING.getDisplayName(),
+ "The list of attachments of the volume", null,
+ DataModelUtil.createEntrySchema(PropertyType.STRING.getDisplayName(), null, null),
+ null));
+ cinderVolumeAttributesDefMap.put("bootable", DataModelUtil
+ .createAttributeDefinition(PropertyType.BOOLEAN.getDisplayName(),
+ "Boolean indicating if the volume can be booted or not", null, null, null));
+ cinderVolumeAttributesDefMap.put("created_at", DataModelUtil
+ .createAttributeDefinition(PropertyType.TIMESTAMP.getDisplayName(),
+ "The timestamp indicating volume creation", null, null, null));
+ cinderVolumeAttributesDefMap.put("display_description", DataModelUtil
+ .createAttributeDefinition(PropertyType.STRING.getDisplayName(),
+ "Description of the volume", null, null, null));
+ cinderVolumeAttributesDefMap.put("display_name", DataModelUtil
+ .createAttributeDefinition(PropertyType.STRING.getDisplayName(), "Name of the volume", null,
+ null, null));
+ cinderVolumeAttributesDefMap.put("encrypted", DataModelUtil
+ .createAttributeDefinition(PropertyType.BOOLEAN.getDisplayName(),
+ "Boolean indicating if the volume is encrypted or not", null, null, null));
+ cinderVolumeAttributesDefMap.put("metadata_values", DataModelUtil
+ .createAttributeDefinition(PropertyType.MAP.getDisplayName(),
+ "Key/value pairs associated with the volume in raw dict form", null,
+ DataModelUtil.createEntrySchema(PropertyType.STRING.getDisplayName(), null, null),
+ null));
+ cinderVolumeAttributesDefMap.put("show", DataModelUtil
+ .createAttributeDefinition(PropertyType.STRING.getDisplayName(),
+ "Detailed information about resource", null, null, null));
+ cinderVolumeAttributesDefMap.put("status", DataModelUtil
+ .createAttributeDefinition(PropertyType.STRING.getDisplayName(),
+ "The current status of the volume", null, null, null));
+ return cinderVolumeAttributesDefMap;
+ }
+
+ private static List<Constraint> getDeviceTypeConstraints() {
+ Constraint validValues;
+ List<Constraint> constraints = new ArrayList<>();
+ validValues = DataModelUtil.createValidValuesConstraint("cdrom", "disk");
+ constraints.add(validValues);
+ return constraints;
+ }
+
+ private static List<Constraint> getDiskBusConstraints() {
+ Constraint validValues;
+ List<Constraint> constraints = new ArrayList<>();
+ validValues =
+ DataModelUtil.createValidValuesConstraint("ide", "lame_bus", "scsi", "usb", "virtio");
+ constraints.add(validValues);
+ return constraints;
+ }
+
+
+ private static List<Constraint> getSizeConstraints() {
+ List<Constraint> constraints;
+ constraints = new ArrayList<>();
+ Constraint constraint = new Constraint();
+ constraint.setGreater_or_equal("1 GB");
+ constraints.add(constraint);
+ return constraints;
+ }
+}
diff --git a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/globaltypes/CommonGlobalTypes.java b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/globaltypes/CommonGlobalTypes.java
new file mode 100644
index 0000000000..43a4782149
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/globaltypes/CommonGlobalTypes.java
@@ -0,0 +1,500 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * SDC
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.sdc.translator.services.heattotosca.globaltypes;
+
+
+import org.openecomp.sdc.tosca.datatypes.ToscaCapabilityType;
+import org.openecomp.sdc.tosca.datatypes.ToscaDataType;
+import org.openecomp.sdc.tosca.datatypes.ToscaGroupType;
+import org.openecomp.sdc.tosca.datatypes.ToscaPolicyType;
+import org.openecomp.sdc.tosca.datatypes.ToscaRelationshipType;
+import org.openecomp.sdc.tosca.datatypes.model.AttributeDefinition;
+import org.openecomp.sdc.tosca.datatypes.model.CapabilityType;
+import org.openecomp.sdc.tosca.datatypes.model.Constraint;
+import org.openecomp.sdc.tosca.datatypes.model.DataType;
+import org.openecomp.sdc.tosca.datatypes.model.GroupType;
+import org.openecomp.sdc.tosca.datatypes.model.Import;
+import org.openecomp.sdc.tosca.datatypes.model.PolicyType;
+import org.openecomp.sdc.tosca.datatypes.model.PropertyDefinition;
+import org.openecomp.sdc.tosca.datatypes.model.PropertyType;
+import org.openecomp.sdc.tosca.datatypes.model.RelationshipType;
+import org.openecomp.sdc.tosca.datatypes.model.ServiceTemplate;
+import org.openecomp.sdc.tosca.services.DataModelUtil;
+import org.openecomp.sdc.tosca.services.ToscaConstants;
+import org.openecomp.sdc.tosca.services.ToscaUtil;
+import org.openecomp.sdc.translator.services.heattotosca.Constants;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+public class CommonGlobalTypes {
+
+ /**
+ * Create service template service template.
+ *
+ * @return the service template
+ */
+ public static ServiceTemplate createServiceTemplate() {
+ ServiceTemplate serviceTemplate = new ServiceTemplate();
+ serviceTemplate.setTosca_definitions_version(ToscaConstants.TOSCA_DEFINITIONS_VERSION);
+ serviceTemplate.setMetadata(
+ DataModelUtil.createMetadata(Constants.COMMON_GLOBAL_TEMPLATE_NAME, "1.0.0", null));
+ serviceTemplate.setDescription("TOSCA Global Types");
+ serviceTemplate.setData_types(createGlobalDataTypes());
+ serviceTemplate.setGroup_types(createGroupTypes());
+ serviceTemplate.setPolicy_types(createPolicyTypes());
+ serviceTemplate.setRelationship_types(createRelationTypes());
+ serviceTemplate.setCapability_types(createCapabilityTypes());
+ serviceTemplate.setImports(createImportList());
+ return serviceTemplate;
+ }
+
+ private static Map<String, CapabilityType> createCapabilityTypes() {
+ Map<String, CapabilityType> capabilityMap = new HashMap<>();
+ capabilityMap.put(ToscaCapabilityType.METRIC.getDisplayName(), createMetricCapabilityType());
+ capabilityMap
+ .put(ToscaCapabilityType.METRIC_CEILOMETER.getDisplayName(), createMetricCeilometerType());
+ capabilityMap.put(ToscaCapabilityType.METRIC_SNMP_TRAP.getDisplayName(), createMetricSnmpType(
+ "A node type that includes the Metric capability"
+ + " indicates that it can be monitored using snmp trap."));
+ capabilityMap.put(ToscaCapabilityType.METRIC_SNMP_POLLING.getDisplayName(),
+ createMetricSnmpType(
+ "A node type that includes the Metric capability indicates"
+ + " that it can be monitored using snmp polling."));
+ return capabilityMap;
+ }
+
+
+ private static CapabilityType createMetricSnmpType(String description) {
+ CapabilityType capabilityType = new CapabilityType();
+ capabilityType.setDerived_from(ToscaCapabilityType.METRIC.getDisplayName());
+ capabilityType.setDescription(description);
+ capabilityType.setProperties(createCapabilityMetricSnmpProperties());
+
+ return capabilityType;
+ }
+
+
+ private static Map<String, PropertyDefinition> createCapabilityMetricSnmpProperties() {
+ Map<String, PropertyDefinition> propertyDefinitionMap = new HashMap<>();
+ propertyDefinitionMap.put("oid", DataModelUtil
+ .createPropertyDefinition(PropertyType.STRING.getDisplayName(), "Object Id of the metric",
+ true, null, null, null, null));
+ return propertyDefinitionMap;
+ }
+
+ private static CapabilityType createMetricCeilometerType() {
+ CapabilityType capabilityType = new CapabilityType();
+ capabilityType.setDerived_from(ToscaCapabilityType.METRIC.getDisplayName());
+ capabilityType.setDescription(
+ "A node type that includes the Metric capability"
+ + " indicates that it can be monitored using ceilometer.");
+ capabilityType.setProperties(createCapabilityMetricCeilometerProperties());
+ return capabilityType;
+ }
+
+
+ private static Map<String, PropertyDefinition> createCapabilityMetricCeilometerProperties() {
+ Map<String, PropertyDefinition> propertyDefinitionMap = new HashMap<>();
+ propertyDefinitionMap.put(Constants.NAME_PROPERTY_NAME, DataModelUtil
+ .createPropertyDefinition(PropertyType.STRING.getDisplayName(),
+ "Ceilometer metric type name to monitor. (The name ceilometer is using)", true, null,
+ null, null, null));
+ return propertyDefinitionMap;
+ }
+
+ private static Map<String, Import> createImportList() {
+ Map<String, Import> importsMap = new HashMap<>();
+ importsMap.put(ToscaConstants.NATIVE_TYPES_SERVICE_TEMPLATE_NAME, GlobalTypesUtil
+ .createServiceTemplateImport(ToscaConstants.NATIVE_TYPES_SERVICE_TEMPLATE_NAME));
+ return importsMap;
+ }
+
+ /**
+ * Create metric capability type capability type.
+ *
+ * @return the capability type
+ */
+ public static CapabilityType createMetricCapabilityType() {
+ CapabilityType capabilityType = new CapabilityType();
+ capabilityType.setDerived_from(ToscaCapabilityType.NFV_METRIC.getDisplayName());
+ capabilityType.setDescription(
+ "A node type that includes the Metric capability indicates that it can be monitored.");
+ capabilityType.setProperties(createCapabilityMetricProperties());
+ capabilityType.setAttributes(createCapabilityMetricAttributes());
+ return capabilityType;
+ }
+
+ private static Map<String, AttributeDefinition> createCapabilityMetricAttributes() {
+ Map<String, AttributeDefinition> attributeDefinitionMap = new HashMap<>();
+
+ attributeDefinitionMap.put("value", DataModelUtil
+ .createAttributeDefinition(PropertyType.STRING.getDisplayName(), "Runtime monitored value",
+ null, null, null));
+ return attributeDefinitionMap;
+ }
+
+ private static Map<String, PropertyDefinition> createCapabilityMetricProperties() {
+ Map<String, PropertyDefinition> propertyDefinitionMap = new HashMap<>();
+ propertyDefinitionMap.put("type", DataModelUtil
+ .createPropertyDefinition(PropertyType.STRING.getDisplayName(),
+ "Type of the metric value, for an example, Cumulative, Delta, Gauge and etc.", true,
+ null, null, null, null));
+ propertyDefinitionMap.put("unit", DataModelUtil
+ .createPropertyDefinition(PropertyType.STRING.getDisplayName(), "Unit of the metric value",
+ true, null, null, null, null));
+ propertyDefinitionMap.put("category", DataModelUtil
+ .createPropertyDefinition(PropertyType.STRING.getDisplayName(),
+ "Category of the metric, for an example, compute, disk, network, storage and etc.",
+ false, null, null, null, null));
+ propertyDefinitionMap.put(Constants.DESCRIPTION_PROPERTY_NAME, DataModelUtil
+ .createPropertyDefinition(PropertyType.STRING.getDisplayName(), "Description of the metric",
+ false, null, null, null, null));
+ return propertyDefinitionMap;
+ }
+
+ private static Map<String, RelationshipType> createRelationTypes() {
+ Map<String, RelationshipType> globalRelationshipTypes = new HashMap<>();
+ globalRelationshipTypes.put(ToscaRelationshipType.ATTACHES_TO.getDisplayName(),
+ createAttachesToRelationshipType());
+ return globalRelationshipTypes;
+ }
+
+ private static RelationshipType createAttachesToRelationshipType() {
+ RelationshipType attachesToRelationType = new RelationshipType();
+ attachesToRelationType.setDerived_from(ToscaRelationshipType.ROOT.getDisplayName());
+ attachesToRelationType.setDescription("This type represents an attachment relationship");
+ return attachesToRelationType;
+ }
+
+ private static Map<String, PolicyType> createPolicyTypes() {
+ Map<String, PolicyType> globalPolicyTypes = new HashMap<>();
+ globalPolicyTypes
+ .put(ToscaPolicyType.PLACEMENT_ANTILOCATE.getDisplayName(), createAntilocatePolicyType());
+ globalPolicyTypes
+ .put(ToscaPolicyType.PLACEMENT_COLOCATE.getDisplayName(), createColocatePolicyType());
+ globalPolicyTypes.put(ToscaPolicyType.PLACEMENT_VALET_AFFINITY.getDisplayName(),
+ createValetAffinityPolicyType());
+ globalPolicyTypes.put(ToscaPolicyType.PLACEMENT_VALET_DIVERSITY.getDisplayName(),
+ createValetDiversityPolicyType());
+ globalPolicyTypes.put(ToscaPolicyType.PLACEMENT_VALET_EXCLUSIVITY.getDisplayName(),
+ createValetExclusivityPolicyType());
+ return globalPolicyTypes;
+ }
+
+ private static PolicyType createValetDiversityPolicyType() {
+ PolicyType policyType = new PolicyType();
+ policyType.setDerived_from(ToscaPolicyType.PLACEMENT.getDisplayName());
+ policyType.setDescription("Valet Diversity");
+ policyType.setProperties(new HashMap<>());
+ policyType.getProperties().put("level", DataModelUtil
+ .createPropertyDefinition(PropertyType.STRING.getDisplayName(), "diversity", false,
+ DataModelUtil.createValidValuesConstraintsList("host", "rack"), null, null, "host"));
+
+ return policyType;
+ }
+
+ private static PolicyType createValetExclusivityPolicyType() {
+ PolicyType policyType = new PolicyType();
+ policyType.setDerived_from(ToscaPolicyType.PLACEMENT.getDisplayName());
+ policyType.setDescription("Valet Exclusivity");
+ policyType.setProperties(addNamePropertyToPolicyType());
+ policyType.setProperties(new HashMap<>());
+ policyType.getProperties().put("level", DataModelUtil
+ .createPropertyDefinition(PropertyType.STRING.getDisplayName(), "exclusivity", false,
+ DataModelUtil.createValidValuesConstraintsList("host", "rack"), null, null, "host"));
+ return policyType;
+ }
+
+ private static PolicyType createValetAffinityPolicyType() {
+ PolicyType policyType = new PolicyType();
+ policyType.setDerived_from(ToscaPolicyType.PLACEMENT.getDisplayName());
+ policyType.setDescription("Valet Affinity");
+ policyType.setProperties(new HashMap<>());
+ policyType.getProperties().put("level", DataModelUtil
+ .createPropertyDefinition(PropertyType.STRING.getDisplayName(), "affinity", false,
+ DataModelUtil.createValidValuesConstraintsList("host", "rack"), null, null, "host"));
+
+ return policyType;
+ }
+
+
+ private static PolicyType createColocatePolicyType() {
+ PolicyType policyType = new PolicyType();
+ policyType.setDerived_from(ToscaPolicyType.PLACEMENT.getDisplayName());
+ policyType.setDescription("Keep associated nodes (groups of nodes) based upon affinity value");
+ policyType.setProperties(addNamePropertyToPolicyType());
+ policyType.getProperties().put("affinity", DataModelUtil
+ .createPropertyDefinition(PropertyType.STRING.getDisplayName(), "affinity", true,
+ DataModelUtil.createValidValuesConstraintsList("host", "region", "compute"), null, null,
+ null));
+
+ return policyType;
+ }
+
+ private static PolicyType createAntilocatePolicyType() {
+ PolicyType policyType = new PolicyType();
+ policyType.setDerived_from(ToscaPolicyType.PLACEMENT.getDisplayName());
+ policyType.setDescription("My placement policy for separation based upon container type value");
+ policyType.setProperties(addNamePropertyToPolicyType());
+ policyType.getProperties().put("container_type", DataModelUtil
+ .createPropertyDefinition(PropertyType.STRING.getDisplayName(), "container type", false,
+ DataModelUtil.createValidValuesConstraintsList("host", "region", "compute"), null, null,
+ null));
+ return policyType;
+ }
+
+ private static Map<String, PropertyDefinition> addNamePropertyToPolicyType() {
+ Map<String, PropertyDefinition> policyTypeProperties = new HashMap<>();
+ policyTypeProperties.put(Constants.NAME_PROPERTY_NAME, DataModelUtil
+ .createPropertyDefinition(PropertyType.STRING.getDisplayName(), "The name of the policy",
+ false, null, null, null, null));
+ return policyTypeProperties;
+ }
+
+ private static Map<String, GroupType> createGroupTypes() {
+ Map<String, GroupType> globalGroupTypes = new HashMap<>();
+ globalGroupTypes.put(ToscaGroupType.HEAT_STACK.getDisplayName(), createHeatStackGroupType());
+ return globalGroupTypes;
+ }
+
+ private static GroupType createHeatStackGroupType() {
+ GroupType heatStackGroupType = new GroupType();
+ heatStackGroupType.setDerived_from(ToscaGroupType.ROOT.getDisplayName());
+ heatStackGroupType
+ .setDescription("Grouped all heat resources which are in the same heat stack");
+ heatStackGroupType.setProperties(createHeatStackGroupProperties());
+
+ return heatStackGroupType;
+ }
+
+ private static Map<String, PropertyDefinition> createHeatStackGroupProperties() {
+ Map<String, PropertyDefinition> propertiesDef = new HashMap<>();
+ propertiesDef.put("heat_file", DataModelUtil
+ .createPropertyDefinition(PropertyType.STRING.getDisplayName(),
+ "Heat file which associate to this group/heat stack", true, null, null, null, null));
+ propertiesDef.put(Constants.DESCRIPTION_PROPERTY_NAME, DataModelUtil
+ .createPropertyDefinition(PropertyType.STRING.getDisplayName(), "Heat file description",
+ false, null, null, null, null));
+ return propertiesDef;
+ }
+
+
+ /**
+ * Create common service template import import.
+ *
+ * @return the import
+ */
+ public static Import createCommonServiceTemplateImport() {
+ Import commonServiceTemplateImport = new Import();
+ commonServiceTemplateImport
+ .setFile(ToscaUtil.getServiceTemplateFileName(Constants.COMMON_GLOBAL_TEMPLATE_NAME));
+ return commonServiceTemplateImport;
+ }
+
+ private static Map<String, DataType> createGlobalDataTypes() {
+ Map<String, DataType> globalDataTypes = new HashMap<>();
+ globalDataTypes.put(ToscaDataType.NETWORK_ALLOCATION_POOL.getDisplayName(),
+ createAllocationPoolDataType());
+ globalDataTypes
+ .put(ToscaDataType.NETWORK_HOST_ROUTE.getDisplayName(), createHostRouteDataType());
+ globalDataTypes.put(ToscaDataType.NEUTRON_SUBNET.getDisplayName(), createSubnetDataType());
+ globalDataTypes
+ .put(ToscaDataType.NETWORK_ADDRESS_PAIR.getDisplayName(), createAddressPairDataType());
+ globalDataTypes.put(ToscaDataType.CONTRAIL_STATIC_ROUTE.getDisplayName(),
+ createContrailStaticRouteDataType());
+ globalDataTypes.put(ToscaDataType.CONTRAIL_ADDRESS_PAIR.getDisplayName(),
+ createContrailAddressPairDataType());
+ return globalDataTypes;
+ }
+
+ private static DataType createContrailStaticRouteDataType() {
+ DataType dataType = new DataType();
+ dataType.setDerived_from(ToscaDataType.ROOT.getDisplayName());
+ dataType.setDescription("static route");
+ Map<String, PropertyDefinition> prop = new HashMap<>();
+
+ prop.put("prefix", DataModelUtil
+ .createPropertyDefinition(PropertyType.STRING.getDisplayName(), "Route prefix", false, null,
+ null, null, null));
+ prop.put("next_hop", DataModelUtil
+ .createPropertyDefinition(PropertyType.STRING.getDisplayName(), "Next hop", false, null,
+ null, null, null));
+ prop.put("next_hop_type", DataModelUtil
+ .createPropertyDefinition(PropertyType.STRING.getDisplayName(), "Next hop type", false,
+ null, null, null, null));
+
+ dataType.setProperties(prop);
+ return dataType;
+ }
+
+ private static DataType createContrailAddressPairDataType() {
+ DataType dataType = new DataType();
+ dataType.setDerived_from(ToscaDataType.ROOT.getDisplayName());
+ dataType.setDescription("Address Pair");
+ Map<String, PropertyDefinition> prop = new HashMap<>();
+
+ prop.put("prefix", DataModelUtil
+ .createPropertyDefinition(PropertyType.STRING.getDisplayName(), "IP address prefix", false,
+ null, null, null, null));
+ prop.put("mac_address", DataModelUtil
+ .createPropertyDefinition(PropertyType.STRING.getDisplayName(), "Mac address", false, null,
+ null, null, null));
+ prop.put("address_mode", DataModelUtil
+ .createPropertyDefinition(PropertyType.STRING.getDisplayName(),
+ "Address mode active-active or active-standy", false,
+ DataModelUtil.createValidValuesConstraintsList("active-active", "active-standby"), null,
+ null, null));
+
+ dataType.setProperties(prop);
+ return dataType;
+ }
+
+ private static DataType createAddressPairDataType() {
+ DataType addressPairDataType = new DataType();
+ addressPairDataType.setDerived_from(ToscaDataType.ROOT.getDisplayName());
+ addressPairDataType.setDescription("MAC/IP address pairs");
+ Map<String, PropertyDefinition> addressPairProp = new HashMap<>();
+
+ addressPairProp.put("ip_address", DataModelUtil
+ .createPropertyDefinition(PropertyType.STRING.getDisplayName(), "IP address", false, null,
+ null, null, null));
+ addressPairProp.put("mac_address", DataModelUtil
+ .createPropertyDefinition(PropertyType.STRING.getDisplayName(), "MAC address", false, null,
+ null, null, null));
+ addressPairDataType.setProperties(addressPairProp);
+
+ return addressPairDataType;
+ }
+
+ private static DataType createHostRouteDataType() {
+ DataType hostRouteDataType = new DataType();
+ hostRouteDataType.setDerived_from(ToscaDataType.ROOT.getDisplayName());
+ hostRouteDataType.setDescription("Host route info for the subnet");
+
+ Map<String, PropertyDefinition> hostRoutePoolProp = new HashMap<>();
+ hostRoutePoolProp.put("destination", DataModelUtil
+ .createPropertyDefinition(PropertyType.STRING.getDisplayName(),
+ "The destination for static route", false, null, null, null, null));
+ hostRoutePoolProp.put("nexthop", DataModelUtil
+ .createPropertyDefinition(PropertyType.STRING.getDisplayName(),
+ "The next hop for the destination", false, null, null, null, null));
+ hostRouteDataType.setProperties(hostRoutePoolProp);
+
+ return hostRouteDataType;
+ }
+
+ private static DataType createAllocationPoolDataType() {
+ DataType allocationPoolDataType = new DataType();
+ allocationPoolDataType.setDerived_from(ToscaDataType.ROOT.getDisplayName());
+ allocationPoolDataType.setDescription("The start and end addresses for the allocation pool");
+
+ Map<String, PropertyDefinition> allocationPoolProp = new HashMap<>();
+ allocationPoolProp.put("start", DataModelUtil
+ .createPropertyDefinition(PropertyType.STRING.getDisplayName(),
+ "Start address for the allocation pool", false, null, null, null, null));
+ allocationPoolProp.put("end", DataModelUtil
+ .createPropertyDefinition(PropertyType.STRING.getDisplayName(),
+ "End address for the allocation pool", false, null, null, null, null));
+ allocationPoolDataType.setProperties(allocationPoolProp);
+
+ return allocationPoolDataType;
+ }
+
+ private static DataType createSubnetDataType() {
+ DataType subnetDataType = new DataType();
+ subnetDataType.setDerived_from(ToscaDataType.ROOT.getDisplayName());
+ subnetDataType.setDescription(
+ "A subnet represents an IP address block that can "
+ + "be used for assigning IP addresses to virtual instances");
+
+ Map<String, PropertyDefinition> subnetProp = new HashMap<>();
+ subnetProp.put("allocation_pools", DataModelUtil
+ .createPropertyDefinition(PropertyType.LIST.getDisplayName(),
+ "The start and end addresses for the allocation pools", false, null, null, DataModelUtil
+ .createEntrySchema(ToscaDataType.NETWORK_ALLOCATION_POOL.getDisplayName(), null,
+ null), null));
+ subnetProp.put("cidr", DataModelUtil
+ .createPropertyDefinition(PropertyType.STRING.getDisplayName(), "The CIDR", false, null,
+ null, null, null));
+ subnetProp.put("dns_nameservers", DataModelUtil
+ .createPropertyDefinition(PropertyType.LIST.getDisplayName(),
+ "A specified set of DNS name servers to be used", false, null, null,
+ DataModelUtil.createEntrySchema(PropertyType.STRING.getDisplayName(), null, null),
+ new ArrayList<String>()));
+ subnetProp.put("enable_dhcp", DataModelUtil
+ .createPropertyDefinition(PropertyType.BOOLEAN.getDisplayName(),
+ "Set to true if DHCP is enabled and false if DHCP is disabled", false, null, null, null,
+ true));
+ subnetProp.put("gateway_ip", DataModelUtil
+ .createPropertyDefinition(PropertyType.STRING.getDisplayName(), "The gateway IP address",
+ false, null, null, null, null));
+ subnetProp.put("host_routes", DataModelUtil
+ .createPropertyDefinition(PropertyType.LIST.getDisplayName(), "The gateway IP address",
+ false, null, null, DataModelUtil
+ .createEntrySchema(ToscaDataType.NETWORK_HOST_ROUTE.getDisplayName(), null, null),
+ null));
+ subnetProp.put("ip_version", DataModelUtil
+ .createPropertyDefinition(PropertyType.INTEGER.getDisplayName(), "The gateway IP address",
+ false, DataModelUtil.createValidValuesConstraintsList("4", "6"), null, null, 4));
+ subnetProp.put("ipv6_address_mode", DataModelUtil
+ .createPropertyDefinition(PropertyType.STRING.getDisplayName(), "IPv6 address mode", false,
+ DataModelUtil
+ .createValidValuesConstraintsList("dhcpv6-stateful", "dhcpv6-stateless", "slaac"),
+ null, null, null));
+ subnetProp.put("ipv6_ra_mode", DataModelUtil
+ .createPropertyDefinition(PropertyType.STRING.getDisplayName(),
+ "IPv6 RA (Router Advertisement) mode", false, DataModelUtil
+ .createValidValuesConstraintsList("dhcpv6-stateful", "dhcpv6-stateless", "slaac"),
+ null, null, null));
+ subnetProp.put(Constants.NAME_PROPERTY_NAME, DataModelUtil
+ .createPropertyDefinition(PropertyType.STRING.getDisplayName(), "The name of the subnet",
+ false, null, null, null, null));
+ subnetProp.put("prefixlen", DataModelUtil
+ .createPropertyDefinition(PropertyType.INTEGER.getDisplayName(),
+ "Prefix length for subnet allocation from subnet pool", false,
+ createPrefixlenConstraint(), null, null, null));
+ subnetProp.put("subnetpool", DataModelUtil
+ .createPropertyDefinition(PropertyType.STRING.getDisplayName(),
+ "The name or ID of the subnet pool", false, null, null, null, null));
+ subnetProp.put("tenant_id", DataModelUtil
+ .createPropertyDefinition(PropertyType.STRING.getDisplayName(),
+ "The ID of the tenant who owns the network", false, null, null, null, null));
+ subnetProp.put("value_specs", DataModelUtil
+ .createPropertyDefinition(PropertyType.MAP.getDisplayName(),
+ "Extra parameters to include in the request", false, null, null,
+ DataModelUtil.createEntrySchema(PropertyType.STRING.getDisplayName(), null, null),
+ new HashMap<>()));
+ subnetDataType.setProperties(subnetProp);
+
+ return subnetDataType;
+ }
+
+ private static List<Constraint> createPrefixlenConstraint() {
+ List<Constraint> constraints = new ArrayList<>();
+ Constraint constraint = new Constraint();
+ constraint.setGreater_or_equal(0);
+ constraints.add(constraint);
+ return constraints;
+ }
+}
diff --git a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/globaltypes/ContrailAbstractSubstituteGlobalType.java b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/globaltypes/ContrailAbstractSubstituteGlobalType.java
new file mode 100644
index 0000000000..7b0b810b61
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/globaltypes/ContrailAbstractSubstituteGlobalType.java
@@ -0,0 +1,196 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * SDC
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.sdc.translator.services.heattotosca.globaltypes;
+
+import org.openecomp.sdc.tosca.datatypes.ToscaDataType;
+import org.openecomp.sdc.tosca.datatypes.ToscaNodeType;
+import org.openecomp.sdc.tosca.datatypes.model.AttributeDefinition;
+import org.openecomp.sdc.tosca.datatypes.model.DataType;
+import org.openecomp.sdc.tosca.datatypes.model.NodeType;
+import org.openecomp.sdc.tosca.datatypes.model.PropertyDefinition;
+import org.openecomp.sdc.tosca.datatypes.model.PropertyType;
+import org.openecomp.sdc.tosca.datatypes.model.ServiceTemplate;
+import org.openecomp.sdc.tosca.services.DataModelUtil;
+import org.openecomp.sdc.tosca.services.ToscaConstants;
+import org.openecomp.sdc.translator.services.heattotosca.Constants;
+
+import java.util.HashMap;
+import java.util.Map;
+
+
+public class ContrailAbstractSubstituteGlobalType {
+
+ /**
+ * Create service template service template.
+ *
+ * @return the service template
+ */
+ public static ServiceTemplate createServiceTemplate() {
+ ServiceTemplate serviceTemplate = new ServiceTemplate();
+ serviceTemplate.setTosca_definitions_version(ToscaConstants.TOSCA_DEFINITIONS_VERSION);
+ serviceTemplate.setMetadata(
+ DataModelUtil.createMetadata(Constants
+ .CONTRAIL_ABSTRACT_SUBSTITUTE_TEMPLATE_NAME, "1.0.0", null));
+ serviceTemplate.setImports(GlobalTypesUtil.createCommonImportList());
+ serviceTemplate.setDescription("Contrail Abstract Substitute Global Types");
+ serviceTemplate.setData_types(createGlobalDataTypes());
+ serviceTemplate.setNode_types(createGlobalNodeTypes());
+ return serviceTemplate;
+ }
+
+ private static Map<String, NodeType> createGlobalNodeTypes() {
+ Map<String, NodeType> globalNodeTypes = new HashMap<>();
+ globalNodeTypes.put(ToscaNodeType.CONTRAIL_ABSTRACT_SUBSTITUTE.getDisplayName(),
+ createContrailAbstractSubstituteNodeType());
+ return globalNodeTypes;
+ }
+
+ private static NodeType createContrailAbstractSubstituteNodeType() {
+ NodeType nodeType = new NodeType();
+ nodeType.setDerived_from(ToscaNodeType.ABSTRACT_SUBSTITUTE.getDisplayName());
+ nodeType.setProperties(createContrailAbstractSubstituteProperties());
+ nodeType.setAttributes(createContrailAbstractSubstituteAttributes());
+
+ return nodeType;
+ }
+
+ private static Map<String, AttributeDefinition> createContrailAbstractSubstituteAttributes() {
+ Map<String, AttributeDefinition> attributesDefMap = new HashMap<>();
+ attributesDefMap.put("service_instance_name", DataModelUtil
+ .createAttributeDefinition(PropertyType.STRING.getDisplayName(),
+ "The name of the service instance", null, null, null));
+ attributesDefMap.put("fq_name", DataModelUtil
+ .createAttributeDefinition(PropertyType.STRING.getDisplayName(),
+ "The FQ name of the service instance", null, null, null));
+ attributesDefMap.put("status", DataModelUtil
+ .createAttributeDefinition(PropertyType.STRING.getDisplayName(),
+ "Status of the service instance", null, null, null));
+ attributesDefMap.put("service_template_name", DataModelUtil
+ .createAttributeDefinition(PropertyType.STRING.getDisplayName(),
+ "Service Template of the Service Instance", null, null, null));
+ attributesDefMap.put("virtual_machines", DataModelUtil
+ .createAttributeDefinition(PropertyType.STRING.getDisplayName(),
+ "Service VMs for the Service Instance", null, null, null));
+ attributesDefMap.put("active_vms", DataModelUtil
+ .createAttributeDefinition(PropertyType.STRING.getDisplayName(),
+ "Number of service VMs active for this Service Instance", null, null, null));
+ attributesDefMap.put("tenant_id", DataModelUtil
+ .createAttributeDefinition(PropertyType.STRING.getDisplayName(),
+ "Tenant id of the Service Instance", null, null, null));
+ attributesDefMap.put("show", DataModelUtil
+ .createAttributeDefinition(PropertyType.STRING.getDisplayName(), "All attributes", null,
+ null, null));
+
+ return attributesDefMap;
+ }
+
+ private static Map<String, PropertyDefinition> createContrailAbstractSubstituteProperties() {
+ Map<String, PropertyDefinition> props = new HashMap<>();
+ props.put("service_template_name", DataModelUtil
+ .createPropertyDefinition(PropertyType.STRING.getDisplayName(), "Service template name",
+ false, null, null, null, null));
+ props.put("service_mode", DataModelUtil
+ .createPropertyDefinition(PropertyType.STRING.getDisplayName(), "Service mode", true,
+ DataModelUtil
+ .createValidValuesConstraintsList("transparent", "in-network", "in-network-nat"),
+ null, null, null));
+ props.put("service_type", DataModelUtil
+ .createPropertyDefinition(PropertyType.STRING.getDisplayName(), "Service type", true,
+ DataModelUtil.createValidValuesConstraintsList("firewall", "analyzer", "source-nat",
+ "loadbalancer"), null, null, null));
+ props.put("image_name", DataModelUtil
+ .createPropertyDefinition(PropertyType.STRING.getDisplayName(), "Image name", true, null,
+ null, null, null));
+ props.put("flavor", DataModelUtil
+ .createPropertyDefinition(PropertyType.STRING.getDisplayName(), "flavor", false, null, null,
+ null, null));
+ props.put("service_interface_type_list", DataModelUtil
+ .createPropertyDefinition(PropertyType.LIST.getDisplayName(), "List of interface types",
+ true, null, null, DataModelUtil
+ .createEntrySchema(PropertyType.STRING.getDisplayName(), null, DataModelUtil
+ .createValidValuesConstraintsList("management", "left", "right", "other")),
+ null));
+ props.put("shared_ip_list", DataModelUtil
+ .createPropertyDefinition(PropertyType.LIST.getDisplayName(), "Shared ips enabled", false,
+ null, null,
+ DataModelUtil.createEntrySchema(PropertyType.BOOLEAN.getDisplayName(), null, null),
+ null));
+ props.put("static_routes_list", DataModelUtil
+ .createPropertyDefinition(PropertyType.LIST.getDisplayName(), "Static routes enabled",
+ false, null, null,
+ DataModelUtil.createEntrySchema(PropertyType.BOOLEAN.getDisplayName(), null, null),
+ null));
+ props.put("ordered_interfaces", DataModelUtil
+ .createPropertyDefinition(PropertyType.BOOLEAN.getDisplayName(),
+ "Indicates if service interface are ordered", false, null, null, null, false));
+ props.put("availability_zone_enable", DataModelUtil
+ .createPropertyDefinition(PropertyType.BOOLEAN.getDisplayName(),
+ "Indicates availability zone is enabled", false, null, null, null, false));
+ props.put("availability_zone", DataModelUtil
+ .createPropertyDefinition(PropertyType.STRING.getDisplayName(),
+ "Availability zone to create servers in", false, null, null, null, null));
+ props.put("service_instance_name", DataModelUtil
+ .createPropertyDefinition(PropertyType.STRING.getDisplayName(), "Service instance name",
+ true, null, null, null, null));
+ props.put("interface_list", DataModelUtil
+ .createPropertyDefinition(PropertyType.LIST.getDisplayName(), "List of interfaces", false,
+ null, null, DataModelUtil
+ .createEntrySchema(ToscaDataType.CONTRAIL_INTERFACE_DATA.getDisplayName(), null,
+ null), null));
+ return props;
+ }
+
+
+ private static Map<String, DataType> createGlobalDataTypes() {
+ Map<String, DataType> globalDataTypes = new HashMap<>();
+ globalDataTypes
+ .put(ToscaDataType.CONTRAIL_INTERFACE_DATA.getDisplayName(), createInterfaceDataType());
+ return globalDataTypes;
+ }
+
+ private static DataType createInterfaceDataType() {
+ DataType dataType = new DataType();
+ dataType.setDerived_from(ToscaDataType.ROOT.getDisplayName());
+ dataType.setDescription("Interface Data");
+ Map<String, PropertyDefinition> propertyDefMap = new HashMap<>();
+ propertyDefMap.put("virtual_network", DataModelUtil
+ .createPropertyDefinition(PropertyType.STRING.getDisplayName(),
+ "Virtual Network for this interface", true, null, null, null, null));
+ propertyDefMap.put("ip_address", DataModelUtil
+ .createPropertyDefinition(PropertyType.STRING.getDisplayName(), "IP for this interface",
+ false, null, null, null, null));
+ propertyDefMap.put("static_routes", DataModelUtil
+ .createPropertyDefinition(PropertyType.LIST.getDisplayName(),
+ "An ordered list of static routes to be added to this interface", false, null, null,
+ DataModelUtil
+ .createEntrySchema(ToscaDataType.CONTRAIL_STATIC_ROUTE.getDisplayName(), null,
+ null), null));
+ propertyDefMap.put("allowed_address_pairs", DataModelUtil
+ .createPropertyDefinition(PropertyType.LIST.getDisplayName(),
+ "List of allowed address pair for this interface", false, null, null, DataModelUtil
+ .createEntrySchema(ToscaDataType.CONTRAIL_ADDRESS_PAIR.getDisplayName(), null,
+ null), null));
+ dataType.setProperties(propertyDefMap);
+ return dataType;
+ }
+
+
+}
diff --git a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/globaltypes/ContrailComputeGlobalType.java b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/globaltypes/ContrailComputeGlobalType.java
new file mode 100644
index 0000000000..50faec0c69
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/globaltypes/ContrailComputeGlobalType.java
@@ -0,0 +1,128 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * SDC
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.sdc.translator.services.heattotosca.globaltypes;
+
+import org.openecomp.sdc.tosca.datatypes.ToscaNodeType;
+import org.openecomp.sdc.tosca.datatypes.model.AttributeDefinition;
+import org.openecomp.sdc.tosca.datatypes.model.NodeType;
+import org.openecomp.sdc.tosca.datatypes.model.PropertyDefinition;
+import org.openecomp.sdc.tosca.datatypes.model.PropertyType;
+import org.openecomp.sdc.tosca.datatypes.model.ServiceTemplate;
+import org.openecomp.sdc.tosca.services.DataModelUtil;
+import org.openecomp.sdc.tosca.services.ToscaConstants;
+import org.openecomp.sdc.translator.services.heattotosca.Constants;
+
+import java.util.HashMap;
+import java.util.Map;
+
+public class ContrailComputeGlobalType {
+
+ /**
+ * Create service template service template.
+ *
+ * @return the service template
+ */
+ public static ServiceTemplate createServiceTemplate() {
+ ServiceTemplate serviceTemplate = new ServiceTemplate();
+ serviceTemplate.setTosca_definitions_version(ToscaConstants.TOSCA_DEFINITIONS_VERSION);
+ serviceTemplate.setMetadata(
+ DataModelUtil.createMetadata(Constants.CONTRAIL_COMPUTE_TEMPLATE_NAME, "1.0.0", null));
+ serviceTemplate.setDescription("Contrail Compute TOSCA Global Types");
+ serviceTemplate.setImports(GlobalTypesUtil.createCommonImportList());
+ serviceTemplate.setNode_types(createGlobalNodeTypes());
+ return serviceTemplate;
+ }
+
+
+ private static Map<String, NodeType> createGlobalNodeTypes() {
+ Map<String, NodeType> globalNodeTypes = new HashMap<>();
+ globalNodeTypes
+ .put(ToscaNodeType.CONTRAIL_COMPUTE.getDisplayName(), createContrailComputeNodeType());
+ return globalNodeTypes;
+ }
+
+ private static NodeType createContrailComputeNodeType() {
+ NodeType nodeType = new NodeType();
+ nodeType.setDerived_from(ToscaNodeType.COMPUTE.getDisplayName());
+ nodeType.setProperties(createContrailComputeProperties());
+ nodeType.setAttributes(createContrailComputeAttributes());
+ return nodeType;
+ }
+
+
+ private static Map<String, PropertyDefinition> createContrailComputeProperties() {
+ Map<String, PropertyDefinition> propertyDefMap = new HashMap<>();
+ propertyDefMap.put("service_instance_name", DataModelUtil
+ .createPropertyDefinition(PropertyType.STRING.getDisplayName(), "Service instance name",
+ true, null, null, null, null));
+ propertyDefMap.put("service_template_name", DataModelUtil
+ .createPropertyDefinition(PropertyType.STRING.getDisplayName(), "Service template name",
+ false, null, null, null, null));
+ propertyDefMap.put("image_name", DataModelUtil
+ .createPropertyDefinition(PropertyType.STRING.getDisplayName(), "Image name", true, null,
+ null, null, null));
+ propertyDefMap.put("service_mode", DataModelUtil
+ .createPropertyDefinition(PropertyType.STRING.getDisplayName(), "Service mode", true,
+ DataModelUtil
+ .createValidValuesConstraintsList("transparent", "in-network", "in-network-nat"),
+ null, null, null));
+ propertyDefMap.put("service_type", DataModelUtil
+ .createPropertyDefinition(PropertyType.STRING.getDisplayName(), "Service type", true,
+ DataModelUtil.createValidValuesConstraintsList("firewall", "analyzer", "source-nat",
+ "loadbalancer"), null, null, null));
+ propertyDefMap.put("image_name", DataModelUtil
+ .createPropertyDefinition(PropertyType.STRING.getDisplayName(), "Image name", true, null,
+ null, null, null));
+ propertyDefMap.put("flavor", DataModelUtil
+ .createPropertyDefinition(PropertyType.STRING.getDisplayName(), "flavor", false, null, null,
+ null, null));
+ propertyDefMap.put("availability_zone_enable", DataModelUtil
+ .createPropertyDefinition(PropertyType.BOOLEAN.getDisplayName(),
+ "Indicates availability zone is enabled", false, null, null, null, false));
+ propertyDefMap.put("availability_zone", DataModelUtil
+ .createPropertyDefinition(PropertyType.STRING.getDisplayName(),
+ "Availability zone to create servers in", false, null, null, null, null));
+ return propertyDefMap;
+ }
+
+ private static Map<String, AttributeDefinition> createContrailComputeAttributes() {
+ Map<String, AttributeDefinition> attributesDefMap = new HashMap<>();
+ attributesDefMap.put("fq_name", DataModelUtil
+ .createAttributeDefinition(PropertyType.STRING.getDisplayName(), "fq_name", null, null,
+ null));
+ attributesDefMap.put("status", DataModelUtil
+ .createAttributeDefinition(PropertyType.STRING.getDisplayName(), "status of the compute",
+ null, null, null));
+ attributesDefMap.put("virtual_machines", DataModelUtil
+ .createAttributeDefinition(PropertyType.STRING.getDisplayName(), "VMs of this compute",
+ null, null, null));
+ attributesDefMap.put("active_vms", DataModelUtil
+ .createAttributeDefinition(PropertyType.STRING.getDisplayName(), "Number of active VMs",
+ null, null, null));
+ attributesDefMap.put("tenant_id", DataModelUtil
+ .createAttributeDefinition(PropertyType.STRING.getDisplayName(), "Tenant id of the VM",
+ null, null, null));
+ attributesDefMap.put("show", DataModelUtil
+ .createAttributeDefinition(PropertyType.STRING.getDisplayName(), "All attributes", null,
+ null, null));
+ return attributesDefMap;
+ }
+}
diff --git a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/globaltypes/ContrailNetworkRuleGlobalType.java b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/globaltypes/ContrailNetworkRuleGlobalType.java
new file mode 100644
index 0000000000..0081ad5a78
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/globaltypes/ContrailNetworkRuleGlobalType.java
@@ -0,0 +1,227 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * SDC
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.sdc.translator.services.heattotosca.globaltypes;
+
+import org.openecomp.sdc.tosca.datatypes.ToscaCapabilityType;
+import org.openecomp.sdc.tosca.datatypes.ToscaDataType;
+import org.openecomp.sdc.tosca.datatypes.ToscaNodeType;
+import org.openecomp.sdc.tosca.datatypes.ToscaRelationshipType;
+import org.openecomp.sdc.tosca.datatypes.model.AttributeDefinition;
+import org.openecomp.sdc.tosca.datatypes.model.DataType;
+import org.openecomp.sdc.tosca.datatypes.model.NodeType;
+import org.openecomp.sdc.tosca.datatypes.model.PropertyDefinition;
+import org.openecomp.sdc.tosca.datatypes.model.PropertyType;
+import org.openecomp.sdc.tosca.datatypes.model.RequirementDefinition;
+import org.openecomp.sdc.tosca.datatypes.model.ServiceTemplate;
+import org.openecomp.sdc.tosca.services.DataModelUtil;
+import org.openecomp.sdc.tosca.services.ToscaConstants;
+import org.openecomp.sdc.translator.services.heattotosca.Constants;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+public class ContrailNetworkRuleGlobalType {
+ /**
+ * Create service template service template.
+ *
+ * @return the service template
+ */
+ public static ServiceTemplate createServiceTemplate() {
+ ServiceTemplate contrailNetworkRuleServiceTemplate = new ServiceTemplate();
+ contrailNetworkRuleServiceTemplate
+ .setTosca_definitions_version(ToscaConstants.TOSCA_DEFINITIONS_VERSION);
+ contrailNetworkRuleServiceTemplate.setMetadata(
+ DataModelUtil.createMetadata(Constants.CONTRAIL_NETWORK_RULE_TEMPLATE_NAME, "1.0.0", null));
+ contrailNetworkRuleServiceTemplate.setImports(GlobalTypesUtil.createCommonImportList());
+ contrailNetworkRuleServiceTemplate.setDescription("Contrail Network Rule Global Types");
+ contrailNetworkRuleServiceTemplate.setData_types(createGlobalDataTypes());
+ contrailNetworkRuleServiceTemplate.setNode_types(createGlobalNodeTypes());
+ return contrailNetworkRuleServiceTemplate;
+ }
+
+
+ private static Map<String, DataType> createGlobalDataTypes() {
+ Map<String, DataType> globalDataTypes = new HashMap<>();
+ globalDataTypes.put(ToscaDataType.CONTRAIL_NETWORK_RULE_PORT_PAIRS.getDisplayName(),
+ createRulePortPairsDataType());
+ globalDataTypes.put(ToscaDataType.CONTRAIL_NETWORK_RULE.getDisplayName(), createRuleDataType());
+ globalDataTypes.put(ToscaDataType.CONTRAIL_NETWORK_RULE_VIRTUAL_NETWORK.getDisplayName(),
+ createRuleVirtualNetworkDataType());
+ globalDataTypes.put(ToscaDataType.CONTRAIL_NETWORK_RULE_LIST.getDisplayName(),
+ createPolicyRulesListDataType());
+ return globalDataTypes;
+ }
+
+ private static DataType createRuleDataType() {
+ DataType dataType = new DataType();
+ dataType.setDerived_from(ToscaDataType.ROOT.getDisplayName());
+ dataType.setDescription("policy rule");
+ Map<String, PropertyDefinition> properties = new HashMap<>();
+ properties.put("direction", DataModelUtil
+ .createPropertyDefinition(PropertyType.STRING.getDisplayName(), "Direction", false, null,
+ null, null, null));
+ properties.put("protocol", DataModelUtil
+ .createPropertyDefinition(PropertyType.STRING.getDisplayName(), "Protocol", false, null,
+ null, null, null));
+ properties.put("src_ports", DataModelUtil
+ .createPropertyDefinition(PropertyType.LIST.getDisplayName(), "Source ports", false, null,
+ null, DataModelUtil
+ .createEntrySchema(ToscaDataType.CONTRAIL_NETWORK_RULE_PORT_PAIRS.getDisplayName(),
+ null, null), null));
+ properties.put("dst_ports", DataModelUtil
+ .createPropertyDefinition(PropertyType.LIST.getDisplayName(), "Destination ports", false,
+ null, null, DataModelUtil
+ .createEntrySchema(ToscaDataType.CONTRAIL_NETWORK_RULE_PORT_PAIRS.getDisplayName(),
+ null, null), null));
+ properties.put("dst_addresses", DataModelUtil
+ .createPropertyDefinition(PropertyType.LIST.getDisplayName(), "Destination addresses",
+ false, null, null, DataModelUtil.createEntrySchema(
+ ToscaDataType.CONTRAIL_NETWORK_RULE_VIRTUAL_NETWORK.getDisplayName(), null, null),
+ null));
+ properties.put("apply_service", DataModelUtil
+ .createPropertyDefinition(PropertyType.STRING.getDisplayName(), "Service to apply", false,
+ null, null, null, null));
+ properties.put("src_addresses", DataModelUtil
+ .createPropertyDefinition(PropertyType.LIST.getDisplayName(), "Source addresses", false,
+ null, null, DataModelUtil.createEntrySchema(
+ ToscaDataType.CONTRAIL_NETWORK_RULE_VIRTUAL_NETWORK.getDisplayName(), null, null),
+ null));
+
+ dataType.setProperties(properties);
+ return dataType;
+
+ }
+
+
+ private static DataType createRuleVirtualNetworkDataType() {
+ DataType dataType = new DataType();
+ dataType.setDerived_from(ToscaDataType.ROOT.getDisplayName());
+ dataType.setDescription("source and destination addresses");
+ Map<String, PropertyDefinition> properties = new HashMap<>();
+
+ properties.put("virtual_network", DataModelUtil
+ .createPropertyDefinition(PropertyType.STRING.getDisplayName(), "Virtual network", false,
+ null, null, null, null));
+
+ dataType.setProperties(properties);
+ return dataType;
+ }
+
+ private static DataType createPolicyRulesListDataType() {
+ DataType dataType = new DataType();
+ dataType.setDerived_from(ToscaDataType.ROOT.getDisplayName());
+ dataType.setDescription("list of policy rules");
+ Map<String, PropertyDefinition> properties = new HashMap<>();
+
+ properties.put("policy_rule", DataModelUtil
+ .createPropertyDefinition(PropertyType.LIST.getDisplayName(), "Contrail network rule",
+ false, null, null, DataModelUtil
+ .createEntrySchema(ToscaDataType.CONTRAIL_NETWORK_RULE.getDisplayName(), null,
+ null), null));
+
+ dataType.setProperties(properties);
+ return dataType;
+ }
+
+
+ private static DataType createRulePortPairsDataType() {
+ DataType dataType = new DataType();
+ dataType.setDerived_from(ToscaDataType.ROOT.getDisplayName());
+ dataType.setDescription("source and destination port pairs");
+ Map<String, PropertyDefinition> properties = new HashMap<>();
+
+ properties.put("start_port", DataModelUtil
+ .createPropertyDefinition(PropertyType.STRING.getDisplayName(), "Start port", false, null,
+ null, null, null));
+ properties.put("end_port", DataModelUtil
+ .createPropertyDefinition(PropertyType.STRING.getDisplayName(), "End port", false, null,
+ null, null, null));
+
+ dataType.setProperties(properties);
+ return dataType;
+ }
+
+ private static Map<String, NodeType> createGlobalNodeTypes() {
+ Map<String, NodeType> globalNodeTypes = new HashMap<>();
+ globalNodeTypes.put(ToscaNodeType.CONTRAIL_NETWORK_RULE.getDisplayName(),
+ createContrailNetworkRuleNodeType());
+ return globalNodeTypes;
+ }
+
+ private static NodeType createContrailNetworkRuleNodeType() {
+ NodeType contrailNetworkRuleNodeType = new NodeType();
+ contrailNetworkRuleNodeType.setDerived_from(ToscaNodeType.ROOT.getDisplayName());
+ contrailNetworkRuleNodeType.setProperties(createContrailNetworkRuleProperties());
+ contrailNetworkRuleNodeType.setAttributes(createContrailNetworkRuleAttributes());
+ contrailNetworkRuleNodeType.setRequirements(createContrailNetworkRuleRequirements());
+ return contrailNetworkRuleNodeType;
+ }
+
+
+ private static Map<String, PropertyDefinition> createContrailNetworkRuleProperties() {
+ Map<String, PropertyDefinition> contrailNetworkRulePropertyDefMap = new HashMap<>();
+ contrailNetworkRulePropertyDefMap.put(Constants.NAME_PROPERTY_NAME, DataModelUtil
+ .createPropertyDefinition(PropertyType.STRING.getDisplayName(),
+ "A symbolic name for this contrail network rule", false, null, null, null, null));
+ contrailNetworkRulePropertyDefMap.put("entries", DataModelUtil
+ .createPropertyDefinition(ToscaDataType.CONTRAIL_NETWORK_RULE_LIST.getDisplayName(),
+ "A symbolic name for this contrail network rule", false, null, null, null, null));
+
+ return contrailNetworkRulePropertyDefMap;
+ }
+
+
+ private static Map<String, AttributeDefinition> createContrailNetworkRuleAttributes() {
+ Map<String, AttributeDefinition> contrailNetworkRuleAttributesDefMap = new HashMap<>();
+ contrailNetworkRuleAttributesDefMap.put("fq_name", DataModelUtil
+ .createAttributeDefinition(PropertyType.STRING.getDisplayName(), "fq_name", null, null,
+ null));
+ contrailNetworkRuleAttributesDefMap.put("tenant_id", DataModelUtil
+ .createAttributeDefinition(PropertyType.STRING.getDisplayName(), "tenant_id", null, null,
+ null));
+ contrailNetworkRuleAttributesDefMap.put("rules", DataModelUtil
+ .createAttributeDefinition(PropertyType.LIST.getDisplayName(), "List of rules", null,
+ DataModelUtil.createEntrySchema(PropertyType.STRING.getDisplayName(), null, null),
+ null));
+ contrailNetworkRuleAttributesDefMap.put("show", DataModelUtil
+ .createAttributeDefinition(PropertyType.STRING.getDisplayName(), "All attributes.", null,
+ null, null));
+
+ return contrailNetworkRuleAttributesDefMap;
+ }
+
+ private static List<Map<String, RequirementDefinition>> createContrailNetworkRuleRequirements() {
+ final List<Map<String, RequirementDefinition>> requirements = new ArrayList<>();
+ final Map<String, RequirementDefinition>
+ contrailNetworkRuleRequirementsDefMap = new HashMap<>();
+ RequirementDefinition req = new RequirementDefinition();
+ req.setCapability(ToscaCapabilityType.ATTACHMENT.getDisplayName());
+ req.setOccurrences(new Object[]{0, ToscaConstants.UNBOUNDED});
+ req.setNode(ToscaNodeType.NETWORK.getDisplayName());
+ req.setRelationship(ToscaRelationshipType.ATTACHES_TO.getDisplayName());
+ contrailNetworkRuleRequirementsDefMap.put("network", req);
+ requirements.add(contrailNetworkRuleRequirementsDefMap);
+
+ return requirements;
+ }
+}
diff --git a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/globaltypes/ContrailPortGlobalType.java b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/globaltypes/ContrailPortGlobalType.java
new file mode 100644
index 0000000000..1590372813
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/globaltypes/ContrailPortGlobalType.java
@@ -0,0 +1,107 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * SDC
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.sdc.translator.services.heattotosca.globaltypes;
+
+import org.openecomp.sdc.tosca.datatypes.ToscaDataType;
+import org.openecomp.sdc.tosca.datatypes.ToscaNodeType;
+import org.openecomp.sdc.tosca.datatypes.model.AttributeDefinition;
+import org.openecomp.sdc.tosca.datatypes.model.NodeType;
+import org.openecomp.sdc.tosca.datatypes.model.PropertyDefinition;
+import org.openecomp.sdc.tosca.datatypes.model.PropertyType;
+import org.openecomp.sdc.tosca.datatypes.model.ServiceTemplate;
+import org.openecomp.sdc.tosca.services.DataModelUtil;
+import org.openecomp.sdc.tosca.services.ToscaConstants;
+import org.openecomp.sdc.translator.services.heattotosca.Constants;
+
+import java.util.HashMap;
+import java.util.Map;
+
+public class ContrailPortGlobalType {
+ /**
+ * Create service template service template.
+ *
+ * @return the service template
+ */
+ public static ServiceTemplate createServiceTemplate() {
+ ServiceTemplate serviceTemplate = new ServiceTemplate();
+ serviceTemplate.setTosca_definitions_version(ToscaConstants.TOSCA_DEFINITIONS_VERSION);
+ serviceTemplate.setMetadata(
+ DataModelUtil.createMetadata(Constants.CONTRAIL_PORT_TEMPLATE_NAME, "1.0.0", null));
+ serviceTemplate.setImports(GlobalTypesUtil.createCommonImportList());
+ serviceTemplate.setDescription("Contrail Port TOSCA Global Types");
+ serviceTemplate.setNode_types(createGlobalNodeTypes());
+ return serviceTemplate;
+ }
+
+ private static Map<String, NodeType> createGlobalNodeTypes() {
+ Map<String, NodeType> globalNodeTypes = new HashMap<>();
+ globalNodeTypes.put(ToscaNodeType.CONTRAIL_PORT.getDisplayName(), createContrailPortNodeType());
+ return globalNodeTypes;
+ }
+
+ private static NodeType createContrailPortNodeType() {
+ NodeType nodeType = new NodeType();
+ nodeType.setDerived_from(ToscaNodeType.NETWORK_PORT.getDisplayName());
+ nodeType.setProperties(createContrailPortProperties());
+ nodeType.setAttributes(createContrailPortAttributes());
+ return nodeType;
+ }
+
+ private static Map<String, PropertyDefinition> createContrailPortProperties() {
+ Map<String, PropertyDefinition> propertyDefMap = new HashMap<>();
+ propertyDefMap.put("interface_type", DataModelUtil
+ .createPropertyDefinition(PropertyType.STRING.getDisplayName(), "Interface type", true,
+ DataModelUtil.createValidValuesConstraintsList("management", "left", "right", "other"),
+ null, null, null));
+ propertyDefMap.put("shared_ip", DataModelUtil
+ .createPropertyDefinition(PropertyType.BOOLEAN.getDisplayName(), "Shared ip enabled", false,
+ null, null, null, false));
+ propertyDefMap.put("static_route", DataModelUtil
+ .createPropertyDefinition(PropertyType.BOOLEAN.getDisplayName(), "Static route enabled",
+ false, null, null, null, false));
+ propertyDefMap.put("virtual_network", DataModelUtil
+ .createPropertyDefinition(PropertyType.STRING.getDisplayName(),
+ "Virtual Network for this interface", true, null, null, null, null));
+ propertyDefMap.put("static_routes", DataModelUtil
+ .createPropertyDefinition(PropertyType.LIST.getDisplayName(),
+ "An ordered list of static routes to be added to this interface", false, null, null,
+ DataModelUtil
+ .createEntrySchema(ToscaDataType.CONTRAIL_STATIC_ROUTE.getDisplayName(), null,
+ null), null));
+ propertyDefMap.put("allowed_address_pairs", DataModelUtil
+ .createPropertyDefinition(PropertyType.LIST.getDisplayName(),
+ "List of allowed address pair for this interface", false, null, null, DataModelUtil
+ .createEntrySchema(ToscaDataType.CONTRAIL_ADDRESS_PAIR.getDisplayName(), null,
+ null), null));
+ propertyDefMap.put("ip_address", DataModelUtil
+ .createPropertyDefinition(PropertyType.STRING.getDisplayName(), "IP for this interface",
+ false, null, null, null, null));
+ return propertyDefMap;
+ }
+
+ private static Map<String, AttributeDefinition> createContrailPortAttributes() {
+ Map<String, AttributeDefinition> attributesDefMap = new HashMap<>();
+ attributesDefMap.put("fq_name", DataModelUtil
+ .createAttributeDefinition(PropertyType.STRING.getDisplayName(), "fq_name", null, null,
+ null));
+ return attributesDefMap;
+ }
+}
diff --git a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/globaltypes/ContrailV2NetworkRuleGlobalType.java b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/globaltypes/ContrailV2NetworkRuleGlobalType.java
new file mode 100644
index 0000000000..4141aa7f0a
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/globaltypes/ContrailV2NetworkRuleGlobalType.java
@@ -0,0 +1,274 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * SDC
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.sdc.translator.services.heattotosca.globaltypes;
+
+import org.openecomp.sdc.tosca.datatypes.ToscaCapabilityType;
+import org.openecomp.sdc.tosca.datatypes.ToscaDataType;
+import org.openecomp.sdc.tosca.datatypes.ToscaNodeType;
+import org.openecomp.sdc.tosca.datatypes.ToscaRelationshipType;
+import org.openecomp.sdc.tosca.datatypes.model.AttributeDefinition;
+import org.openecomp.sdc.tosca.datatypes.model.DataType;
+import org.openecomp.sdc.tosca.datatypes.model.NodeType;
+import org.openecomp.sdc.tosca.datatypes.model.PropertyDefinition;
+import org.openecomp.sdc.tosca.datatypes.model.PropertyType;
+import org.openecomp.sdc.tosca.datatypes.model.RequirementDefinition;
+import org.openecomp.sdc.tosca.datatypes.model.ServiceTemplate;
+import org.openecomp.sdc.tosca.services.DataModelUtil;
+import org.openecomp.sdc.tosca.services.ToscaConstants;
+import org.openecomp.sdc.translator.services.heattotosca.Constants;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+public class ContrailV2NetworkRuleGlobalType {
+ /**
+ * Create service template service template.
+ *
+ * @return the service template
+ */
+ public static ServiceTemplate createServiceTemplate() {
+ ServiceTemplate contrailNetworkRuleServiceTemplate = new ServiceTemplate();
+ contrailNetworkRuleServiceTemplate
+ .setTosca_definitions_version(ToscaConstants.TOSCA_DEFINITIONS_VERSION);
+ contrailNetworkRuleServiceTemplate.setMetadata(
+ DataModelUtil.createMetadata(Constants
+ .CONTRAILV2_NETWORK_RULE_TEMPLATE_NAME, "1.0.0", null));
+ contrailNetworkRuleServiceTemplate.setImports(GlobalTypesUtil.createCommonImportList());
+ contrailNetworkRuleServiceTemplate.setDescription("Contrail V2 Network Rule Global Types");
+ contrailNetworkRuleServiceTemplate.setData_types(createGlobalDataTypes());
+ contrailNetworkRuleServiceTemplate.setNode_types(createGlobalNodeTypes());
+ return contrailNetworkRuleServiceTemplate;
+ }
+
+
+ private static Map<String, DataType> createGlobalDataTypes() {
+ Map<String, DataType> globalDataTypes = new HashMap<>();
+ globalDataTypes.put(ToscaDataType.CONTRAILV2_NETWORK_RULE_SRC_PORT_PAIRS.getDisplayName(),
+ createRuleSrcPortPairsDataType());
+ globalDataTypes.put(ToscaDataType.CONTRAILV2_NETWORK_RULE_DST_PORT_PAIRS.getDisplayName(),
+ createRuleDstPortPairsDataType());
+ globalDataTypes
+ .put(ToscaDataType.CONTRAILV2_NETWORK_RULE.getDisplayName(), createRuleDataType());
+ globalDataTypes.put(ToscaDataType.CONTRAILV2_NETWORK_RULE_DST_VIRTUAL_NETWORK.getDisplayName(),
+ createRuleDstVirtualNetworkDataType());
+ globalDataTypes.put(ToscaDataType.CONTRAILV2_NETWORK_RULE_SRC_VIRTUAL_NETWORK.getDisplayName(),
+ createRuleSrcVirtualNetworkDataType());
+ globalDataTypes.put(ToscaDataType.CONTRAILV2_NETWORK_RULE_LIST.getDisplayName(),
+ createPolicyRulesListDataType());
+ globalDataTypes.put(ToscaDataType.CONTRAILV2_NETWORK_RULE_ACTION_LIST.getDisplayName(),
+ createRuleActionListDataType());
+ return globalDataTypes;
+ }
+
+ private static DataType createRuleDataType() {
+ DataType dataType = new DataType();
+ dataType.setDerived_from(ToscaDataType.ROOT.getDisplayName());
+ dataType.setDescription("policy rule");
+ Map<String, PropertyDefinition> properties = new HashMap<>();
+ properties.put("network_policy_entries_policy_rule_direction", DataModelUtil
+ .createPropertyDefinition(PropertyType.STRING.getDisplayName(), "Direction", false, null,
+ null, null, null));
+ properties.put("network_policy_entries_policy_rule_protocol", DataModelUtil
+ .createPropertyDefinition(PropertyType.STRING.getDisplayName(), "Protocol", false, null,
+ null, null, null));
+ properties.put("network_policy_entries_policy_rule_src_ports", DataModelUtil
+ .createPropertyDefinition(PropertyType.LIST.getDisplayName(), "Source ports", false, null,
+ null, DataModelUtil.createEntrySchema(
+ ToscaDataType.CONTRAILV2_NETWORK_RULE_SRC_PORT_PAIRS.getDisplayName(), null, null),
+ null));
+ properties.put("network_policy_entries_policy_rule_dst_ports", DataModelUtil
+ .createPropertyDefinition(PropertyType.LIST.getDisplayName(), "Destination ports", false,
+ null, null, DataModelUtil.createEntrySchema(
+ ToscaDataType.CONTRAILV2_NETWORK_RULE_DST_PORT_PAIRS.getDisplayName(), null, null),
+ null));
+ properties.put("network_policy_entries_policy_rule_dst_addresses", DataModelUtil
+ .createPropertyDefinition(PropertyType.LIST.getDisplayName(), "Destination addresses",
+ false, null, null, DataModelUtil.createEntrySchema(
+ ToscaDataType.CONTRAILV2_NETWORK_RULE_DST_VIRTUAL_NETWORK.getDisplayName(), null,
+ null), null));
+ properties.put("network_policy_entries_policy_rule_src_addresses", DataModelUtil
+ .createPropertyDefinition(PropertyType.LIST.getDisplayName(), "Source addresses", false,
+ null, null, DataModelUtil.createEntrySchema(
+ ToscaDataType.CONTRAILV2_NETWORK_RULE_SRC_VIRTUAL_NETWORK.getDisplayName(), null,
+ null), null));
+ properties.put("network_policy_entries_policy_rule_action_list", DataModelUtil
+ .createPropertyDefinition(
+ ToscaDataType.CONTRAILV2_NETWORK_RULE_ACTION_LIST.getDisplayName(), "Action list",
+ false, null, null, null, null));
+
+ dataType.setProperties(properties);
+ return dataType;
+
+ }
+
+
+ private static DataType createRuleDstVirtualNetworkDataType() {
+ DataType dataType = new DataType();
+ dataType.setDerived_from(ToscaDataType.ROOT.getDisplayName());
+ dataType.setDescription("destination addresses");
+ Map<String, PropertyDefinition> properties = new HashMap<>();
+
+ properties.put("network_policy_entries_policy_rule_dst_addresses_virtual_network", DataModelUtil
+ .createPropertyDefinition(PropertyType.STRING.getDisplayName(),
+ "Destination addresses Virtual network", false, null, null, null, null));
+
+ dataType.setProperties(properties);
+ return dataType;
+ }
+
+ private static DataType createRuleSrcVirtualNetworkDataType() {
+ DataType dataType = new DataType();
+ dataType.setDerived_from(ToscaDataType.ROOT.getDisplayName());
+ dataType.setDescription("source addresses");
+ Map<String, PropertyDefinition> properties = new HashMap<>();
+
+ properties.put("network_policy_entries_policy_rule_src_addresses_virtual_network", DataModelUtil
+ .createPropertyDefinition(PropertyType.STRING.getDisplayName(),
+ "Source addresses Virtual network", false, null, null, null, null));
+
+ dataType.setProperties(properties);
+ return dataType;
+ }
+
+ private static DataType createPolicyRulesListDataType() {
+ DataType dataType = new DataType();
+ dataType.setDerived_from(ToscaDataType.ROOT.getDisplayName());
+ dataType.setDescription("list of policy rules");
+ Map<String, PropertyDefinition> properties = new HashMap<>();
+
+ properties.put("network_policy_entries_policy_rule", DataModelUtil
+ .createPropertyDefinition(PropertyType.LIST.getDisplayName(), "Contrail network rule",
+ false, null, null, DataModelUtil
+ .createEntrySchema(ToscaDataType.CONTRAILV2_NETWORK_RULE.getDisplayName(), null,
+ null), null));
+
+ dataType.setProperties(properties);
+ return dataType;
+ }
+
+ private static DataType createRuleActionListDataType() {
+ DataType dataType = new DataType();
+ dataType.setDerived_from(ToscaDataType.ROOT.getDisplayName());
+ dataType.setDescription("Action List");
+ Map<String, PropertyDefinition> properties = new HashMap<>();
+
+ properties.put("network_policy_entries_policy_rule_action_list_simple_action", DataModelUtil
+ .createPropertyDefinition(PropertyType.STRING.getDisplayName(), "Simple Action", false,
+ null, null, null, null));
+ properties.put("network_policy_entries_policy_rule_action_list_apply_service", DataModelUtil
+ .createPropertyDefinition(PropertyType.LIST.getDisplayName(), "Apply Service", false, null,
+ null, DataModelUtil.createEntrySchema(PropertyType.STRING.getDisplayName(), null, null),
+ null));
+
+ dataType.setProperties(properties);
+ return dataType;
+ }
+
+ private static DataType createRuleDstPortPairsDataType() {
+ DataType dataType = new DataType();
+ dataType.setDerived_from(ToscaDataType.ROOT.getDisplayName());
+ dataType.setDescription("destination port pairs");
+ Map<String, PropertyDefinition> properties = new HashMap<>();
+
+ properties.put("network_policy_entries_policy_rule_dst_ports_start_port", DataModelUtil
+ .createPropertyDefinition(PropertyType.STRING.getDisplayName(), "Start port", false, null,
+ null, null, null));
+ properties.put("network_policy_entries_policy_rule_dst_ports_end_port", DataModelUtil
+ .createPropertyDefinition(PropertyType.STRING.getDisplayName(), "End port", false, null,
+ null, null, null));
+
+ dataType.setProperties(properties);
+ return dataType;
+ }
+
+ private static DataType createRuleSrcPortPairsDataType() {
+ DataType dataType = new DataType();
+ dataType.setDerived_from(ToscaDataType.ROOT.getDisplayName());
+ dataType.setDescription("source port pairs");
+ Map<String, PropertyDefinition> properties = new HashMap<>();
+
+ properties.put("network_policy_entries_policy_rule_src_ports_start_port", DataModelUtil
+ .createPropertyDefinition(PropertyType.STRING.getDisplayName(), "Start port", false, null,
+ null, null, null));
+ properties.put("network_policy_entries_policy_rule_src_ports_end_port", DataModelUtil
+ .createPropertyDefinition(PropertyType.STRING.getDisplayName(), "End port", false, null,
+ null, null, null));
+
+ dataType.setProperties(properties);
+ return dataType;
+ }
+
+ private static Map<String, NodeType> createGlobalNodeTypes() {
+ Map<String, NodeType> globalNodeTypes = new HashMap<>();
+ globalNodeTypes.put(ToscaNodeType.CONTRAILV2_NETWORK_RULE.getDisplayName(),
+ createContrailV2NetworkRuleNodeType());
+ return globalNodeTypes;
+ }
+
+ private static NodeType createContrailV2NetworkRuleNodeType() {
+ NodeType contrailNetworkRuleNodeType = new NodeType();
+ contrailNetworkRuleNodeType.setDerived_from(ToscaNodeType.ROOT.getDisplayName());
+ contrailNetworkRuleNodeType.setProperties(createContrailNetworkRuleProperties());
+ contrailNetworkRuleNodeType.setAttributes(createContrailNetworkRuleAttributes());
+ contrailNetworkRuleNodeType.setRequirements(createContrailNetworkRuleRequirements());
+ return contrailNetworkRuleNodeType;
+ }
+
+
+ private static Map<String, PropertyDefinition> createContrailNetworkRuleProperties() {
+ Map<String, PropertyDefinition> contrailNetworkRulePropertyDefMap = new HashMap<>();
+ contrailNetworkRulePropertyDefMap.put(Constants.NAME_PROPERTY_NAME, DataModelUtil
+ .createPropertyDefinition(PropertyType.STRING.getDisplayName(),
+ "A symbolic name for this contrail v2 network rule", false, null, null, null, null));
+ contrailNetworkRulePropertyDefMap.put("network_policy_entries", DataModelUtil
+ .createPropertyDefinition(ToscaDataType.CONTRAILV2_NETWORK_RULE_LIST.getDisplayName(),
+ "A symbolic name for this contrail v2 network rule", false, null, null, null, null));
+
+ return contrailNetworkRulePropertyDefMap;
+ }
+
+
+ private static Map<String, AttributeDefinition> createContrailNetworkRuleAttributes() {
+ Map<String, AttributeDefinition> contrailNetworkRuleAttributesDefMap = new HashMap<>();
+ contrailNetworkRuleAttributesDefMap.put("fq_name", DataModelUtil
+ .createAttributeDefinition(PropertyType.STRING.getDisplayName(), "fq_name", null, null,
+ null));
+
+ return contrailNetworkRuleAttributesDefMap;
+ }
+
+ private static List<Map<String, RequirementDefinition>> createContrailNetworkRuleRequirements() {
+ final List<Map<String, RequirementDefinition>> requirements = new ArrayList<>();
+ final Map<String, RequirementDefinition>
+ contrailNetworkRuleRequirementsDefMap = new HashMap<>();
+ RequirementDefinition req = new RequirementDefinition();
+ req.setCapability(ToscaCapabilityType.ATTACHMENT.getDisplayName());
+ req.setOccurrences(new Object[]{0, ToscaConstants.UNBOUNDED});
+ req.setNode(ToscaNodeType.NETWORK.getDisplayName());
+ req.setRelationship(ToscaRelationshipType.ATTACHES_TO.getDisplayName());
+ contrailNetworkRuleRequirementsDefMap.put("network", req);
+ requirements.add(contrailNetworkRuleRequirementsDefMap);
+
+ return requirements;
+ }
+}
diff --git a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/globaltypes/ContrailV2VirtualMachineInterfaceGlobalType.java b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/globaltypes/ContrailV2VirtualMachineInterfaceGlobalType.java
new file mode 100644
index 0000000000..75501cb8d4
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/globaltypes/ContrailV2VirtualMachineInterfaceGlobalType.java
@@ -0,0 +1,136 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * SDC
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.sdc.translator.services.heattotosca.globaltypes;
+
+import org.openecomp.sdc.tosca.datatypes.ToscaDataType;
+import org.openecomp.sdc.tosca.datatypes.ToscaNodeType;
+import org.openecomp.sdc.tosca.datatypes.model.AttributeDefinition;
+import org.openecomp.sdc.tosca.datatypes.model.DataType;
+import org.openecomp.sdc.tosca.datatypes.model.NodeType;
+import org.openecomp.sdc.tosca.datatypes.model.PropertyDefinition;
+import org.openecomp.sdc.tosca.datatypes.model.PropertyType;
+import org.openecomp.sdc.tosca.datatypes.model.ServiceTemplate;
+import org.openecomp.sdc.tosca.services.DataModelUtil;
+import org.openecomp.sdc.tosca.services.ToscaConstants;
+import org.openecomp.sdc.translator.services.heattotosca.Constants;
+
+import java.util.HashMap;
+import java.util.Map;
+
+class ContrailV2VirtualMachineInterfaceGlobalType {
+ private ContrailV2VirtualMachineInterfaceGlobalType() {
+ }
+
+ public static ServiceTemplate createServiceTemplate() {
+ ServiceTemplate contrailVirtualMachineInterface = new ServiceTemplate();
+ contrailVirtualMachineInterface
+ .setTosca_definitions_version(ToscaConstants.TOSCA_DEFINITIONS_VERSION);
+ contrailVirtualMachineInterface.setMetadata(DataModelUtil
+ .createMetadata(Constants.CONTRAILV2_VIRTUAL_MACHINE_INTERFACE_TEMPLATE_NAME, "1.0.0",
+ null));
+ contrailVirtualMachineInterface.setImports(GlobalTypesUtil.createCommonImportList());
+ contrailVirtualMachineInterface
+ .setDescription("Contrail Virtual Machine Interface TOSCA Global Types");
+ contrailVirtualMachineInterface.setNode_types(createGlobalNodeTypes());
+ contrailVirtualMachineInterface.setData_types(createGlobalDataTypes());
+ return contrailVirtualMachineInterface;
+ }
+
+ private static Map<String, DataType> createGlobalDataTypes() {
+ Map<String, DataType> globalDataTypes = new HashMap<>();
+ globalDataTypes
+ .put(ToscaDataType.CONTRAILV2_VIRTUAL_MACHINE_INTERFACE_PROPERTIES.getDisplayName(),
+ createVmiPropertiesDataType());
+ return globalDataTypes;
+ }
+
+ private static DataType createVmiPropertiesDataType() {
+ DataType dataType = new DataType();
+ dataType.setDerived_from(ToscaDataType.ROOT.getDisplayName());
+ dataType.setDescription("Virtual Machine Interface Properties.");
+ Map<String, PropertyDefinition> properties = new HashMap<>();
+
+ properties.put("virtual_machine_interface_properties_service_interface_type", DataModelUtil
+ .createPropertyDefinition(PropertyType.STRING.getDisplayName(), "Service Interface Type.",
+ false, null, null, null, null));
+ dataType.setProperties(properties);
+ return dataType;
+ }
+
+ private static Map<String, NodeType> createGlobalNodeTypes() {
+ Map<String, NodeType> globalNodeTypes = new HashMap<>();
+ globalNodeTypes.put(ToscaNodeType.CONTRAILV2_VIRTUAL_MACHINE_INTERFACE.getDisplayName(),
+ createVmiNodeType());
+ return globalNodeTypes;
+ }
+
+ private static NodeType createVmiNodeType() {
+ NodeType nodeType = new NodeType();
+ nodeType.setDerived_from(ToscaNodeType.NETWORK_PORT.getDisplayName());
+ nodeType.setProperties(createVmiProperties());
+ nodeType.setAttributes(createVmiAttributes());
+ return nodeType;
+ }
+
+ private static Map<String, AttributeDefinition> createVmiAttributes() {
+ Map<String, AttributeDefinition> vmiAttributesDefMap = new HashMap<>();
+ vmiAttributesDefMap.put("fq_name", DataModelUtil
+ .createAttributeDefinition(PropertyType.STRING.getDisplayName(),
+ "The FQ name of the Virtual Network.", null, null, null));
+ vmiAttributesDefMap.put("show", DataModelUtil
+ .createAttributeDefinition(PropertyType.STRING.getDisplayName(), "All attributes.", null,
+ null, null));
+ return vmiAttributesDefMap;
+ }
+
+ private static Map<String, PropertyDefinition> createVmiProperties() {
+ Map<String, PropertyDefinition> virtualMachineInterfacePropertyDefMap = new HashMap<>();
+ virtualMachineInterfacePropertyDefMap.put(Constants.NAME_PROPERTY_NAME, DataModelUtil
+ .createPropertyDefinition(PropertyType.STRING.getDisplayName(),
+ "Virtual Machine Interface name", false, null, null, null, null));
+ virtualMachineInterfacePropertyDefMap.put("virtual_machine_intefrace_mac_addresses",
+ DataModelUtil
+ .createPropertyDefinition(PropertyType.LIST.getDisplayName(), "List of mac addresses.",
+ false, null, null,
+ DataModelUtil.createEntrySchema(PropertyType.STRING.getDisplayName(), null, null),
+ null));
+ virtualMachineInterfacePropertyDefMap.put("virtual_network_refs", DataModelUtil
+ .createPropertyDefinition(PropertyType.LIST.getDisplayName(), "List of virtual networks.",
+ false, null, null,
+ DataModelUtil.createEntrySchema(PropertyType.STRING.getDisplayName(), null, null),
+ null));
+ virtualMachineInterfacePropertyDefMap.put("port_tuple_refs", DataModelUtil
+ .createPropertyDefinition(PropertyType.LIST.getDisplayName(), "List of port tuples.", false,
+ null, null,
+ DataModelUtil.createEntrySchema(PropertyType.STRING.getDisplayName(), null, null),
+ null));
+ virtualMachineInterfacePropertyDefMap.put("security_group_refs", DataModelUtil
+ .createPropertyDefinition(PropertyType.LIST.getDisplayName(), "List of security groups.",
+ false, null, null,
+ DataModelUtil.createEntrySchema(PropertyType.STRING.getDisplayName(), null, null),
+ null));
+ virtualMachineInterfacePropertyDefMap.put("virtual_machine_interface_properties", DataModelUtil
+ .createPropertyDefinition(
+ ToscaDataType.CONTRAILV2_VIRTUAL_MACHINE_INTERFACE_PROPERTIES.getDisplayName(),
+ "virtual machine interface properties.", false, null, null, null, null));
+ return virtualMachineInterfacePropertyDefMap;
+ }
+}
diff --git a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/globaltypes/ContrailV2VirtualNetworkGlobalType.java b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/globaltypes/ContrailV2VirtualNetworkGlobalType.java
new file mode 100644
index 0000000000..728b9f6149
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/globaltypes/ContrailV2VirtualNetworkGlobalType.java
@@ -0,0 +1,239 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * SDC
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.sdc.translator.services.heattotosca.globaltypes;
+
+import org.openecomp.sdc.tosca.datatypes.ToscaDataType;
+import org.openecomp.sdc.tosca.datatypes.ToscaNodeType;
+import org.openecomp.sdc.tosca.datatypes.model.AttributeDefinition;
+import org.openecomp.sdc.tosca.datatypes.model.CapabilityDefinition;
+import org.openecomp.sdc.tosca.datatypes.model.DataType;
+import org.openecomp.sdc.tosca.datatypes.model.NodeType;
+import org.openecomp.sdc.tosca.datatypes.model.PropertyDefinition;
+import org.openecomp.sdc.tosca.datatypes.model.PropertyType;
+import org.openecomp.sdc.tosca.datatypes.model.ServiceTemplate;
+import org.openecomp.sdc.tosca.services.DataModelUtil;
+import org.openecomp.sdc.tosca.services.ToscaConstants;
+import org.openecomp.sdc.translator.services.heattotosca.Constants;
+
+import java.util.HashMap;
+import java.util.Map;
+
+public class ContrailV2VirtualNetworkGlobalType {
+
+ /**
+ * Create service template service template.
+ *
+ * @return the service template
+ */
+ public static ServiceTemplate createServiceTemplate() {
+ ServiceTemplate contrailVirtualNetworkServiceTemplate = new ServiceTemplate();
+ contrailVirtualNetworkServiceTemplate
+ .setTosca_definitions_version(ToscaConstants.TOSCA_DEFINITIONS_VERSION);
+ contrailVirtualNetworkServiceTemplate.setMetadata(DataModelUtil
+ .createMetadata(Constants.CONTRAILV2_VIRTUAL_NETWORK_TEMPLATE_NAME, "1.0.0", null));
+ contrailVirtualNetworkServiceTemplate
+ .setDescription("Contrail V2 Virtual Network Global Types");
+ contrailVirtualNetworkServiceTemplate.setImports(GlobalTypesUtil.createCommonImportList());
+ contrailVirtualNetworkServiceTemplate.setNode_types(createGlobalNodeTypes());
+ contrailVirtualNetworkServiceTemplate.setData_types(createGlobalDataTypes());
+ return contrailVirtualNetworkServiceTemplate;
+ }
+
+ private static Map<String, NodeType> createGlobalNodeTypes() {
+ Map<String, NodeType> globalNodeTypes = new HashMap<>();
+ globalNodeTypes.put(ToscaNodeType.CONTRAILV2_VIRTUAL_NETWORK.getDisplayName(),
+ createContrailVirtualNetworkNodeType());
+ return globalNodeTypes;
+ }
+
+ private static NodeType createContrailVirtualNetworkNodeType() {
+ NodeType contrailV2VirtualNetworkNodeType = new NodeType();
+ contrailV2VirtualNetworkNodeType.setDerived_from(ToscaNodeType.NETWORK.getDisplayName());
+ contrailV2VirtualNetworkNodeType.setProperties(createContrailVirtualNetworkProperties());
+ contrailV2VirtualNetworkNodeType.setAttributes(createContrailVirtualNetworkAttributes());
+ contrailV2VirtualNetworkNodeType.setCapabilities(createContrailVirtualNetworkCapabilities());
+ return contrailV2VirtualNetworkNodeType;
+ }
+
+ private static Map<String, CapabilityDefinition> createContrailVirtualNetworkCapabilities() {
+ Map<String, CapabilityDefinition> capabilities = new HashMap<>();
+ capabilities.put("attachment", GlobalTypesUtil.createAttachmentCapability());
+ return capabilities;
+ }
+
+ private static Map<String, PropertyDefinition> createContrailVirtualNetworkProperties() {
+ Map<String, PropertyDefinition> contrailVirtualNetworkPropertyDefMap = new HashMap<>();
+ //contrailVirtualNetworkPropertyDefMap.put("name", DataModelUtil.
+ // createPropertyDefinition(PropertyType.STRING.getDisplayName()
+ // , "Name", false, null, null, null, null));
+ contrailVirtualNetworkPropertyDefMap.put("network_ipam_refs", DataModelUtil
+ .createPropertyDefinition(PropertyType.LIST.getDisplayName(), "IPAM references", false,
+ null, null,
+ DataModelUtil.createEntrySchema(PropertyType.STRING.getDisplayName(), null, null),
+ null));
+ contrailVirtualNetworkPropertyDefMap.put("network_ipam_refs_data", DataModelUtil
+ .createPropertyDefinition(PropertyType.LIST.getDisplayName(), "IPAM references Data", false,
+ null, null, DataModelUtil.createEntrySchema(
+ ToscaDataType.CONTRAILV2_VIRTUAL_NETWORK_IPAM_REF_DATA.getDisplayName(), null,
+ null), null));
+ contrailVirtualNetworkPropertyDefMap.put("network_policy_refs", DataModelUtil
+ .createPropertyDefinition(PropertyType.LIST.getDisplayName(), "Policy references", false,
+ null, null,
+ DataModelUtil.createEntrySchema(PropertyType.STRING.getDisplayName(), null, null),
+ null));
+ contrailVirtualNetworkPropertyDefMap.put("network_policy_refs_data", DataModelUtil
+ .createPropertyDefinition(PropertyType.LIST.getDisplayName(), "Policy references data",
+ false, null, null, DataModelUtil.createEntrySchema(
+ ToscaDataType.CONTRAILV2_VIRTUAL_NETWORK_POLICY_REF_DATA.getDisplayName(), null,
+ null), null));
+ contrailVirtualNetworkPropertyDefMap.put("subnets", DataModelUtil
+ .createPropertyDefinition(PropertyType.MAP.getDisplayName(), "Network related subnets",
+ false, null, null, DataModelUtil
+ .createEntrySchema(ToscaDataType.NEUTRON_SUBNET.getDisplayName(), null, null),
+ null));
+ return contrailVirtualNetworkPropertyDefMap;
+ }
+
+ private static Map<String, DataType> createGlobalDataTypes() {
+ Map<String, DataType> globalDataTypes = new HashMap<>();
+ globalDataTypes.put(ToscaDataType.CONTRAILV2_VIRTUAL_NETWORK_IPAM_REF_DATA.getDisplayName(),
+ createVirtualNetworkIpamRefDataDataType());
+ globalDataTypes.put(
+ ToscaDataType.CONTRAILV2_VIRTUAL_NETWORK_IPAM_REF_DATA_IPAM_SUBNET_LIST.getDisplayName(),
+ createVirtualNetworkIpamRefDataIpanSubnetListDataType());
+ globalDataTypes
+ .put(ToscaDataType.CONTRAILV2_VIRTUAL_NETWORK_IPAM_REF_DATA_IPAM_SUBNET.getDisplayName(),
+ createVirtualNetworkIpamRefDataIpanSubnetDataType());
+ globalDataTypes.put(ToscaDataType.CONTRAILV2_VIRTUAL_NETWORK_POLICY_REF_DATA.getDisplayName(),
+ createVirtualNetworkPolicyRefDataDataType());
+ globalDataTypes
+ .put(ToscaDataType.CONTRAILV2_VIRTUAL_NETWORK_POLICY_REF_DATA_SEQUENCE.getDisplayName(),
+ createVirtualNetworkPolicyRefSequenceDataDataType());
+ return globalDataTypes;
+ }
+
+ private static DataType createVirtualNetworkIpamRefDataDataType() {
+ DataType dataType = new DataType();
+ dataType.setDerived_from(ToscaDataType.ROOT.getDisplayName());
+ dataType.setDescription("Network Ipam Ref Data");
+ Map<String, PropertyDefinition> properties = new HashMap<>();
+
+ properties.put("network_ipam_refs_data_ipam_subnets", DataModelUtil
+ .createPropertyDefinition(PropertyType.LIST.getDisplayName(),
+ "Network ipam refs data ipam subnets", false, null, null, DataModelUtil
+ .createEntrySchema(
+ ToscaDataType.CONTRAILV2_VIRTUAL_NETWORK_IPAM_REF_DATA_IPAM_SUBNET_LIST
+ .getDisplayName(), null, null), null));
+ dataType.setProperties(properties);
+ return dataType;
+ }
+
+ private static DataType createVirtualNetworkIpamRefDataIpanSubnetListDataType() {
+ DataType dataType = new DataType();
+ dataType.setDerived_from(ToscaDataType.ROOT.getDisplayName());
+ dataType.setDescription("Network Ipam Ref Data Subnet List");
+ Map<String, PropertyDefinition> properties = new HashMap<>();
+
+ properties.put("network_ipam_refs_data_ipam_subnets_subnet", DataModelUtil
+ .createPropertyDefinition(
+ ToscaDataType.CONTRAILV2_VIRTUAL_NETWORK_IPAM_REF_DATA_IPAM_SUBNET.getDisplayName(),
+ "Network ipam refs data ipam subnets", false, null, null, null, null));
+ properties.put("network_ipam_refs_data_ipam_subnets_addr_from_start", DataModelUtil
+ .createPropertyDefinition(PropertyType.STRING.getDisplayName(),
+ "Network ipam refs data ipam subnets addr from start", false, null, null, null, null));
+
+ dataType.setProperties(properties);
+ return dataType;
+ }
+
+ private static DataType createVirtualNetworkIpamRefDataIpanSubnetDataType() {
+ DataType dataType = new DataType();
+ dataType.setDerived_from(ToscaDataType.ROOT.getDisplayName());
+ dataType.setDescription("Network Ipam Ref Data Subnet");
+ Map<String, PropertyDefinition> properties = new HashMap<>();
+
+ properties.put("network_ipam_refs_data_ipam_subnets_subnet_ip_prefix", DataModelUtil
+ .createPropertyDefinition(PropertyType.STRING.getDisplayName(),
+ "Network ipam refs data ipam subnets ip prefix", false, null, null, null, null));
+ properties.put("network_ipam_refs_data_ipam_subnets_subnet_ip_prefix_len", DataModelUtil
+ .createPropertyDefinition(PropertyType.STRING.getDisplayName(),
+ "Network ipam refs data ipam subnets ip prefix len", false, null, null, null, null));
+ dataType.setProperties(properties);
+ return dataType;
+ }
+
+
+ private static DataType createVirtualNetworkPolicyRefDataDataType() {
+ DataType dataType = new DataType();
+ dataType.setDerived_from(ToscaDataType.ROOT.getDisplayName());
+ dataType.setDescription("network policy refs data");
+ Map<String, PropertyDefinition> properties = new HashMap<>();
+
+ properties.put("network_policy_refs_data_sequence", DataModelUtil.createPropertyDefinition(
+ ToscaDataType.CONTRAILV2_VIRTUAL_NETWORK_POLICY_REF_DATA_SEQUENCE.getDisplayName(),
+ "Network Policy ref data sequence", false, null, null, null, null));
+
+
+ dataType.setProperties(properties);
+ return dataType;
+ }
+
+
+ private static DataType createVirtualNetworkPolicyRefSequenceDataDataType() {
+ DataType dataType = new DataType();
+ dataType.setDerived_from(ToscaDataType.ROOT.getDisplayName());
+ dataType.setDescription("network policy refs data sequence");
+ Map<String, PropertyDefinition> properties = new HashMap<>();
+
+ properties.put("network_policy_refs_data_sequence_major", DataModelUtil
+ .createPropertyDefinition(PropertyType.INTEGER.getDisplayName(),
+ "Network Policy ref data sequence Major", false, null, null, null, null));
+ properties.put("network_policy_refs_data_sequence_minor", DataModelUtil
+ .createPropertyDefinition(PropertyType.INTEGER.getDisplayName(),
+ "Network Policy ref data sequence Minor", false, null, null, null, null));
+
+ dataType.setProperties(properties);
+ return dataType;
+ }
+
+ private static Map<String, AttributeDefinition> createContrailVirtualNetworkAttributes() {
+ Map<String, AttributeDefinition> contrailVirtualNetworkAttributesDefMap = new HashMap<>();
+ contrailVirtualNetworkAttributesDefMap.put("subnets_name", DataModelUtil
+ .createAttributeDefinition(PropertyType.LIST.getDisplayName(),
+ "Subnets name of this network", null,
+ DataModelUtil.createEntrySchema(PropertyType.STRING.getDisplayName(), null, null),
+ null));
+ contrailVirtualNetworkAttributesDefMap.put("subnets", DataModelUtil
+ .createAttributeDefinition(PropertyType.MAP.getDisplayName(), "Network related subnets",
+ null, DataModelUtil
+ .createEntrySchema(ToscaDataType.NEUTRON_SUBNET.getDisplayName(), null, null),
+ null));
+ contrailVirtualNetworkAttributesDefMap.put("subnets_show", DataModelUtil
+ .createAttributeDefinition(PropertyType.MAP.getDisplayName(),
+ "Detailed information about each subnet", null,
+ DataModelUtil.createEntrySchema(PropertyType.STRING.getDisplayName(), null, null),
+ null));
+ contrailVirtualNetworkAttributesDefMap.put("fq_name", DataModelUtil
+ .createAttributeDefinition(PropertyType.STRING.getDisplayName(), "fq_name", null, null,
+ null));
+ return contrailVirtualNetworkAttributesDefMap;
+ }
+}
diff --git a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/globaltypes/ContrailVirtualNetworkGlobalType.java b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/globaltypes/ContrailVirtualNetworkGlobalType.java
new file mode 100644
index 0000000000..1014757a2c
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/globaltypes/ContrailVirtualNetworkGlobalType.java
@@ -0,0 +1,134 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * SDC
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.sdc.translator.services.heattotosca.globaltypes;
+
+import org.openecomp.sdc.tosca.datatypes.ToscaDataType;
+import org.openecomp.sdc.tosca.datatypes.ToscaNodeType;
+import org.openecomp.sdc.tosca.datatypes.model.AttributeDefinition;
+import org.openecomp.sdc.tosca.datatypes.model.CapabilityDefinition;
+import org.openecomp.sdc.tosca.datatypes.model.NodeType;
+import org.openecomp.sdc.tosca.datatypes.model.PropertyDefinition;
+import org.openecomp.sdc.tosca.datatypes.model.PropertyType;
+import org.openecomp.sdc.tosca.datatypes.model.ServiceTemplate;
+import org.openecomp.sdc.tosca.services.DataModelUtil;
+import org.openecomp.sdc.tosca.services.ToscaConstants;
+import org.openecomp.sdc.translator.services.heattotosca.Constants;
+
+import java.util.HashMap;
+import java.util.Map;
+
+public class ContrailVirtualNetworkGlobalType {
+
+ /**
+ * Create service template service template.
+ *
+ * @return the service template
+ */
+ public static ServiceTemplate createServiceTemplate() {
+ ServiceTemplate contrailVirtualNetworkServiceTemplate = new ServiceTemplate();
+ contrailVirtualNetworkServiceTemplate
+ .setTosca_definitions_version(ToscaConstants.TOSCA_DEFINITIONS_VERSION);
+ contrailVirtualNetworkServiceTemplate.setMetadata(DataModelUtil
+ .createMetadata(Constants.CONTRAIL_VIRTUAL_NETWORK_TEMPLATE_NAME, "1.0.0", null));
+ contrailVirtualNetworkServiceTemplate.setDescription("Contrail Virtual Network Global Types");
+ contrailVirtualNetworkServiceTemplate.setImports(GlobalTypesUtil.createCommonImportList());
+ contrailVirtualNetworkServiceTemplate.setNode_types(createGlobalNodeTypes());
+ return contrailVirtualNetworkServiceTemplate;
+ }
+
+ private static Map<String, NodeType> createGlobalNodeTypes() {
+ Map<String, NodeType> globalNodeTypes = new HashMap<>();
+ globalNodeTypes.put(ToscaNodeType.CONTRAIL_VIRTUAL_NETWORK.getDisplayName(),
+ createContrailVirtualNetworkNodeType());
+ return globalNodeTypes;
+ }
+
+ private static NodeType createContrailVirtualNetworkNodeType() {
+ NodeType contrailVirtualNetworkNodeType = new NodeType();
+ contrailVirtualNetworkNodeType.setDerived_from(ToscaNodeType.NETWORK.getDisplayName());
+ contrailVirtualNetworkNodeType.setProperties(createContrailVirtualNetworkProperties());
+ contrailVirtualNetworkNodeType.setAttributes(createContrailVirtualNetworkAttributes());
+ contrailVirtualNetworkNodeType.setCapabilities(createContrailVirtualNetworkCapabilities());
+ return contrailVirtualNetworkNodeType;
+ }
+
+ private static Map<String, CapabilityDefinition> createContrailVirtualNetworkCapabilities() {
+ Map<String, CapabilityDefinition> capabilities = new HashMap<>();
+ capabilities.put("attachment", GlobalTypesUtil.createAttachmentCapability());
+ return capabilities;
+ }
+
+ private static Map<String, PropertyDefinition> createContrailVirtualNetworkProperties() {
+ Map<String, PropertyDefinition> contrailVirtualNetworkPropertyDefMap = new HashMap<>();
+ contrailVirtualNetworkPropertyDefMap.put("shared", DataModelUtil
+ .createPropertyDefinition(PropertyType.STRING.getDisplayName(), "Is virtual network shared",
+ false, null, null, null, null));
+ contrailVirtualNetworkPropertyDefMap.put("external", DataModelUtil
+ .createPropertyDefinition(PropertyType.STRING.getDisplayName(),
+ "Is virtual network external", false, null, null, null, null));
+ contrailVirtualNetworkPropertyDefMap.put("allow_transit", DataModelUtil
+ .createPropertyDefinition(PropertyType.STRING.getDisplayName(),
+ "Whether this network should be transitive.", false, null, null, null, null));
+ contrailVirtualNetworkPropertyDefMap.put("route_targets", DataModelUtil
+ .createPropertyDefinition(PropertyType.LIST.getDisplayName(),
+ "route targets associated with the virtual network", false, null, null,
+ DataModelUtil.createEntrySchema(PropertyType.STRING.getDisplayName(), null, null),
+ null));
+ contrailVirtualNetworkPropertyDefMap.put("forwarding_mode", DataModelUtil
+ .createPropertyDefinition(PropertyType.STRING.getDisplayName(),
+ "forwarding mode of the virtual network", false, null, null, null, null));
+ contrailVirtualNetworkPropertyDefMap.put("flood_unknown_unicast", DataModelUtil
+ .createPropertyDefinition(PropertyType.STRING.getDisplayName(),
+ "flood L2 packets on network", false, null, null, null, null));
+ contrailVirtualNetworkPropertyDefMap.put("subnets", DataModelUtil
+ .createPropertyDefinition(PropertyType.MAP.getDisplayName(), "Network related subnets",
+ false, null, null, DataModelUtil
+ .createEntrySchema(ToscaDataType.NEUTRON_SUBNET.getDisplayName(), null, null),
+ null));
+ return contrailVirtualNetworkPropertyDefMap;
+ }
+
+ private static Map<String, AttributeDefinition> createContrailVirtualNetworkAttributes() {
+ Map<String, AttributeDefinition> contrailVirtualNetworkAttributesDefMap = new HashMap<>();
+ contrailVirtualNetworkAttributesDefMap.put("subnets_name", DataModelUtil
+ .createAttributeDefinition(PropertyType.LIST.getDisplayName(),
+ "Subnets name of this network", null,
+ DataModelUtil.createEntrySchema(PropertyType.STRING.getDisplayName(), null, null),
+ null));
+ contrailVirtualNetworkAttributesDefMap.put("subnets", DataModelUtil
+ .createAttributeDefinition(PropertyType.MAP.getDisplayName(), "Network related subnets",
+ null, DataModelUtil
+ .createEntrySchema(ToscaDataType.NEUTRON_SUBNET.getDisplayName(), null, null),
+ null));
+ contrailVirtualNetworkAttributesDefMap.put("subnets_show", DataModelUtil
+ .createAttributeDefinition(PropertyType.MAP.getDisplayName(),
+ "Detailed information about each subnet", null,
+ DataModelUtil.createEntrySchema(PropertyType.STRING.getDisplayName(), null, null),
+ null));
+ contrailVirtualNetworkAttributesDefMap.put("fq_name", DataModelUtil
+ .createAttributeDefinition(PropertyType.STRING.getDisplayName(), "fq_name", null, null,
+ null));
+ contrailVirtualNetworkAttributesDefMap.put("show", DataModelUtil
+ .createAttributeDefinition(PropertyType.STRING.getDisplayName(), "All attributes.", null,
+ null, null));
+ return contrailVirtualNetworkAttributesDefMap;
+ }
+}
diff --git a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/globaltypes/GlobalTypesGenerator.java b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/globaltypes/GlobalTypesGenerator.java
new file mode 100644
index 0000000000..a4ec764e14
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/globaltypes/GlobalTypesGenerator.java
@@ -0,0 +1,128 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * SDC
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.sdc.translator.services.heattotosca.globaltypes;
+
+import org.openecomp.sdc.tosca.datatypes.model.Import;
+import org.openecomp.sdc.tosca.datatypes.model.ServiceTemplate;
+import org.openecomp.sdc.tosca.services.ToscaNativeTypesServiceTemplate;
+import org.openecomp.sdc.tosca.services.ToscaUtil;
+import org.openecomp.sdc.translator.services.heattotosca.Constants;
+
+import java.util.HashMap;
+import java.util.Map;
+
+public class GlobalTypesGenerator {
+
+ private GlobalTypesGenerator() {
+ }
+
+ /**
+ * Gets global types service template.
+ *
+ * @return the global types service template
+ */
+ public static Map<String, ServiceTemplate> getGlobalTypesServiceTemplate() {
+ Map<String, ServiceTemplate> serviceTemplates = new HashMap<>();
+
+ ToscaUtil.addServiceTemplateToMapWithKeyFileName(serviceTemplates,
+ CommonGlobalTypes.createServiceTemplate());
+ ToscaUtil.addServiceTemplateToMapWithKeyFileName(serviceTemplates,
+ NovaServerGlobalType.createServiceTemplate());
+ ToscaUtil.addServiceTemplateToMapWithKeyFileName(serviceTemplates,
+ CinderVolumeGlobalType.createServiceTemplate());
+ ToscaUtil.addServiceTemplateToMapWithKeyFileName(serviceTemplates,
+ ContrailVirtualNetworkGlobalType.createServiceTemplate());
+ ToscaUtil.addServiceTemplateToMapWithKeyFileName(serviceTemplates,
+ ContrailV2VirtualNetworkGlobalType.createServiceTemplate());
+ ToscaUtil.addServiceTemplateToMapWithKeyFileName(serviceTemplates,
+ ContrailV2VirtualMachineInterfaceGlobalType.createServiceTemplate());
+ ToscaUtil.addServiceTemplateToMapWithKeyFileName(serviceTemplates,
+ NeutronNetGlobalType.createServiceTemplate());
+ ToscaUtil.addServiceTemplateToMapWithKeyFileName(serviceTemplates,
+ NeutronPortGlobalType.createServiceTemplate());
+ ToscaUtil.addServiceTemplateToMapWithKeyFileName(serviceTemplates,
+ ContrailNetworkRuleGlobalType.createServiceTemplate());
+ ToscaUtil.addServiceTemplateToMapWithKeyFileName(serviceTemplates,
+ ContrailV2NetworkRuleGlobalType.createServiceTemplate());
+ ToscaUtil.addServiceTemplateToMapWithKeyFileName(serviceTemplates,
+ NeutronSecurityRulesGlobalType.createServiceTemplate());
+ ToscaUtil.addServiceTemplateToMapWithKeyFileName(serviceTemplates,
+ AbstractSubstituteGlobalType.createServiceTemplate());
+ ToscaUtil.addServiceTemplateToMapWithKeyFileName(serviceTemplates,
+ ToscaNativeTypesServiceTemplate.createServiceTemplate());
+ ToscaUtil.addServiceTemplateToMapWithKeyFileName(serviceTemplates,
+ ContrailComputeGlobalType.createServiceTemplate());
+ ToscaUtil.addServiceTemplateToMapWithKeyFileName(serviceTemplates,
+ ContrailPortGlobalType.createServiceTemplate());
+ ToscaUtil.addServiceTemplateToMapWithKeyFileName(serviceTemplates,
+ ContrailV2NetworkRuleGlobalType.createServiceTemplate());
+ ToscaUtil.addServiceTemplateToMapWithKeyFileName(serviceTemplates,
+ ContrailV2VirtualNetworkGlobalType.createServiceTemplate());
+ ToscaUtil.addServiceTemplateToMapWithKeyFileName(serviceTemplates,
+ ContrailAbstractSubstituteGlobalType.createServiceTemplate());
+ return serviceTemplates;
+ }
+
+ private static void addGlobalServiceTemplate(Map<String, ServiceTemplate> serviceTemplates,
+ ServiceTemplate commonServiceTemplate) {
+ serviceTemplates
+ .put(ToscaUtil.getServiceTemplateFileName(commonServiceTemplate), commonServiceTemplate);
+ }
+
+ /**
+ * Gets global types import list.
+ *
+ * @return the global types import list
+ */
+ public static Map<String, Import> getGlobalTypesImportList() {
+ Map<String, Import> globalImportMap = new HashMap<>();
+ globalImportMap.put(Constants.COMMON_GLOBAL_TEMPLATE_NAME,
+ GlobalTypesUtil.createServiceTemplateImport(Constants.COMMON_GLOBAL_TEMPLATE_NAME));
+ globalImportMap.put(Constants.NOVA_SERVER_TEMPLATE_NAME,
+ GlobalTypesUtil.createServiceTemplateImport(Constants.NOVA_SERVER_TEMPLATE_NAME));
+ globalImportMap.put(Constants.NEUTRON_PORT_TEMPLATE_NAME,
+ GlobalTypesUtil.createServiceTemplateImport(Constants.NEUTRON_PORT_TEMPLATE_NAME));
+ globalImportMap.put(Constants.NEUTRON_SECURITY_RULES_TEMPLATE_NAME, GlobalTypesUtil
+ .createServiceTemplateImport(Constants.NEUTRON_SECURITY_RULES_TEMPLATE_NAME));
+ globalImportMap.put(Constants.NEUTRON_NET_TEMPLATE_NAME,
+ GlobalTypesUtil.createServiceTemplateImport(Constants.NEUTRON_NET_TEMPLATE_NAME));
+ globalImportMap.put(Constants.CINDER_VOLUME_TEMPLATE_NAME,
+ GlobalTypesUtil.createServiceTemplateImport(Constants.CINDER_VOLUME_TEMPLATE_NAME));
+ globalImportMap.put(Constants.CONTRAIL_VIRTUAL_NETWORK_TEMPLATE_NAME, GlobalTypesUtil
+ .createServiceTemplateImport(Constants.CONTRAIL_VIRTUAL_NETWORK_TEMPLATE_NAME));
+ globalImportMap.put(Constants.CONTRAIL_NETWORK_RULE_TEMPLATE_NAME,
+ GlobalTypesUtil.createServiceTemplateImport(Constants.CONTRAIL_NETWORK_RULE_TEMPLATE_NAME));
+ globalImportMap.put(Constants.ABSTRACT_SUBSTITUTE_TEMPLATE_NAME,
+ GlobalTypesUtil.createServiceTemplateImport(Constants.ABSTRACT_SUBSTITUTE_TEMPLATE_NAME));
+ globalImportMap.put(Constants.CONTRAILV2_VIRTUAL_MACHINE_INTERFACE_TEMPLATE_NAME,
+ GlobalTypesUtil.createServiceTemplateImport(
+ Constants.CONTRAILV2_VIRTUAL_MACHINE_INTERFACE_TEMPLATE_NAME));
+ globalImportMap.put(Constants.CONTRAIL_COMPUTE_TEMPLATE_NAME,
+ GlobalTypesUtil.createServiceTemplateImport(Constants.CONTRAIL_COMPUTE_TEMPLATE_NAME));
+ globalImportMap.put(Constants.CONTRAIL_PORT_TEMPLATE_NAME,
+ GlobalTypesUtil.createServiceTemplateImport(Constants.CONTRAIL_PORT_TEMPLATE_NAME));
+ globalImportMap.put(Constants.CONTRAIL_ABSTRACT_SUBSTITUTE_TEMPLATE_NAME, GlobalTypesUtil
+ .createServiceTemplateImport(Constants.CONTRAIL_ABSTRACT_SUBSTITUTE_TEMPLATE_NAME));
+ return globalImportMap;
+ }
+
+
+}
diff --git a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/globaltypes/GlobalTypesUtil.java b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/globaltypes/GlobalTypesUtil.java
new file mode 100644
index 0000000000..9566dec581
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/globaltypes/GlobalTypesUtil.java
@@ -0,0 +1,69 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * SDC
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.sdc.translator.services.heattotosca.globaltypes;
+
+
+import org.openecomp.sdc.tosca.datatypes.ToscaCapabilityType;
+import org.openecomp.sdc.tosca.datatypes.model.CapabilityDefinition;
+import org.openecomp.sdc.tosca.datatypes.model.Import;
+import org.openecomp.sdc.tosca.services.ToscaUtil;
+
+import java.util.HashMap;
+import java.util.Map;
+
+public class GlobalTypesUtil {
+
+
+ /**
+ * Create common import list map.
+ *
+ * @return the map
+ */
+ public static Map<String, Import> createCommonImportList() {
+ Map<String, Import> importsMap = new HashMap<>();
+ importsMap.put("common_definitions", CommonGlobalTypes.createCommonServiceTemplateImport());
+ return importsMap;
+ }
+
+ /**
+ * Create attachment capability capability definition.
+ *
+ * @return the capability definition
+ */
+ public static CapabilityDefinition createAttachmentCapability() {
+ CapabilityDefinition capability = new CapabilityDefinition();
+ capability.setType(ToscaCapabilityType.ATTACHMENT.getDisplayName());
+
+ return capability;
+ }
+
+ /**
+ * Create service template import import.
+ *
+ * @param serviceTemplateName the service template name
+ * @return the import
+ */
+ public static Import createServiceTemplateImport(String serviceTemplateName) {
+ Import serviceTemplateImport = new Import();
+ serviceTemplateImport.setFile(ToscaUtil.getServiceTemplateFileName(serviceTemplateName));
+ return serviceTemplateImport;
+ }
+}
diff --git a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/globaltypes/NeutronNetGlobalType.java b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/globaltypes/NeutronNetGlobalType.java
new file mode 100644
index 0000000000..2532f87cf5
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/globaltypes/NeutronNetGlobalType.java
@@ -0,0 +1,143 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * SDC
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.sdc.translator.services.heattotosca.globaltypes;
+
+import org.openecomp.sdc.tosca.datatypes.ToscaDataType;
+import org.openecomp.sdc.tosca.datatypes.ToscaNodeType;
+import org.openecomp.sdc.tosca.datatypes.model.AttributeDefinition;
+import org.openecomp.sdc.tosca.datatypes.model.CapabilityDefinition;
+import org.openecomp.sdc.tosca.datatypes.model.NodeType;
+import org.openecomp.sdc.tosca.datatypes.model.PropertyDefinition;
+import org.openecomp.sdc.tosca.datatypes.model.PropertyType;
+import org.openecomp.sdc.tosca.datatypes.model.ServiceTemplate;
+import org.openecomp.sdc.tosca.services.DataModelUtil;
+import org.openecomp.sdc.tosca.services.ToscaConstants;
+import org.openecomp.sdc.translator.services.heattotosca.Constants;
+
+import java.util.HashMap;
+import java.util.Map;
+
+public class NeutronNetGlobalType {
+ /**
+ * Create service template service template.
+ *
+ * @return the service template
+ */
+ public static ServiceTemplate createServiceTemplate() {
+ ServiceTemplate neutronNetServiceTemplate = new ServiceTemplate();
+ neutronNetServiceTemplate
+ .setTosca_definitions_version(ToscaConstants.TOSCA_DEFINITIONS_VERSION);
+ neutronNetServiceTemplate.setMetadata(
+ DataModelUtil.createMetadata(Constants.NEUTRON_NET_TEMPLATE_NAME, "1.0.0", null));
+ neutronNetServiceTemplate.setDescription("Neutron Network TOSCA Global Types");
+ neutronNetServiceTemplate.setImports(GlobalTypesUtil.createCommonImportList());
+ neutronNetServiceTemplate.setNode_types(createGlobalNodeTypes());
+ return neutronNetServiceTemplate;
+ }
+
+
+ private static Map<String, NodeType> createGlobalNodeTypes() {
+ Map<String, NodeType> globalNodeTypes = new HashMap<>();
+ globalNodeTypes.put(ToscaNodeType.NEUTRON_NET.getDisplayName(), createNeutronNetworkNodeType());
+ return globalNodeTypes;
+ }
+
+ private static NodeType createNeutronNetworkNodeType() {
+ NodeType neutronNetworkNode = new NodeType();
+ neutronNetworkNode.setDerived_from(ToscaNodeType.NETWORK.getDisplayName());
+ neutronNetworkNode.setProperties(createNeutronNetworkProperties());
+ neutronNetworkNode.setAttributes(createNeutronNetworkAttributes());
+ neutronNetworkNode.setCapabilities(createNeutronNetworkCapabilities());
+
+ return neutronNetworkNode;
+ }
+
+ private static Map<String, CapabilityDefinition> createNeutronNetworkCapabilities() {
+ Map<String, CapabilityDefinition> capabilities = new HashMap<>();
+ capabilities.put("attachment", GlobalTypesUtil.createAttachmentCapability());
+ return capabilities;
+ }
+
+ private static Map<String, PropertyDefinition> createNeutronNetworkProperties() {
+ Map<String, PropertyDefinition> neutronNetworkPropertyDefMap = new HashMap<>();
+ neutronNetworkPropertyDefMap.put("admin_state_up", DataModelUtil
+ .createPropertyDefinition(PropertyType.BOOLEAN.getDisplayName(),
+ "A boolean value specifying the administrative status of the network", false, null,
+ null, null, true));
+ neutronNetworkPropertyDefMap.put("dhcp_agent_ids", DataModelUtil
+ .createPropertyDefinition(PropertyType.LIST.getDisplayName(),
+ "The IDs of the DHCP agent to schedule the network", false, null, null,
+ DataModelUtil.createEntrySchema(PropertyType.STRING.getDisplayName(), null, null),
+ null));
+ neutronNetworkPropertyDefMap.put("port_security_enabled", DataModelUtil
+ .createPropertyDefinition(PropertyType.BOOLEAN.getDisplayName(),
+ "Flag to enable/disable port security on the network", false, null, null, null, null));
+ neutronNetworkPropertyDefMap.put("qos_policy", DataModelUtil
+ .createPropertyDefinition(PropertyType.STRING.getDisplayName(),
+ "The name or ID of QoS policy to attach to this network", false, null, null, null,
+ null));
+ neutronNetworkPropertyDefMap.put("shared", DataModelUtil
+ .createPropertyDefinition(PropertyType.BOOLEAN.getDisplayName(),
+ "Whether this network should be shared across all tenants", false, null, null, null,
+ false));
+ neutronNetworkPropertyDefMap.put("tenant_id", DataModelUtil
+ .createPropertyDefinition(PropertyType.STRING.getDisplayName(),
+ "The ID of the tenant which will own the network", false, null, null, null, null));
+ neutronNetworkPropertyDefMap.put("value_specs", DataModelUtil
+ .createPropertyDefinition(PropertyType.MAP.getDisplayName(),
+ "Extra parameters to include in the request", false, null, null,
+ DataModelUtil.createEntrySchema(PropertyType.STRING.getDisplayName(), null, null),
+ new HashMap<String, String>()));
+ neutronNetworkPropertyDefMap.put("subnets", DataModelUtil
+ .createPropertyDefinition(PropertyType.MAP.getDisplayName(), "Network related subnets",
+ false, null, null, DataModelUtil
+ .createEntrySchema(ToscaDataType.NEUTRON_SUBNET.getDisplayName(), null, null),
+ null));
+ return neutronNetworkPropertyDefMap;
+ }
+
+ private static Map<String, AttributeDefinition> createNeutronNetworkAttributes() {
+ Map<String, AttributeDefinition> neutronNetworkAttributesDefMap = new HashMap<>();
+ neutronNetworkAttributesDefMap.put("mtu", DataModelUtil
+ .createAttributeDefinition(PropertyType.SCALAR_UNIT_SIZE.getDisplayName(),
+ "The maximum transmission unit size(in bytes) for the network", null, null, null));
+ neutronNetworkAttributesDefMap.put("qos_policy_id", DataModelUtil
+ .createAttributeDefinition(PropertyType.STRING.getDisplayName(),
+ "The QoS policy ID attached to this network", null, null, null));
+ neutronNetworkAttributesDefMap.put("show", DataModelUtil
+ .createAttributeDefinition(PropertyType.STRING.getDisplayName(),
+ "Detailed information about resource", null, null, null));
+ neutronNetworkAttributesDefMap.put("status", DataModelUtil
+ .createAttributeDefinition(PropertyType.STRING.getDisplayName(),
+ "The status of the network", null, null, null));
+ neutronNetworkAttributesDefMap.put("subnets_name", DataModelUtil
+ .createAttributeDefinition(PropertyType.LIST.getDisplayName(),
+ "Subnets name of this network", null,
+ DataModelUtil.createEntrySchema(PropertyType.STRING.getDisplayName(), null, null),
+ null));
+ neutronNetworkAttributesDefMap.put("subnets", DataModelUtil
+ .createAttributeDefinition(PropertyType.MAP.getDisplayName(), "Network related subnets",
+ null, DataModelUtil
+ .createEntrySchema(ToscaDataType.NEUTRON_SUBNET.getDisplayName(), null, null),
+ null));
+ return neutronNetworkAttributesDefMap;
+ }
+}
diff --git a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/globaltypes/NeutronPortGlobalType.java b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/globaltypes/NeutronPortGlobalType.java
new file mode 100644
index 0000000000..2106b9b3bc
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/globaltypes/NeutronPortGlobalType.java
@@ -0,0 +1,203 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * SDC
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.sdc.translator.services.heattotosca.globaltypes;
+
+import org.openecomp.sdc.tosca.datatypes.ToscaDataType;
+import org.openecomp.sdc.tosca.datatypes.ToscaNodeType;
+import org.openecomp.sdc.tosca.datatypes.model.AttributeDefinition;
+import org.openecomp.sdc.tosca.datatypes.model.CapabilityDefinition;
+import org.openecomp.sdc.tosca.datatypes.model.Constraint;
+import org.openecomp.sdc.tosca.datatypes.model.DataType;
+import org.openecomp.sdc.tosca.datatypes.model.NodeType;
+import org.openecomp.sdc.tosca.datatypes.model.PropertyDefinition;
+import org.openecomp.sdc.tosca.datatypes.model.PropertyType;
+import org.openecomp.sdc.tosca.datatypes.model.ServiceTemplate;
+import org.openecomp.sdc.tosca.services.DataModelUtil;
+import org.openecomp.sdc.tosca.services.ToscaConstants;
+import org.openecomp.sdc.translator.services.heattotosca.Constants;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+public class NeutronPortGlobalType {
+ /**
+ * Create service template service template.
+ *
+ * @return the service template
+ */
+ public static ServiceTemplate createServiceTemplate() {
+ ServiceTemplate neutronPortServiceTemplate = new ServiceTemplate();
+ neutronPortServiceTemplate
+ .setTosca_definitions_version(ToscaConstants.TOSCA_DEFINITIONS_VERSION);
+ neutronPortServiceTemplate.setMetadata(
+ DataModelUtil.createMetadata(Constants.NEUTRON_PORT_TEMPLATE_NAME, "1.0.0", null));
+ neutronPortServiceTemplate.setImports(GlobalTypesUtil.createCommonImportList());
+ neutronPortServiceTemplate.setDescription("Neutron Port TOSCA Global Types");
+ neutronPortServiceTemplate.setData_types(createGlobalDataTypes());
+ neutronPortServiceTemplate.setNode_types(createGlobalNodeTypes());
+ return neutronPortServiceTemplate;
+ }
+
+ private static Map<String, DataType> createGlobalDataTypes() {
+ Map<String, DataType> globalDataTypes = new HashMap<>();
+ globalDataTypes
+ .put(ToscaDataType.NEUTRON_PORT_FIXED_IPS.getDisplayName(), createFixedIpsDataType());
+ return globalDataTypes;
+ }
+
+ private static DataType createFixedIpsDataType() {
+ DataType dataType = new DataType();
+ dataType.setDerived_from(ToscaDataType.ROOT.getDisplayName());
+ dataType.setDescription("subnet/ip_address");
+ Map<String, PropertyDefinition> prop = new HashMap<>();
+
+ prop.put("subnet", DataModelUtil.createPropertyDefinition(PropertyType.STRING.getDisplayName(),
+ "Subnet in which to allocate the IP address for this port", false, null, null, null, null));
+ prop.put("ip_address", DataModelUtil
+ .createPropertyDefinition(PropertyType.STRING.getDisplayName(),
+ "IP address desired in the subnet for this port", false, null, null, null, null));
+
+ dataType.setProperties(prop);
+ return dataType;
+ }
+
+ private static Map<String, NodeType> createGlobalNodeTypes() {
+ Map<String, NodeType> globalNodeTypes = new HashMap<>();
+ globalNodeTypes.put(ToscaNodeType.NEUTRON_PORT.getDisplayName(), createNeutronPortNodeType());
+ return globalNodeTypes;
+ }
+
+ private static NodeType createNeutronPortNodeType() {
+ NodeType nodeType = new NodeType();
+ nodeType.setDerived_from(ToscaNodeType.NETWORK_PORT.getDisplayName());
+ nodeType.setProperties(createNeutronPortProperties());
+ nodeType.setAttributes(createNeutronPortAttributes());
+ nodeType.setCapabilities(createNeutronPortCapabilities());
+ return nodeType;
+ }
+
+ private static Map<String, CapabilityDefinition> createNeutronPortCapabilities() {
+ Map<String, CapabilityDefinition> capabilities = new HashMap<>();
+ capabilities.put("attachment", GlobalTypesUtil.createAttachmentCapability());
+ return capabilities;
+ }
+
+ private static Map<String, PropertyDefinition> createNeutronPortProperties() {
+ Map<String, PropertyDefinition> neutronPortPropertyDefMap = new HashMap<>();
+ neutronPortPropertyDefMap.put("admin_state_up", DataModelUtil
+ .createPropertyDefinition(PropertyType.BOOLEAN.getDisplayName(),
+ "A boolean value specifying the administrative status of the network", false, null,
+ null, null, true));
+ neutronPortPropertyDefMap.put("allowed_address_pairs", DataModelUtil
+ .createPropertyDefinition(PropertyType.LIST.getDisplayName(),
+ "Additional MAC/IP address pairs allowed to pass through the port", false, null, null,
+ DataModelUtil
+ .createEntrySchema(ToscaDataType.NETWORK_ADDRESS_PAIR.getDisplayName(), null, null),
+ null));
+ neutronPortPropertyDefMap.put("binding:vnic_type", DataModelUtil
+ .createPropertyDefinition(PropertyType.STRING.getDisplayName(),
+ "The vnic type to be bound on the neutron port", false, createBindingConstraint(), null,
+ null, null));
+ neutronPortPropertyDefMap.put("device_id", DataModelUtil
+ .createPropertyDefinition(PropertyType.STRING.getDisplayName(), "Device ID of this port",
+ false, null, null, null, null));
+ neutronPortPropertyDefMap.put("device_owner", DataModelUtil
+ .createPropertyDefinition(PropertyType.STRING.getDisplayName(),
+ "Name of the network owning the port", false, null, null, null, null));
+ neutronPortPropertyDefMap.put("fixed_ips", DataModelUtil
+ .createPropertyDefinition(PropertyType.LIST.getDisplayName(), "Desired IPs for this port",
+ false, null, null, DataModelUtil
+ .createEntrySchema(ToscaDataType.NEUTRON_PORT_FIXED_IPS.getDisplayName(), null,
+ null), null));
+ neutronPortPropertyDefMap.put("mac_address", DataModelUtil
+ .createPropertyDefinition(PropertyType.STRING.getDisplayName(),
+ "MAC address to give to this port", false, null, null, null, null));
+ neutronPortPropertyDefMap.put(Constants.NAME_PROPERTY_NAME, DataModelUtil
+ .createPropertyDefinition(PropertyType.STRING.getDisplayName(),
+ "A symbolic name for this port", false, null, null, null, null));
+ neutronPortPropertyDefMap.put("port_security_enabled", DataModelUtil
+ .createPropertyDefinition(PropertyType.BOOLEAN.getDisplayName(),
+ "Flag to enable/disable port security on the network", false, null, null, null, null));
+ neutronPortPropertyDefMap.put("qos_policy", DataModelUtil
+ .createPropertyDefinition(PropertyType.STRING.getDisplayName(),
+ "The name or ID of QoS policy to attach to this network", false, null, null, null,
+ null));
+ neutronPortPropertyDefMap.put(Constants.SECURITY_GROUPS_PROPERTY_NAME, DataModelUtil
+ .createPropertyDefinition(PropertyType.LIST.getDisplayName(),
+ "List of security group names or IDs", false, null, null,
+ DataModelUtil.createEntrySchema(PropertyType.STRING.getDisplayName(), null, null),
+ null));
+ neutronPortPropertyDefMap.put("value_specs", DataModelUtil
+ .createPropertyDefinition(PropertyType.MAP.getDisplayName(),
+ "Extra parameters to include in the request", false, null, null,
+ DataModelUtil.createEntrySchema(PropertyType.STRING.getDisplayName(), null, null),
+ new HashMap<String, String>()));
+ neutronPortPropertyDefMap.put("replacement_policy", DataModelUtil
+ .createPropertyDefinition(PropertyType.STRING.getDisplayName(),
+ "Policy on how to respond to a stack-update for this resource", false,
+ createReplacementPolicyConstrain(), null, null, "AUTO"));
+ neutronPortPropertyDefMap.put("network", DataModelUtil
+ .createPropertyDefinition(PropertyType.STRING.getDisplayName(),
+ "Network this port belongs to", false, null, null, null, null));
+ return neutronPortPropertyDefMap;
+ }
+
+ private static List<Constraint> createBindingConstraint() {
+ List<Constraint> constraints = new ArrayList<>();
+ Constraint validValues =
+ DataModelUtil.createValidValuesConstraint("macvtap", "direct", "normal");
+ constraints.add(validValues);
+ return constraints;
+ }
+
+ private static List<Constraint> createReplacementPolicyConstrain() {
+ List<Constraint> constraints = new ArrayList<>();
+ Constraint validValues = DataModelUtil.createValidValuesConstraint("REPLACE_ALWAYS", "AUTO");
+ constraints.add(validValues);
+ return constraints;
+ }
+
+ private static Map<String, AttributeDefinition> createNeutronPortAttributes() {
+ Map<String, AttributeDefinition> neutronPortAttributesDefMap = new HashMap<>();
+ neutronPortAttributesDefMap.put("network_id", DataModelUtil
+ .createAttributeDefinition(PropertyType.STRING.getDisplayName(),
+ "Unique identifier for the network owning the port", null, null, null));
+ neutronPortAttributesDefMap.put("qos_policy_id", DataModelUtil
+ .createAttributeDefinition(PropertyType.STRING.getDisplayName(),
+ "The QoS policy ID attached to this network", null, null, null));
+ neutronPortAttributesDefMap.put("show", DataModelUtil
+ .createAttributeDefinition(PropertyType.STRING.getDisplayName(),
+ "Detailed information about resource", null, null, null));
+ neutronPortAttributesDefMap.put("status", DataModelUtil
+ .createAttributeDefinition(PropertyType.STRING.getDisplayName(),
+ "The status of the network", null, null, null));
+ neutronPortAttributesDefMap.put("subnets", DataModelUtil
+ .createAttributeDefinition(PropertyType.LIST.getDisplayName(), "Subnets of this network",
+ null, DataModelUtil.createEntrySchema(PropertyType.STRING.getDisplayName(), null, null),
+ null));
+ neutronPortAttributesDefMap.put("tenant_id", DataModelUtil
+ .createAttributeDefinition(PropertyType.STRING.getDisplayName(), "Tenant owning the port",
+ null, null, null));
+ return neutronPortAttributesDefMap;
+ }
+}
diff --git a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/globaltypes/NeutronSecurityRulesGlobalType.java b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/globaltypes/NeutronSecurityRulesGlobalType.java
new file mode 100644
index 0000000000..4c5b033e0e
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/globaltypes/NeutronSecurityRulesGlobalType.java
@@ -0,0 +1,175 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * SDC
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.sdc.translator.services.heattotosca.globaltypes;
+
+import org.openecomp.sdc.tosca.datatypes.ToscaCapabilityType;
+import org.openecomp.sdc.tosca.datatypes.ToscaDataType;
+import org.openecomp.sdc.tosca.datatypes.ToscaNodeType;
+import org.openecomp.sdc.tosca.datatypes.ToscaRelationshipType;
+import org.openecomp.sdc.tosca.datatypes.model.AttributeDefinition;
+import org.openecomp.sdc.tosca.datatypes.model.Constraint;
+import org.openecomp.sdc.tosca.datatypes.model.DataType;
+import org.openecomp.sdc.tosca.datatypes.model.NodeType;
+import org.openecomp.sdc.tosca.datatypes.model.PropertyDefinition;
+import org.openecomp.sdc.tosca.datatypes.model.PropertyType;
+import org.openecomp.sdc.tosca.datatypes.model.RequirementDefinition;
+import org.openecomp.sdc.tosca.datatypes.model.ServiceTemplate;
+import org.openecomp.sdc.tosca.services.DataModelUtil;
+import org.openecomp.sdc.tosca.services.ToscaConstants;
+import org.openecomp.sdc.translator.services.heattotosca.Constants;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+public class NeutronSecurityRulesGlobalType {
+ /**
+ * Create service template service template.
+ *
+ * @return the service template
+ */
+ public static ServiceTemplate createServiceTemplate() {
+ ServiceTemplate neutronSecurityRulesServiceTemplate = new ServiceTemplate();
+ neutronSecurityRulesServiceTemplate
+ .setTosca_definitions_version(ToscaConstants.TOSCA_DEFINITIONS_VERSION);
+ neutronSecurityRulesServiceTemplate.setMetadata(DataModelUtil
+ .createMetadata(Constants.NEUTRON_SECURITY_RULES_TEMPLATE_NAME, "1.0.0", null));
+ neutronSecurityRulesServiceTemplate.setImports(GlobalTypesUtil.createCommonImportList());
+ neutronSecurityRulesServiceTemplate.setDescription("Neutron Security Rules TOSCA Global Types");
+ neutronSecurityRulesServiceTemplate.setData_types(createGlobalDataTypes());
+ neutronSecurityRulesServiceTemplate.setNode_types(createGlobalNodeTypes());
+ return neutronSecurityRulesServiceTemplate;
+ }
+
+
+ private static Map<String, DataType> createGlobalDataTypes() {
+ Map<String, DataType> globalDataTypes = new HashMap<>();
+ globalDataTypes.put(ToscaDataType.NEUTRON_SECURITY_RULES_RULE.getDisplayName(),
+ createSecurityRulesDataType());
+ return globalDataTypes;
+ }
+
+ private static DataType createSecurityRulesDataType() {
+ DataType addressPairDataType = new DataType();
+ addressPairDataType.setDerived_from(ToscaDataType.ROOT.getDisplayName());
+ addressPairDataType.setDescription("Rules Pairs");
+ Map<String, PropertyDefinition> addressPairProp = new HashMap<>();
+
+ addressPairProp.put("direction", DataModelUtil
+ .createPropertyDefinition(PropertyType.STRING.getDisplayName(),
+ "The direction in which the security group rule is applied", false,
+ DataModelUtil.createValidValuesConstraintsList("egress", "ingress"), null, null,
+ "ingress"));
+ addressPairProp.put("ethertype", DataModelUtil
+ .createPropertyDefinition(PropertyType.STRING.getDisplayName(), "Ethertype of the traffic",
+ false, DataModelUtil.createValidValuesConstraintsList("IPv4", "IPv6"), null, null,
+ "IPv4"));
+ Constraint portRangeMaxConstraint = new Constraint();
+ portRangeMaxConstraint.setIn_range(new Integer[]{0, 65535});
+ addressPairProp.put("port_range_max", DataModelUtil
+ .createPropertyDefinition(PropertyType.INTEGER.getDisplayName(),
+ "The maximum port number in the range that is matched by the security group rule. ",
+ false, DataModelUtil.getConstrainList(portRangeMaxConstraint), null, null, null));
+ Constraint portRangeMinConstraint = new Constraint();
+ portRangeMinConstraint.setIn_range(new Integer[]{0, 65535});
+ addressPairProp.put("port_range_min", DataModelUtil
+ .createPropertyDefinition(PropertyType.INTEGER.getDisplayName(),
+ "The minimum port number in the range that is matched by the security group rule.",
+ false, DataModelUtil.getConstrainList(portRangeMinConstraint), null, null, null));
+ addressPairProp.put("protocol", DataModelUtil
+ .createPropertyDefinition(PropertyType.STRING.getDisplayName(),
+ "The protocol that is matched by the security group rule", false,
+ DataModelUtil.createValidValuesConstraintsList("tcp", "udp", "icmp"), null, null,
+ null));
+ addressPairProp.put("remote_group_id", DataModelUtil
+ .createPropertyDefinition(PropertyType.STRING.getDisplayName(),
+ "The remote group ID to be associated with this security group rule", false, null, null,
+ null, null));
+ addressPairProp.put("remote_ip_prefix", DataModelUtil
+ .createPropertyDefinition(PropertyType.STRING.getDisplayName(),
+ "The remote IP prefix (CIDR) to be associated with this security group rule", false,
+ null, null, null, null));
+ addressPairProp.put("remote_mode", DataModelUtil
+ .createPropertyDefinition(PropertyType.STRING.getDisplayName(),
+ "Whether to specify a remote group or a remote IP prefix", false,
+ DataModelUtil.createValidValuesConstraintsList("remote_ip_prefix", "remote_group_id"),
+ null, null, "remote_ip_prefix"));
+ addressPairDataType.setProperties(addressPairProp);
+
+ return addressPairDataType;
+ }
+
+ private static Map<String, NodeType> createGlobalNodeTypes() {
+ Map<String, NodeType> globalNodeTypes = new HashMap<>();
+ globalNodeTypes.put(ToscaNodeType.NEUTRON_SECURITY_RULES.getDisplayName(),
+ createNeutronSecurityRulesNodeType());
+ return globalNodeTypes;
+ }
+
+ private static NodeType createNeutronSecurityRulesNodeType() {
+ NodeType novaServerNodeType = new NodeType();
+ novaServerNodeType.setDerived_from(ToscaNodeType.ROOT.getDisplayName());
+ novaServerNodeType.setProperties(createNeutronSecurityRulesProperties());
+ novaServerNodeType.setAttributes(createNeutronSecurityRulesAttributes());
+ novaServerNodeType.setRequirements(createNeutronSecurityRequirements());
+ return novaServerNodeType;
+ }
+
+ private static List<Map<String, RequirementDefinition>> createNeutronSecurityRequirements() {
+ final List<Map<String, RequirementDefinition>> requirements = new ArrayList<>();
+ final Map<String, RequirementDefinition> portRequirement = new HashMap<>();
+ RequirementDefinition requirementDefinition = new RequirementDefinition();
+ requirementDefinition.setCapability(ToscaCapabilityType.ATTACHMENT.getDisplayName());
+ requirementDefinition.setNode(ToscaNodeType.NEUTRON_PORT.getDisplayName());
+ requirementDefinition.setRelationship(ToscaRelationshipType.ATTACHES_TO.getDisplayName());
+ requirementDefinition.setOccurrences(new Object[]{0, ToscaConstants.UNBOUNDED});
+ portRequirement.put(ToscaConstants.PORT_REQUIREMENT_ID, requirementDefinition);
+ requirements.add(portRequirement);
+
+ return requirements;
+ }
+
+ private static Map<String, PropertyDefinition> createNeutronSecurityRulesProperties() {
+ Map<String, PropertyDefinition> neutronSecurityRulesPropertyDefMap = new HashMap<>();
+ neutronSecurityRulesPropertyDefMap.put(Constants.NAME_PROPERTY_NAME, DataModelUtil
+ .createPropertyDefinition(PropertyType.STRING.getDisplayName(),
+ "A symbolic name for this security group, which is not required to be unique.", false,
+ null, null, null, null));
+ neutronSecurityRulesPropertyDefMap.put(Constants.DESCRIPTION_PROPERTY_NAME, DataModelUtil
+ .createPropertyDefinition(PropertyType.STRING.getDisplayName(),
+ "Description of the security group", false, null, null, null, null));
+ neutronSecurityRulesPropertyDefMap.put(Constants.RULES_PROPERTY_NAME, DataModelUtil
+ .createPropertyDefinition(PropertyType.LIST.getDisplayName(),
+ "List of security group rules", false, null, null, DataModelUtil
+ .createEntrySchema(ToscaDataType.NEUTRON_SECURITY_RULES_RULE.getDisplayName(), null,
+ null), null));
+ return neutronSecurityRulesPropertyDefMap;
+ }
+
+ private static Map<String, AttributeDefinition> createNeutronSecurityRulesAttributes() {
+ Map<String, AttributeDefinition> neutronSecurityRulesAttributesDefMap = new HashMap<>();
+ neutronSecurityRulesAttributesDefMap.put("show", DataModelUtil
+ .createAttributeDefinition(PropertyType.STRING.getDisplayName(),
+ "Detailed information about resource", null, null, null));
+ return neutronSecurityRulesAttributesDefMap;
+ }
+}
diff --git a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/globaltypes/NovaServerGlobalType.java b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/globaltypes/NovaServerGlobalType.java
new file mode 100644
index 0000000000..d38d70a4f7
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/globaltypes/NovaServerGlobalType.java
@@ -0,0 +1,307 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * SDC
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.sdc.translator.services.heattotosca.globaltypes;
+
+import org.openecomp.sdc.tosca.datatypes.ToscaDataType;
+import org.openecomp.sdc.tosca.datatypes.ToscaNodeType;
+import org.openecomp.sdc.tosca.datatypes.model.AttributeDefinition;
+import org.openecomp.sdc.tosca.datatypes.model.Constraint;
+import org.openecomp.sdc.tosca.datatypes.model.DataType;
+import org.openecomp.sdc.tosca.datatypes.model.NodeType;
+import org.openecomp.sdc.tosca.datatypes.model.PropertyDefinition;
+import org.openecomp.sdc.tosca.datatypes.model.PropertyType;
+import org.openecomp.sdc.tosca.datatypes.model.ServiceTemplate;
+import org.openecomp.sdc.tosca.datatypes.model.heatextend.PropertyTypeExt;
+import org.openecomp.sdc.tosca.services.DataModelUtil;
+import org.openecomp.sdc.tosca.services.ToscaConstants;
+import org.openecomp.sdc.translator.services.heattotosca.Constants;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+public class NovaServerGlobalType {
+
+ /**
+ * Create service template service template.
+ *
+ * @return the service template
+ */
+ public static ServiceTemplate createServiceTemplate() {
+ ServiceTemplate novaeServerServiceTemplate = new ServiceTemplate();
+ novaeServerServiceTemplate
+ .setTosca_definitions_version(ToscaConstants.TOSCA_DEFINITIONS_VERSION);
+ novaeServerServiceTemplate.setMetadata(
+ DataModelUtil.createMetadata(Constants.NOVA_SERVER_TEMPLATE_NAME, "1.0.0", null));
+ novaeServerServiceTemplate.setDescription("Nova Server TOSCA Global Types");
+ novaeServerServiceTemplate.setImports(GlobalTypesUtil.createCommonImportList());
+ novaeServerServiceTemplate.setData_types(createGlobalDataTypes());
+ novaeServerServiceTemplate.setNode_types(createGlobalNodeTypes());
+ return novaeServerServiceTemplate;
+ }
+
+
+ private static Map<String, NodeType> createGlobalNodeTypes() {
+ Map<String, NodeType> globalNodeTypes = new HashMap<>();
+ globalNodeTypes.put(ToscaNodeType.NOVA_SERVER.getDisplayName(), createNovaServerNodeType());
+ return globalNodeTypes;
+ }
+
+ private static NodeType createNovaServerNodeType() {
+ NodeType novaServerNodeType = new NodeType();
+ novaServerNodeType.setDerived_from(ToscaNodeType.COMPUTE.getDisplayName());
+ novaServerNodeType.setProperties(createNovaServerProperties());
+ novaServerNodeType.setAttributes(createNovaServerAttributes());
+ return novaServerNodeType;
+ }
+
+
+ private static Map<String, PropertyDefinition> createNovaServerProperties() {
+ Map<String, PropertyDefinition> novaServerPropertyDefMap = new HashMap<>();
+ novaServerPropertyDefMap.put("flavor", DataModelUtil
+ .createPropertyDefinition(PropertyType.STRING.getDisplayName(),
+ "The ID or name of the flavor to boot onto", true, null, null, null, null));
+ novaServerPropertyDefMap.put("admin_pass", DataModelUtil
+ .createPropertyDefinition(PropertyType.STRING.getDisplayName(),
+ "The administrator password for the server", false, null, null, null, null));
+ novaServerPropertyDefMap.put("availability_zone", DataModelUtil
+ .createPropertyDefinition(PropertyType.STRING.getDisplayName(),
+ "Availability zone to create servers in", false, null, null, null, null));
+ novaServerPropertyDefMap.put("config_drive", DataModelUtil
+ .createPropertyDefinition(PropertyType.BOOLEAN.getDisplayName(),
+ "enable config drive on the server", false, null, null, null, null));
+ novaServerPropertyDefMap.put("contrail_service_instance_ind", DataModelUtil
+ .createPropertyDefinition(PropertyType.BOOLEAN.getDisplayName(),
+ "Nova server related to service instance indicator", false, null, null, null, false));
+ novaServerPropertyDefMap.put("diskConfig", DataModelUtil
+ .createPropertyDefinition(PropertyType.STRING.getDisplayName(),
+ "Control how the disk is partitioned when the server is created", false,
+ getDiskConfigConstraints(), null, null, null));
+ novaServerPropertyDefMap.put("flavor_update_policy", DataModelUtil
+ .createPropertyDefinition(PropertyType.STRING.getDisplayName(),
+ "Policy on how to apply a flavor update", false, getFlavorUpdatePolicyConstraints(),
+ null, null, "RESIZE"));
+ novaServerPropertyDefMap.put("image", DataModelUtil
+ .createPropertyDefinition(PropertyType.STRING.getDisplayName(),
+ "The ID or name of the image to boot with", false, null, null, null, null));
+ novaServerPropertyDefMap.put("image_update_policy", DataModelUtil
+ .createPropertyDefinition(PropertyType.STRING.getDisplayName(),
+ "Policy on how to apply an image-id update", false, getImageUpdatePolicyConstraints(),
+ null, null, "REBUILD"));
+ novaServerPropertyDefMap.put("key_name", DataModelUtil
+ .createPropertyDefinition(PropertyType.STRING.getDisplayName(),
+ "Name of keypair to inject into the server", false, null, null, null, null));
+ novaServerPropertyDefMap.put("metadata", DataModelUtil
+ .createPropertyDefinition(PropertyTypeExt.JSON.getDisplayName(),
+ "Arbitrary JSON metadata to store for this server", false, null, null, null, null));
+ novaServerPropertyDefMap.put(Constants.NAME_PROPERTY_NAME, DataModelUtil
+ .createPropertyDefinition(PropertyType.STRING.getDisplayName(), "Server name", false, null,
+ null, null, null));
+ novaServerPropertyDefMap.put("personality", DataModelUtil
+ .createPropertyDefinition(PropertyType.MAP.getDisplayName(),
+ "A map of files to create/overwrite on the server upon boot", false, null, null,
+ DataModelUtil.createEntrySchema(PropertyType.STRING.getDisplayName(), null, null),
+ new HashMap<String, String>()));
+ novaServerPropertyDefMap.put("reservation_id", DataModelUtil
+ .createPropertyDefinition(PropertyType.STRING.getDisplayName(),
+ "A UUID for the set of servers being requested", false, null, null, null, null));
+ novaServerPropertyDefMap.put("scheduler_hints", DataModelUtil
+ .createPropertyDefinition(PropertyType.MAP.getDisplayName(),
+ "Arbitrary key-value pairs specified by the client to help boot a server", false, null,
+ null, DataModelUtil.createEntrySchema(PropertyType.STRING.getDisplayName(), null, null),
+ null));
+ novaServerPropertyDefMap.put(Constants.SECURITY_GROUPS_PROPERTY_NAME, DataModelUtil
+ .createPropertyDefinition(PropertyType.LIST.getDisplayName(),
+ "List of security group names or IDs", false, null, null,
+ DataModelUtil.createEntrySchema(PropertyType.STRING.getDisplayName(), null, null),
+ new ArrayList<>()));
+ novaServerPropertyDefMap.put("software_config_transport", DataModelUtil
+ .createPropertyDefinition(PropertyType.STRING.getDisplayName(),
+ "How the server should receive the metadata required for software configuration", false,
+ getSoftwareConfigTransportConstraints(), null, null, "POLL_SERVER_CFN"));
+ novaServerPropertyDefMap.put("user_data", DataModelUtil
+ .createPropertyDefinition(PropertyType.STRING.getDisplayName(),
+ "User data script to be executed by cloud-init", false, null, null, null, ""));
+ novaServerPropertyDefMap.put("user_data_format", DataModelUtil
+ .createPropertyDefinition(PropertyType.STRING.getDisplayName(),
+ "How the user_data should be formatted for the server", false,
+ getUserDataFormatConstraint(), null, null, "HEAT_CFNTOOLS"));
+ novaServerPropertyDefMap.put("user_data_update_policy", DataModelUtil
+ .createPropertyDefinition(PropertyType.STRING.getDisplayName(),
+ "Policy on how to apply a user_data update", false,
+ getUserDataUpdatePolicyConstraints(), null, null, "REPLACE"));
+ return novaServerPropertyDefMap;
+ }
+
+ private static Map<String, AttributeDefinition> createNovaServerAttributes() {
+ Map<String, AttributeDefinition> novaServerAttributesDefMap = new HashMap<>();
+ novaServerAttributesDefMap.put("accessIPv4", DataModelUtil
+ .createAttributeDefinition(PropertyType.STRING.getDisplayName(),
+ "The manually assigned alternative public IPv4 address of the server", null, null,
+ null));
+ novaServerAttributesDefMap.put("accessIPv6", DataModelUtil
+ .createAttributeDefinition(PropertyType.STRING.getDisplayName(),
+ "The manually assigned alternative public IPv6 address of the server", null, null,
+ null));
+ novaServerAttributesDefMap.put("addresses", DataModelUtil
+ .createAttributeDefinition(PropertyType.MAP.getDisplayName(),
+ "A dict of all network addresses with corresponding port_id", null, DataModelUtil
+ .createEntrySchema(ToscaDataType.NOVA_SERVER_NETWORK_ADDRESS_INFO.getDisplayName(),
+ null, null), null));
+ novaServerAttributesDefMap.put("console_urls", DataModelUtil
+ .createAttributeDefinition(PropertyType.STRING.getDisplayName(), "URLs of servers consoles",
+ null, null, null));
+ novaServerAttributesDefMap.put("instance_name", DataModelUtil
+ .createAttributeDefinition(PropertyType.STRING.getDisplayName(),
+ "AWS compatible instance name", null, null, null));
+ novaServerAttributesDefMap.put(Constants.NAME_PROPERTY_NAME, DataModelUtil
+ .createAttributeDefinition(PropertyType.STRING.getDisplayName(), "Name of the server", null,
+ null, null));
+ novaServerAttributesDefMap.put("show", DataModelUtil
+ .createAttributeDefinition(PropertyType.STRING.getDisplayName(),
+ "Detailed information about resource", null, null, null));
+ return novaServerAttributesDefMap;
+ }
+
+ private static List<Constraint> getUserDataFormatConstraint() {
+ List<Constraint> constraints;
+ Constraint validValues;
+ constraints = new ArrayList<>();
+ validValues =
+ DataModelUtil.createValidValuesConstraint("SOFTWARE_CONFIG", "RAW", "HEAT_CFNTOOLS");
+ constraints.add(validValues);
+ return constraints;
+ }
+
+ private static List<Constraint> getUserDataUpdatePolicyConstraints() {
+ List<Constraint> constraints;
+ Constraint validValues;
+ constraints = new ArrayList<>();
+ validValues = DataModelUtil.createValidValuesConstraint("REPLACE", "IGNORE");
+ constraints.add(validValues);
+ return constraints;
+ }
+
+ private static List<Constraint> getSoftwareConfigTransportConstraints() {
+ List<Constraint> constraints;
+ Constraint validValues;
+ constraints = new ArrayList<>();
+ validValues = DataModelUtil
+ .createValidValuesConstraint("POLL_SERVER_CFN", "POLL_SERVER_HEAT", "POLL_TEMP_URL",
+ "ZAQAR_MESSAGE");
+ constraints.add(validValues);
+ return constraints;
+ }
+
+ private static List<Constraint> getImageUpdatePolicyConstraints() {
+ List<Constraint> constraints;
+ Constraint validValues;
+ constraints = new ArrayList<>();
+ validValues = DataModelUtil
+ .createValidValuesConstraint("REBUILD_PRESERVE_EPHEMERAL", "REPLACE", "REBUILD");
+ constraints.add(validValues);
+ return constraints;
+ }
+
+ private static List<Constraint> getFlavorUpdatePolicyConstraints() {
+ Constraint validValues;
+ List<Constraint> constraints = new ArrayList<>();
+ validValues = DataModelUtil.createValidValuesConstraint("RESIZE", "REPLACE");
+ constraints.add(validValues);
+ return constraints;
+ }
+
+ private static List<Constraint> getDiskConfigConstraints() {
+ List<Constraint> constraints = new ArrayList<>();
+ Constraint validValues = DataModelUtil.createValidValuesConstraint("AUTO", "MANUAL");
+ constraints.add(validValues);
+ return constraints;
+ }
+
+ private static Map<String, DataType> createGlobalDataTypes() {
+ Map<String, DataType> globalDataTypes = new HashMap<>();
+ globalDataTypes.put(ToscaDataType.NOVA_SERVER_PORT_EXTRA_PROPERTIES.getDisplayName(),
+ createPortExtraDataDataType());
+ globalDataTypes.put(ToscaDataType.NOVA_SERVER_NETWORK_ADDRESS_INFO.getDisplayName(),
+ createAddressInfoDataType());
+ return globalDataTypes;
+ }
+
+ private static DataType createAddressInfoDataType() {
+ DataType addressInfoDataType = new DataType();
+ addressInfoDataType.setDerived_from(ToscaDataType.NETWORK_NETWORK_INFO.getDisplayName());
+ addressInfoDataType.setDescription("Network addresses with corresponding port id");
+
+ Map<String, PropertyDefinition> addressInfoProp = new HashMap<>();
+ addressInfoProp.put("port_id", DataModelUtil
+ .createPropertyDefinition(PropertyType.STRING.getDisplayName(), "Port id", false, null,
+ null, null, null));
+ addressInfoDataType.setProperties(addressInfoProp);
+
+ return addressInfoDataType;
+ }
+
+
+ private static DataType createPortExtraDataDataType() {
+ DataType portExtraDataType = new DataType();
+ portExtraDataType.setDerived_from(ToscaDataType.ROOT.getDisplayName());
+ portExtraDataType.setDescription("Nova server network expand properties for port");
+ Map<String, PropertyDefinition> portExtraPropMap = new HashMap<>();
+
+ portExtraPropMap.put("admin_state_up", DataModelUtil
+ .createPropertyDefinition(PropertyType.BOOLEAN.getDisplayName(),
+ "The administrative state of this port", false, null, null, null, true));
+ portExtraPropMap.put("allowed_address_pairs", DataModelUtil
+ .createPropertyDefinition(PropertyType.LIST.getDisplayName(),
+ "Additional MAC/IP address pairs allowed to pass through the port", false, null, null,
+ DataModelUtil
+ .createEntrySchema(ToscaDataType.NETWORK_ADDRESS_PAIR.getDisplayName(), null, null),
+ null));
+
+ List<Constraint> bindingVnicConstraints = new ArrayList<>();
+ Constraint validValues =
+ DataModelUtil.createValidValuesConstraint("macvtap", "direct", "normal");
+ bindingVnicConstraints.add(validValues);
+ portExtraPropMap.put("binding:vnic_type", DataModelUtil
+ .createPropertyDefinition(PropertyType.STRING.getDisplayName(),
+ "The vnic type to be bound on the neutron port", false, bindingVnicConstraints, null,
+ null, null));
+
+ portExtraPropMap.put("mac_address", DataModelUtil
+ .createPropertyDefinition(PropertyType.STRING.getDisplayName(),
+ "MAC address to give to this port", false, null, null, null, null));
+ portExtraPropMap.put("port_security_enabled", DataModelUtil
+ .createPropertyDefinition(PropertyType.BOOLEAN.getDisplayName(),
+ "Flag to enable/disable port security on the port", false, null, null, null, null));
+ portExtraPropMap.put("qos_policy", DataModelUtil
+ .createPropertyDefinition(PropertyType.STRING.getDisplayName(),
+ "The name or ID of QoS policy to attach to this port", false, null, null, null, null));
+ portExtraPropMap.put("value_specs", DataModelUtil
+ .createPropertyDefinition(PropertyType.MAP.getDisplayName(),
+ "Extra parameters to include in the request", false, null, null,
+ DataModelUtil.createEntrySchema(PropertyType.STRING.getDisplayName(), null, null),
+ new HashMap<String, String>()));
+ portExtraDataType.setProperties(portExtraPropMap);
+ return portExtraDataType;
+ }
+
+}