2 * ============LICENSE_START=======================================================
3 * sdc-distribution-client
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
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
17 * ============LICENSE_END=========================================================
19 package org.openecomp.sdc.tosca.parser.api;
22 import java.util.List;
25 import org.apache.commons.lang3.tuple.Pair;
26 import org.openecomp.sdc.tosca.parser.impl.FilterType;
27 import org.openecomp.sdc.tosca.parser.impl.SdcTypes;
28 import org.openecomp.sdc.toscaparser.api.*;
29 import org.openecomp.sdc.toscaparser.api.elements.Metadata;
30 import org.openecomp.sdc.toscaparser.api.parameters.Input;
33 public interface ISdcCsarHelper {
36 * Get all node templates by node_type for this CSAR service.
38 * @param nodeType - the TOSCA type of the node.
39 * @return service node templates of this type.
41 public List<NodeTemplate> getServiceNodeTemplatesByType(String nodeType);
44 * Get all node templates for this CSAR service.
46 * @return service node templates.
48 public List<NodeTemplate> getServiceNodeTemplates();
51 * Get groups of a VF with type "org.openecomp.groups.VfModule".
53 * @param vfCustomizationUuid - customizationUuid of VF instance.
54 * @return list of vfModule groups.
56 public List<Group> getVfModulesByVf(String vfCustomizationUuid);
60 * Get any property leaf value for node template by full path separated by #.<br>
61 * For example, for node template with this property:<br><br>
62 * network_assignments:<br>
63 ecomp_generated_network_assignment: true<br>
64 is_shared_network: false<br>
65 is_external_network: false<br>
66 ipv4_subnet_default_assignments:<br>
67 use_ipv4: true<br>
68 ip_network_address_plan: 1.2.3.4<br>
69 dhcp_enabled: true<br>
70 ip_version: 4<br>
71 cidr_mask: 24<br>
72 min_subnets_count: 1<br>
73 ipv6_subnet_default_assignments:<br>
74 use_ipv6: false<br><br>
77 * getNodeTemplatePropertyLeafValue(nodeTemplate, "network_assignments#ipv6_subnet_default_assignments#use_ipv6")<br>
78 * will return "false".
79 * @param nodeTemplate - nodeTemplate where the property should be looked up.
80 * @param pathToPropertyLeafValue - the full path of the required property.
81 * @return the leaf value as String, or null if there's no such property, or it's not a leaf.
83 public String getNodeTemplatePropertyLeafValue(NodeTemplate nodeTemplate, String pathToPropertyLeafValue);
86 * Get any property leaf value for node template by full path separated by #.<br>
87 * For example, for node template with this property:<br><br>
88 * network_assignments:<br>
89 ecomp_generated_network_assignment: true<br>
90 is_shared_network: false<br>
91 is_external_network: false<br>
92 ipv4_subnet_default_assignments:<br>
93 use_ipv4: true<br>
94 ip_network_address_plan: 1.2.3.4<br>
95 dhcp_enabled: true<br>
96 ip_version: 4<br>
97 cidr_mask: 24<br>
98 min_subnets_count: 1<br>
99 ipv6_subnet_default_assignments:<br>
100 use_ipv6: false<br><br>
103 * getNodeTemplatePropertyLeafValue(nodeTemplate, "network_assignments#ipv6_subnet_default_assignments#use_ipv6")<br>
104 * will return "false".
105 * @param nodeTemplate - nodeTemplate where the property should be looked up.
106 * @param pathToPropertyLeafValue - the full path of the required property.
107 * @return the leaf value as Object, or null if there's no such property. It's up to the caller to cast it to a proper type.
109 public Object getNodeTemplatePropertyAsObject(NodeTemplate nodeTemplate, String pathToPropertyLeafValue);
112 * Get any property leaf value for a group definition by full path separated by #.
113 * Same logic as in {@link #getNodeTemplatePropertyLeafValue(NodeTemplate, String) getNodeTemplatePropertyLeafValue}, only for a group.
114 * @param group - group where the property should be looked up.
115 * @param propertyName - the name of the required property.
116 * @return the leaf value as String, or null if there's no such property, or it's not a leaf.
118 public String getGroupPropertyLeafValue(Group group, String propertyName);
121 * Get any property value for a group definition by full path separated by #.
122 * Same logic as in {@link #getNodeTemplatePropertyLeafValue(NodeTemplate, String) getNodeTemplatePropertyLeafValue}, only for a group.
123 * @param group - group where the property should be looked up.
124 * @param propertyName - the name of the required property.
125 * @return the leaf value as Object, or null if there's no such property. It's up to the caller to cast it to a proper type.
127 public Object getGroupPropertyAsObject(Group group, String propertyName);
130 * Get all VL node templates of the CSAR service.
131 * @return - all VL node templates.
133 public List<NodeTemplate> getServiceVlList();
136 * Get all VF node templates of the CSAR service.
137 * @return - all VF node templates.
139 public List<NodeTemplate> getServiceVfList();
144 * Get a property from a metadata object.<br>
145 * This is just sugaring method, same as calling metadata.getMetadataPropertyValue(metadataPropertyName).<br>
147 * For metadata object representing the below: <br><br>
150 invariantUUID: 4598a404-00e1-42a6-8767-0bda343e2066<br>
151 UUID: e17940d6-42f8-4989-bad0-31de5addc619<br>
152 customizationUUID: 83d086b2-a861-4d3b-aa84-3bfbb9b2ec20<br>
153 version: '0.1'<br>
154 name: vIPR_ATM<br>
155 description: vIPR_ATM<br>
156 type: VF<br>
157 category: category1<br>
158 subcategory: subCategory1<br><br>
161 getMetadataPropertyValue(metadata,"invariantUUID")<br>
162 will return "4598a404-00e1-42a6-8767-0bda343e2066".
164 * @param metadata - metadata object.
165 * @param metadataPropertyName - the name of the metadata property.
166 * @return metadata property value
168 public String getMetadataPropertyValue(Metadata metadata, String metadataPropertyName);
172 * Get input leaf value for the CSAR service, by full path separated by #.<br>
173 * Same logic as in {@link #getNodeTemplatePropertyLeafValue(NodeTemplate, String) getNodeTemplatePropertyLeafValue}, only for an input full path.
174 * The expected format is "input_name#default[optionally #rest_of_path]"
175 * @param inputLeafValuePath by full path separated by #.
176 * @return input leaf value for the service.
178 public String getServiceInputLeafValueOfDefault(String inputLeafValuePath);
181 * Get input leaf value for the CSAR service, by full path separated by #.<br>
182 * Same logic as in {@link #getNodeTemplatePropertyLeafValue(NodeTemplate, String) getNodeTemplatePropertyLeafValue}, only for an input full path.
183 * The expected format is "input_name#default[optionally #rest_of_path]"
184 * @param inputLeafValuePath by full path separated by #.
185 * @return input value for the service as Object. It's up to the caller to cast it to a proper type.
187 public Object getServiceInputLeafValueOfDefaultAsObject(String inputLeafValuePath);
190 * Get the type name of the CSAR service's substitution mappings element.<br>
192 * For the below:<br><br>
194 * substitution_mappings:<br>
195 type: org.openecomp.services.ViprATM<br>
198 getServiceSubstitutionMappingsTypeName()<br>
199 will return "org.openecomp.services.ViprATM"
200 * @return - the type name of the CSAR service's substitution mappings element
202 public String getServiceSubstitutionMappingsTypeName();
205 * Get service Metadata object.<br>
206 * This object represents the "metadata" section of a CSAR service.
207 * @return - the service Metadata object.
209 public Metadata getServiceMetadata();
212 * Get the CSAR service metadata as map.
213 * @return - the service metadata object as Map.
214 * @deprecated This function is deprecated since its not tosca compliant. <br>
215 * Tosca defines the Metadata section as map of string (not map of object).<br>
216 * This function is targeted to be removed as part of 1802.<br>
217 * Please use {@link #getServiceMetadataAllProperties() getServiceMetadataAllProperties()}.
220 public Map<String, Object> getServiceMetadataProperties();
223 * Get the CSAR service metadata as map
224 * @return - the service metadata object as Map
226 public Map<String, String> getServiceMetadataAllProperties();
229 * Get all VFC node templates from a specified VF.
230 * @param vfCustomizationId - customizationUuid of the VF node template.
231 * @return all VFC node templates from a specified VF
233 public List<NodeTemplate> getVfcListByVf(String vfCustomizationId);
236 * Get all CP node templates from a specified VF.
237 * @param vfCustomizationId - customizationUuid of the VF node template.
238 * @return all CP node templates from a specified VF
240 public List<NodeTemplate> getCpListByVf(String vfCustomizationId);
243 * Get all members of this group definition.<br>
245 * For example, for this group definition:<br><br>
247 * ViprAtm..vIPR-ATM-Base..module-0:<br>
248 type: org.openecomp.groups.VfModule<br>
249 .................<br>
250 members: [vIPR_ATM_Ha_Two, vIPR_ATM_Ha_One, vIPR_ATM_OAM_SG, vIPR_ATM_HA_TWO_SG, vIPR_ATM_HA_ONE_SG]<br><br>
253 getMembersOfVfModule(NoteTemplate vfNodeTemplate, Group group)<br>
254 will return List of the following Node templates in the vfNodeTemplate: "vIPR_ATM_Ha_Two, vIPR_ATM_Ha_One, vIPR_ATM_OAM_SG, vIPR_ATM_HA_TWO_SG, vIPR_ATM_HA_ONE_SG"<br>
255 * @param vf - VF to return the node templates from.
256 * @param vfModule - group to return the members from.
257 * @return node templates from vf with the names as in members section.
260 public List<NodeTemplate> getMembersOfVfModule(NodeTemplate vf, Group vfModule);
264 * Get list of node template pairs, where for each pair,<br>
265 * the left node template in pair has requirement with name reqName, <br>
266 * which should be satisfied with respective capability by the right node template in pair.<br>
268 * For example, if we have the below two node templates in the vIPR VF:<br><br>
271 type: org.openecomp.resources.cp.extCP<br>
272 requirements:<br>
273 - virtualBinding: vipr_atm_firewall<br><br>
275 * vipr_atm_firewall: <br>
276 type: org.openecomp.resources.vfc.ViprAtm.abstract.nodes.heat.vipr_atm<br>
281 * getNodeTemplatePairsByReqName(getCpListByVf(viprCustomUuid), getVfcListByVf(viprCustomUuid), "virtualBinding")<br>
282 * will return a list with one Pair - where left element of pair will be "oam_extCP" node template,<br>
283 * and right element will be "vipr_atm_firewall" node template.<br>
285 * @param listOfReqNodeTemplates - list of node templates in which the "reqName" requirement should be looked.
286 * @param listOfCapNodeTemplates - list of node templates in which the capability matching the "reqName" requirement should be looked.
287 * @param reqName - the name of a requirement definition to match by.
288 * @return pairs of node templates according to described above.
290 public List<Pair<NodeTemplate,NodeTemplate>> getNodeTemplatePairsByReqName(List<NodeTemplate> listOfReqNodeTemplates, List<NodeTemplate> listOfCapNodeTemplates, String reqName);
293 * Get all allotted node templates from this service.
294 * @return all allotted node templates from this service.
296 public List<NodeTemplate> getAllottedResources();
299 * Get node_type of a node template.<br>
301 * For this node template:<br>
303 * vipr_atm_firewall: <br>
304 type: org.openecomp.resources.vfc.ViprAtm.abstract.nodes.heat.vipr_atm<br>
307 * the function will return "org.openecomp.resources.vfc.ViprAtm.abstract.nodes.heat.vipr_atm"
309 * @param nodeTemplate - node template object
310 * @return - node type string.
312 public String getTypeOfNodeTemplate(NodeTemplate nodeTemplate);
315 * Get the CSAR service inputs list.
316 * @return - the service inputs list.
318 public List<Input> getServiceInputs();
322 * Get the conformance level of this CSAR. <br>
323 * The conformance level value of the CSAR is located in csar.meta file at the top level of the CSAR file.<br>
324 * For 1707 CSARs, the conformance level is 3.0.
325 * @return the conformance level of the CSAR.
327 public String getConformanceLevel();
331 * Get the map of CP-related props from a VFC node template. <br>
332 * Let's say there are 5 CPs related to this VFC. Then the output will look like this: <br><br>
333 * {port_fe1_sigtran={ip_requirements#ip_count_required#count=1, ip_requirements#dhcp_enabled=true, ip_requirements#ip_version=4, subnetpoolid="subnet_1", network_role_tag="SIGNET_vrf_B1_direct"},<br>
334 * port_fe_cluster={ip_requirements#ip_count_required#count=2, ip_requirements#dhcp_enabled=true, ip_requirements#ip_version=4},<br>
335 * port_fe_slan={ip_requirements#ip_count_required#count=1, ip_requirements#dhcp_enabled=true, ip_requirements#ip_version=4},<br>
336 * port_fe_interce={ip_requirements#ip_count_required#count=1, ip_requirements#dhcp_enabled=true, ip_requirements#ip_version=4},<br>
337 * port_fe_oam={ip_requirements#ip_count_required#count=2, ip_requirements#dhcp_enabled=true, ip_requirements#ip_version=4, subnetpoolid="subnet_2", network_role_tag="Mobility_OAM_protected"}}<br><br>
338 * @param vfc - VFC node template to look for CP-related props.
339 * @return map <b>CP node template name</b> to a map of <b>full path to a property on this CP</b> - <b> value of this property on this CP</b>.
340 * @deprecated This function is deprecated since its flattened form doesn't provide solution for cp properties of type List.
341 * Will be removed in 1802.
344 public Map<String, Map<String, Object>> getCpPropertiesFromVfc(NodeTemplate vfc);
347 * Get the map of CP-related props from a VFC node template. <br>
348 * Let's say there are 2 CPs (ports) related to this VFC. Then the output will look like this: <br><br>
349 * {port_fe_sigtran={ip_requirements={ip_count_required: {count: 1}, dhcp_enabled: true, ip_version: 4}, subnetpoolid: "subnet_1", network_role_tag: "SIGNET_vrf_B1_direct"}<br>
350 * port_fe_cluster={ip_requirements={ip_count_required: {count: 2}, dhcp_enabled: true, ip_version: 4}}<br>
351 * @param vfc - VFC node template to look for CP-related props.
352 * @return map <b>CP node template name</b> to a map of <b>property name</b> - <b> property value as object</b>.
354 public Map<String, Map<String, Object>> getCpPropertiesFromVfcAsObject(NodeTemplate vfc);
357 * Get customization UUID of a node template
358 * @param nt - node template
359 * @return customization UUID of a node template.
361 public String getNodeTemplateCustomizationUuid(NodeTemplate nt);
364 * Filter Node Template property values by equals/contains operator and a pattern
365 * @param nodeTemplate Node Template to filter its properties
366 * @param filterType filter type - equals or contains
367 * @param pattern value to filter with it
368 * @return Map <b>full path to a property</b> mapped to <b>property value</b> filtered by type and pattern
370 public Map<String, String> filterNodeTemplatePropertiesByValue(NodeTemplate nodeTemplate, FilterType filterType, String pattern);
373 * Get all node templates by sdcType for parent Node Template.
375 * @param parentNodeTemplate - parent node template
376 * @param sdcType - the SDC type of the node.
377 * @return node templates of this SDC type.
379 public List<NodeTemplate> getNodeTemplateBySdcType(NodeTemplate parentNodeTemplate, SdcTypes sdcType);
382 * Get all node templates by SDC type enum for this CSAR service.
384 * @param sdcType - the SDC type of the node (for example, CP, VF...).
385 * @return service node templates of this SDC type.
387 public List<NodeTemplate> getServiceNodeTemplateBySdcType(SdcTypes sdcType);
390 * Get all node templates for this CSAR service.
391 * @param vfCustomizationUuid - the Customization UUID of the node.
392 * @return VNF Configuration Node Template.
394 public NodeTemplate getVnfConfig(String vfCustomizationUuid);
397 * Check if Node Template has Topology Template
398 * @param nodeTemplate - Node Template to check
399 * @return true if node template has topology template, false if not.
401 public boolean hasTopology(NodeTemplate nodeTemplate);
404 * Get children node templates for node template.
405 * @param nodeTemplate - Node Template to get its children
406 * @return return list of children node templates for node template.
408 public List<NodeTemplate> getNodeTemplateChildren(NodeTemplate nodeTemplate);
411 * Get node template on service level by node template name.
412 * @param nodeName - the name of the node template.
413 * @return service-level node template with this name, or null if no such node template was found.
415 public NodeTemplate getServiceNodeTemplateByNodeName(String nodeName);
418 * Get node template Metadata object.<br>
419 * This object represents the "metadata" section of node template.
420 * @param nt - Node template to get its Metadata object.
421 * @return Metadata for this node template, or null if not found.
423 public Metadata getNodeTemplateMetadata(NodeTemplate nt);
426 * Get CapabilityAssignments object for this node template.<br>
427 * This should be an entry point function for working with capability assignments of node template.<br>
428 * This object allows filtering capability assignments objects.<br>
429 * @param nt - Node Template to get its capability assignments.
430 * @return CapabilitiesAssignments that contains list of capability assignments for the node template.<br>
431 * If none found, an empty list will be returned.
433 public CapabilityAssignments getCapabilitiesOf(NodeTemplate nt);
436 * Get RequirementAssignments object for this node template.<br>
437 * This should be an entry point function for working with requirement assignments of node template.<br>
438 * This object allows filtering requirement assignments objects.<br>
439 * @param nt - Node Template to get its requirement assignments.
440 * @return RequirementAssignments that contains list of requirement assignments for the node template.
441 * If none found, an empty list will be returned.
443 public RequirementAssignments getRequirementsOf(NodeTemplate nt);
446 * Get any property leaf value for capability by full path separated by #.
447 * Same logic as in {@link #getNodeTemplatePropertyLeafValue(NodeTemplate, String) getNodeTemplatePropertyLeafValue}, only for a capability assignment.
448 * @param capability - capability assignment where the property should be looked up.
449 * @param pathToPropertyLeafValue - the full path of the required property.
450 * @return the leaf value as String, or null if there's no such property, or it's not a leaf.
452 public String getCapabilityPropertyLeafValue(CapabilityAssignment capability, String pathToPropertyLeafValue);