[sdc] docker file fix for cassandra
[sdc.git] / openecomp-be / lib / openecomp-sdc-translator-lib / openecomp-sdc-translator-core / src / main / java / org / openecomp / sdc / translator / services / heattotosca / globaltypes / ContrailComputeGlobalType.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * SDC
4  * ================================================================================
5  * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6  * ================================================================================
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  * 
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  * 
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  * ============LICENSE_END=========================================================
19  */
20
21 package org.openecomp.sdc.translator.services.heattotosca.globaltypes;
22
23 import org.openecomp.sdc.tosca.datatypes.ToscaNodeType;
24 import org.openecomp.sdc.tosca.datatypes.model.AttributeDefinition;
25 import org.openecomp.sdc.tosca.datatypes.model.NodeType;
26 import org.openecomp.sdc.tosca.datatypes.model.PropertyDefinition;
27 import org.openecomp.sdc.tosca.datatypes.model.PropertyType;
28 import org.openecomp.sdc.tosca.datatypes.model.ServiceTemplate;
29 import org.openecomp.sdc.tosca.services.DataModelUtil;
30 import org.openecomp.sdc.tosca.services.ToscaConstants;
31 import org.openecomp.sdc.translator.services.heattotosca.Constants;
32
33 import java.util.HashMap;
34 import java.util.Map;
35
36 public class ContrailComputeGlobalType {
37
38   /**
39    * Create service template service template.
40    *
41    * @return the service template
42    */
43   public static ServiceTemplate createServiceTemplate() {
44     ServiceTemplate serviceTemplate = new ServiceTemplate();
45     serviceTemplate.setTosca_definitions_version(ToscaConstants.TOSCA_DEFINITIONS_VERSION);
46     serviceTemplate.setMetadata(
47         DataModelUtil.createMetadata(Constants.CONTRAIL_COMPUTE_TEMPLATE_NAME, "1.0.0", null));
48     serviceTemplate.setDescription("Contrail Compute TOSCA Global Types");
49     serviceTemplate.setImports(GlobalTypesUtil.createCommonImportList());
50     serviceTemplate.setNode_types(createGlobalNodeTypes());
51     return serviceTemplate;
52   }
53
54
55   private static Map<String, NodeType> createGlobalNodeTypes() {
56     Map<String, NodeType> globalNodeTypes = new HashMap<>();
57     globalNodeTypes
58         .put(ToscaNodeType.CONTRAIL_COMPUTE.getDisplayName(), createContrailComputeNodeType());
59     return globalNodeTypes;
60   }
61
62   private static NodeType createContrailComputeNodeType() {
63     NodeType nodeType = new NodeType();
64     nodeType.setDerived_from(ToscaNodeType.COMPUTE.getDisplayName());
65     nodeType.setProperties(createContrailComputeProperties());
66     nodeType.setAttributes(createContrailComputeAttributes());
67     return nodeType;
68   }
69
70
71   private static Map<String, PropertyDefinition> createContrailComputeProperties() {
72     Map<String, PropertyDefinition> propertyDefMap = new HashMap<>();
73     propertyDefMap.put("service_instance_name", DataModelUtil
74         .createPropertyDefinition(PropertyType.STRING.getDisplayName(), "Service instance name",
75             true, null, null, null, null));
76     propertyDefMap.put("service_template_name", DataModelUtil
77         .createPropertyDefinition(PropertyType.STRING.getDisplayName(), "Service template name",
78             false, null, null, null, null));
79     propertyDefMap.put("image_name", DataModelUtil
80         .createPropertyDefinition(PropertyType.STRING.getDisplayName(), "Image name", true, null,
81             null, null, null));
82     propertyDefMap.put("service_mode", DataModelUtil
83         .createPropertyDefinition(PropertyType.STRING.getDisplayName(), "Service mode", true,
84             DataModelUtil
85                 .createValidValuesConstraintsList("transparent", "in-network", "in-network-nat"),
86             null, null, null));
87     propertyDefMap.put("service_type", DataModelUtil
88         .createPropertyDefinition(PropertyType.STRING.getDisplayName(), "Service type", true,
89             DataModelUtil.createValidValuesConstraintsList("firewall", "analyzer", "source-nat",
90                 "loadbalancer"), null, null, null));
91     propertyDefMap.put("image_name", DataModelUtil
92         .createPropertyDefinition(PropertyType.STRING.getDisplayName(), "Image name", true, null,
93             null, null, null));
94     propertyDefMap.put("flavor", DataModelUtil
95         .createPropertyDefinition(PropertyType.STRING.getDisplayName(), "flavor", false, null, null,
96             null, null));
97     propertyDefMap.put("availability_zone_enable", DataModelUtil
98         .createPropertyDefinition(PropertyType.BOOLEAN.getDisplayName(),
99             "Indicates availability zone is enabled", false, null, null, null, false));
100     propertyDefMap.put("availability_zone", DataModelUtil
101         .createPropertyDefinition(PropertyType.STRING.getDisplayName(),
102             "Availability zone to create servers in", false, null, null, null, null));
103     return propertyDefMap;
104   }
105
106   private static Map<String, AttributeDefinition> createContrailComputeAttributes() {
107     Map<String, AttributeDefinition> attributesDefMap = new HashMap<>();
108     attributesDefMap.put("fq_name", DataModelUtil
109         .createAttributeDefinition(PropertyType.STRING.getDisplayName(), "fq_name", null, null,
110             null));
111     attributesDefMap.put("status", DataModelUtil
112         .createAttributeDefinition(PropertyType.STRING.getDisplayName(), "status of the compute",
113             null, null, null));
114     attributesDefMap.put("virtual_machines", DataModelUtil
115         .createAttributeDefinition(PropertyType.STRING.getDisplayName(), "VMs of this compute",
116             null, null, null));
117     attributesDefMap.put("active_vms", DataModelUtil
118         .createAttributeDefinition(PropertyType.STRING.getDisplayName(), "Number of active VMs",
119             null, null, null));
120     attributesDefMap.put("tenant_id", DataModelUtil
121         .createAttributeDefinition(PropertyType.STRING.getDisplayName(), "Tenant id of the VM",
122             null, null, null));
123     attributesDefMap.put("show", DataModelUtil
124         .createAttributeDefinition(PropertyType.STRING.getDisplayName(), "All attributes", null,
125             null, null));
126     return attributesDefMap;
127   }
128 }