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.Metadata;
31 import org.onap.sdc.toscaparser.api.parameters.Input;
34 public interface ISdcCsarHelper {
37 * Get all node templates by node_type for this CSAR service.
39 * @param nodeType - the TOSCA type of the node.
40 * @return service node templates of this type.
42 public List<NodeTemplate> getServiceNodeTemplatesByType(String nodeType);
45 * Get all node templates for this CSAR service.
47 * @return service node templates.
49 public List<NodeTemplate> getServiceNodeTemplates();
52 * Get groups of a VF with type "org.onap.groups.VfModule".
54 * @param vfCustomizationUuid - customizationUuid of VF instance.
55 * @return list of vfModule groups.
57 public List<Group> getVfModulesByVf(String vfCustomizationUuid);
61 * Get any property leaf value for node template by full path separated by #.<br>
62 * For example, for node template with this property:<br><br>
63 * network_assignments:<br>
64 ecomp_generated_network_assignment: true<br>
65 is_shared_network: false<br>
66 is_external_network: false<br>
67 ipv4_subnet_default_assignments:<br>
68 use_ipv4: true<br>
69 ip_network_address_plan: 1.2.3.4<br>
70 dhcp_enabled: true<br>
71 ip_version: 4<br>
72 cidr_mask: 24<br>
73 min_subnets_count: 1<br>
74 ipv6_subnet_default_assignments:<br>
75 use_ipv6: false<br><br>
78 * getNodeTemplatePropertyLeafValue(nodeTemplate, "network_assignments#ipv6_subnet_default_assignments#use_ipv6")<br>
79 * will return "false".
80 * @param nodeTemplate - nodeTemplate where the property should be looked up.
81 * @param pathToPropertyLeafValue - the full path of the required property.
82 * @return the leaf value as String, or null if there's no such property, or it's not a leaf.
84 public String getNodeTemplatePropertyLeafValue(NodeTemplate nodeTemplate, String pathToPropertyLeafValue);
87 * Get any property leaf value for node template by full path separated by #.<br>
88 * For example, for node template with this property:<br><br>
89 * network_assignments:<br>
90 ecomp_generated_network_assignment: true<br>
91 is_shared_network: false<br>
92 is_external_network: false<br>
93 ipv4_subnet_default_assignments:<br>
94 use_ipv4: true<br>
95 ip_network_address_plan: 1.2.3.4<br>
96 dhcp_enabled: true<br>
97 ip_version: 4<br>
98 cidr_mask: 24<br>
99 min_subnets_count: 1<br>
100 ipv6_subnet_default_assignments:<br>
101 use_ipv6: false<br><br>
104 * getNodeTemplatePropertyLeafValue(nodeTemplate, "network_assignments#ipv6_subnet_default_assignments#use_ipv6")<br>
105 * will return "false".
106 * @param nodeTemplate - nodeTemplate where the property should be looked up.
107 * @param pathToPropertyLeafValue - the full path of the required property.
108 * @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.
110 public Object getNodeTemplatePropertyAsObject(NodeTemplate nodeTemplate, String pathToPropertyLeafValue);
113 * Get any property leaf value for a group definition by full path separated by #.
114 * Same logic as in {@link #getNodeTemplatePropertyLeafValue(NodeTemplate, String) getNodeTemplatePropertyLeafValue}, only for a group.
115 * @param group - group where the property should be looked up.
116 * @param propertyName - the name of the required property.
117 * @return the leaf value as String, or null if there's no such property, or it's not a leaf.
119 public String getGroupPropertyLeafValue(Group group, String propertyName);
122 * Get any property value for a group definition by full path separated by #.
123 * Same logic as in {@link #getNodeTemplatePropertyLeafValue(NodeTemplate, String) getNodeTemplatePropertyLeafValue}, only for a group.
124 * @param group - group where the property should be looked up.
125 * @param propertyName - the name of the required property.
126 * @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.
128 public Object getGroupPropertyAsObject(Group group, String propertyName);
131 * Get all VL node templates of the CSAR service.
132 * @return - all VL node templates.
134 public List<NodeTemplate> getServiceVlList();
137 * Get all VF node templates of the CSAR service.
138 * @return - all VF node templates.
140 public List<NodeTemplate> getServiceVfList();
145 * Get a property from a metadata object.<br>
146 * This is just sugaring method, same as calling metadata.getMetadataPropertyValue(metadataPropertyName).<br>
148 * For metadata object representing the below: <br><br>
151 invariantUUID: 4598a404-00e1-42a6-8767-0bda343e2066<br>
152 UUID: e17940d6-42f8-4989-bad0-31de5addc619<br>
153 customizationUUID: 83d086b2-a861-4d3b-aa84-3bfbb9b2ec20<br>
154 version: '0.1'<br>
155 name: vIPR_ATM<br>
156 description: vIPR_ATM<br>
157 type: VF<br>
158 category: category1<br>
159 subcategory: subCategory1<br><br>
162 getMetadataPropertyValue(metadata,"invariantUUID")<br>
163 will return "4598a404-00e1-42a6-8767-0bda343e2066".
165 * @param metadata - metadata object.
166 * @param metadataPropertyName - the name of the metadata property.
167 * @return metadata property value
169 public String getMetadataPropertyValue(Metadata metadata, String metadataPropertyName);
173 * Get input leaf value for the CSAR service, by full path separated by #.<br>
174 * Same logic as in {@link #getNodeTemplatePropertyLeafValue(NodeTemplate, String) getNodeTemplatePropertyLeafValue}, only for an input full path.
175 * The expected format is "input_name#default[optionally #rest_of_path]"
176 * @param inputLeafValuePath by full path separated by #.
177 * @return input leaf value for the service.
179 public String getServiceInputLeafValueOfDefault(String inputLeafValuePath);
182 * Get input leaf value for the CSAR service, by full path separated by #.<br>
183 * Same logic as in {@link #getNodeTemplatePropertyLeafValue(NodeTemplate, String) getNodeTemplatePropertyLeafValue}, only for an input full path.
184 * The expected format is "input_name#default[optionally #rest_of_path]"
185 * @param inputLeafValuePath by full path separated by #.
186 * @return input value for the service as Object. It's up to the caller to cast it to a proper type.
188 public Object getServiceInputLeafValueOfDefaultAsObject(String inputLeafValuePath);
191 * Get the type name of the CSAR service's substitution mappings element.<br>
193 * For the below:<br><br>
195 * substitution_mappings:<br>
196 type: org.onap.services.ViprATM<br>
199 getServiceSubstitutionMappingsTypeName()<br>
200 will return "org.onap.services.ViprATM"
201 * @return - the type name of the CSAR service's substitution mappings element
203 public String getServiceSubstitutionMappingsTypeName();
206 * Get service Metadata object.<br>
207 * This object represents the "metadata" section of a CSAR service.
208 * @return - the service Metadata object.
210 public Metadata getServiceMetadata();
213 * Get the CSAR service metadata as map.
214 * @return - the service metadata object as Map.
215 * @deprecated This function is deprecated since its not tosca compliant. <br>
216 * Tosca defines the Metadata section as map of string (not map of object).<br>
217 * This function is targeted to be removed as part of 1802.<br>
218 * Please use {@link #getServiceMetadataAllProperties() getServiceMetadataAllProperties()}.
221 public Map<String, Object> getServiceMetadataProperties();
224 * Get the CSAR service metadata as map
225 * @return - the service metadata object as Map
227 public Map<String, String> getServiceMetadataAllProperties();
230 * Get all VFC node templates from a specified VF.
231 * @param vfCustomizationId - customizationUuid of the VF node template.
232 * @return all VFC node templates from a specified VF
234 public List<NodeTemplate> getVfcListByVf(String vfCustomizationId);
237 * Get all CP node templates from a specified VF.
238 * @param vfCustomizationId - customizationUuid of the VF node template.
239 * @return all CP node templates from a specified VF
241 public List<NodeTemplate> getCpListByVf(String vfCustomizationId);
244 * Get all members of this group definition.<br>
246 * For example, for this group definition:<br><br>
248 * ViprAtm..vIPR-ATM-Base..module-0:<br>
249 type: org.onap.groups.VfModule<br>
250 .................<br>
251 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>
254 getMembersOfVfModule(NoteTemplate vfNodeTemplate, Group group)<br>
255 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>
256 * @param vf - VF to return the node templates from.
257 * @param vfModule - group to return the members from.
258 * @return node templates from vf with the names as in members section.
261 public List<NodeTemplate> getMembersOfVfModule(NodeTemplate vf, Group vfModule);
265 * Get list of node template pairs, where for each pair,<br>
266 * the left node template in pair has requirement with name reqName, <br>
267 * which should be satisfied with respective capability by the right node template in pair.<br>
269 * For example, if we have the below two node templates in the vIPR VF:<br><br>
272 type: org.onap.resources.cp.extCP<br>
273 requirements:<br>
274 - virtualBinding: vipr_atm_firewall<br><br>
276 * vipr_atm_firewall: <br>
277 type: org.onap.resources.vfc.ViprAtm.abstract.nodes.heat.vipr_atm<br>
282 * getNodeTemplatePairsByReqName(getCpListByVf(viprCustomUuid), getVfcListByVf(viprCustomUuid), "virtualBinding")<br>
283 * will return a list with one Pair - where left element of pair will be "oam_extCP" node template,<br>
284 * and right element will be "vipr_atm_firewall" node template.<br>
286 * @param listOfReqNodeTemplates - list of node templates in which the "reqName" requirement should be looked.
287 * @param listOfCapNodeTemplates - list of node templates in which the capability matching the "reqName" requirement should be looked.
288 * @param reqName - the name of a requirement definition to match by.
289 * @return pairs of node templates according to described above.
291 public List<Pair<NodeTemplate,NodeTemplate>> getNodeTemplatePairsByReqName(List<NodeTemplate> listOfReqNodeTemplates, List<NodeTemplate> listOfCapNodeTemplates, String reqName);
294 * Get all allotted node templates from this service.
295 * @return all allotted node templates from this service.
297 public List<NodeTemplate> getAllottedResources();
300 * Get node_type of a node template.<br>
302 * For this node template:<br>
304 * vipr_atm_firewall: <br>
305 type: org.onap.resources.vfc.ViprAtm.abstract.nodes.heat.vipr_atm<br>
308 * the function will return "org.onap.resources.vfc.ViprAtm.abstract.nodes.heat.vipr_atm"
310 * @param nodeTemplate - node template object
311 * @return - node type string.
313 public String getTypeOfNodeTemplate(NodeTemplate nodeTemplate);
316 * Get the CSAR service inputs list.
317 * @return - the service inputs list.
319 public List<Input> getServiceInputs();
323 * Get the conformance level of this CSAR. <br>
324 * The conformance level value of the CSAR is located in csar.meta file at the top level of the CSAR file.<br>
325 * For 1707 CSARs, the conformance level is 3.0.
326 * @return the conformance level of the CSAR.
328 public String getConformanceLevel();
332 * Get the map of CP-related props from a VFC node template. <br>
333 * Let's say there are 5 CPs related to this VFC. Then the output will look like this: <br><br>
334 * {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>
335 * port_fe_cluster={ip_requirements#ip_count_required#count=2, ip_requirements#dhcp_enabled=true, ip_requirements#ip_version=4},<br>
336 * port_fe_slan={ip_requirements#ip_count_required#count=1, ip_requirements#dhcp_enabled=true, ip_requirements#ip_version=4},<br>
337 * port_fe_interce={ip_requirements#ip_count_required#count=1, ip_requirements#dhcp_enabled=true, ip_requirements#ip_version=4},<br>
338 * 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>
339 * @param vfc - VFC node template to look for CP-related props.
340 * @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>.
341 * @deprecated This function is deprecated since its flattened form doesn't provide solution for cp properties of type List.
342 * Will be removed in 1802.
345 public Map<String, Map<String, Object>> getCpPropertiesFromVfc(NodeTemplate vfc);
348 * Get the map of CP-related props from a VFC node template. <br>
349 * Let's say there are 2 CPs (ports) related to this VFC. Then the output will look like this: <br><br>
350 * {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>
351 * port_fe_cluster={ip_requirements={ip_count_required: {count: 2}, dhcp_enabled: true, ip_version: 4}}<br>
352 * @param vfc - VFC node template to look for CP-related props.
353 * @return map <b>CP node template name</b> to a map of <b>property name</b> - <b> property value as object</b>.
355 public Map<String, Map<String, Object>> getCpPropertiesFromVfcAsObject(NodeTemplate vfc);
358 * Get customization UUID of a node template
359 * @param nt - node template
360 * @return customization UUID of a node template.
362 public String getNodeTemplateCustomizationUuid(NodeTemplate nt);
365 * Filter Node Template property values by equals/contains operator and a pattern
366 * @param nodeTemplate Node Template to filter its properties
367 * @param filterType filter type - equals or contains
368 * @param pattern value to filter with it
369 * @return Map <b>full path to a property</b> mapped to <b>property value</b> filtered by type and pattern
371 public Map<String, String> filterNodeTemplatePropertiesByValue(NodeTemplate nodeTemplate, FilterType filterType, String pattern);
374 * Get all node templates by sdcType for parent Node Template.
376 * @param parentNodeTemplate - parent node template
377 * @param sdcType - the SDC type of the node.
378 * @return node templates of this SDC type.
380 public List<NodeTemplate> getNodeTemplateBySdcType(NodeTemplate parentNodeTemplate, SdcTypes sdcType);
383 * Get all node templates by SDC type enum for this CSAR service.
385 * @param sdcType - the SDC type of the node (for example, CP, VF...).
386 * @return service node templates of this SDC type.
388 public List<NodeTemplate> getServiceNodeTemplateBySdcType(SdcTypes sdcType);
391 * Get all node templates for this CSAR service.
392 * @param vfCustomizationUuid - the Customization UUID of the node.
393 * @return VNF Configuration Node Template.
395 public NodeTemplate getVnfConfig(String vfCustomizationUuid);
398 * Check if Node Template has Topology Template
399 * @param nodeTemplate - Node Template to check
400 * @return true if node template has topology template, false if not.
402 public boolean hasTopology(NodeTemplate nodeTemplate);
405 * Get children node templates for node template.
406 * @param nodeTemplate - Node Template to get its children
407 * @return return list of children node templates for node template.
409 public List<NodeTemplate> getNodeTemplateChildren(NodeTemplate nodeTemplate);
412 * Get node template on service level by node template name.
413 * @param nodeName - the name of the node template.
414 * @return service-level node template with this name, or null if no such node template was found.
416 public NodeTemplate getServiceNodeTemplateByNodeName(String nodeName);
419 * Get node template Metadata object.<br>
420 * This object represents the "metadata" section of node template.
421 * @param nt - Node template to get its Metadata object.
422 * @return Metadata for this node template, or null if not found.
424 public Metadata getNodeTemplateMetadata(NodeTemplate nt);
427 * Get CapabilityAssignments object for this node template.<br>
428 * This should be an entry point function for working with capability assignments of node template.<br>
429 * This object allows filtering capability assignments objects.<br>
430 * @param nt - Node Template to get its capability assignments.
431 * @return CapabilitiesAssignments that contains list of capability assignments for the node template.<br>
432 * If none found, an empty list will be returned.
434 public CapabilityAssignments getCapabilitiesOf(NodeTemplate nt);
437 * Get RequirementAssignments object for this node template.<br>
438 * This should be an entry point function for working with requirement assignments of node template.<br>
439 * This object allows filtering requirement assignments objects.<br>
440 * @param nt - Node Template to get its requirement assignments.
441 * @return RequirementAssignments that contains list of requirement assignments for the node template.
442 * If none found, an empty list will be returned.
444 public RequirementAssignments getRequirementsOf(NodeTemplate nt);
447 * Get any property leaf value for capability by full path separated by #.
448 * Same logic as in {@link #getNodeTemplatePropertyLeafValue(NodeTemplate, String) getNodeTemplatePropertyLeafValue}, only for a capability assignment.
449 * @param capability - capability assignment where the property should be looked up.
450 * @param pathToPropertyLeafValue - the full path of the required property.
451 * @return the leaf value as String, or null if there's no such property, or it's not a leaf.
453 public String getCapabilityPropertyLeafValue(CapabilityAssignment capability, String pathToPropertyLeafValue);
456 * Get all the policies of the main topology template (either VF or service)
457 * @return the list of the policies
459 public List<Policy> getPoliciesOfTopologyTemplate();
462 * Get all the policies of the main topology template (either VF or service) specified by policy type
463 * @param policyTypeName the name of the policy type
464 * @return the list of the policies
466 public List<Policy> getPoliciesOfTopologyTemplateByToscaPolicyType(String policyTypeName);
469 * Get all the policies of the origin component (nested topology template) of the node template
470 * @param nodeTemplate the node template
471 * @return the list of the policies
473 public List<Policy> getPoliciesOfOriginOfNodeTemplate(NodeTemplate nodeTemplate);
476 * Get all the policies of the origin component (nested topology template) of the node template specified by policy type
477 * @param nodeTemplate the node template
478 * @param policyTypeName the name of the policy type
479 * @return the list of the policies
481 public List<Policy> getPoliciesOfOriginOfNodeTemplateByToscaPolicyType(NodeTemplate nodeTemplate, String policyTypeName);
484 * Get all the node templates of the topology template, which are the targets of the policy specified by name
485 * @param policyName the name of the policy
486 * @return the list of the node templates
488 public List<NodeTemplate> getPolicyTargetsFromTopologyTemplate(String policyName);
491 * 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
492 * @param nodeTemplate the node template
493 * @param policyName the name of the policy
494 * @return the list of the node templates
496 public List<NodeTemplate> getPolicyTargetsFromOrigin(NodeTemplate nodeTemplate, String policyName);
499 * Get the node template of the topology template specified by name
500 * @param nodeTemplateName the name of the node template
501 * @return the node template
503 public NodeTemplate getNodeTemplateByName(String nodeTemplateName);
506 * Get all the policies, which contain the specified node template as a target
507 * @param targetNode the node template
508 * @return the list of the policies
510 public List<Policy> getPoliciesOfTarget(NodeTemplate targetNode);
513 * Get all the policies of the specified type, which contain the specified node template as a target
514 * @param nodeTemplate the node template
515 * @param policyTypeName the name of the policy type
516 * @return the list of the policies
518 public List<Policy> getPoliciesOfTargetByToscaPolicyType(NodeTemplate nodeTemplate, String policyTypeName);
521 * Get all the groups of the origin component (nested topology template) of the node template
522 * @param nodeTemplate the node template
523 * @return the list of the groups
525 public ArrayList<Group> getGroupsOfOriginOfNodeTemplate(NodeTemplate nodeTemplate);
528 * Get all groups of this of the main topology template (either VF or service) by specified tosca group type
529 * @param groupType the group type
530 * @return the list of the groups
532 public ArrayList<Group> getGroupsOfTopologyTemplateByToscaGroupType(String groupType);
535 * Get all groups of this of the main topology template (either VF or service)
536 * @return the list of the groups
538 public ArrayList<Group> getGroupsOfTopologyTemplate();
541 * Get all groups of this of the origin component (nested topology template) of the node template by specified tosca group type
542 * @param nodeTemplate the node template
543 * @param groupType the group type
544 * @return the list of the groups
546 public ArrayList<Group> getGroupsOfOriginOfNodeTemplateByToscaGroupType(NodeTemplate nodeTemplate, String groupType);
549 * Get members of the group belongs to the main topology template (either VF or service) by group name
550 * @param groupName the name of the group
551 * @return the list of the node templates
553 public List<NodeTemplate> getGroupMembersFromTopologyTemplate(String groupName);
556 * Get members of the group belongs to the origin component (nested topology template) of the node template by group name
557 * @param nodeTemplate the node template
558 * @param groupName the name of the group
559 * @return the list of the node templates
561 public List<NodeTemplate> getGroupMembersOfOriginOfNodeTemplate(NodeTemplate nodeTemplate, String groupName);