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.onap.sdc.tosca.parser.api;
22 import java.util.ArrayList;
23 import java.util.List;
26 import org.apache.commons.lang3.tuple.Pair;
27 import org.onap.sdc.tosca.parser.impl.SdcTypes;
28 import org.onap.sdc.tosca.parser.impl.FilterType;
29 import org.onap.sdc.toscaparser.api.*;
30 import org.onap.sdc.toscaparser.api.elements.InterfacesDef;
31 import org.onap.sdc.toscaparser.api.elements.Metadata;
32 import org.onap.sdc.toscaparser.api.parameters.Input;
35 public interface ISdcCsarHelper {
38 * Get all node templates by node_type for this CSAR service.
40 * @param nodeType - the TOSCA type of the node.
41 * @return service node templates of this type.
43 public List<NodeTemplate> getServiceNodeTemplatesByType(String nodeType);
46 * Get all node templates for this CSAR service.
48 * @return service node templates.
50 public List<NodeTemplate> getServiceNodeTemplates();
53 * Get groups of a VF with type "org.onap.groups.VfModule".
55 * @param vfCustomizationUuid - customizationUuid of VF instance.
56 * @return list of vfModule groups.
58 public List<Group> getVfModulesByVf(String vfCustomizationUuid);
62 * Get any property leaf value for node template by full path separated by #.<br>
63 * For example, for node template with this property:<br><br>
64 * network_assignments:<br>
65 ecomp_generated_network_assignment: true<br>
66 is_shared_network: false<br>
67 is_external_network: false<br>
68 ipv4_subnet_default_assignments:<br>
69 use_ipv4: true<br>
70 ip_network_address_plan: 1.2.3.4<br>
71 dhcp_enabled: true<br>
72 ip_version: 4<br>
73 cidr_mask: 24<br>
74 min_subnets_count: 1<br>
75 ipv6_subnet_default_assignments:<br>
76 use_ipv6: false<br><br>
79 * getNodeTemplatePropertyLeafValue(nodeTemplate, "network_assignments#ipv6_subnet_default_assignments#use_ipv6")<br>
80 * will return "false".
81 * @param nodeTemplate - nodeTemplate where the property should be looked up.
82 * @param pathToPropertyLeafValue - the full path of the required property.
83 * @return the leaf value as String, or null if there's no such property, or it's not a leaf.
85 public String getNodeTemplatePropertyLeafValue(NodeTemplate nodeTemplate, String pathToPropertyLeafValue);
88 * Get any property leaf value for node template by full path separated by #.<br>
89 * For example, for node template with this property:<br><br>
90 * network_assignments:<br>
91 ecomp_generated_network_assignment: true<br>
92 is_shared_network: false<br>
93 is_external_network: false<br>
94 ipv4_subnet_default_assignments:<br>
95 use_ipv4: true<br>
96 ip_network_address_plan: 1.2.3.4<br>
97 dhcp_enabled: true<br>
98 ip_version: 4<br>
99 cidr_mask: 24<br>
100 min_subnets_count: 1<br>
101 ipv6_subnet_default_assignments:<br>
102 use_ipv6: false<br><br>
105 * getNodeTemplatePropertyLeafValue(nodeTemplate, "network_assignments#ipv6_subnet_default_assignments#use_ipv6")<br>
106 * will return "false".
107 * @param nodeTemplate - nodeTemplate where the property should be looked up.
108 * @param pathToPropertyLeafValue - the full path of the required property.
109 * @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.
111 public Object getNodeTemplatePropertyAsObject(NodeTemplate nodeTemplate, String pathToPropertyLeafValue);
114 * Get any property leaf value for a group definition by full path separated by #.
115 * Same logic as in {@link #getNodeTemplatePropertyLeafValue(NodeTemplate, String) getNodeTemplatePropertyLeafValue}, only for a group.
116 * @param group - group where the property should be looked up.
117 * @param propertyName - the name of the required property.
118 * @return the leaf value as String, or null if there's no such property, or it's not a leaf.
120 public String getGroupPropertyLeafValue(Group group, String propertyName);
123 * Get any property value for a group definition by full path separated by #.
124 * Same logic as in {@link #getNodeTemplatePropertyLeafValue(NodeTemplate, String) getNodeTemplatePropertyLeafValue}, only for a group.
125 * @param group - group where the property should be looked up.
126 * @param propertyName - the name of the required property.
127 * @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.
129 public Object getGroupPropertyAsObject(Group group, String propertyName);
132 * Get all VL node templates of the CSAR service.
133 * @return - all VL node templates.
135 public List<NodeTemplate> getServiceVlList();
138 * Get all VF node templates of the CSAR service.
139 * @return - all VF node templates.
141 public List<NodeTemplate> getServiceVfList();
146 * Get a property from a metadata object.<br>
147 * This is just sugaring method, same as calling metadata.getMetadataPropertyValue(metadataPropertyName).<br>
149 * For metadata object representing the below: <br><br>
152 invariantUUID: 4598a404-00e1-42a6-8767-0bda343e2066<br>
153 UUID: e17940d6-42f8-4989-bad0-31de5addc619<br>
154 customizationUUID: 83d086b2-a861-4d3b-aa84-3bfbb9b2ec20<br>
155 version: '0.1'<br>
156 name: vIPR_ATM<br>
157 description: vIPR_ATM<br>
158 type: VF<br>
159 category: category1<br>
160 subcategory: subCategory1<br><br>
163 getMetadataPropertyValue(metadata,"invariantUUID")<br>
164 will return "4598a404-00e1-42a6-8767-0bda343e2066".
166 * @param metadata - metadata object.
167 * @param metadataPropertyName - the name of the metadata property.
168 * @return metadata property value
170 public String getMetadataPropertyValue(Metadata metadata, String metadataPropertyName);
174 * Get input leaf value for the CSAR service, by full path separated by #.<br>
175 * Same logic as in {@link #getNodeTemplatePropertyLeafValue(NodeTemplate, String) getNodeTemplatePropertyLeafValue}, only for an input full path.
176 * The expected format is "input_name#default[optionally #rest_of_path]"
177 * @param inputLeafValuePath by full path separated by #.
178 * @return input leaf value for the service.
180 public String getServiceInputLeafValueOfDefault(String inputLeafValuePath);
183 * Get input leaf value for the CSAR service, by full path separated by #.<br>
184 * Same logic as in {@link #getNodeTemplatePropertyLeafValue(NodeTemplate, String) getNodeTemplatePropertyLeafValue}, only for an input full path.
185 * The expected format is "input_name#default[optionally #rest_of_path]"
186 * @param inputLeafValuePath by full path separated by #.
187 * @return input value for the service as Object. It's up to the caller to cast it to a proper type.
189 public Object getServiceInputLeafValueOfDefaultAsObject(String inputLeafValuePath);
192 * Get the type name of the CSAR service's substitution mappings element.<br>
194 * For the below:<br><br>
196 * substitution_mappings:<br>
197 type: org.onap.services.ViprATM<br>
200 getServiceSubstitutionMappingsTypeName()<br>
201 will return "org.onap.services.ViprATM"
202 * @return - the type name of the CSAR service's substitution mappings element
204 public String getServiceSubstitutionMappingsTypeName();
207 * Get service Metadata object.<br>
208 * This object represents the "metadata" section of a CSAR service.
209 * @return - the service Metadata object.
211 public Metadata getServiceMetadata();
214 * Get the CSAR service metadata as map.
215 * @return - the service metadata object as Map.
216 * @deprecated This function is deprecated since its not tosca compliant. <br>
217 * Tosca defines the Metadata section as map of string (not map of object).<br>
218 * This function is targeted to be removed as part of 1802.<br>
219 * Please use {@link #getServiceMetadataAllProperties() getServiceMetadataAllProperties()}.
222 public Map<String, Object> getServiceMetadataProperties();
225 * Get the CSAR service metadata as map
226 * @return - the service metadata object as Map
228 public Map<String, String> getServiceMetadataAllProperties();
231 * Get all VFC node templates from a specified VF.
232 * @param vfCustomizationId - customizationUuid of the VF node template.
233 * @return all VFC node templates from a specified VF
235 public List<NodeTemplate> getVfcListByVf(String vfCustomizationId);
238 * Get all CP node templates from a specified VF.
239 * @param vfCustomizationId - customizationUuid of the VF node template.
240 * @return all CP node templates from a specified VF
242 public List<NodeTemplate> getCpListByVf(String vfCustomizationId);
245 * Get all members of this group definition.<br>
247 * For example, for this group definition:<br><br>
249 * ViprAtm..vIPR-ATM-Base..module-0:<br>
250 type: org.onap.groups.VfModule<br>
251 .................<br>
252 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>
255 getMembersOfVfModule(NoteTemplate vfNodeTemplate, Group group)<br>
256 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>
257 * @param vf - VF to return the node templates from.
258 * @param vfModule - group to return the members from.
259 * @return node templates from vf with the names as in members section.
262 public List<NodeTemplate> getMembersOfVfModule(NodeTemplate vf, Group vfModule);
266 * Get list of node template pairs, where for each pair,<br>
267 * the left node template in pair has requirement with name reqName, <br>
268 * which should be satisfied with respective capability by the right node template in pair.<br>
270 * For example, if we have the below two node templates in the vIPR VF:<br><br>
273 type: org.onap.resources.cp.extCP<br>
274 requirements:<br>
275 - virtualBinding: vipr_atm_firewall<br><br>
277 * vipr_atm_firewall: <br>
278 type: org.onap.resources.vfc.ViprAtm.abstract.nodes.heat.vipr_atm<br>
283 * getNodeTemplatePairsByReqName(getCpListByVf(viprCustomUuid), getVfcListByVf(viprCustomUuid), "virtualBinding")<br>
284 * will return a list with one Pair - where left element of pair will be "oam_extCP" node template,<br>
285 * and right element will be "vipr_atm_firewall" node template.<br>
287 * @param listOfReqNodeTemplates - list of node templates in which the "reqName" requirement should be looked.
288 * @param listOfCapNodeTemplates - list of node templates in which the capability matching the "reqName" requirement should be looked.
289 * @param reqName - the name of a requirement definition to match by.
290 * @return pairs of node templates according to described above.
292 public List<Pair<NodeTemplate,NodeTemplate>> getNodeTemplatePairsByReqName(List<NodeTemplate> listOfReqNodeTemplates, List<NodeTemplate> listOfCapNodeTemplates, String reqName);
295 * Get all allotted node templates from this service.
296 * @return all allotted node templates from this service.
298 public List<NodeTemplate> getAllottedResources();
301 * Get node_type of a node template.<br>
303 * For this node template:<br>
305 * vipr_atm_firewall: <br>
306 type: org.onap.resources.vfc.ViprAtm.abstract.nodes.heat.vipr_atm<br>
309 * the function will return "org.onap.resources.vfc.ViprAtm.abstract.nodes.heat.vipr_atm"
311 * @param nodeTemplate - node template object
312 * @return - node type string.
314 public String getTypeOfNodeTemplate(NodeTemplate nodeTemplate);
317 * Get the CSAR service inputs list.
318 * @return - the service inputs list.
320 public List<Input> getServiceInputs();
324 * Get the conformance level of this CSAR. <br>
325 * The conformance level value of the CSAR is located in csar.meta file at the top level of the CSAR file.<br>
326 * For 1707 CSARs, the conformance level is 3.0.
327 * @return the conformance level of the CSAR.
329 public String getConformanceLevel();
333 * Get the map of CP-related props from a VFC node template. <br>
334 * Let's say there are 5 CPs related to this VFC. Then the output will look like this: <br><br>
335 * {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>
336 * port_fe_cluster={ip_requirements#ip_count_required#count=2, ip_requirements#dhcp_enabled=true, ip_requirements#ip_version=4},<br>
337 * port_fe_slan={ip_requirements#ip_count_required#count=1, ip_requirements#dhcp_enabled=true, ip_requirements#ip_version=4},<br>
338 * port_fe_interce={ip_requirements#ip_count_required#count=1, ip_requirements#dhcp_enabled=true, ip_requirements#ip_version=4},<br>
339 * 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>
340 * @param vfc - VFC node template to look for CP-related props.
341 * @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>.
342 * @deprecated This function is deprecated since its flattened form doesn't provide solution for cp properties of type List.
343 * Will be removed in 1802.
346 public Map<String, Map<String, Object>> getCpPropertiesFromVfc(NodeTemplate vfc);
349 * Get the map of CP-related props from a VFC node template. <br>
350 * Let's say there are 2 CPs (ports) related to this VFC. Then the output will look like this: <br><br>
351 * {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>
352 * port_fe_cluster={ip_requirements={ip_count_required: {count: 2}, dhcp_enabled: true, ip_version: 4}}<br>
353 * @param vfc - VFC node template to look for CP-related props.
354 * @return map <b>CP node template name</b> to a map of <b>property name</b> - <b> property value as object</b>.
356 public Map<String, Map<String, Object>> getCpPropertiesFromVfcAsObject(NodeTemplate vfc);
359 * Get customization UUID of a node template
360 * @param nt - node template
361 * @return customization UUID of a node template.
363 public String getNodeTemplateCustomizationUuid(NodeTemplate nt);
366 * Filter Node Template property values by equals/contains operator and a pattern
367 * @param nodeTemplate Node Template to filter its properties
368 * @param filterType filter type - equals or contains
369 * @param pattern value to filter with it
370 * @return Map <b>full path to a property</b> mapped to <b>property value</b> filtered by type and pattern
372 public Map<String, String> filterNodeTemplatePropertiesByValue(NodeTemplate nodeTemplate, FilterType filterType, String pattern);
375 * Get all node templates by sdcType for parent Node Template.
377 * @param parentNodeTemplate - parent node template
378 * @param sdcType - the SDC type of the node.
379 * @return node templates of this SDC type.
381 public List<NodeTemplate> getNodeTemplateBySdcType(NodeTemplate parentNodeTemplate, SdcTypes sdcType);
384 * Get all node templates by SDC type enum for this CSAR service.
386 * @param sdcType - the SDC type of the node (for example, CP, VF...).
387 * @return service node templates of this SDC type.
389 public List<NodeTemplate> getServiceNodeTemplateBySdcType(SdcTypes sdcType);
392 * Get all node templates for this CSAR service.
393 * @param vfCustomizationUuid - the Customization UUID of the node.
394 * @return VNF Configuration Node Template.
396 public NodeTemplate getVnfConfig(String vfCustomizationUuid);
399 * Check if Node Template has Topology Template
400 * @param nodeTemplate - Node Template to check
401 * @return true if node template has topology template, false if not.
403 public boolean hasTopology(NodeTemplate nodeTemplate);
406 * Get children node templates for node template.
407 * @param nodeTemplate - Node Template to get its children
408 * @return return list of children node templates for node template.
410 public List<NodeTemplate> getNodeTemplateChildren(NodeTemplate nodeTemplate);
413 * Get node template on service level by node template name.
414 * @param nodeName - the name of the node template.
415 * @return service-level node template with this name, or null if no such node template was found.
417 public NodeTemplate getServiceNodeTemplateByNodeName(String nodeName);
420 * Get node template Metadata object.<br>
421 * This object represents the "metadata" section of node template.
422 * @param nt - Node template to get its Metadata object.
423 * @return Metadata for this node template, or null if not found.
425 public Metadata getNodeTemplateMetadata(NodeTemplate nt);
428 * Get CapabilityAssignments object for this node template.<br>
429 * This should be an entry point function for working with capability assignments of node template.<br>
430 * This object allows filtering capability assignments objects.<br>
431 * @param nt - Node Template to get its capability assignments.
432 * @return CapabilitiesAssignments that contains list of capability assignments for the node template.<br>
433 * If none found, an empty list will be returned.
435 public CapabilityAssignments getCapabilitiesOf(NodeTemplate nt);
438 * Get RequirementAssignments object for this node template.<br>
439 * This should be an entry point function for working with requirement assignments of node template.<br>
440 * This object allows filtering requirement assignments objects.<br>
441 * @param nt - Node Template to get its requirement assignments.
442 * @return RequirementAssignments that contains list of requirement assignments for the node template.
443 * If none found, an empty list will be returned.
445 public RequirementAssignments getRequirementsOf(NodeTemplate nt);
448 * Get any property leaf value for capability by full path separated by #.
449 * Same logic as in {@link #getNodeTemplatePropertyLeafValue(NodeTemplate, String) getNodeTemplatePropertyLeafValue}, only for a capability assignment.
450 * @param capability - capability assignment where the property should be looked up.
451 * @param pathToPropertyLeafValue - the full path of the required property.
452 * @return the leaf value as String, or null if there's no such property, or it's not a leaf.
454 public String getCapabilityPropertyLeafValue(CapabilityAssignment capability, String pathToPropertyLeafValue);
457 * Get all the policies of the main topology template (either VF or service)
458 * @return the list of the policies
460 public List<Policy> getPoliciesOfTopologyTemplate();
463 * Get all the policies of the main topology template (either VF or service) specified by policy type
464 * @param policyTypeName the name of the policy type
465 * @return the list of the policies
467 public List<Policy> getPoliciesOfTopologyTemplateByToscaPolicyType(String policyTypeName);
470 * Get all the policies of the origin component (nested topology template) of the node template
471 * @param nodeTemplate the node template
472 * @return the list of the policies
474 public List<Policy> getPoliciesOfOriginOfNodeTemplate(NodeTemplate nodeTemplate);
477 * Get all the policies of the origin component (nested topology template) of the node template specified by policy type
478 * @param nodeTemplate the node template
479 * @param policyTypeName the name of the policy type
480 * @return the list of the policies
482 public List<Policy> getPoliciesOfOriginOfNodeTemplateByToscaPolicyType(NodeTemplate nodeTemplate, String policyTypeName);
485 * Get all the node templates of the topology template, which are the targets of the policy specified by name
486 * @param policyName the name of the policy
487 * @return the list of the node templates
489 public List<NodeTemplate> getPolicyTargetsFromTopologyTemplate(String policyName);
492 * Get all the node templates of the origin component (nested topology template) of node template, which are the targets of the policy specified by name
493 * @param nodeTemplate the node template
494 * @param policyName the name of the policy
495 * @return the list of the node templates
497 public List<NodeTemplate> getPolicyTargetsFromOrigin(NodeTemplate nodeTemplate, String policyName);
500 * Get the node template of the topology template specified by name
501 * @param nodeTemplateName the name of the node template
502 * @return the node template
504 public NodeTemplate getNodeTemplateByName(String nodeTemplateName);
507 * Get all the policies, which contain the specified node template as a target
508 * @param targetNode the node template
509 * @return the list of the policies
511 public List<Policy> getPoliciesOfTarget(NodeTemplate targetNode);
514 * Get all the policies of the specified type, which contain the specified node template as a target
515 * @param nodeTemplate the node template
516 * @param policyTypeName the name of the policy type
517 * @return the list of the policies
519 public List<Policy> getPoliciesOfTargetByToscaPolicyType(NodeTemplate nodeTemplate, String policyTypeName);
522 * Get all the groups of the origin component (nested topology template) of the node template
523 * @param nodeTemplate the node template
524 * @return the list of the groups
526 public ArrayList<Group> getGroupsOfOriginOfNodeTemplate(NodeTemplate nodeTemplate);
529 * Get all groups of this of the main topology template (either VF or service) by specified tosca group type
530 * @param groupType the group type
531 * @return the list of the groups
533 public ArrayList<Group> getGroupsOfTopologyTemplateByToscaGroupType(String groupType);
536 * Get all groups of this of the main topology template (either VF or service)
537 * @return the list of the groups
539 public ArrayList<Group> getGroupsOfTopologyTemplate();
542 * Get all groups of this of the origin component (nested topology template) of the node template by specified tosca group type
543 * @param nodeTemplate the node template
544 * @param groupType the group type
545 * @return the list of the groups
547 public ArrayList<Group> getGroupsOfOriginOfNodeTemplateByToscaGroupType(NodeTemplate nodeTemplate, String groupType);
550 * Get members of the group belongs to the main topology template (either VF or service) by group name
551 * @param groupName the name of the group
552 * @return the list of the node templates
554 public List<NodeTemplate> getGroupMembersFromTopologyTemplate(String groupName);
557 * Get members of the group belongs to the origin component (nested topology template) of the node template by group name
558 * @param nodeTemplate the node template
559 * @param groupName the name of the group
560 * @return the list of the node templates
562 public List<NodeTemplate> getGroupMembersOfOriginOfNodeTemplate(NodeTemplate nodeTemplate, String groupName);
565 * Get all interface details for given node template.<br>
566 * @return Map that contains the list of all interfaces and their definitions.
567 * If none found, an empty map will be returned.
569 public Map<String, List<InterfacesDef>> getInterfacesOf(NodeTemplate nt);
572 * Get all interface names for given node template.<br>
573 * @return List that contains the name of all interfaces.
574 * If none found, an empty list will be returned.
576 public List<String> getInterfaces(NodeTemplate nt);
579 * Get all details for given node template and interface name.<br>
580 * @return List that contains the definitions of given interface name.
581 * If none found, an empty list will be returned.
583 public List<InterfacesDef> getInterfaceDetails(NodeTemplate nt, String interfaceName);
586 * Get all operation names for given node template and interface name.<br>
587 * @return List that contains the name of all operations for a given node template and interface name.
588 * If none found, an empty list will be returned.
590 public List<String> getAllInterfaceOperations(NodeTemplate nt, String interfaceName);
593 * Get interface details for a given node template, interface name and operation name.<br>
594 * @return InterfaceDef representing the operation details.
595 * If none found, null will be returned.
597 public InterfacesDef getInterfaceOperationDetails(NodeTemplate nt, String interfaceName, String operationName);