2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ============LICENSE_END=========================================================
21 package org.openecomp.sdc.translator.services.heattotosca.globaltypes;
23 import org.openecomp.sdc.tosca.datatypes.ToscaDataType;
24 import org.openecomp.sdc.tosca.datatypes.ToscaNodeType;
25 import org.openecomp.sdc.tosca.datatypes.model.AttributeDefinition;
26 import org.openecomp.sdc.tosca.datatypes.model.CapabilityDefinition;
27 import org.openecomp.sdc.tosca.datatypes.model.NodeType;
28 import org.openecomp.sdc.tosca.datatypes.model.PropertyDefinition;
29 import org.openecomp.sdc.tosca.datatypes.model.PropertyType;
30 import org.openecomp.sdc.tosca.datatypes.model.ServiceTemplate;
31 import org.openecomp.sdc.tosca.services.DataModelUtil;
32 import org.openecomp.sdc.tosca.services.ToscaConstants;
33 import org.openecomp.sdc.translator.services.heattotosca.Constants;
35 import java.util.HashMap;
38 public class NeutronNetGlobalType {
40 * Create service template service template.
42 * @return the service template
44 public static ServiceTemplate createServiceTemplate() {
45 ServiceTemplate neutronNetServiceTemplate = new ServiceTemplate();
46 neutronNetServiceTemplate
47 .setTosca_definitions_version(ToscaConstants.TOSCA_DEFINITIONS_VERSION);
48 neutronNetServiceTemplate.setMetadata(
49 DataModelUtil.createMetadata(Constants.NEUTRON_NET_TEMPLATE_NAME, "1.0.0", null));
50 neutronNetServiceTemplate.setDescription("Neutron Network TOSCA Global Types");
51 neutronNetServiceTemplate.setImports(GlobalTypesUtil.createCommonImportList());
52 neutronNetServiceTemplate.setNode_types(createGlobalNodeTypes());
53 return neutronNetServiceTemplate;
57 private static Map<String, NodeType> createGlobalNodeTypes() {
58 Map<String, NodeType> globalNodeTypes = new HashMap<>();
59 globalNodeTypes.put(ToscaNodeType.NEUTRON_NET.getDisplayName(), createNeutronNetworkNodeType());
60 return globalNodeTypes;
63 private static NodeType createNeutronNetworkNodeType() {
64 NodeType neutronNetworkNode = new NodeType();
65 neutronNetworkNode.setDerived_from(ToscaNodeType.NETWORK.getDisplayName());
66 neutronNetworkNode.setProperties(createNeutronNetworkProperties());
67 neutronNetworkNode.setAttributes(createNeutronNetworkAttributes());
68 neutronNetworkNode.setCapabilities(createNeutronNetworkCapabilities());
70 return neutronNetworkNode;
73 private static Map<String, CapabilityDefinition> createNeutronNetworkCapabilities() {
74 Map<String, CapabilityDefinition> capabilities = new HashMap<>();
75 capabilities.put("attachment", GlobalTypesUtil.createAttachmentCapability());
79 private static Map<String, PropertyDefinition> createNeutronNetworkProperties() {
80 Map<String, PropertyDefinition> neutronNetworkPropertyDefMap = new HashMap<>();
81 neutronNetworkPropertyDefMap.put("admin_state_up", DataModelUtil
82 .createPropertyDefinition(PropertyType.BOOLEAN.getDisplayName(),
83 "A boolean value specifying the administrative status of the network", false, null,
85 neutronNetworkPropertyDefMap.put("dhcp_agent_ids", DataModelUtil
86 .createPropertyDefinition(PropertyType.LIST.getDisplayName(),
87 "The IDs of the DHCP agent to schedule the network", false, null, null,
88 DataModelUtil.createEntrySchema(PropertyType.STRING.getDisplayName(), null, null),
90 neutronNetworkPropertyDefMap.put("port_security_enabled", DataModelUtil
91 .createPropertyDefinition(PropertyType.BOOLEAN.getDisplayName(),
92 "Flag to enable/disable port security on the network", false, null, null, null, null));
93 neutronNetworkPropertyDefMap.put("qos_policy", DataModelUtil
94 .createPropertyDefinition(PropertyType.STRING.getDisplayName(),
95 "The name or ID of QoS policy to attach to this network", false, null, null, null,
97 neutronNetworkPropertyDefMap.put("shared", DataModelUtil
98 .createPropertyDefinition(PropertyType.BOOLEAN.getDisplayName(),
99 "Whether this network should be shared across all tenants", false, null, null, null,
101 neutronNetworkPropertyDefMap.put("tenant_id", DataModelUtil
102 .createPropertyDefinition(PropertyType.STRING.getDisplayName(),
103 "The ID of the tenant which will own the network", false, null, null, null, null));
104 neutronNetworkPropertyDefMap.put("value_specs", DataModelUtil
105 .createPropertyDefinition(PropertyType.MAP.getDisplayName(),
106 "Extra parameters to include in the request", false, null, null,
107 DataModelUtil.createEntrySchema(PropertyType.STRING.getDisplayName(), null, null),
108 new HashMap<String, String>()));
109 neutronNetworkPropertyDefMap.put("subnets", DataModelUtil
110 .createPropertyDefinition(PropertyType.MAP.getDisplayName(), "Network related subnets",
111 false, null, null, DataModelUtil
112 .createEntrySchema(ToscaDataType.NEUTRON_SUBNET.getDisplayName(), null, null),
114 return neutronNetworkPropertyDefMap;
117 private static Map<String, AttributeDefinition> createNeutronNetworkAttributes() {
118 Map<String, AttributeDefinition> neutronNetworkAttributesDefMap = new HashMap<>();
119 neutronNetworkAttributesDefMap.put("mtu", DataModelUtil
120 .createAttributeDefinition(PropertyType.SCALAR_UNIT_SIZE.getDisplayName(),
121 "The maximum transmission unit size(in bytes) for the network", null, null, null));
122 neutronNetworkAttributesDefMap.put("qos_policy_id", DataModelUtil
123 .createAttributeDefinition(PropertyType.STRING.getDisplayName(),
124 "The QoS policy ID attached to this network", null, null, null));
125 neutronNetworkAttributesDefMap.put("show", DataModelUtil
126 .createAttributeDefinition(PropertyType.STRING.getDisplayName(),
127 "Detailed information about resource", null, null, null));
128 neutronNetworkAttributesDefMap.put("status", DataModelUtil
129 .createAttributeDefinition(PropertyType.STRING.getDisplayName(),
130 "The status of the network", null, null, null));
131 neutronNetworkAttributesDefMap.put("subnets_name", DataModelUtil
132 .createAttributeDefinition(PropertyType.LIST.getDisplayName(),
133 "Subnets name of this network", null,
134 DataModelUtil.createEntrySchema(PropertyType.STRING.getDisplayName(), null, null),
136 neutronNetworkAttributesDefMap.put("subnets", DataModelUtil
137 .createAttributeDefinition(PropertyType.MAP.getDisplayName(), "Network related subnets",
139 .createEntrySchema(ToscaDataType.NEUTRON_SUBNET.getDisplayName(), null, null),
141 return neutronNetworkAttributesDefMap;