diff options
author | Ramya Balaji <rb111y@att.com> | 2018-01-02 21:58:59 -0500 |
---|---|---|
committer | Skip Wonnell <skip@att.com> | 2018-01-04 21:10:36 +0000 |
commit | 13b9505921e2cbbd4b155a78bfdaa5caa3375ec0 (patch) | |
tree | 7c661f5c3c8b7895cad1d4c3c90b9077ba74c1fd | |
parent | 9ebb5ddcb60345dea668049c73f5f2d9c3cdf731 (diff) |
Updated SDC listener and dependent bundles
Changes related to SDC adapter.Also includes
sequence generator changes and changes to
appc-dg-shared.
Issue-ID: APPC-355
Change-Id: Ib8a0b1d304199db6d2595291539b266885842d63
Signed-off-by: Ramya Balaji <rb111y@att.com>
66 files changed, 2953 insertions, 1621 deletions
diff --git a/appc-dg/appc-dg-shared/appc-dg-aai/src/main/java/org/onap/appc/dg/aai/impl/AAIPluginImpl.java b/appc-dg/appc-dg-shared/appc-dg-aai/src/main/java/org/onap/appc/dg/aai/impl/AAIPluginImpl.java index 1b510a8ca..7848c412e 100644 --- a/appc-dg/appc-dg-shared/appc-dg-aai/src/main/java/org/onap/appc/dg/aai/impl/AAIPluginImpl.java +++ b/appc-dg/appc-dg-shared/appc-dg-aai/src/main/java/org/onap/appc/dg/aai/impl/AAIPluginImpl.java @@ -49,14 +49,16 @@ import java.util.HashMap; import java.util.HashSet; import java.util.Map; import java.util.Set; +import java.util.stream.Collectors; public class AAIPluginImpl implements AAIPlugin { - private AAIClient aaiClient; - private static final EELFLogger logger = EELFManager.getInstance().getLogger(AAIPluginImpl.class); - @SuppressWarnings("unchecked") - public AAIPluginImpl() { + protected AAIClient aaiClient; + + private final EELFLogger logger = EELFManager.getInstance().getLogger(AAIPluginImpl.class); + + public void initialize(){ BundleContext bctx = FrameworkUtil.getBundle(this.getClass()).getBundleContext(); ServiceReference sref = bctx.getServiceReference(AAIService.class); aaiClient = (AAIClient) bctx.getService(sref); @@ -142,7 +144,7 @@ public class AAIPluginImpl implements AAIPlugin { @Override public void getVnfHierarchy(Map<String, String> params, SvcLogicContext ctx) throws APPCException { - Map<Vnfc,Set<Vserver>> vnfcMap = new HashMap<>(); + Set<Vnfc> vnfcSet = new HashSet<>(); String vnfType,vnfVersion; String vnfId = params.get("resourceKey"); AAIQueryResult vnfQueryResult; @@ -153,6 +155,8 @@ public class AAIPluginImpl implements AAIPlugin { vnfType = vnfQueryResult.getAdditionProperties().get("vnf-type"); vnfVersion = vnfQueryResult.getAdditionProperties().get(Constants.AAI_VNF_MODEL_VERSION_ID); + Vnf vnf = createVnf(vnfType, vnfVersion, vnfId); + for(Relationship vnfRelationship:vnfQueryResult.getRelationshipList()){ if("vserver".equalsIgnoreCase(vnfRelationship.getRelatedTo())){ vmCount++; @@ -166,7 +170,8 @@ public class AAIPluginImpl implements AAIPlugin { AAIQueryResult vmQueryResult = readVM(vmId,tenantId,cloudOwner,cloudRegionId); String vmURL = vmQueryResult.getAdditionProperties().get("vserver-selflink"); - Vserver vm = new Vserver(vmURL,tenantId,vmId,vmRelatedLink,vmName); + Vserver vm = createVserver(tenantId, vmId, vmRelatedLink, vmName, vmURL); + vnf.addVserver(vm); for(Relationship vmRelation:vmQueryResult.getRelationshipList()){ if("vnfc".equalsIgnoreCase(vmRelation.getRelatedTo())){ @@ -174,18 +179,23 @@ public class AAIPluginImpl implements AAIPlugin { AAIQueryResult vnfcQueryResult = readVnfc(vnfcName); String vnfcType = vnfcQueryResult.getAdditionProperties().get("vnfc-type"); - Vnfc vnfc = new Vnfc(vnfcType,null,vnfcName); - Set<Vserver> vmSet = vnfcMap.get(vnfc); - if(vmSet == null){ - vmSet = new HashSet<>(); - vnfcMap.put(vnfc,vmSet); + Vnfc newVnfc = createVnfc(vnfcName, vnfcType); + if(vnfcSet.contains(newVnfc)){ + Vnfc vnfcFromSet = vnfcSet.stream().filter(vnfc -> vnfc.equals(newVnfc)).collect(Collectors.toList()).get(0); + vnfcFromSet.addVserver(vm); + vm.setVnfc(vnfcFromSet); + } + else{ + vm.setVnfc(newVnfc); + newVnfc.addVserver(vm); + vnfcSet.add(newVnfc); } - vmSet.add(vm); } } } } ctx.setAttribute("VNF.VMCount",String.valueOf(vmCount)); + populateContext(vnf,ctx); } catch (AAIQueryException e) { ctx.setAttribute("getVnfHierarchy_result", "FAILURE"); String msg = EELFResourceManager.format(Msg.AAI_QUERY_FAILED, vnfId); @@ -195,22 +205,37 @@ public class AAIPluginImpl implements AAIPlugin { logger.warn("Incorrect or Incomplete VNF Hierarchy"); throw new APPCException("Error Retrieving VNF hierarchy"); } - - Vnf vnf = new Vnf(vnfId,vnfType,vnfVersion); - for(Vnfc vnfc:vnfcMap.keySet()){ - for(Vserver vm:vnfcMap.get(vnfc)){ - vnfc.addVm(vm); - } - vnf.addVnfc(vnfc); - } - - populateContext(vnf,ctx); ctx.setAttribute("getVnfHierarchy_result", "SUCCESS"); String msg = EELFResourceManager.format(Msg.SUCCESS_EVENT_MESSAGE, "GetVNFHierarchy","VNF ID " + vnfId); ctx.setAttribute(org.onap.appc.Constants.ATTRIBUTE_SUCCESS_MESSAGE, msg); } + private Vnf createVnf(String vnfType, String vnfVersion, String vnfId) { + Vnf vnf = new Vnf(); + vnf.setVnfId(vnfId); + vnf.setVnfType(vnfType); + vnf.setVnfVersion(vnfVersion); + return vnf; + } + + private Vnfc createVnfc(String vnfcName, String vnfcType) { + Vnfc vnfc = new Vnfc(); + vnfc.setVnfcName(vnfcName); + vnfc.setVnfcType(vnfcType); + return vnfc; + } + + private Vserver createVserver(String tenantId, String vmId, String vmRelatedLink, String vmName, String vmURL) { + Vserver vserver = new Vserver(); + vserver.setTenantId(tenantId); + vserver.setId(vmId); + vserver.setRelatedLink(vmRelatedLink); + vserver.setName(vmName); + vserver.setUrl(vmURL); + return vserver; + } + private void populateContext(Vnf vnf ,SvcLogicContext ctx) { ctx.setAttribute("vnf.type",vnf.getVnfType()); ctx.setAttribute("vnf.version",vnf.getVnfVersion()); @@ -239,11 +264,9 @@ public class AAIPluginImpl implements AAIPlugin { return readRelationDataAndProperties(prefix, vnfContext,additionalProperties); } - private AAIQueryResult readVM(String vmId,String tenantId,String cloudOwner,String cloudRegionId) - throws AAIQueryException { - String query = "vserver.vserver-id = '" + vmId + "' AND tenant.tenant_id = '" + tenantId - + "' AND cloud-region.cloud-owner = '" + cloudOwner - + "' AND cloud-region.cloud-region-id = '" + cloudRegionId + "'"; + private AAIQueryResult readVM(String vmId,String tenantId,String cloudOwner,String cloudRegionId) throws AAIQueryException { + String query = "vserver.vserver-id = '" + vmId + "' AND tenant.tenant_id = '" + tenantId + "' AND cloud-region.cloud-owner = '" + + cloudOwner + "' AND cloud-region.cloud-region-id = '" + cloudRegionId + "'"; String prefix = "VM"; String resourceType = "vserver"; SvcLogicContext vnfContext = readResource(query,prefix,resourceType); @@ -267,21 +290,18 @@ public class AAIPluginImpl implements AAIPlugin { return readRelationDataAndProperties(prefix, vnfContext,additionalProperties); } - private AAIQueryResult readRelationDataAndProperties(String prefix, - SvcLogicContext context, - String[] additionalProperties) { + private AAIQueryResult readRelationDataAndProperties(String prefix, SvcLogicContext context,String[] additionalProperties) { AAIQueryResult result = new AAIQueryResult(); if (context != null && context.getAttribute(prefix + ".relationship-list.relationship_length") != null) { Integer relationsCount = Integer.parseInt(context.getAttribute( - prefix + ".relationship-list.relationship_length")); + prefix + ".relationship-list.relationship_length")); for (int i = 0; i < relationsCount; i++) { String rsKey = prefix + ".relationship-list.relationship[" + i + "]"; Relationship relationShip = new Relationship(); relationShip.setRelatedLink(context.getAttribute(rsKey + ".related-link")); relationShip.setRelatedTo(context.getAttribute(rsKey + ".related-to")); - Integer relationDataCount = - Integer.parseInt(context.getAttribute(rsKey + ".relationship-data_length")); + Integer relationDataCount = Integer.parseInt(context.getAttribute(rsKey + ".relationship-data_length")); for (int j = 0; j < relationDataCount; j++) { String rsDataKey = rsKey + ".relationship-data[" + j + "]"; String key = context.getAttribute(rsDataKey + ".relationship-key"); @@ -294,8 +314,7 @@ public class AAIPluginImpl implements AAIPlugin { relatedPropertyCountStr = context.getAttribute(rsKey + ".related-to-property_length"); relatedPropertyCount = Integer.parseInt(relatedPropertyCountStr); } catch (NumberFormatException e) { - logger.debug( - "Invalid value in the context for Related Property Count " + relatedPropertyCountStr); + logger.debug("Invalid value in the context for Related Property Count " + relatedPropertyCountStr); } for (int j = 0; j < relatedPropertyCount; j++) { @@ -308,7 +327,7 @@ public class AAIPluginImpl implements AAIPlugin { } } else { logger.error("Relationship-list not present in the SvcLogicContext attributes set." - + (context == null ? "" : "Attribute KeySet = "+ context.getAttributeKeySet())); + + (context == null ? "" : "Attribute KeySet = "+ context.getAttributeKeySet())); } if (context != null) { @@ -322,8 +341,7 @@ public class AAIPluginImpl implements AAIPlugin { private SvcLogicContext readResource(String query, String prefix, String resourceType) throws AAIQueryException { SvcLogicContext resourceContext = new SvcLogicContext(); try { - SvcLogicResource.QueryStatus response = - aaiClient.query(resourceType,false,null,query,prefix,null,resourceContext); + SvcLogicResource.QueryStatus response = aaiClient.query(resourceType,false,null,query,prefix,null,resourceContext); logger.info("AAIResponse: " + response.toString()); if(!SvcLogicResource.QueryStatus.SUCCESS.equals(response)){ throw new AAIQueryException("Error Retrieving VNF hierarchy from A&AI"); @@ -348,8 +366,7 @@ public class AAIPluginImpl implements AAIPlugin { logger.info("AAIResponse: " + response.toString()); ctx.setAttribute("getResource_result", response.toString()); } catch (SvcLogicException e) { - logger.error( - EELFResourceManager.format(Msg.AAI_GET_DATA_FAILED, resourceKey, "", e.getMessage())); + logger.error(EELFResourceManager.format(Msg.AAI_GET_DATA_FAILED, resourceKey, "", e.getMessage())); } if (logger.isDebugEnabled()) { logger.debug("exiting getResource======"); diff --git a/appc-dg/appc-dg-shared/appc-dg-common/src/main/java/org/onap/appc/dg/common/impl/JsonDgUtilImpl.java b/appc-dg/appc-dg-shared/appc-dg-common/src/main/java/org/onap/appc/dg/common/impl/JsonDgUtilImpl.java index fff43cbf5..caad8b809 100644 --- a/appc-dg/appc-dg-shared/appc-dg-common/src/main/java/org/onap/appc/dg/common/impl/JsonDgUtilImpl.java +++ b/appc-dg/appc-dg-shared/appc-dg-common/src/main/java/org/onap/appc/dg/common/impl/JsonDgUtilImpl.java @@ -29,7 +29,7 @@ import java.text.SimpleDateFormat; import java.util.Map; import java.util.Set; -import org.apache.commons.lang3.ObjectUtils; +import org.apache.commons.lang.ObjectUtils; import org.apache.commons.lang3.StringUtils; import org.onap.appc.dg.common.JsonDgUtil; import org.onap.appc.exceptions.APPCException; @@ -63,7 +63,7 @@ public class JsonDgUtilImpl implements JsonDgUtil { try { String paramName = Constants.PAYLOAD; String payload = params.get(paramName); - if (payload == "") + if (payload == null || payload.isEmpty()) payload = ctx.getAttribute("input.payload"); if (!StringUtils.isEmpty(payload)) { Map<String, String> flatMap = JsonUtil.convertJsonStringToFlatMap(payload); diff --git a/appc-dg/appc-dg-shared/appc-dg-common/src/main/java/org/onap/appc/dg/common/impl/VnfExecutionFlowImpl.java b/appc-dg/appc-dg-shared/appc-dg-common/src/main/java/org/onap/appc/dg/common/impl/VnfExecutionFlowImpl.java index 65b364f62..8129e2e02 100644 --- a/appc-dg/appc-dg-shared/appc-dg-common/src/main/java/org/onap/appc/dg/common/impl/VnfExecutionFlowImpl.java +++ b/appc-dg/appc-dg-shared/appc-dg-common/src/main/java/org/onap/appc/dg/common/impl/VnfExecutionFlowImpl.java @@ -28,6 +28,7 @@ import com.att.eelf.configuration.EELFLogger; import com.att.eelf.configuration.EELFManager; import com.att.eelf.i18n.EELFResourceManager; import org.onap.ccsdk.sli.core.sli.SvcLogicContext; +import org.onap.appc.exceptions.APPCException; import java.util.*; @@ -36,7 +37,7 @@ import org.onap.appc.dg.dependencymanager.DependencyManager; import org.onap.appc.dg.dependencymanager.exception.DependencyModelNotFound; import org.onap.appc.dg.dependencymanager.impl.DependencyModelFactory; import org.onap.appc.dg.flowbuilder.FlowBuilder; -import org.onap.appc.dg.flowbuilder.exception.InvalidDependencyModel; +import org.onap.appc.dg.flowbuilder.exception.InvalidDependencyModelException; import org.onap.appc.dg.flowbuilder.impl.FlowBuilderFactory; import org.onap.appc.dg.objects.*; import org.onap.appc.domainmodel.Vnf; @@ -47,10 +48,15 @@ import org.onap.appc.metadata.objects.DependencyModelIdentifier; public class VnfExecutionFlowImpl implements VnfExecutionFlow { - private static final EELFLogger logger = EELFManager.getInstance().getLogger(VnfExecutionFlowImpl.class); - + private final EELFLogger logger = EELFManager.getInstance().getLogger(VnfExecutionFlowImpl.class); + private static final String VNFC_FLOW="vnfcFlow["; + private static final String VNF_VNFC="vnf.vnfc["; + /** + * Constructor + * <p>Used through blueprint + */ public VnfExecutionFlowImpl(){ - + // do nothing } @Override @@ -58,7 +64,7 @@ public class VnfExecutionFlowImpl implements VnfExecutionFlow { String dependencyType = params.get(Constants.DEPENDENCY_TYPE); String flowStrategy = params.get(Constants.FLOW_STRATEGY); DependencyModelIdentifier modelIdentifier = readDependencyModelIdentifier(params); - VnfcDependencyModel dependencyModel = null; + VnfcDependencyModel dependencyModel; try { validateInput(dependencyType, flowStrategy, params); @@ -69,8 +75,6 @@ public class VnfExecutionFlowImpl implements VnfExecutionFlow { } DependencyManager dependencyManager = DependencyModelFactory.createDependencyManager(); - - dependencyModel = dependencyManager.getVnfcDependencyModel( modelIdentifier, DependencyTypes.findByString(dependencyType)); } catch (DependencyModelNotFound e) { @@ -79,12 +83,17 @@ public class VnfExecutionFlowImpl implements VnfExecutionFlow { context.setAttribute(Constants.ATTRIBUTE_ERROR_MESSAGE,msg); context.setAttribute("dependencyModelFound","false"); return; - } catch (InvalidDependencyModel e){ + } catch (InvalidDependencyModelException e){ String msg = EELFResourceManager.format(Msg.INVALID_DEPENDENCY_MODEL,params.get(Constants.VNF_TYPE), e.getMessage()); logger.error(msg); context.setAttribute(Constants.ATTRIBUTE_ERROR_MESSAGE,msg); - throw e; - }catch (RuntimeException e){ + throw new RuntimeException(e.getMessage(),e); + } catch (APPCException e){ + logger.error(e.getMessage()); + context.setAttribute(Constants.ATTRIBUTE_ERROR_MESSAGE,e.getMessage()); + throw new RuntimeException(e.getMessage(),e); + } + catch (RuntimeException e){ logger.error(e.getMessage()); context.setAttribute(Constants.ATTRIBUTE_ERROR_MESSAGE,e.getMessage()); throw e; @@ -96,7 +105,14 @@ public class VnfExecutionFlowImpl implements VnfExecutionFlow { logger.debug("Dependency Model = " +dependencyModel); } logger.info("Building Inventory Model from DG context"); - InventoryModel inventoryModel = readInventoryModel(context); + InventoryModel inventoryModel = null; + try { + inventoryModel = readInventoryModel(context); + } catch (APPCException e) { + logger.error(e.getMessage()); + context.setAttribute(Constants.ATTRIBUTE_ERROR_MESSAGE,e.getMessage()); + throw new RuntimeException(e.getMessage(),e); + } if(logger.isDebugEnabled()){ logger.debug("Inventory Model = " +inventoryModel); } @@ -106,25 +122,26 @@ public class VnfExecutionFlowImpl implements VnfExecutionFlow { } try { validateInventoryModelWithDependencyModel(dependencyModel, inventoryModel); - }catch (RuntimeException e){ + } + catch (APPCException e){ logger.error(e.getMessage()); context.setAttribute(Constants.ATTRIBUTE_ERROR_MESSAGE,e.getMessage()); - throw e; + throw new RuntimeException(e.getMessage(),e); } logger.info("Creating flow builder"); FlowBuilder flowBuilder = FlowBuilderFactory.getInstance().getFlowBuilder( FlowStrategies.findByString(flowStrategy)); logger.info("Building Vnf flow model"); - VnfcFlowModel flowModel = null; + VnfcFlowModel flowModel; try{ flowModel = flowBuilder.buildFlowModel(dependencyModel,inventoryModel); } - catch (InvalidDependencyModel e){ + catch (InvalidDependencyModelException e){ String msg = EELFResourceManager.format(Msg.INVALID_DEPENDENCY_MODEL,params.get(Constants.VNF_TYPE), e.getMessage()); logger.error(msg); context.setAttribute(Constants.ATTRIBUTE_ERROR_MESSAGE,msg); - throw e; + throw new RuntimeException(e.getMessage(),e); } // remove VNFCs from the flow model where vserver list is empty @@ -137,22 +154,22 @@ public class VnfExecutionFlowImpl implements VnfExecutionFlow { context.setAttribute(org.onap.appc.Constants.ATTRIBUTE_SUCCESS_MESSAGE, msg); } - private void validateInput(String dependencyType, String flowStrategy, Map<String, String> params) { + private void validateInput(String dependencyType, String flowStrategy, Map<String, String> params) throws APPCException { DependencyTypes dependencyTypes = DependencyTypes.findByString(dependencyType); if(dependencyTypes == null){ - throw new RuntimeException("Dependency type from the input : " + dependencyType +" is invalid."); + throw new APPCException("Dependency type from the input : " + dependencyType +" is invalid."); } FlowStrategies flowStrategies = FlowStrategies.findByString(flowStrategy); if(flowStrategies == null){ - throw new RuntimeException("Flow Strategy from the input : " + flowStrategy +" is invalid."); + throw new APPCException("Flow Strategy from the input : " + flowStrategy +" is invalid."); } String vnfType = params.get(Constants.VNF_TYPE); if(vnfType ==null || vnfType.length() ==0){ - throw new RuntimeException("Vnf Type is not passed in the input"); + throw new APPCException("Vnf Type is not passed in the input"); } String vnfVersion = params.get(Constants.VNF_VERION); if(vnfVersion == null || vnfVersion.length() ==0){ - throw new RuntimeException("Vnf Version not found"); + throw new APPCException("Vnf Version not found"); } } @@ -167,13 +184,13 @@ public class VnfExecutionFlowImpl implements VnfExecutionFlow { Iterator<List<Vnfc>> iterator = flowModel.getModelIterator(); while (iterator.hasNext()){ for(Vnfc vnfc:iterator.next()){ - context.setAttribute("vnfcFlow["+flowIndex+"].vnfcName",vnfc.getVnfcName()); - context.setAttribute("vnfcFlow["+flowIndex+"].vnfcType",vnfc.getVnfcType()); - context.setAttribute("vnfcFlow["+flowIndex+"].resilienceType",vnfc.getResilienceType()); - context.setAttribute("vnfcFlow["+flowIndex+"].vmCount",Integer.toString(vnfc.getVserverList().size())); + context.setAttribute(VNFC_FLOW+flowIndex+"].vnfcName",vnfc.getVnfcName()); + context.setAttribute(VNFC_FLOW+flowIndex+"].vnfcType",vnfc.getVnfcType()); + context.setAttribute(VNFC_FLOW+flowIndex+"].resilienceType",vnfc.getResilienceType()); + context.setAttribute(VNFC_FLOW+flowIndex+"].vmCount",Integer.toString(vnfc.getVserverList().size())); int vmIndex =0; for(Vserver vm :vnfc.getVserverList()){ - context.setAttribute("vnfcFlow["+flowIndex+"].vm["+vmIndex+"].url",vm.getUrl()); + context.setAttribute(VNFC_FLOW+flowIndex+"].vm["+vmIndex+"].url",vm.getUrl()); vmIndex++; } flowIndex++; @@ -182,73 +199,88 @@ public class VnfExecutionFlowImpl implements VnfExecutionFlow { context.setAttribute("vnfcFlowCount",Integer.toString(flowIndex)); } - private InventoryModel readInventoryModel(SvcLogicContext context) { + private InventoryModel readInventoryModel(SvcLogicContext context) throws APPCException { String vnfId = context.getAttribute("input.action-identifiers.vnf-id"); String vnfType = context.getAttribute("vnf.type"); String vnfVersion = context.getAttribute("vnf.version"); String vnfcCountStr = context.getAttribute("vnf.vnfcCount"); Integer vnfcCount = Integer.parseInt(vnfcCountStr); - - Vnf vnf = new Vnf(vnfId,vnfType,vnfVersion); - + Vnf vnf = createVnf(vnfId, vnfType, vnfVersion); for(Integer i=0;i<vnfcCount;i++){ - String vnfcName = context.getAttribute("vnf.vnfc["+ i+"].name"); - String vnfcType = context.getAttribute("vnf.vnfc["+ i+"].type"); - String vmCountStr = context.getAttribute("vnf.vnfc["+ i+"].vm_count"); + String vnfcName = context.getAttribute(VNF_VNFC+ i+"].name"); + String vnfcType = context.getAttribute(VNF_VNFC+ i+"].type"); + String vmCountStr = context.getAttribute(VNF_VNFC+ i+"].vm_count"); if(vnfcType ==null || vnfcType.length() ==0){ - throw new RuntimeException("Could not retrieve VNFC Type from DG Context for vnf.vnfc["+ i+"].type"); + throw new APPCException("Could not retrieve VNFC Type from DG Context for vnf.vnfc["+ i+"].type"); } Integer vmCount = Integer.parseInt(vmCountStr); - Vnfc vnfc = new Vnfc(vnfcType,null,vnfcName); + Vnfc vnfc = createVnfc(vnfcName, vnfcType); for(Integer j=0;j<vmCount;j++){ - String vmURL = context.getAttribute("vnf.vnfc["+i+"].vm["+j+"].url"); - Vserver vm = new Vserver(vmURL); - vnfc.addVm(vm); + String vmURL = context.getAttribute(VNF_VNFC+i+"].vm["+j+"].url"); + Vserver vm = createVserver(vmURL); + vm.setVnfc(vnfc); + vnfc.addVserver(vm); + vnf.addVserver(vm); } - vnf.addVnfc(vnfc); } return new InventoryModel(vnf); } + private Vserver createVserver(String vmURL) { + Vserver vserver = new Vserver(); + vserver.setUrl(vmURL); + return vserver; + } + + private Vnfc createVnfc(String vnfcName, String vnfcType) { + Vnfc vnfc =new Vnfc(); + vnfc.setVnfcName(vnfcName); + vnfc.setVnfcType(vnfcType); + return vnfc; + } + + private Vnf createVnf(String vnfId, String vnfType, String vnfVersion) { + Vnf vnf =new Vnf(); + vnf.setVnfType(vnfType); + vnf.setVnfId(vnfId); + vnf.setVnfVersion(vnfVersion); + return vnf; + } + private DependencyModelIdentifier readDependencyModelIdentifier(Map<String, String> params) { String vnfType = params.get(Constants.VNF_TYPE); String catalogVersion = params.get(Constants.VNF_VERION); return new DependencyModelIdentifier(vnfType,catalogVersion); } - private void validateInventoryModelWithDependencyModel(VnfcDependencyModel dependencyModel, InventoryModel inventoryModel) { - Set<String> dependencyModelVnfcSet = new HashSet<String>(); - Set<String> dependencyModelMandatoryVnfcSet = new HashSet<String>(); - Set<String> inventoryModelVnfcsSet = new HashSet<String>(); - + private void validateInventoryModelWithDependencyModel(VnfcDependencyModel dependencyModel, InventoryModel inventoryModel) throws APPCException { + Set<String> dependencyModelVnfcSet = new HashSet<>(); + Set<String> dependencyModelMandatoryVnfcSet = new HashSet<>(); + Set<String> inventoryModelVnfcsSet = new HashSet<>(); for (Node<Vnfc> node : dependencyModel.getDependencies()) { dependencyModelVnfcSet.add(node.getChild().getVnfcType().toLowerCase()); if (node.getChild().isMandatory()) { dependencyModelMandatoryVnfcSet.add(node.getChild().getVnfcType().toLowerCase()); } } - for (Vnfc vnfc : inventoryModel.getVnf().getVnfcs()) { inventoryModelVnfcsSet.add(vnfc.getVnfcType().toLowerCase()); } - // if dependency model and inventory model contains same set of VNFCs, validation succeed and hence return if (dependencyModelVnfcSet.equals(inventoryModelVnfcsSet)) { return; } - if (inventoryModelVnfcsSet.size() >= dependencyModelVnfcSet.size()) { - Set<String> difference = new HashSet<String>(inventoryModelVnfcsSet); + Set<String> difference = new HashSet<>(inventoryModelVnfcsSet); difference.removeAll(dependencyModelVnfcSet); logger.error("Dependency model is missing following vnfc type(s): " + difference); - throw new RuntimeException("Dependency model is missing following vnfc type(s): " + difference); + throw new APPCException("Dependency model is missing following vnfc type(s): " + difference); } else { - Set<String> difference = new HashSet<String>(dependencyModelVnfcSet); + Set<String> difference = new HashSet<>(dependencyModelMandatoryVnfcSet); difference.removeAll(inventoryModelVnfcsSet); - difference.retainAll(dependencyModelMandatoryVnfcSet); if (difference.size() > 0) { logger.error("Inventory model is missing following mandatory vnfc type(s): " + difference); - throw new RuntimeException("Inventory model is missing following mandatory vnfc type(s): " + difference); + throw new APPCException("Inventory model is missing following mandatory vnfc type(s): " + difference); } } } @@ -268,4 +300,5 @@ public class VnfExecutionFlowImpl implements VnfExecutionFlow { } } } + } diff --git a/appc-dg/appc-dg-shared/appc-dg-common/src/test/java/org/onap/appc/dg/common/impl/DCAEReporterPluginImplTest.java b/appc-dg/appc-dg-shared/appc-dg-common/src/test/java/org/onap/appc/dg/common/impl/DCAEReporterPluginImplTest.java index 7c36360f8..42f7a6bc6 100644 --- a/appc-dg/appc-dg-shared/appc-dg-common/src/test/java/org/onap/appc/dg/common/impl/DCAEReporterPluginImplTest.java +++ b/appc-dg/appc-dg-shared/appc-dg-common/src/test/java/org/onap/appc/dg/common/impl/DCAEReporterPluginImplTest.java @@ -28,7 +28,10 @@ import org.junit.Assert; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; -import org.mockito.*; +import org.mockito.InjectMocks; +import org.mockito.Matchers; +import org.mockito.Mockito; +import org.mockito.Spy; import org.onap.appc.adapter.message.EventSender; import org.onap.appc.adapter.message.MessageDestination; import org.onap.appc.adapter.message.event.EventMessage; diff --git a/appc-dg/appc-dg-shared/appc-dg-common/src/test/java/org/onap/appc/dg/common/impl/TestVnfExecutionFlowImpl.java b/appc-dg/appc-dg-shared/appc-dg-common/src/test/java/org/onap/appc/dg/common/impl/VnfExecutionFlowImplTest.java index bad862030..558a463ac 100644 --- a/appc-dg/appc-dg-shared/appc-dg-common/src/test/java/org/onap/appc/dg/common/impl/TestVnfExecutionFlowImpl.java +++ b/appc-dg/appc-dg-shared/appc-dg-common/src/test/java/org/onap/appc/dg/common/impl/VnfExecutionFlowImplTest.java @@ -26,23 +26,19 @@ package org.onap.appc.dg.common.impl; import com.att.eelf.configuration.EELFLogger; import com.att.eelf.configuration.EELFManager; -import org.onap.ccsdk.sli.core.sli.SvcLogicContext; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.Matchers; import org.onap.appc.dg.common.VnfExecutionFlow; -import org.onap.appc.dg.common.impl.Constants; -import org.onap.appc.dg.common.impl.VnfExecutionFlowImpl; import org.onap.appc.dg.dependencymanager.DependencyManager; import org.onap.appc.dg.dependencymanager.exception.DependencyModelNotFound; import org.onap.appc.dg.dependencymanager.impl.DependencyModelFactory; -import org.onap.appc.dg.flowbuilder.exception.InvalidDependencyModel; -import org.onap.appc.dg.objects.DependencyTypes; +import org.onap.appc.dg.flowbuilder.exception.InvalidDependencyModelException; import org.onap.appc.dg.objects.Node; import org.onap.appc.dg.objects.VnfcDependencyModel; import org.onap.appc.domainmodel.Vnfc; -import org.onap.appc.metadata.objects.DependencyModelIdentifier; +import org.onap.ccsdk.sli.core.sli.SvcLogicContext; import org.osgi.framework.FrameworkUtil; import org.powermock.api.mockito.PowerMockito; import org.powermock.core.classloader.annotations.PrepareForTest; @@ -54,10 +50,11 @@ import java.util.Map; import java.util.Set; @RunWith(PowerMockRunner.class) -@PrepareForTest({TestVnfExecutionFlowImpl.class, FrameworkUtil.class,DependencyManager.class,DependencyModelFactory.class}) -public class TestVnfExecutionFlowImpl { +@PrepareForTest({VnfExecutionFlowImplTest.class, FrameworkUtil.class,DependencyManager.class,DependencyModelFactory.class}) +@SuppressWarnings("unchecked") +public class VnfExecutionFlowImplTest { - private static final EELFLogger logger = EELFManager.getInstance().getLogger(TestVnfExecutionFlowImpl.class); + private final EELFLogger logger = EELFManager.getInstance().getLogger(VnfExecutionFlowImplTest.class); @Before public void setUp() { @@ -65,7 +62,7 @@ public class TestVnfExecutionFlowImpl { } @Test - public void testPositiveFlow() throws DependencyModelNotFound { + public void testPositiveFlow() throws DependencyModelNotFound, InvalidDependencyModelException { Map<String, String> params = prepareParams(); SvcLogicContext context = prepareContext(); VnfcDependencyModel dependencyModel = readDependencyModel(); @@ -74,8 +71,7 @@ public class TestVnfExecutionFlowImpl { DependencyManager dependencyManager = PowerMockito.mock(DependencyManager.class); PowerMockito.when(DependencyModelFactory.createDependencyManager()).thenReturn(dependencyManager); - PowerMockito.when(dependencyManager.getVnfcDependencyModel(( - DependencyModelIdentifier) Matchers.any(),(DependencyTypes) Matchers.any())) + PowerMockito.when(dependencyManager.getVnfcDependencyModel(Matchers.any(), Matchers.any())) .thenReturn(dependencyModel); VnfExecutionFlow vnfExecutionFlow = new VnfExecutionFlowImpl(); @@ -83,7 +79,7 @@ public class TestVnfExecutionFlowImpl { } @Test - public void testComplexFlow() throws DependencyModelNotFound { + public void testComplexFlow() throws DependencyModelNotFound, InvalidDependencyModelException { Map<String, String> params = prepareParams(); SvcLogicContext context = prepareContextForComplexDependency(); VnfcDependencyModel dependencyModel = readComplexDependencyModel(); @@ -92,16 +88,15 @@ public class TestVnfExecutionFlowImpl { DependencyManager dependencyManager = PowerMockito.mock(DependencyManager.class); PowerMockito.when(DependencyModelFactory.createDependencyManager()).thenReturn(dependencyManager); - PowerMockito.when(dependencyManager.getVnfcDependencyModel(( - DependencyModelIdentifier) Matchers.any(),(DependencyTypes) Matchers.any())) + PowerMockito.when(dependencyManager.getVnfcDependencyModel(Matchers.any(), Matchers.any())) .thenReturn(dependencyModel); VnfExecutionFlow vnfExecutionFlow = new VnfExecutionFlowImpl(); vnfExecutionFlow.getVnfExecutionFlowData(params,context); } - @Test(expected = InvalidDependencyModel.class) - public void testCycleFlow() throws DependencyModelNotFound { + @Test(expected = RuntimeException.class) + public void testCycleFlow() throws DependencyModelNotFound, InvalidDependencyModelException { Map<String, String> params = prepareParams(); SvcLogicContext context = prepareContextForComplexDependency(); VnfcDependencyModel dependencyModel = readCyclicDependencyModel(); @@ -109,8 +104,7 @@ public class TestVnfExecutionFlowImpl { DependencyManager dependencyManager = PowerMockito.mock(DependencyManager.class); PowerMockito.when(DependencyModelFactory.createDependencyManager()).thenReturn(dependencyManager); - PowerMockito.when(dependencyManager.getVnfcDependencyModel(( - DependencyModelIdentifier) Matchers.any(),(DependencyTypes) Matchers.any())) + PowerMockito.when(dependencyManager.getVnfcDependencyModel(Matchers.any(), Matchers.any())) .thenReturn(dependencyModel); VnfExecutionFlow vnfExecutionFlow = new VnfExecutionFlowImpl(); @@ -119,13 +113,13 @@ public class TestVnfExecutionFlowImpl { private VnfcDependencyModel readCyclicDependencyModel() { - Vnfc a = new Vnfc("A","Active-Passive",null); - Vnfc b = new Vnfc("B","Active-Active",null); - Vnfc c = new Vnfc("C","Active-Active",null); - Vnfc d = new Vnfc("D","Active-Active",null); - Vnfc e = new Vnfc("E","Active-Active",null); - Vnfc f = new Vnfc("F","Active-Active",null); - Vnfc g = new Vnfc("G","Active-Active",null); + Vnfc a = createVnfc("A","Active-Passive",null,false); + Vnfc b = createVnfc("B","Active-Active",null,false); + Vnfc c = createVnfc("C","Active-Active",null,false); + Vnfc d = createVnfc("D","Active-Active",null,false); + Vnfc e = createVnfc("E","Active-Active",null,false); + Vnfc f = createVnfc("F","Active-Active",null,false); + Vnfc g = createVnfc("G","Active-Active",null,false); Node aNode = new Node(a); Node bNode = new Node(b); @@ -155,6 +149,15 @@ public class TestVnfExecutionFlowImpl { } + private Vnfc createVnfc(String vnfcType,String resilienceType,String vnfcName,boolean mandatory) { + Vnfc vnfc = new Vnfc(); + vnfc.setVnfcType(vnfcType); + vnfc.setResilienceType(resilienceType); + vnfc.setVnfcName(vnfcName); + vnfc.setMandatory(mandatory); + return vnfc; + } + private SvcLogicContext prepareContextForComplexDependency() { SvcLogicContext context = new SvcLogicContext(); context.setAttribute("input.action-identifiers.vnf-id","1"); @@ -212,13 +215,13 @@ public class TestVnfExecutionFlowImpl { } private VnfcDependencyModel readComplexDependencyModel() { - Vnfc a = new Vnfc("A","Active-Passive",null); - Vnfc b = new Vnfc("B","Active-Active",null); - Vnfc c = new Vnfc("C","Active-Active",null); - Vnfc d = new Vnfc("D","Active-Active",null); - Vnfc e = new Vnfc("E","Active-Active",null); - Vnfc f = new Vnfc("F","Active-Active",null); - Vnfc g = new Vnfc("G","Active-Active",null); + Vnfc a = createVnfc("A","Active-Passive",null,false); + Vnfc b = createVnfc("B","Active-Active",null,false); + Vnfc c = createVnfc("C","Active-Active",null,false); + Vnfc d = createVnfc("D","Active-Active",null,false); + Vnfc e = createVnfc("E","Active-Active",null,false); + Vnfc f = createVnfc("F","Active-Active",null,false); + Vnfc g = createVnfc("G","Active-Active",null,false); Node aNode = new Node(a); @@ -254,9 +257,9 @@ public class TestVnfExecutionFlowImpl { private VnfcDependencyModel readDependencyModel() { - Vnfc smp = new Vnfc("SMP","Active-Passive",null); - Vnfc be = new Vnfc("BE","Active-Active",null); - Vnfc fe = new Vnfc("FE","Active-Active",null); + Vnfc smp = createVnfc("SMP","Active-Passive",null,false); + Vnfc be = createVnfc("BE","Active-Active",null,false); + Vnfc fe = createVnfc("FE","Active-Active",null,false); Node smpNode = new Node(smp); @@ -316,7 +319,7 @@ public class TestVnfExecutionFlowImpl { } @Test(expected = RuntimeException.class) - public void testMissingVnfcTypeInDependencyModel() throws DependencyModelNotFound { + public void testMissingVnfcTypeInDependencyModel() throws DependencyModelNotFound, InvalidDependencyModelException { Map<String, String> params = prepareParams(); SvcLogicContext context = prepareContext(); context.setAttribute("vnf.vnfc[3].name","XEname"); @@ -332,8 +335,7 @@ public class TestVnfExecutionFlowImpl { DependencyManager dependencyManager = PowerMockito.mock(DependencyManager.class); PowerMockito.when(DependencyModelFactory.createDependencyManager()).thenReturn(dependencyManager); - PowerMockito.when(dependencyManager.getVnfcDependencyModel(( - DependencyModelIdentifier) Matchers.any(),(DependencyTypes) Matchers.any())) + PowerMockito.when(dependencyManager.getVnfcDependencyModel(Matchers.any(), Matchers.any())) .thenReturn(dependencyModel); VnfExecutionFlow vnfExecutionFlow = new VnfExecutionFlowImpl(); @@ -341,12 +343,12 @@ public class TestVnfExecutionFlowImpl { } @Test(expected = RuntimeException.class) - public void testMissingMandatoryVnfcTypeInInventoryModel() throws DependencyModelNotFound { + public void testMissingMandatoryVnfcTypeInInventoryModel() throws DependencyModelNotFound, InvalidDependencyModelException { Map<String, String> params = prepareParams(); SvcLogicContext context = prepareContext(); VnfcDependencyModel dependencyModel = readDependencyModel(); - Vnfc xe = new Vnfc("XE","Active-Active",null, true); + Vnfc xe = createVnfc("XE","Active-Active",null, true); Node xeNode = new Node(xe); dependencyModel.getDependencies().add(xeNode); @@ -354,8 +356,7 @@ public class TestVnfExecutionFlowImpl { DependencyManager dependencyManager = PowerMockito.mock(DependencyManager.class); PowerMockito.when(DependencyModelFactory.createDependencyManager()).thenReturn(dependencyManager); - PowerMockito.when(dependencyManager.getVnfcDependencyModel(( - DependencyModelIdentifier) Matchers.any(),(DependencyTypes) Matchers.any())) + PowerMockito.when(dependencyManager.getVnfcDependencyModel(Matchers.any(), Matchers.any())) .thenReturn(dependencyModel); VnfExecutionFlow vnfExecutionFlow = new VnfExecutionFlowImpl(); @@ -363,12 +364,12 @@ public class TestVnfExecutionFlowImpl { } @Test - public void testMissingOptionalVnfcTypeInInventoryModel() throws DependencyModelNotFound { + public void testMissingOptionalVnfcTypeInInventoryModel() throws DependencyModelNotFound, InvalidDependencyModelException { Map<String, String> params = prepareParams(); SvcLogicContext context = prepareContext(); VnfcDependencyModel dependencyModel = readDependencyModel(); - Vnfc xe = new Vnfc("XE","Active-Active",null, false); + Vnfc xe = createVnfc("XE","Active-Active",null, false); Node xeNode = new Node(xe); dependencyModel.getDependencies().add(xeNode); @@ -376,8 +377,7 @@ public class TestVnfExecutionFlowImpl { DependencyManager dependencyManager = PowerMockito.mock(DependencyManager.class); PowerMockito.when(DependencyModelFactory.createDependencyManager()).thenReturn(dependencyManager); - PowerMockito.when(dependencyManager.getVnfcDependencyModel(( - DependencyModelIdentifier) Matchers.any(),(DependencyTypes) Matchers.any())) + PowerMockito.when(dependencyManager.getVnfcDependencyModel(Matchers.any(), Matchers.any())) .thenReturn(dependencyModel); VnfExecutionFlow vnfExecutionFlow = new VnfExecutionFlowImpl(); @@ -385,7 +385,7 @@ public class TestVnfExecutionFlowImpl { } @Test - public void testMissingOptionalVnfcTypeInInventoryModelWithDependentChild() throws DependencyModelNotFound { + public void testMissingOptionalVnfcTypeInInventoryModelWithDependentChild() throws DependencyModelNotFound, InvalidDependencyModelException { Map<String, String> params = prepareParams(); SvcLogicContext context = prepareContext(); context.setAttribute("vnf.vnfc[3].name","YEname"); @@ -397,8 +397,8 @@ public class TestVnfExecutionFlowImpl { VnfcDependencyModel dependencyModel = readDependencyModel(); - Vnfc xe = new Vnfc("XE","Active-Active",null, false); - Vnfc ye = new Vnfc("YE","Active-Active",null, true); + Vnfc xe = createVnfc("XE","Active-Active",null, false); + Vnfc ye = createVnfc("YE","Active-Active",null, true); Node xeNode = new Node(xe); Node yeNode = new Node(ye); yeNode.addParent(xe); @@ -410,11 +410,12 @@ public class TestVnfExecutionFlowImpl { DependencyManager dependencyManager = PowerMockito.mock(DependencyManager.class); PowerMockito.when(DependencyModelFactory.createDependencyManager()).thenReturn(dependencyManager); - PowerMockito.when(dependencyManager.getVnfcDependencyModel(( - DependencyModelIdentifier) Matchers.any(),(DependencyTypes) Matchers.any())) + PowerMockito.when(dependencyManager.getVnfcDependencyModel(Matchers.any(), Matchers.any())) .thenReturn(dependencyModel); VnfExecutionFlow vnfExecutionFlow = new VnfExecutionFlowImpl(); vnfExecutionFlow.getVnfExecutionFlowData(params,context); } + + } diff --git a/appc-dg/appc-dg-shared/appc-dg-dependency-model/src/main/java/org/onap/appc/dg/dependencymanager/DependencyManager.java b/appc-dg/appc-dg-shared/appc-dg-dependency-model/src/main/java/org/onap/appc/dg/dependencymanager/DependencyManager.java index 8d04cea11..481d4dcad 100644 --- a/appc-dg/appc-dg-shared/appc-dg-dependency-model/src/main/java/org/onap/appc/dg/dependencymanager/DependencyManager.java +++ b/appc-dg/appc-dg-shared/appc-dg-dependency-model/src/main/java/org/onap/appc/dg/dependencymanager/DependencyManager.java @@ -25,12 +25,12 @@ package org.onap.appc.dg.dependencymanager; import org.onap.appc.dg.dependencymanager.exception.DependencyModelNotFound; -import org.onap.appc.dg.flowbuilder.exception.InvalidDependencyModel; +import org.onap.appc.dg.flowbuilder.exception.InvalidDependencyModelException; import org.onap.appc.dg.objects.DependencyTypes; import org.onap.appc.dg.objects.VnfcDependencyModel; import org.onap.appc.metadata.objects.DependencyModelIdentifier; public interface DependencyManager { - VnfcDependencyModel getVnfcDependencyModel(DependencyModelIdentifier modelIdentifier, DependencyTypes dependencyType) throws InvalidDependencyModel, DependencyModelNotFound; + VnfcDependencyModel getVnfcDependencyModel(DependencyModelIdentifier modelIdentifier, DependencyTypes dependencyType) throws InvalidDependencyModelException, DependencyModelNotFound; } diff --git a/appc-dg/appc-dg-shared/appc-dg-dependency-model/src/main/java/org/onap/appc/dg/dependencymanager/DependencyType.java b/appc-dg/appc-dg-shared/appc-dg-dependency-model/src/main/java/org/onap/appc/dg/dependencymanager/DependencyType.java index 15717f06b..7d2b0677f 100644 --- a/appc-dg/appc-dg-shared/appc-dg-dependency-model/src/main/java/org/onap/appc/dg/dependencymanager/DependencyType.java +++ b/appc-dg/appc-dg-shared/appc-dg-dependency-model/src/main/java/org/onap/appc/dg/dependencymanager/DependencyType.java @@ -25,11 +25,11 @@ package org.onap.appc.dg.dependencymanager; import org.onap.appc.dg.dependencymanager.exception.DependencyModelNotFound; -import org.onap.appc.dg.flowbuilder.exception.InvalidDependencyModel; +import org.onap.appc.dg.flowbuilder.exception.InvalidDependencyModelException; import org.onap.appc.dg.objects.VnfcDependencyModel; import org.onap.appc.metadata.objects.DependencyModelIdentifier; public interface DependencyType { - VnfcDependencyModel getVnfcDependencyModel(DependencyModelIdentifier modelIdentifier) throws InvalidDependencyModel, DependencyModelNotFound; + VnfcDependencyModel getVnfcDependencyModel(DependencyModelIdentifier modelIdentifier) throws InvalidDependencyModelException, DependencyModelNotFound; } diff --git a/appc-dg/appc-dg-shared/appc-dg-dependency-model/src/main/java/org/onap/appc/dg/dependencymanager/helper/DependencyModelParser.java b/appc-dg/appc-dg-shared/appc-dg-dependency-model/src/main/java/org/onap/appc/dg/dependencymanager/helper/DependencyModelParser.java index 187020028..ea00f09ec 100644 --- a/appc-dg/appc-dg-shared/appc-dg-dependency-model/src/main/java/org/onap/appc/dg/dependencymanager/helper/DependencyModelParser.java +++ b/appc-dg/appc-dg-shared/appc-dg-dependency-model/src/main/java/org/onap/appc/dg/dependencymanager/helper/DependencyModelParser.java @@ -31,7 +31,7 @@ import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.node.ObjectNode; import com.fasterxml.jackson.dataformat.yaml.YAMLFactory; import org.apache.commons.lang3.StringUtils; -import org.onap.appc.dg.flowbuilder.exception.InvalidDependencyModel; +import org.onap.appc.dg.flowbuilder.exception.InvalidDependencyModelException; import org.onap.appc.dg.objects.Node; import org.onap.appc.dg.objects.VnfcDependencyModel; import org.onap.appc.domainmodel.Vnfc; @@ -39,18 +39,19 @@ import org.onap.appc.domainmodel.Vnfc; import java.io.IOException; import java.util.*; - public class DependencyModelParser { - private static final EELFLogger logger = EELFManager.getInstance().getLogger(DependencyModelParser.class); - private static Map<String, String> dependencyMap; + private final EELFLogger logger = EELFManager.getInstance().getLogger(DependencyModelParser.class); + private static final String PROPERTIES = "properties"; private static final String ACTIVE_ACTIVE = "Active-Active"; private static final String ACTIVE_PASSIVE = "Active-Passive"; private static final String HIGH_AVAILABLITY = "high_availablity"; private static final String MANDATORY = "mandatory"; private static final String TOPOLOGY_TEMPLATE = "topology_template"; + private static final String RELATIONSHIP="relationship"; + private static Map<String, String> dependencyMap; static { Map<String, String> dependencyTypeMappingMap =new HashMap<>(); dependencyTypeMappingMap.put("geo-activeactive", ACTIVE_ACTIVE); @@ -60,17 +61,17 @@ public class DependencyModelParser { dependencyMap = Collections.unmodifiableMap(dependencyTypeMappingMap); } - public VnfcDependencyModel generateDependencyModel(String vnfModel,String vnfType) { + public VnfcDependencyModel generateDependencyModel(String vnfModel,String vnfType) throws InvalidDependencyModelException { Set<Node<Vnfc>> dependencies = new HashSet<>(); ObjectMapper mapper = new ObjectMapper(new YAMLFactory()); boolean mandatory; String resilienceType; - String prefix = "org.openecomp.resource.vfc."+vnfType+".abstract.nodes."; + String prefix = "org.onap.resource.vfc."+vnfType+".abstract.nodes."; try { ObjectNode root = (ObjectNode) mapper.readTree(vnfModel); if(root.get(TOPOLOGY_TEMPLATE) == null || root.get(TOPOLOGY_TEMPLATE).get("node_templates") == null) { - throw new InvalidDependencyModel("Dependency model is missing 'topology_template' or 'node_templates' elements"); + throw new InvalidDependencyModelException("Dependency model is missing 'topology_template' or 'node_templates' elements"); } JsonNode topologyTemplateNode = root.get(TOPOLOGY_TEMPLATE); @@ -81,7 +82,7 @@ public class DependencyModelParser { String fullvnfcType = itretor.next().getValue().get("type").textValue(); String vnfcType= getQualifiedVnfcType(fullvnfcType); String type = yamlNode.get("type").textValue(); - type = type.substring(0,type.lastIndexOf(".")+1); + type = type.substring(0,type.lastIndexOf('.')+1); if(type.concat(vnfcType).toLowerCase().startsWith(prefix.concat(vnfcType).toLowerCase())) { if(yamlNode.get(PROPERTIES).findValue(HIGH_AVAILABLITY) == null || yamlNode.get(PROPERTIES).findValue(HIGH_AVAILABLITY).asText().isEmpty()) { @@ -110,7 +111,7 @@ public class DependencyModelParser { } else { logger.debug("Creating dependency node for : " + vnfcType); - vnfcNode = new Node<>(new Vnfc(vnfcType, resilienceType, null, mandatory)); + vnfcNode = new Node<>(createVnfc(mandatory, resilienceType, vnfcType)); if (parentList != null && parentList.length > 0) addDependencies(dependencies, vnfcNode, parentList); logger.debug("Adding VNFC to dependency model : " + vnfcNode); @@ -121,13 +122,21 @@ public class DependencyModelParser { } catch (IOException e) { logger.error("Error parsing dependency model : " + vnfModel); logger.error("Error message : " + e); - throw new InvalidDependencyModel("Error parsing dependency model. " + e.getMessage()); + throw new InvalidDependencyModelException("Error parsing dependency model. " + e.getMessage()); } return new VnfcDependencyModel(dependencies); } + private Vnfc createVnfc(boolean mandatory, String resilienceType, String vnfcType) { + Vnfc vnfc = new Vnfc(); + vnfc.setMandatory(mandatory); + vnfc.setResilienceType(resilienceType); + vnfc.setVnfcType(vnfcType); + return vnfc; + } + private String getQualifiedVnfcType(String fullvnfcType) { - return fullvnfcType.substring(fullvnfcType.lastIndexOf(".")+1,fullvnfcType.length()); + return fullvnfcType.substring(fullvnfcType.lastIndexOf('.')+1,fullvnfcType.length()); } private void addDependencies(Set<Node<Vnfc>> nodes, Node node, String[] parentList) { @@ -139,7 +148,7 @@ public class DependencyModelParser { node.addParent(parentNode.getChild()); } else { logger.debug("VNFC does not exist for VNFC type: " + parentType + ". Creating new VNFC "); - parentNode = new Node<>(new Vnfc(parentType, null)); + parentNode = new Node<>(createVnfc(false,null,parentType)); node.addParent(parentNode.getChild()); logger.debug("Adding VNFC to dependency model : " + parentNode); nodes.add(parentNode); @@ -147,20 +156,20 @@ public class DependencyModelParser { } } - private String[] getDependencyArray(JsonNode node, JsonNode nodeTemplateNode) { + private String[] getDependencyArray(JsonNode node, JsonNode nodeTemplateNode) throws InvalidDependencyModelException { JsonNode requirementsNode = node.get("requirements"); - List<String> dependencyList = new ArrayList(); + Set<String> dependencyList = new HashSet<>(); if(requirementsNode!=null) { for (JsonNode internalNode : requirementsNode) { //TODO : In this release we are supporting both relationship = tosca.capabilities.Node and relationship =tosca.relationships.DependsOn we need to remove one of them in next release post confirming with SDC team if (nodeNullCheck(internalNode) &&"tosca.capabilities.Node".equalsIgnoreCase(internalNode.findValue("capability").asText()) - && ("tosca.relationships.DependsOn".equalsIgnoreCase(internalNode.findValue("relationship").asText()) || "tosca.capabilities.Node".equalsIgnoreCase(internalNode.findValue("relationship").asText()))) { + && ("tosca.relationships.DependsOn".equalsIgnoreCase(internalNode.findValue(RELATIONSHIP).asText()) || "tosca.capabilities.Node".equalsIgnoreCase(internalNode.findValue(RELATIONSHIP).asText()))) { if(internalNode.findValue("node") != null) { String nodeName = internalNode.findValue("node").asText(); String fullVnfcName = nodeTemplateNode.get(nodeName).get("type").asText(); dependencyList.add(getQualifiedVnfcType(fullVnfcName)); }else{ - throw new InvalidDependencyModel("Error parsing dependency model. " + "Dependent Node not found for "+ node.get("type")); + throw new InvalidDependencyModelException("Error parsing dependency model. " + "Dependent Node not found for "+ node.get("type")); } } } @@ -171,7 +180,7 @@ public class DependencyModelParser { } private boolean nodeNullCheck(JsonNode internalNode) { - return internalNode.get("dependency") != null && internalNode.findValue("capability") != null && internalNode.findValue("relationship") != null; + return internalNode.get("dependency") != null && internalNode.findValue("capability") != null && internalNode.findValue(RELATIONSHIP) != null; } private Node<Vnfc> getNode(Set<Node<Vnfc>> nodes, String vnfcType) { diff --git a/appc-dg/appc-dg-shared/appc-dg-dependency-model/src/main/java/org/onap/appc/dg/dependencymanager/impl/DependencyManagerImpl.java b/appc-dg/appc-dg-shared/appc-dg-dependency-model/src/main/java/org/onap/appc/dg/dependencymanager/impl/DependencyManagerImpl.java index 31ea46cc6..e4261f8d4 100644 --- a/appc-dg/appc-dg-shared/appc-dg-dependency-model/src/main/java/org/onap/appc/dg/dependencymanager/impl/DependencyManagerImpl.java +++ b/appc-dg/appc-dg-shared/appc-dg-dependency-model/src/main/java/org/onap/appc/dg/dependencymanager/impl/DependencyManagerImpl.java @@ -27,7 +27,7 @@ package org.onap.appc.dg.dependencymanager.impl; import org.onap.appc.dg.dependencymanager.DependencyManager; import org.onap.appc.dg.dependencymanager.DependencyType; import org.onap.appc.dg.dependencymanager.exception.DependencyModelNotFound; -import org.onap.appc.dg.flowbuilder.exception.InvalidDependencyModel; +import org.onap.appc.dg.flowbuilder.exception.InvalidDependencyModelException; import org.onap.appc.dg.objects.DependencyTypes; import org.onap.appc.dg.objects.VnfcDependencyModel; @@ -47,7 +47,7 @@ public class DependencyManagerImpl implements DependencyManager { cache = MetadataCacheFactory.getInstance().getMetadataCache(); } - public VnfcDependencyModel getVnfcDependencyModel(DependencyModelIdentifier modelIdentifier,DependencyTypes dependencyType) throws InvalidDependencyModel, DependencyModelNotFound { + public VnfcDependencyModel getVnfcDependencyModel(DependencyModelIdentifier modelIdentifier,DependencyTypes dependencyType) throws InvalidDependencyModelException, DependencyModelNotFound { if (logger.isTraceEnabled()) { logger.trace("Entering to getVnfcDependencyModel with DependencyModelIdentifier = "+ modelIdentifier + " , DependencyTypes = " + dependencyType); diff --git a/appc-dg/appc-dg-shared/appc-dg-dependency-model/src/main/java/org/onap/appc/dg/dependencymanager/impl/ResourceDependency.java b/appc-dg/appc-dg-shared/appc-dg-dependency-model/src/main/java/org/onap/appc/dg/dependencymanager/impl/ResourceDependency.java index 73792d3ad..484241639 100644 --- a/appc-dg/appc-dg-shared/appc-dg-dependency-model/src/main/java/org/onap/appc/dg/dependencymanager/impl/ResourceDependency.java +++ b/appc-dg/appc-dg-shared/appc-dg-dependency-model/src/main/java/org/onap/appc/dg/dependencymanager/impl/ResourceDependency.java @@ -32,7 +32,7 @@ import com.att.eelf.configuration.EELFManager; import org.onap.appc.dg.dependencymanager.DependencyType; import org.onap.appc.dg.dependencymanager.exception.DependencyModelNotFound; import org.onap.appc.dg.dependencymanager.helper.DependencyModelParser; -import org.onap.appc.dg.flowbuilder.exception.InvalidDependencyModel; +import org.onap.appc.dg.flowbuilder.exception.InvalidDependencyModelException; import org.onap.appc.dg.objects.VnfcDependencyModel; import org.osgi.framework.BundleContext; import org.osgi.framework.FrameworkUtil; @@ -68,7 +68,7 @@ public class ResourceDependency implements DependencyType{ this.metadataService = metadataService; } - public VnfcDependencyModel getVnfcDependencyModel(DependencyModelIdentifier modelIdentifier) throws InvalidDependencyModel, DependencyModelNotFound { + public VnfcDependencyModel getVnfcDependencyModel(DependencyModelIdentifier modelIdentifier) throws InvalidDependencyModelException, DependencyModelNotFound { if (logger.isTraceEnabled()) { logger.trace("Entering to getVnfcDependencyModel with DependencyModelIdentifier = "+ modelIdentifier); } diff --git a/appc-dg/appc-dg-shared/appc-dg-dependency-model/src/main/java/org/onap/appc/dg/flowbuilder/FlowBuilder.java b/appc-dg/appc-dg-shared/appc-dg-dependency-model/src/main/java/org/onap/appc/dg/flowbuilder/FlowBuilder.java index 78dacd105..2c572516a 100644 --- a/appc-dg/appc-dg-shared/appc-dg-dependency-model/src/main/java/org/onap/appc/dg/flowbuilder/FlowBuilder.java +++ b/appc-dg/appc-dg-shared/appc-dg-dependency-model/src/main/java/org/onap/appc/dg/flowbuilder/FlowBuilder.java @@ -24,11 +24,12 @@ package org.onap.appc.dg.flowbuilder; +import org.onap.appc.dg.flowbuilder.exception.InvalidDependencyModelException; import org.onap.appc.dg.objects.InventoryModel; import org.onap.appc.dg.objects.VnfcDependencyModel; import org.onap.appc.dg.objects.VnfcFlowModel; public interface FlowBuilder { - VnfcFlowModel buildFlowModel(VnfcDependencyModel dependencyModel,InventoryModel inventoryModel); + VnfcFlowModel buildFlowModel(VnfcDependencyModel dependencyModel,InventoryModel inventoryModel) throws InvalidDependencyModelException; } diff --git a/appc-dg/appc-dg-shared/appc-dg-dependency-model/src/main/java/org/onap/appc/dg/flowbuilder/FlowStrategy.java b/appc-dg/appc-dg-shared/appc-dg-dependency-model/src/main/java/org/onap/appc/dg/flowbuilder/FlowStrategy.java index e2c292776..dcea86197 100644 --- a/appc-dg/appc-dg-shared/appc-dg-dependency-model/src/main/java/org/onap/appc/dg/flowbuilder/FlowStrategy.java +++ b/appc-dg/appc-dg-shared/appc-dg-dependency-model/src/main/java/org/onap/appc/dg/flowbuilder/FlowStrategy.java @@ -24,6 +24,7 @@ package org.onap.appc.dg.flowbuilder; +import org.onap.appc.dg.flowbuilder.exception.InvalidDependencyModelException; import org.onap.appc.dg.objects.InventoryModel; import org.onap.appc.dg.objects.VnfcDependencyModel; import org.onap.appc.dg.objects.VnfcFlowModel; @@ -31,5 +32,5 @@ import org.onap.appc.dg.objects.VnfcFlowModel; public interface FlowStrategy { - VnfcFlowModel buildFlowModel(VnfcDependencyModel dependencyModel, InventoryModel inventoryModel); + VnfcFlowModel buildFlowModel(VnfcDependencyModel dependencyModel, InventoryModel inventoryModel) throws InvalidDependencyModelException; } diff --git a/appc-dg/appc-dg-shared/appc-dg-dependency-model/src/main/java/org/onap/appc/dg/flowbuilder/exception/InvalidDependencyModel.java b/appc-dg/appc-dg-shared/appc-dg-dependency-model/src/main/java/org/onap/appc/dg/flowbuilder/exception/InvalidDependencyModelException.java index 9f4cfed93..a4a674b8a 100644 --- a/appc-dg/appc-dg-shared/appc-dg-dependency-model/src/main/java/org/onap/appc/dg/flowbuilder/exception/InvalidDependencyModel.java +++ b/appc-dg/appc-dg-shared/appc-dg-dependency-model/src/main/java/org/onap/appc/dg/flowbuilder/exception/InvalidDependencyModelException.java @@ -25,8 +25,8 @@ package org.onap.appc.dg.flowbuilder.exception; -public class InvalidDependencyModel extends RuntimeException { - public InvalidDependencyModel(String message){ +public class InvalidDependencyModelException extends Exception { + public InvalidDependencyModelException(String message){ super(message); } } diff --git a/appc-dg/appc-dg-shared/appc-dg-dependency-model/src/main/java/org/onap/appc/dg/flowbuilder/helper/Graph.java b/appc-dg/appc-dg-shared/appc-dg-dependency-model/src/main/java/org/onap/appc/dg/flowbuilder/helper/Graph.java index 95e0b6675..3b409a70e 100644 --- a/appc-dg/appc-dg-shared/appc-dg-dependency-model/src/main/java/org/onap/appc/dg/flowbuilder/helper/Graph.java +++ b/appc-dg/appc-dg-shared/appc-dg-dependency-model/src/main/java/org/onap/appc/dg/flowbuilder/helper/Graph.java @@ -26,8 +26,6 @@ package org.onap.appc.dg.flowbuilder.helper; import java.util.*; -import org.onap.appc.dg.flowbuilder.exception.InvalidDependencyModel; - public class Graph<T> { private int size; diff --git a/appc-dg/appc-dg-shared/appc-dg-dependency-model/src/main/java/org/onap/appc/dg/flowbuilder/impl/AbstractFlowStrategy.java b/appc-dg/appc-dg-shared/appc-dg-dependency-model/src/main/java/org/onap/appc/dg/flowbuilder/impl/AbstractFlowStrategy.java index fbb2d5d67..8d3eab3e9 100644 --- a/appc-dg/appc-dg-shared/appc-dg-dependency-model/src/main/java/org/onap/appc/dg/flowbuilder/impl/AbstractFlowStrategy.java +++ b/appc-dg/appc-dg-shared/appc-dg-dependency-model/src/main/java/org/onap/appc/dg/flowbuilder/impl/AbstractFlowStrategy.java @@ -32,7 +32,7 @@ import java.util.List; import java.util.Set; import org.onap.appc.dg.flowbuilder.FlowStrategy; -import org.onap.appc.dg.flowbuilder.exception.InvalidDependencyModel; +import org.onap.appc.dg.flowbuilder.exception.InvalidDependencyModelException; import org.onap.appc.dg.flowbuilder.helper.Graph; import org.onap.appc.dg.objects.*; import org.onap.appc.domainmodel.Vnfc; @@ -40,11 +40,11 @@ import org.onap.appc.domainmodel.Vnfc; public abstract class AbstractFlowStrategy implements FlowStrategy { - protected Graph<Vnfc> graph; + private final EELFLogger logger = EELFManager.getInstance().getLogger(AbstractFlowStrategy.class); - private static final EELFLogger logger = EELFManager.getInstance().getLogger(AbstractFlowStrategy.class); + Graph<Vnfc> graph; - public VnfcFlowModel buildFlowModel(VnfcDependencyModel dependencyModel, InventoryModel inventoryModel) { + public VnfcFlowModel buildFlowModel(VnfcDependencyModel dependencyModel, InventoryModel inventoryModel) throws InvalidDependencyModelException { if(logger.isTraceEnabled()){ logger.trace("Entering into buildFlowModel with dependency model = " + dependencyModel + "inventory model = " +inventoryModel); @@ -54,7 +54,7 @@ public abstract class AbstractFlowStrategy implements FlowStrategy { || dependencyModel.getDependencies() ==null || dependencyModel.getDependencies().size() ==0){ logger.debug("Dependency model not available, building flow model with sequence"); - throw new InvalidDependencyModel("Dependency model either null or does not contain any dependency"); + throw new InvalidDependencyModelException("Dependency model either null or does not contain any dependency"); } VnfcFlowModel flowModel = buildFlowModel(dependencyModel); @@ -72,7 +72,7 @@ public abstract class AbstractFlowStrategy implements FlowStrategy { } private void populateFlowModel(VnfcFlowModel flowModel, InventoryModel inventoryModel) { - Iterator<List<Vnfc>> flowIterator = null; + Iterator<List<Vnfc>> flowIterator; for(Vnfc vnfcFromInventory:inventoryModel.getVnf().getVnfcs()){ flowIterator = flowModel.getModelIterator(); @@ -81,7 +81,7 @@ public abstract class AbstractFlowStrategy implements FlowStrategy { for(Vnfc vnfcFromFlowModel:flowIterator.next() ){ if(vnfcType.equalsIgnoreCase(vnfcFromFlowModel.getVnfcType())){ vnfcFromFlowModel.setVnfcName(vnfcFromInventory.getVnfcName()); - vnfcFromFlowModel.addVms(vnfcFromInventory.getVserverList()); + vnfcFromFlowModel.setVserverList(vnfcFromInventory.getVserverList()); } } } @@ -90,7 +90,8 @@ public abstract class AbstractFlowStrategy implements FlowStrategy { } - private VnfcFlowModel buildFlowModel(VnfcDependencyModel dependencyModel) throws InvalidDependencyModel { + @SuppressWarnings("unchecked") + private VnfcFlowModel buildFlowModel(VnfcDependencyModel dependencyModel) throws InvalidDependencyModelException { Set<Node<Vnfc>> dependencies = dependencyModel.getDependencies(); graph = new Graph(dependencies.size()); @@ -116,21 +117,11 @@ public abstract class AbstractFlowStrategy implements FlowStrategy { count++; } if(flowModelSize != dependencies.size()){ - throw new InvalidDependencyModel("Cycle detected in the VNFC dependencies"); + throw new InvalidDependencyModelException("Cyclic dependency detected between the VNFC's"); } return builder.build(); } - protected abstract List<List<Vnfc>> orderDependencies(); - - /*private VnfcFlowModel buildFlowModelWithoutSequence(InventoryModel inventoryModel) { - VnfcFlowModel.VnfcFlowModelBuilder builder = new VnfcFlowModel.VnfcFlowModelBuilder(); - - for(Vnfc vnfc:inventoryModel.getVnf().getVnfcs()){ - builder = builder.addMetadata(0,vnfc); - } - - return builder.build(); - }*/ + protected abstract List<List<Vnfc>> orderDependencies() throws InvalidDependencyModelException; } diff --git a/appc-dg/appc-dg-shared/appc-dg-dependency-model/src/main/java/org/onap/appc/dg/flowbuilder/impl/FlowBuilderImpl.java b/appc-dg/appc-dg-shared/appc-dg-dependency-model/src/main/java/org/onap/appc/dg/flowbuilder/impl/FlowBuilderImpl.java index 59d1e4bf9..e57e2d38a 100644 --- a/appc-dg/appc-dg-shared/appc-dg-dependency-model/src/main/java/org/onap/appc/dg/flowbuilder/impl/FlowBuilderImpl.java +++ b/appc-dg/appc-dg-shared/appc-dg-dependency-model/src/main/java/org/onap/appc/dg/flowbuilder/impl/FlowBuilderImpl.java @@ -24,6 +24,7 @@ package org.onap.appc.dg.flowbuilder.impl; +import org.onap.appc.dg.flowbuilder.exception.InvalidDependencyModelException; import org.onap.appc.dg.flowbuilder.FlowBuilder; import org.onap.appc.dg.flowbuilder.FlowStrategy; import org.onap.appc.dg.objects.InventoryModel; @@ -44,7 +45,7 @@ public class FlowBuilderImpl implements FlowBuilder { this.strategy = strategy; } - public VnfcFlowModel buildFlowModel(VnfcDependencyModel dependencyModel, InventoryModel inventoryModel) { + public VnfcFlowModel buildFlowModel(VnfcDependencyModel dependencyModel, InventoryModel inventoryModel) throws InvalidDependencyModelException{ return strategy.buildFlowModel(dependencyModel, inventoryModel); } diff --git a/appc-dg/appc-dg-shared/appc-dg-dependency-model/src/main/java/org/onap/appc/dg/flowbuilder/impl/ForwardFlowStrategy.java b/appc-dg/appc-dg-shared/appc-dg-dependency-model/src/main/java/org/onap/appc/dg/flowbuilder/impl/ForwardFlowStrategy.java index 9c5aae64f..053981989 100644 --- a/appc-dg/appc-dg-shared/appc-dg-dependency-model/src/main/java/org/onap/appc/dg/flowbuilder/impl/ForwardFlowStrategy.java +++ b/appc-dg/appc-dg-shared/appc-dg-dependency-model/src/main/java/org/onap/appc/dg/flowbuilder/impl/ForwardFlowStrategy.java @@ -26,13 +26,13 @@ package org.onap.appc.dg.flowbuilder.impl; import java.util.*; -import org.onap.appc.dg.flowbuilder.exception.InvalidDependencyModel; +import org.onap.appc.dg.flowbuilder.exception.InvalidDependencyModelException; import org.onap.appc.domainmodel.Vnfc; public class ForwardFlowStrategy extends AbstractFlowStrategy { @Override - protected List<List<Vnfc>> orderDependencies() { + protected List<List<Vnfc>> orderDependencies() throws InvalidDependencyModelException{ ArrayList<List<Vnfc>> arrayList = new ArrayList<>(); Queue<Vnfc> queue1 = new LinkedList(); @@ -53,7 +53,7 @@ public class ForwardFlowStrategy extends AbstractFlowStrategy { } } if(queue1.isEmpty()){ - throw new InvalidDependencyModel("There seems to be no Root/Independent node for Vnfc dependencies"); + throw new InvalidDependencyModelException("There seems to be no Root/Independent node for Vnfc dependencies"); } arrayList.add((List<Vnfc>)queue1); queue1 = new LinkedList<>(queue1); @@ -86,7 +86,7 @@ public class ForwardFlowStrategy extends AbstractFlowStrategy { if(arrayList.size()>graph.getSize()){ // dependency list cannot be larger than total number of nodes // if it happens indicates cycle in the dependency - throw new InvalidDependencyModel("Cycle detected in the VNFC dependencies"); + throw new InvalidDependencyModelException("Cycle detected in the VNFC dependencies"); } queue1.addAll(queue2); queue2 = new LinkedHashSet<>(); diff --git a/appc-dg/appc-dg-shared/appc-dg-dependency-model/src/main/java/org/onap/appc/dg/flowbuilder/impl/ReverseFlowStrategy.java b/appc-dg/appc-dg-shared/appc-dg-dependency-model/src/main/java/org/onap/appc/dg/flowbuilder/impl/ReverseFlowStrategy.java index 79cd4420c..72b88f6e5 100644 --- a/appc-dg/appc-dg-shared/appc-dg-dependency-model/src/main/java/org/onap/appc/dg/flowbuilder/impl/ReverseFlowStrategy.java +++ b/appc-dg/appc-dg-shared/appc-dg-dependency-model/src/main/java/org/onap/appc/dg/flowbuilder/impl/ReverseFlowStrategy.java @@ -26,14 +26,14 @@ package org.onap.appc.dg.flowbuilder.impl; import java.util.*; -import org.onap.appc.dg.flowbuilder.exception.InvalidDependencyModel; +import org.onap.appc.dg.flowbuilder.exception.InvalidDependencyModelException; import org.onap.appc.domainmodel.Vnfc; public class ReverseFlowStrategy extends AbstractFlowStrategy { @Override - protected List<List<Vnfc>> orderDependencies() { + protected List<List<Vnfc>> orderDependencies() throws InvalidDependencyModelException{ ArrayList<List<Vnfc>> arrayList = new ArrayList<>(); Queue<Vnfc> queue1 = new LinkedList(); @@ -54,7 +54,7 @@ public class ReverseFlowStrategy extends AbstractFlowStrategy { } } if(queue1.isEmpty()){ - throw new InvalidDependencyModel("There seems to be no leaf node for Vnfc dependencies"); + throw new InvalidDependencyModelException("There seems to be no leaf node for Vnfc dependencies"); } arrayList.add((List<Vnfc>)queue1); queue1 = new LinkedList<>(queue1); @@ -87,7 +87,7 @@ public class ReverseFlowStrategy extends AbstractFlowStrategy { if(arrayList.size()>graph.getSize()){ // dependency list cannot be larger than total number of nodes // if it happens indicates cycle in the dependency - throw new InvalidDependencyModel("Cycle detected in the VNFC dependencies"); + throw new InvalidDependencyModelException("Cyclic dependency detected between the VNFCs"); } queue1.addAll(queue2); queue2 = new LinkedHashSet<>(); diff --git a/appc-dg/appc-dg-shared/appc-dg-dependency-model/src/test/java/org/onap/appc/dg/flowbuilder/TestFlowBuilder.java b/appc-dg/appc-dg-shared/appc-dg-dependency-model/src/test/java/org/onap/appc/dg/flowbuilder/TestFlowBuilder.java index 009515378..03037afeb 100644 --- a/appc-dg/appc-dg-shared/appc-dg-dependency-model/src/test/java/org/onap/appc/dg/flowbuilder/TestFlowBuilder.java +++ b/appc-dg/appc-dg-shared/appc-dg-dependency-model/src/test/java/org/onap/appc/dg/flowbuilder/TestFlowBuilder.java @@ -27,7 +27,7 @@ package org.onap.appc.dg.flowbuilder; import org.junit.Assert; import org.junit.Test; import org.onap.appc.dg.flowbuilder.FlowBuilder; -import org.onap.appc.dg.flowbuilder.exception.InvalidDependencyModel; +import org.onap.appc.dg.flowbuilder.exception.InvalidDependencyModelException; import org.onap.appc.dg.flowbuilder.impl.FlowBuilderFactory; import org.onap.appc.dg.objects.*; import org.onap.appc.domainmodel.Vnf; @@ -41,9 +41,8 @@ import java.util.Set; public class TestFlowBuilder { - @Test - public void testForwardFlowBuilder(){ + public void testForwardFlowBuilder() throws InvalidDependencyModelException { FlowBuilder builder = FlowBuilderFactory.getInstance().getFlowBuilder(FlowStrategies.FORWARD); VnfcDependencyModel dependencyModel = readDependencyModel(); InventoryModel inventoryModel = readInventoryModel(); @@ -51,17 +50,25 @@ public class TestFlowBuilder { Iterator<List<Vnfc>> itr = flowModel.getModelIterator(); List<Vnfc> list = itr.next(); - Assert.assertTrue(list.contains(new Vnfc("SMP","Active-Passive","SMP_Name"))); + Assert.assertTrue(list.contains(createVnfc("SMP","Active-Passive","SMP_Name"))); list = itr.next(); - Assert.assertTrue(list.contains(new Vnfc("BE","Active-Active","BE_Name"))); + Assert.assertTrue(list.contains(createVnfc("BE","Active-Active","BE_Name"))); list = itr.next(); - Assert.assertTrue(list.contains(new Vnfc("FE","Active-Active","FE_Name"))); + Assert.assertTrue(list.contains(createVnfc("FE","Active-Active","FE_Name"))); + } + + private Vnfc createVnfc(String vnfcType,String resilienceType,String vnfcName) { + Vnfc vnfc = new Vnfc(); + vnfc.setVnfcType(vnfcType); + vnfc.setVnfcName(vnfcName); + vnfc.setResilienceType(resilienceType); + return vnfc; } @Test - public void testReverseFlowBuilder(){ + public void testReverseFlowBuilder() throws InvalidDependencyModelException { FlowBuilder builder = FlowBuilderFactory.getInstance().getFlowBuilder(FlowStrategies.REVERSE); VnfcDependencyModel dependencyModel = readDependencyModel(); InventoryModel inventoryModel = readInventoryModel(); @@ -69,42 +76,45 @@ public class TestFlowBuilder { Iterator<List<Vnfc>> itr = flowModel.getModelIterator(); List<Vnfc> list = itr.next(); - Assert.assertTrue(list.contains(new Vnfc("FE","Active-Active","FE_Name"))); + Assert.assertTrue(list.contains(createVnfc("FE","Active-Active","FE_Name"))); list = itr.next(); - Assert.assertTrue(list.contains(new Vnfc("BE","Active-Active","BE_Name"))); + Assert.assertTrue(list.contains(createVnfc("BE","Active-Active","BE_Name"))); list = itr.next(); - Assert.assertTrue(list.contains(new Vnfc("SMP","Active-Passive","SMP_Name"))); + Assert.assertTrue(list.contains(createVnfc("SMP","Active-Passive","SMP_Name"))); } @Test - public void testComplexFlowBuilderForward(){ + public void testComplexFlowBuilderForward() throws InvalidDependencyModelException { FlowBuilder builder = FlowBuilderFactory.getInstance().getFlowBuilder(FlowStrategies.FORWARD); VnfcDependencyModel dependencyModel = readComplexDependencyModel(); InventoryModel inventoryModel = readComplexInventoryModel(); VnfcFlowModel flowModel = builder.buildFlowModel(dependencyModel,inventoryModel); Iterator<List<Vnfc>> itr = flowModel.getModelIterator(); - - List<Vnfc> list = itr.next(); - Assert.assertTrue(list.contains(new Vnfc("A","Active-Active","A_Name"))); - Assert.assertTrue(list.contains(new Vnfc("E","Active-Active","E_Name"))); - - list = itr.next(); - Assert.assertTrue(list.contains(new Vnfc("B","Active-Active","B_Name"))); - Assert.assertTrue(list.contains(new Vnfc("C","Active-Active","C_Name"))); - - list = itr.next(); - Assert.assertTrue(list.contains(new Vnfc("D","Active-Active","D_Name"))); - Assert.assertTrue(list.contains(new Vnfc("F","Active-Active","F_Name"))); - - list = itr.next(); - Assert.assertTrue(list.contains(new Vnfc("G","Active-Active","G_Name"))); - + try{ + List<Vnfc> list = itr.next(); + Assert.assertTrue(list.contains(createVnfc("A","Active-Active","A_Name"))); + Assert.assertTrue(list.contains(createVnfc("E","Active-Active","E_Name"))); + + list = itr.next(); + Assert.assertTrue(list.contains(createVnfc("B","Active-Active","B_Name"))); + Assert.assertTrue(list.contains(createVnfc("C","Active-Active","C_Name"))); + + list = itr.next(); + Assert.assertTrue(list.contains(createVnfc("D","Active-Active","D_Name"))); + Assert.assertTrue(list.contains(createVnfc("F","Active-Active","F_Name"))); + + list = itr.next(); + Assert.assertTrue(list.contains(createVnfc("G","Active-Active","G_Name"))); + } + catch (Exception e){ + e.printStackTrace(); + } } @Test - public void testComplexFlowBuilderReverse(){ + public void testComplexFlowBuilderReverse() throws InvalidDependencyModelException { FlowBuilder builder = FlowBuilderFactory.getInstance().getFlowBuilder(FlowStrategies.REVERSE); VnfcDependencyModel dependencyModel = readComplexDependencyModel(); InventoryModel inventoryModel = readComplexInventoryModel(); @@ -112,33 +122,33 @@ public class TestFlowBuilder { Iterator<List<Vnfc>> itr = flowModel.getModelIterator(); List<Vnfc> list = itr.next(); - Assert.assertTrue(list.contains(new Vnfc("D","Active-Active","D_Name"))); + Assert.assertTrue(list.contains(createVnfc("D","Active-Active","D_Name"))); - Assert.assertTrue(list.contains(new Vnfc("G","Active-Active","G_Name"))); + Assert.assertTrue(list.contains(createVnfc("G","Active-Active","G_Name"))); list = itr.next(); - Assert.assertTrue(list.contains(new Vnfc("B","Active-Active","B_Name"))); - Assert.assertTrue(list.contains(new Vnfc("F","Active-Active","F_Name"))); + Assert.assertTrue(list.contains(createVnfc("B","Active-Active","B_Name"))); + Assert.assertTrue(list.contains(createVnfc("F","Active-Active","F_Name"))); list = itr.next(); - Assert.assertTrue(list.contains(new Vnfc("C","Active-Active","C_Name"))); + Assert.assertTrue(list.contains(createVnfc("C","Active-Active","C_Name"))); list = itr.next(); - Assert.assertTrue(list.contains(new Vnfc("E","Active-Active","E_Name"))); - Assert.assertTrue(list.contains(new Vnfc("A","Active-Active","A_Name"))); + Assert.assertTrue(list.contains(createVnfc("E","Active-Active","E_Name"))); + Assert.assertTrue(list.contains(createVnfc("A","Active-Active","A_Name"))); } - @Test(expected = InvalidDependencyModel.class) - public void testCyclicBuilder(){ + @Test(expected = InvalidDependencyModelException.class) + public void testCyclicBuilder() throws InvalidDependencyModelException { FlowBuilder builder = FlowBuilderFactory.getInstance().getFlowBuilder(FlowStrategies.FORWARD); VnfcDependencyModel dependencyModel = readCyclicDependencyModel(); InventoryModel inventoryModel = readInventoryModel(); builder.buildFlowModel(dependencyModel,inventoryModel); } - @Test(expected = InvalidDependencyModel.class) - public void testCyclicBuilderWithRootNode(){ + @Test(expected = InvalidDependencyModelException.class) + public void testCyclicBuilderWithRootNode() throws InvalidDependencyModelException { FlowBuilder builder = FlowBuilderFactory.getInstance().getFlowBuilder(FlowStrategies.FORWARD); VnfcDependencyModel dependencyModel = readCyclicDependencyModelWithRootNode(); InventoryModel inventoryModel = readInventoryModel(); @@ -146,9 +156,9 @@ public class TestFlowBuilder { } private VnfcDependencyModel readCyclicDependencyModelWithRootNode() { - Vnfc a = new Vnfc("A","Active-Passive",null); - Vnfc b = new Vnfc("B","Active-Active",null); - Vnfc c = new Vnfc("C","Active-Active",null); + Vnfc a = createVnfc("A","Active-Passive",null); + Vnfc b = createVnfc("B","Active-Active",null); + Vnfc c = createVnfc("C","Active-Active",null); Node aNode = new Node(a); @@ -168,43 +178,43 @@ public class TestFlowBuilder { } private InventoryModel readComplexInventoryModel() { - Vnf vnf = new Vnf("vnf_1","vABCD","1"); - - Vnfc vnfcA = new Vnfc("A","Active-Active","A_Name"); - Vnfc vnfcB = new Vnfc("B","Active-Active","B_Name"); - Vnfc vnfcC = new Vnfc("C","Active-Active","C_Name"); - Vnfc vnfcD = new Vnfc("D","Active-Active","D_Name"); - Vnfc vnfcE = new Vnfc("E","Active-Active","E_Name"); - Vnfc vnfcF = new Vnfc("F","Active-Active","F_Name"); - Vnfc vnfcG = new Vnfc("G","Active-Active","G_Name"); - - vnfcA.addVm(new Vserver("VM_URL_A1")); - vnfcB.addVm(new Vserver("VM_URL_B1")); - vnfcC.addVm(new Vserver("VM_URL_C1")); - vnfcD.addVm(new Vserver("VM_URL_D1")); - vnfcE.addVm(new Vserver("VM_URL_E1")); - vnfcF.addVm(new Vserver("VM_URL_F1")); - vnfcG.addVm(new Vserver("VM_URL_G1")); - - vnf.addVnfc(vnfcA); - vnf.addVnfc(vnfcB); - vnf.addVnfc(vnfcC); - vnf.addVnfc(vnfcD); - vnf.addVnfc(vnfcE); - vnf.addVnfc(vnfcF); - vnf.addVnfc(vnfcG); + Vnf vnf = createVnf("vnf_1","vABCD","1"); + + Vnfc vnfcA = createVnfc("A","Active-Active","A_Name"); + Vnfc vnfcB = createVnfc("B","Active-Active","B_Name"); + Vnfc vnfcC = createVnfc("C","Active-Active","C_Name"); + Vnfc vnfcD = createVnfc("D","Active-Active","D_Name"); + Vnfc vnfcE = createVnfc("E","Active-Active","E_Name"); + Vnfc vnfcF = createVnfc("F","Active-Active","F_Name"); + Vnfc vnfcG = createVnfc("G","Active-Active","G_Name"); + + vnf.addVserver(createVserver("VM_URL_A1",vnfcA)); + vnf.addVserver(createVserver("VM_URL_B1",vnfcB)); + vnf.addVserver(createVserver("VM_URL_C1",vnfcC)); + vnf.addVserver(createVserver("VM_URL_D1",vnfcD)); + vnf.addVserver(createVserver("VM_URL_E1",vnfcE)); + vnf.addVserver(createVserver("VM_URL_F1",vnfcF)); + vnf.addVserver(createVserver("VM_URL_G1",vnfcG)); return new InventoryModel(vnf); } + private Vnf createVnf(String vnfId,String vnfType,String vnfVersion) { + Vnf vnf = new Vnf(); + vnf.setVnfId(vnfId); + vnf.setVnfType(vnfType); + vnf.setVnfVersion(vnfVersion); + return vnf; + } + private VnfcDependencyModel readComplexDependencyModel() { - Vnfc a = new Vnfc("A","Active-Active",null); - Vnfc b = new Vnfc("B","Active-Active",null); - Vnfc c = new Vnfc("C","Active-Active",null); - Vnfc d = new Vnfc("D","Active-Active",null); - Vnfc e = new Vnfc("E","Active-Active",null); - Vnfc f = new Vnfc("F","Active-Active",null); - Vnfc g = new Vnfc("G","Active-Active",null); + Vnfc a = createVnfc("A","Active-Active",null); + Vnfc b = createVnfc("B","Active-Active",null); + Vnfc c = createVnfc("C","Active-Active",null); + Vnfc d = createVnfc("D","Active-Active",null); + Vnfc e = createVnfc("E","Active-Active",null); + Vnfc f = createVnfc("F","Active-Active",null); + Vnfc g = createVnfc("G","Active-Active",null); Node aNode = new Node(a); @@ -242,10 +252,10 @@ public class TestFlowBuilder { private VnfcDependencyModel readCyclicDependencyModel() { - Vnfc a = new Vnfc("A","Active-Passive",null); - Vnfc b = new Vnfc("B","Active-Active",null); - Vnfc c = new Vnfc("C","Active-Active",null); - Vnfc d = new Vnfc("D","Active-Active",null); + Vnfc a = createVnfc("A","Active-Passive",null); + Vnfc b = createVnfc("B","Active-Active",null); + Vnfc c = createVnfc("C","Active-Active",null); + Vnfc d = createVnfc("D","Active-Active",null); Node aNode = new Node(a); @@ -271,48 +281,52 @@ public class TestFlowBuilder { } private InventoryModel readInventoryModel() { - Vnf vnf = new Vnf("vnf_1","vSCP","1"); - - Vnfc smp = new Vnfc("SMP",null,"SMP_Name"); - Vserver smpVm1 = new Vserver("SMP_URL1"); - Vserver smpVm2 = new Vserver("SMP_URL2"); + Vnf vnf = createVnf("vnf_1","vSCP","1"); - smp.addVm(smpVm1); - smp.addVm(smpVm2); + Vnfc smp = createVnfc("SMP",null,"SMP_Name"); + Vserver smpVm1 = createVserver("SMP_URL1",smp); + Vserver smpVm2 = createVserver("SMP_URL2",smp); - Vnfc be = new Vnfc("BE",null,"BE_Name"); + vnf.addVserver(smpVm1); + vnf.addVserver(smpVm2); - Vserver beVm1 = new Vserver("BE_URL1"); - Vserver beVm2 = new Vserver("BE_URL2"); - Vserver beVm3 = new Vserver("BE_URL3"); - Vserver beVm4 = new Vserver("BE_URL4"); - Vserver beVm5 = new Vserver("BE_URL5"); + Vnfc be = createVnfc("BE",null,"BE_Name"); - be.addVm(beVm1); - be.addVm(beVm2); - be.addVm(beVm3); - be.addVm(beVm4); - be.addVm(beVm5); + Vserver beVm1 = createVserver("BE_URL1",be); + Vserver beVm2 = createVserver("BE_URL2",be); + Vserver beVm3 = createVserver("BE_URL3",be); + Vserver beVm4 = createVserver("BE_URL4",be); + Vserver beVm5 = createVserver("BE_URL5",be); - Vnfc fe = new Vnfc("FE",null,"FE_Name"); + vnf.addVserver(beVm1); + vnf.addVserver(beVm2); + vnf.addVserver(beVm3); + vnf.addVserver(beVm4); + vnf.addVserver(beVm5); - Vserver feVm1 = new Vserver("FE_URL1"); - Vserver feVm2 = new Vserver("FE_URL2"); + Vnfc fe = createVnfc("FE",null,"FE_Name"); - fe.addVm(feVm1); - fe.addVm(feVm2); + Vserver feVm1 = createVserver("FE_URL1",fe); + Vserver feVm2 = createVserver("FE_URL2",fe); - vnf.addVnfc(smp); - vnf.addVnfc(be); - vnf.addVnfc(fe); + vnf.addVserver(feVm1); + vnf.addVserver(feVm2); return new InventoryModel(vnf); } + private Vserver createVserver(String url,Vnfc vnfc) { + Vserver vserver = new Vserver(); + vserver.setUrl(url); + vserver.setVnfc(vnfc); + vnfc.addVserver(vserver); + return vserver; + } + private VnfcDependencyModel readDependencyModel() { - Vnfc smp = new Vnfc("SMP","Active-Passive",null); - Vnfc be = new Vnfc("BE","Active-Active",null); - Vnfc fe = new Vnfc("FE","Active-Active",null); + Vnfc smp = createVnfc("SMP","Active-Passive",null); + Vnfc be = createVnfc("BE","Active-Active",null); + Vnfc fe = createVnfc("FE","Active-Active",null); Node smpNode = new Node(smp); diff --git a/appc-dg/appc-dg-shared/appc-dg-domain-model-lib/src/main/java/org/onap/appc/domainmodel/Vnf.java b/appc-dg/appc-dg-shared/appc-dg-domain-model-lib/src/main/java/org/onap/appc/domainmodel/Vnf.java index 9f75779cd..87e528b78 100644 --- a/appc-dg/appc-dg-shared/appc-dg-domain-model-lib/src/main/java/org/onap/appc/domainmodel/Vnf.java +++ b/appc-dg/appc-dg-shared/appc-dg-domain-model-lib/src/main/java/org/onap/appc/domainmodel/Vnf.java @@ -24,49 +24,75 @@ package org.onap.appc.domainmodel; +import java.util.HashSet; import java.util.LinkedList; import java.util.List; +import java.util.Set; public class Vnf { + private String vnfId; private String vnfType; private String vnfVersion; + private List <Vserver> vservers; - private List<Vnfc> vnfcs; + public Vnf(){ + vservers = new LinkedList<>(); + } - public Vnf(String vnfId,String vnfType,String vnfVersion){ + public String getVnfId() { + return vnfId; + } + + public void setVnfId(String vnfId) { this.vnfId = vnfId; + } + + public String getVnfType() { + return vnfType; + } + + public void setVnfType(String vnfType) { this.vnfType = vnfType; - this.vnfVersion = vnfVersion; - this.vnfcs = new LinkedList<>(); } public String getVnfVersion() { return vnfVersion; } - public String getVnfId() { - return vnfId; - } - - public String getVnfType() { - return vnfType; + public void setVnfVersion(String vnfVersion) { + this.vnfVersion = vnfVersion; } - public void addVnfc(Vnfc vnfc){ - this.vnfcs.add(vnfc); + public List<Vserver> getVservers() { + return vservers; } - public List<Vnfc> getVnfcs() { - return vnfcs; + public void setVservers(List<Vserver> vservers) { + this.vservers = vservers; } @Override public String toString() { - StringBuilder stringBuilder = new StringBuilder("Vnf : vnfId = " + vnfId +" , vnfType = " + vnfType); - for(Vnfc vnfc:vnfcs){ - stringBuilder.append(vnfc.toString()).append(","); + StringBuilder stringBuilder = new StringBuilder().append("Vnf : vnfId = ").append(vnfId ).append(" , vnfType = ").append( vnfType); + for(Vserver vserver:vservers){ + stringBuilder.append(vserver.toString()).append(","); } return stringBuilder.toString(); } + + public void addVserver(Vserver vserver) { + this.vservers.add(vserver); + } + + public List<Vnfc> getVnfcs(){ + Set<Vnfc> vnfcs = new HashSet<>(); + for(Vserver vserver:vservers){ + if(vserver.getVnfc() != null) + vnfcs.add(vserver.getVnfc()); + } + return new LinkedList<>(vnfcs); + } + + } diff --git a/appc-dg/appc-dg-shared/appc-dg-domain-model-lib/src/main/java/org/onap/appc/domainmodel/Vnfc.java b/appc-dg/appc-dg-shared/appc-dg-domain-model-lib/src/main/java/org/onap/appc/domainmodel/Vnfc.java index de075f085..6e7d24158 100644 --- a/appc-dg/appc-dg-shared/appc-dg-domain-model-lib/src/main/java/org/onap/appc/domainmodel/Vnfc.java +++ b/appc-dg/appc-dg-shared/appc-dg-domain-model-lib/src/main/java/org/onap/appc/domainmodel/Vnfc.java @@ -31,35 +31,18 @@ import java.util.List; public class Vnfc { private String vnfcType; - - public void setResilienceType(String resilienceType) { - this.resilienceType = resilienceType; - } - private String resilienceType; private boolean mandatory; private String vnfcName; private List<Vserver> vserverList; - public Vnfc(String vnfcType,String resilienceType){ - this(vnfcType,resilienceType,null, false); - } - - public Vnfc(String vnfcType,String resilienceType,String vnfcName){ - this(vnfcType,resilienceType,vnfcName, false); - } - - public Vnfc(String vnfcType,String resilienceType,String vnfcName, boolean mandatory){ - this.vnfcName = vnfcName; - this.vnfcType = vnfcType; - this.resilienceType = resilienceType; - this.mandatory = mandatory; + public Vnfc(){ this.vserverList = new LinkedList<>(); } @Override public String toString() { - StringBuilder stringBuilder = new StringBuilder("Vnfc : vnfcType = " + vnfcType + ", vnfcName = " +vnfcName + ", resilienceType = " + resilienceType+", mandatory = " + mandatory); + StringBuilder stringBuilder = new StringBuilder().append("Vnfc : vnfcType = ").append(vnfcType).append(", vnfcName = ").append(vnfcName).append(", resilienceType = " ).append(resilienceType).append(", mandatory = ").append(mandatory); for(Vserver vserver:vserverList){ stringBuilder.append(vserver.toString()).append(", \n"); } @@ -111,38 +94,53 @@ public class Vnfc { return true; } - public void addVm(Vserver vserver){ - this.vserverList.add(vserver); + public String getVnfcType() { + return vnfcType; } - public void addVms(List<Vserver> vserverList){ - this.vserverList.addAll(vserverList); + + public void setVnfcType(String vnfcType) { + this.vnfcType = vnfcType; } - public void setVnfcName(String vnfcName) { - this.vnfcName = vnfcName; + public String getResilienceType() { + return resilienceType; } - public String getVnfcType() { - return vnfcType; + public void setResilienceType(String resilienceType) { + this.resilienceType = resilienceType; } - public String getResilienceType() { - return resilienceType; + public boolean isMandatory() { + return mandatory; + } + + public void setMandatory(boolean mandatory) { + this.mandatory = mandatory; } public String getVnfcName() { return vnfcName; } + public void setVnfcName(String vnfcName) { + this.vnfcName = vnfcName; + } + public List<Vserver> getVserverList() { return vserverList; } - public boolean isMandatory() { - return mandatory; + public void setVserverList(List<Vserver> vserverList) { + this.vserverList = vserverList; } - public void setMandatory(boolean mandatory) { - this.mandatory = mandatory; + public void addVservers(List<Vserver> vserverList){ + this.vserverList.addAll(vserverList); + } + + public void addVserver(Vserver vm) { + this.vserverList.add(vm); } + + } diff --git a/appc-dg/appc-dg-shared/appc-dg-domain-model-lib/src/main/java/org/onap/appc/domainmodel/Vserver.java b/appc-dg/appc-dg-shared/appc-dg-domain-model-lib/src/main/java/org/onap/appc/domainmodel/Vserver.java index 0840bd91e..ce89c2ed4 100644 --- a/appc-dg/appc-dg-shared/appc-dg-domain-model-lib/src/main/java/org/onap/appc/domainmodel/Vserver.java +++ b/appc-dg/appc-dg-shared/appc-dg-domain-model-lib/src/main/java/org/onap/appc/domainmodel/Vserver.java @@ -28,51 +28,67 @@ package org.onap.appc.domainmodel; public class Vserver { private String url; - private String tenantId; private String id; private String relatedLink; private String name; + private Vnfc vnfc; - public Vserver(String url){ - this(url,null,null,null,null); - } + public Vserver(){ - public Vserver(String url, - String tenantId, - String id, - String relatedLink, - String name){ - this.url = url; - this.tenantId =tenantId; - this.id = id; - this.relatedLink =relatedLink; - this.name = name; + } + @Override + public String toString() { + return new StringBuilder().append("Vserver : url = ").append(url).append(", tenantId = ").append(tenantId).append(", id = ").append(id).append(" ,relatedLink = ").append(relatedLink).append(" , name = ").append(name).toString(); } public String getUrl() { return url; } - @Override - public String toString() { - return "Vserver : url = " +url + ", tenantId = " +tenantId +", id = " +id + " ,relatedLink = " +relatedLink +" , name = "+name; + public void setUrl(String url) { + this.url = url; } public String getTenantId() { return tenantId; } + public void setTenantId(String tenantId) { + this.tenantId = tenantId; + } + public String getId() { return id; } + public void setId(String id) { + this.id = id; + } + public String getRelatedLink() { return relatedLink; } + public void setRelatedLink(String relatedLink) { + this.relatedLink = relatedLink; + } + public String getName() { return name; } + + public void setName(String name) { + this.name = name; + } + + public Vnfc getVnfc() { + return vnfc; + } + + public void setVnfc(Vnfc vnfc) { + this.vnfc = vnfc; + } + } diff --git a/appc-sdc-listener/appc-sdc-listener-bundle/src/main/java/org/onap/appc/sdc/artifacts/helper/DependencyModelGenerator.java b/appc-sdc-listener/appc-sdc-listener-bundle/src/main/java/org/onap/appc/sdc/artifacts/helper/DependencyModelGenerator.java index 295ee47c8..62212d74c 100644 --- a/appc-sdc-listener/appc-sdc-listener-bundle/src/main/java/org/onap/appc/sdc/artifacts/helper/DependencyModelGenerator.java +++ b/appc-sdc-listener/appc-sdc-listener-bundle/src/main/java/org/onap/appc/sdc/artifacts/helper/DependencyModelGenerator.java @@ -32,6 +32,7 @@ import com.fasterxml.jackson.databind.MapperFeature; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.ObjectWriter; import org.onap.appc.dg.dependencymanager.helper.DependencyModelParser; +import org.onap.appc.dg.flowbuilder.exception.InvalidDependencyModelException; import org.onap.appc.dg.objects.Node; import org.onap.appc.dg.objects.VnfcDependencyModel; import org.onap.appc.domainmodel.Vnfc; @@ -58,7 +59,13 @@ public class DependencyModelGenerator { logger.debug(String.format("Generating dependency model for vnfType : %s , TOSCA: %s ", vnfType ,tosca)); String dependencyJson; DependencyModelParser dependencyModelParser = new DependencyModelParser(); - VnfcDependencyModel vnfcDependencyModel = dependencyModelParser.generateDependencyModel(tosca, vnfType); + VnfcDependencyModel vnfcDependencyModel = null; + try { + vnfcDependencyModel = dependencyModelParser.generateDependencyModel(tosca, vnfType); + } catch (InvalidDependencyModelException e) { + logger.error("Error generating dependency model"); + throw new APPCException(e.getMessage(),e); + } if (vnfcDependencyModel != null && !vnfcDependencyModel.getDependencies().isEmpty()) { logger.debug(String.format("Dependency Model generated : %s ", vnfcDependencyModel.toString())); diff --git a/appc-sdc-listener/appc-sdc-listener-bundle/src/main/java/org/onap/appc/sdc/artifacts/impl/ConfigArtifactProcessor.java b/appc-sdc-listener/appc-sdc-listener-bundle/src/main/java/org/onap/appc/sdc/artifacts/impl/ConfigArtifactProcessor.java index 41230ea30..b9eedc466 100644 --- a/appc-sdc-listener/appc-sdc-listener-bundle/src/main/java/org/onap/appc/sdc/artifacts/impl/ConfigArtifactProcessor.java +++ b/appc-sdc-listener/appc-sdc-listener-bundle/src/main/java/org/onap/appc/sdc/artifacts/impl/ConfigArtifactProcessor.java @@ -24,6 +24,7 @@ package org.onap.appc.sdc.artifacts.impl; +import org.apache.commons.lang.StringUtils; import org.onap.appc.adapter.message.EventSender; import org.onap.appc.sdc.listener.ProviderOperations; import org.onap.appc.sdc.listener.ProviderResponse; @@ -63,11 +64,21 @@ public class ConfigArtifactProcessor extends AbstractArtifactProcessor { @Override public void processArtifact(SDCArtifact artifact) throws APPCException { String postData = Util.toSdcStoreDocumentInput(notification, resource, super.artifact, artifact.getArtifactContent()); + logger.debug("ConfigArtifactProcessor::processArtifact::postData="+postData); try { - ProviderResponse result = ProviderOperations.post(storeUri.toURL(), postData, null); + ProviderOperations providerOperations = new ProviderOperations(); + if (null != storeUri) + logger.debug("ConfigArtifactProcessor::processArtifact::URI is"+storeUri.toString()); + ProviderResponse result = providerOperations.post(storeUri.toURL(), postData, null); if (result.getStatus() == 200) { + logger.debug("ConfigArtifactProcessor::processArtifact::post request success!!"); Util.parseResponse(result.getBody()); } + else { + logger.debug("ConfigArtifactProcessor::processArtifact()::post request failed!! Returned :" + +result.getStatus()+"-Result body- "+result.getBody()); + throw new APPCException("ConfigArtifactProcessor::processArtifact: Invalid status retrurned from post "+result.getStatus()); + } } catch (MalformedURLException | APPCException e) { logger.error("Error processing artifact : " + this.artifact.toString(),e); throw new APPCException(e.getMessage(),e); diff --git a/appc-sdc-listener/appc-sdc-listener-bundle/src/main/java/org/onap/appc/sdc/artifacts/impl/ToscaCsarArtifactProcessor.java b/appc-sdc-listener/appc-sdc-listener-bundle/src/main/java/org/onap/appc/sdc/artifacts/impl/ToscaCsarArtifactProcessor.java index 46a37273f..4cc4cfbdb 100644 --- a/appc-sdc-listener/appc-sdc-listener-bundle/src/main/java/org/onap/appc/sdc/artifacts/impl/ToscaCsarArtifactProcessor.java +++ b/appc-sdc-listener/appc-sdc-listener-bundle/src/main/java/org/onap/appc/sdc/artifacts/impl/ToscaCsarArtifactProcessor.java @@ -42,7 +42,16 @@ import org.openecomp.sdc.api.notification.INotificationData; import org.openecomp.sdc.api.notification.IResourceInstance; import org.openecomp.sdc.api.results.IDistributionClientDownloadResult; -import java.io.*; +import java.io.BufferedReader; +import java.io.ByteArrayInputStream; +import java.io.IOException; +import java.io.InputStreamReader; +import java.net.URI; +import java.util.HashMap; +import java.util.Iterator; +import java.util.LinkedList; +import java.util.List; +import java.util.Map; import java.net.URI; import java.util.*; import java.util.zip.ZipEntry; @@ -54,8 +63,12 @@ public class ToscaCsarArtifactProcessor extends AbstractArtifactProcessor{ private DependencyModelGenerator dependencyModelGenerator; - public ToscaCsarArtifactProcessor(IDistributionClient client, EventSender eventSender, INotificationData notification, IResourceInstance resource, - IArtifactInfo artifact, URI storeUri){ + public ToscaCsarArtifactProcessor(IDistributionClient client, + EventSender eventSender, + INotificationData notification, + IResourceInstance resource, + IArtifactInfo artifact, + URI storeUri){ super(client,eventSender,notification,resource,artifact,storeUri); dependencyModelGenerator = new DependencyModelGenerator(); } diff --git a/appc-sdc-listener/appc-sdc-listener-bundle/src/main/java/org/onap/appc/sdc/listener/SdcCallback.java b/appc-sdc-listener/appc-sdc-listener-bundle/src/main/java/org/onap/appc/sdc/listener/SdcCallback.java index 8be458200..a3d82a703 100644 --- a/appc-sdc-listener/appc-sdc-listener-bundle/src/main/java/org/onap/appc/sdc/listener/SdcCallback.java +++ b/appc-sdc-listener/appc-sdc-listener-bundle/src/main/java/org/onap/appc/sdc/listener/SdcCallback.java @@ -49,7 +49,7 @@ import java.util.concurrent.atomic.AtomicBoolean; public class SdcCallback implements INotificationCallback { private final EELFLogger logger = EELFManager.getInstance().getLogger(SdcCallback.class); - private ArtifactProcessorFactory artifactProcessorFactory=new ArtifactProcessorFactory(); + private ArtifactProcessorFactory artifactProcessorFactory = new ArtifactProcessorFactory(); private URI storeUri; private IDistributionClient client; @@ -92,7 +92,8 @@ public class SdcCallback implements INotificationCallback { if (isRunning.get()) { for(IArtifactInfo artifact:data.getServiceArtifacts()){ - ArtifactProcessor artifactProcessor = artifactProcessorFactory.getArtifactProcessor(client, eventSender, data, null, artifact, storeUri); + ArtifactProcessor artifactProcessor = artifactProcessorFactory.getArtifactProcessor( + client, eventSender, data, null, artifact, storeUri); if(artifactProcessor!=null){ executor.submit(artifactProcessor); } @@ -102,9 +103,11 @@ public class SdcCallback implements INotificationCallback { for (IArtifactInfo artifact : resource.getArtifacts()) { logger.info(Util.toSdcStoreDocumentInput(data, resource, artifact, "abc")); if (executor.getQueue().size() >= threadCount) { - // log warning about job backlog + logger.warn(String.format("excuter queue size (%d) is exceeding thread count (%s).", + executor.getQueue().size(), threadCount)); } - ArtifactProcessor artifactProcessor = artifactProcessorFactory.getArtifactProcessor(client, eventSender, data, resource, artifact, storeUri); + ArtifactProcessor artifactProcessor = artifactProcessorFactory.getArtifactProcessor( + client, eventSender, data, resource, artifact, storeUri); if(artifactProcessor != null){ executor.submit(artifactProcessor); } @@ -115,7 +118,8 @@ public class SdcCallback implements INotificationCallback { we are sending the download status as positive just to have the same behaviour as before refactoring. */ - client.sendDownloadStatus(Util.buildDistributionStatusMessage(client, data, artifact, DistributionStatusEnum.DOWNLOAD_OK)); + client.sendDownloadStatus(Util.buildDistributionStatusMessage( + client, data, artifact, DistributionStatusEnum.DOWNLOAD_OK)); logger.error("Artifact type not supported : " + artifact.getArtifactType()); } } diff --git a/appc-sdc-listener/appc-sdc-listener-bundle/src/main/java/org/onap/appc/sdc/listener/SdcConfig.java b/appc-sdc-listener/appc-sdc-listener-bundle/src/main/java/org/onap/appc/sdc/listener/SdcConfig.java index 86ba9e1f5..2acb2e625 100644 --- a/appc-sdc-listener/appc-sdc-listener-bundle/src/main/java/org/onap/appc/sdc/listener/SdcConfig.java +++ b/appc-sdc-listener/appc-sdc-listener-bundle/src/main/java/org/onap/appc/sdc/listener/SdcConfig.java @@ -34,6 +34,7 @@ import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Properties; +import org.apache.commons.lang.StringUtils; public class SdcConfig implements IConfiguration { @@ -50,11 +51,8 @@ public class SdcConfig implements IConfiguration { private List<String> types = new ArrayList<>(); private String user; private String pass; - private URI storeOp; - private Properties props; - private final EELFLogger logger = EELFManager.getInstance().getLogger(SdcConfig.class); SdcConfig(Properties props) throws Exception { @@ -67,7 +65,6 @@ public class SdcConfig implements IConfiguration { logger.error("SdcConfig init is skipped due to properties is null"); return; } - // Keystore for ca cert keystorePath = props.getProperty("appc.sdc.keystore.path"); keystorePass = props.getProperty("appc.sdc.keystore.pass"); @@ -181,6 +178,31 @@ public class SdcConfig implements IConfiguration { return true; } + @Override + public List <String> getMsgBusAddress() { + return (getMsgBusProperties()); + } + + public List<String> getMsgBusProperties() { + List<String> uebAddresses = new ArrayList<String>(); + String uebAddressesList=null; + if (null != this.props) + uebAddressesList = this.props.getProperty("appc.ClosedLoop.poolMembers"); + else { + logger.info("SdcConfig:SdcConfig:getMsgBusProperties()::props is null for SdcConfig"); + return null; + } + if (null == uebAddressesList) { + logger.info("SdcConfig:SdcConfig:getMsgBusProperties()::uebAddressesList is null for SdcConfig"); + return null; + } + logger.debug("SdcConfig:SdcConfig:getMsgBusProperties()::uebAddressesList is="+ uebAddressesList); + String[] sList = uebAddressesList.split(","); + uebAddresses= formatAddresses(sList); + logger.debug("SdcConfig:getMsgBusProperties:::Returning addresses as "+uebAddresses.toString()); + return uebAddresses; + } + URI getStoreOpURI() { return storeOp; } @@ -199,4 +221,19 @@ public class SdcConfig implements IConfiguration { logger.info(String.format("SDC Params: %s", params)); } + + protected List<String> formatAddresses(String[] sList) { + List<String> uebAddresses = new ArrayList<String>(); + for (String fqdnPort:sList) { + if (fqdnPort.startsWith("http")) { + fqdnPort=StringUtils.substringAfter(fqdnPort, "://"); + } + if (null != fqdnPort && fqdnPort.contains(":")) { + fqdnPort=StringUtils.substringBefore(fqdnPort,":"); + } + logger.debug("SdcConfig:formatAddresses:: "+fqdnPort); + uebAddresses.add(fqdnPort); + } + return uebAddresses; + } } diff --git a/appc-sdc-listener/appc-sdc-listener-bundle/src/test/java/org/onap/appc/sdc/listener/SdcConfigTest.java b/appc-sdc-listener/appc-sdc-listener-bundle/src/test/java/org/onap/appc/sdc/listener/SdcConfigTest.java new file mode 100644 index 000000000..f799db5e1 --- /dev/null +++ b/appc-sdc-listener/appc-sdc-listener-bundle/src/test/java/org/onap/appc/sdc/listener/SdcConfigTest.java @@ -0,0 +1,46 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : APPC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Copyright (C) 2017 Amdocs + * ============================================================================= + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * ECOMP is a trademark and service mark of AT&T Intellectual Property. + * ============LICENSE_END========================================================= + */ + +package org.onap.appc.sdc.listener; + +import static org.junit.Assert.assertNotNull; + +import java.util.List; +import java.util.Properties; + +import org.junit.Test; + +public class SdcConfigTest { + + @Test + public void testGetMsgBusProperties() throws Exception { + Properties properties = new Properties(); + properties.setProperty("appc.sdc.provider.url", + "http://localhost:8181/restconf/operations/SdcMessage:configuration-document-request"); + properties.setProperty("appc.ClosedLoop.poolMembers","uebsb91bodc.it.att.com:3905,uebsb92bodc.it.att.com:3905,uebsb93bodc.it.att.com:3905"); + SdcConfig sdc = new SdcConfig(properties); + List<String> uebAddresses = sdc.getMsgBusProperties(); + assertNotNull(uebAddresses); + } +} diff --git a/appc-sequence-generator/appc-sequence-generator-bundle/src/main/java/org/onap/appc/seqgen/dgplugin/impl/SequenceGeneratorPluginImpl.java b/appc-sequence-generator/appc-sequence-generator-bundle/src/main/java/org/onap/appc/seqgen/dgplugin/impl/SequenceGeneratorPluginImpl.java index c0ea4134c..8e44bc3bd 100644 --- a/appc-sequence-generator/appc-sequence-generator-bundle/src/main/java/org/onap/appc/seqgen/dgplugin/impl/SequenceGeneratorPluginImpl.java +++ b/appc-sequence-generator/appc-sequence-generator-bundle/src/main/java/org/onap/appc/seqgen/dgplugin/impl/SequenceGeneratorPluginImpl.java @@ -27,8 +27,10 @@ import com.fasterxml.jackson.core.JsonParser; import com.fasterxml.jackson.databind.DeserializationFeature; import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; -import org.apache.commons.lang3.StringUtils; -import org.onap.appc.dg.objects.*; +import org.onap.appc.dg.flowbuilder.exception.InvalidDependencyModelException; +import org.onap.appc.dg.objects.InventoryModel; +import org.onap.appc.dg.objects.Node; +import org.onap.appc.dg.objects.VnfcDependencyModel; import org.onap.appc.domainmodel.Vnf; import org.onap.appc.domainmodel.Vnfc; import org.onap.appc.domainmodel.Vserver; @@ -43,7 +45,12 @@ import org.onap.appc.seqgen.objects.Transaction; import org.onap.ccsdk.sli.core.sli.SvcLogicContext; import java.io.IOException; -import java.util.*; +import java.util.Map; +import java.util.List; +import java.util.HashSet; +import java.util.Set; +import java.util.HashMap; +import java.util.LinkedList; public class SequenceGeneratorPluginImpl implements SequenceGeneratorPlugin { @@ -79,6 +86,9 @@ public class SequenceGeneratorPluginImpl implements SequenceGeneratorPlugin { sequenceGeneratorInput.setInventoryModel(inventoryModel); VnfcDependencyModel dependencyModel = buildDependencyModel(inputJson); + if(dependencyModel!=null){ + validateInventoryModelWithDependencyModel(dependencyModel,inventoryModel); + } sequenceGeneratorInput.setDependencyModel(dependencyModel); return sequenceGeneratorInput; @@ -92,13 +102,54 @@ public class SequenceGeneratorPluginImpl implements SequenceGeneratorPlugin { if (operation == null) { throw new APPCException("Invalid Action " + action); } + if(Constants.ActionLevel.findByString(sequenceGeneratorInput.getRequestInfo().getActionLevel().toUpperCase())==null){ + throw new APPCException("Invalid Action Level " + sequenceGeneratorInput.getRequestInfo().getActionLevel()); + } SequenceGenerator sequenceGenerator = SequenceGeneratorFactory.getInstance().createSequenceGenerator(operation); return sequenceGenerator.generateSequence(sequenceGeneratorInput); } + private void validateInventoryModelWithDependencyModel(VnfcDependencyModel dependencyModel, InventoryModel inventoryModel) throws APPCException { + Set<String> dependencyModelVnfcSet = new HashSet<>(); + Set<String> dependencyModelMandatoryVnfcSet = new HashSet<>(); + Set<String> inventoryModelVnfcsSet = new HashSet<>(); + + for (Node<Vnfc> node : dependencyModel.getDependencies()) { + dependencyModelVnfcSet.add(node.getChild().getVnfcType().toLowerCase()); + if (node.getChild().isMandatory()) { + dependencyModelMandatoryVnfcSet.add(node.getChild().getVnfcType().toLowerCase()); + } + } + + for (Vnfc vnfc : inventoryModel.getVnf().getVnfcs()) { + inventoryModelVnfcsSet.add(vnfc.getVnfcType().toLowerCase()); + } + + // if dependency model and inventory model contains same set of VNFCs, validation succeed and hence return + if (dependencyModelVnfcSet.equals(inventoryModelVnfcsSet)) { + return; + } + + if (inventoryModelVnfcsSet.size() >= dependencyModelVnfcSet.size()) { + Set<String> difference = new HashSet<>(inventoryModelVnfcsSet); + difference.removeAll(dependencyModelVnfcSet); + logger.error("Dependency model is missing following vnfc type(s): " + difference); + throw new APPCException("Dependency model is missing following vnfc type(s): " + difference); + } else { + Set<String> difference = new HashSet<>(dependencyModelMandatoryVnfcSet); + difference.removeAll(inventoryModelVnfcsSet); + if (difference.size() > 0) { + logger.error("Inventory model is missing following mandatory vnfc type(s): " + difference); + throw new APPCException("VMs missing for the mandatory VNFC : " + difference); + } + } + } + // Dependency model is an optional attribute and may contain null values private VnfcDependencyModel buildDependencyModel(String inputJson) throws IOException, APPCException { Set<Node<Vnfc>> dependency = new HashSet<>(); + Set<String> parentVnfcs=new HashSet<>(); + Set<String> allVnfcTypes=new HashSet<>(); ObjectMapper objectMapper = new ObjectMapper(); objectMapper.configure(JsonParser.Feature.ALLOW_COMMENTS, true); JsonNode rootNode = objectMapper.readTree(inputJson); @@ -106,9 +157,13 @@ public class SequenceGeneratorPluginImpl implements SequenceGeneratorPlugin { if (vnfcs != null) { for (JsonNode vnfcNode : vnfcs) { String vnfcType = readVnfcType(vnfcNode); + allVnfcTypes.add(vnfcType); String mandatory = readMandatory(vnfcNode); String resilience = readResilience(vnfcNode); - Vnfc vnfc = new Vnfc(vnfcType, resilience, null, Boolean.parseBoolean(mandatory)); + Vnfc vnfc = new Vnfc(); + vnfc.setVnfcType(vnfcType); + vnfc.setResilienceType(resilience); + vnfc.setMandatory(Boolean.parseBoolean(mandatory)); Node<Vnfc> currentNode = getNode(dependency, vnfcType); if (currentNode == null) { currentNode = new Node<>(vnfc); @@ -120,11 +175,14 @@ public class SequenceGeneratorPluginImpl implements SequenceGeneratorPlugin { JsonNode parents = vnfcNode.get("parents"); for (JsonNode parent : parents) { String parentVnfcType = parent.asText(); + parentVnfcs.add(parentVnfcType); Node<Vnfc> parentNode = getNode(dependency, parentVnfcType); if (parentNode != null) { currentNode.addParent(parentNode.getChild()); } else { - Vnfc parentVnfc = new Vnfc(parentVnfcType, null, null, false); + Vnfc parentVnfc=new Vnfc(); + parentVnfc.setVnfcType(parentVnfcType); + parentVnfc.setMandatory(false); parentNode = new Node<>(parentVnfc); currentNode.addParent(parentVnfc); dependency.add(parentNode); @@ -132,6 +190,11 @@ public class SequenceGeneratorPluginImpl implements SequenceGeneratorPlugin { } } + for(String parent:parentVnfcs){ + if(!allVnfcTypes.contains(parent)){ + throw new APPCException("Dependency model missing vnfc type "+parent); + } + } return new VnfcDependencyModel(dependency); } return null; @@ -184,7 +247,6 @@ public class SequenceGeneratorPluginImpl implements SequenceGeneratorPlugin { private InventoryModel buildInventoryModel(String inputJson) throws IOException, APPCException { ObjectMapper objectMapper = new ObjectMapper(); - objectMapper.configure(JsonParser.Feature.ALLOW_COMMENTS, true); JsonNode jsonNode = objectMapper.readTree(inputJson); JsonNode inventoryInfo = jsonNode.get("inventory-info"); if (inventoryInfo == null) { @@ -197,45 +259,40 @@ public class SequenceGeneratorPluginImpl implements SequenceGeneratorPlugin { String vnfId = vnfInfo.get("vnf-id").asText(); String vnfType = vnfInfo.get("vnf-type").asText(); - String vnfVersion = vnfInfo.get("vnf-version").asText(); - - Vnf vnf = new Vnf(vnfId, vnfType, vnfVersion); - - JsonNode vms = vnfInfo.get("vm"); - + Vnf vnf =new Vnf(); + vnf.setVnfId(vnfId); + vnf.setVnfType(vnfType); Map<Vnfc, List<Vserver>> vfcs = new HashMap<>(); + JsonNode vms = vnfInfo.get("vm"); + if(vms.size()<1){ + throw new APPCException("vm info not provided in the input"); + } for (JsonNode vm : vms) { if(vm.get("vserver-id")== null){ throw new APPCException("vserver-id not found "); } String vserverId = vm.get("vserver-id").asText(); - Vserver vserver = new Vserver(null, null, vserverId, null, null); - JsonNode vnfc = vm.get("vnfc"); - if (vnfc.get("vnfc-name") == null) { - throw new APPCException("vnfc-name not found for vserver " + vserverId); - } - String vnfcName = vnfc.get("vnfc-name").asText(); - if (vnfc.get("vnfc-type") == null) { - throw new APPCException("vnfc-type not found for vserver " + vserverId); - } - String vnfcType = vnfc.get("vnfc-type").asText(); - if (StringUtils.isEmpty(vnfcType)) { - throw new APPCException("vserver " + vserverId + " is not associated with any vnfc"); - } - Vnfc vfc = new Vnfc(vnfcType, null, vnfcName); - List<Vserver> vServers = vfcs.get(vfc); - if (vServers == null) { - vServers = new LinkedList<>(); - vfcs.put(vfc, vServers); + Vserver vserver = new Vserver(); + vserver.setId(vserverId); + if (vm.get("vnfc")!=null&& vm.get("vnfc").get("vnfc-name") != null && vm.get("vnfc").get("vnfc-type")!= null) { + Vnfc vfc = new Vnfc(); + vfc.setVnfcType(vm.get("vnfc").get("vnfc-type").asText()); + vfc.setVnfcName(vm.get("vnfc").get("vnfc-name").asText()); + vserver.setVnfc(vfc); + List<Vserver> vServers = vfcs.get(vfc); + if (vServers == null) { + vServers = new LinkedList<>(); + vfcs.put(vfc, vServers); + } + vServers.add(vserver); } - vServers.add(vserver); + vnf.addVserver(vserver); } for (Map.Entry<Vnfc, List<Vserver>> entry : vfcs.entrySet()) { Vnfc vnfc = entry.getKey(); List<Vserver> vServers = vfcs.get(vnfc); - vnfc.addVms(vServers); - vnf.addVnfc(vnfc); + vnfc.addVservers(vServers); } return new InventoryModel(vnf); diff --git a/appc-sequence-generator/appc-sequence-generator-bundle/src/main/java/org/onap/appc/seqgen/impl/RestartSequenceGenerator.java b/appc-sequence-generator/appc-sequence-generator-bundle/src/main/java/org/onap/appc/seqgen/impl/RestartSequenceGenerator.java new file mode 100644 index 000000000..49fad50de --- /dev/null +++ b/appc-sequence-generator/appc-sequence-generator-bundle/src/main/java/org/onap/appc/seqgen/impl/RestartSequenceGenerator.java @@ -0,0 +1,108 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : APPC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Copyright (C) 2017 Amdocs + * ============================================================================= + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * ECOMP is a trademark and service mark of AT&T Intellectual Property. + * ============LICENSE_END========================================================= + */ + +package org.onap.appc.seqgen.impl; + +import com.att.eelf.configuration.EELFLogger; +import com.att.eelf.configuration.EELFManager; +import org.onap.appc.domainmodel.Vserver; +import org.onap.appc.exceptions.APPCException; +import org.onap.appc.seqgen.SequenceGenerator; +import org.onap.appc.seqgen.objects.ActionIdentifier; +import org.onap.appc.seqgen.objects.Constants; +import org.onap.appc.seqgen.objects.Response; +import org.onap.appc.seqgen.objects.SequenceGeneratorInput; +import org.onap.appc.seqgen.objects.Transaction;; + +import java.util.HashMap; +import java.util.LinkedList; +import java.util.List; +import java.util.Map; + +public class RestartSequenceGenerator implements SequenceGenerator{ + private static final EELFLogger logger = EELFManager.getInstance().getLogger(RestartSequenceGenerator.class); + + @Override + public List<Transaction> generateSequence(SequenceGeneratorInput input) throws APPCException { + logger.info("Generating sequence without dependency model"); + return generateSequenceWithOutDependency(input); + } + + private List<Transaction> generateSequenceWithOutDependency(SequenceGeneratorInput input) { + List<Transaction> transactionList = new LinkedList<>(); + Integer transactionId = 1; + List<Vserver> vservers = input.getInventoryModel().getVnf().getVservers(); + List<Integer> transactionIds = new LinkedList<>(); + for (Vserver vm : vservers) { + Transaction transactionStop = new Transaction(); + transactionStop.setTransactionId(transactionId); + transactionIds.add(transactionId++); + transactionStop.setAction(Constants.Action.STOP.getActionType()); + transactionStop.setActionLevel(Constants.ActionLevel.VM.getAction()); + ActionIdentifier actionIdentifier = new ActionIdentifier(); + actionIdentifier.setvServerId(vm.getId()); + transactionStop.setActionIdentifier(actionIdentifier); + transactionStop.setPayload(input.getRequestInfo().getPayload()); + if (vservers.size()>1) { + Response failureResponse = new Response(); + failureResponse.setResponseMessage(Constants.ResponseMessage.FAILURE.getResponse()); + Map<String,String> failureAction = new HashMap<>(); + if(!checkLastVM(vservers,vm.getId())) + { + failureAction.put(Constants.ResponseAction.JUMP.getAction(), String.valueOf(transactionId+1)); + failureResponse.setResponseAction(failureAction); + transactionStop.addResponse(failureResponse); + } + } + transactionList.add(transactionStop); + Transaction transactionStart = new Transaction(); + transactionStart.setTransactionId(transactionId); + transactionIds.add(transactionId++); + transactionStart.setAction(Constants.Action.START.getActionType()); + transactionStart.setActionLevel(Constants.ActionLevel.VM.getAction()); + ActionIdentifier actionIdentifierStart = new ActionIdentifier(); + actionIdentifierStart.setvServerId(vm.getId()); + transactionStart.setActionIdentifier(actionIdentifierStart); + transactionStart.setPayload(input.getRequestInfo().getPayload()); + if (vservers.size()>1) { + Response failureResponse = new Response(); + failureResponse.setResponseMessage(Constants.ResponseMessage.FAILURE.getResponse()); + Map<String,String> failureAction = new HashMap<>(); + if(!checkLastVM(vservers,vm.getId())) + { + failureAction.put(Constants.ResponseAction.JUMP.getAction(),transactionId.toString()); + failureResponse.setResponseAction(failureAction); + transactionStart.addResponse(failureResponse); + } + } + transactionList.add(transactionStart); + } + return transactionList; + } + + private boolean checkLastVM(List<Vserver> vservers, String vmId){ + Vserver vm= vservers.get(vservers.size()-1); + return vm.getId().equals(vmId); + } +} diff --git a/appc-sequence-generator/appc-sequence-generator-bundle/src/main/java/org/onap/appc/seqgen/impl/SequenceGeneratorFactory.java b/appc-sequence-generator/appc-sequence-generator-bundle/src/main/java/org/onap/appc/seqgen/impl/SequenceGeneratorFactory.java index 3c6a11962..15d88c9cf 100644 --- a/appc-sequence-generator/appc-sequence-generator-bundle/src/main/java/org/onap/appc/seqgen/impl/SequenceGeneratorFactory.java +++ b/appc-sequence-generator/appc-sequence-generator-bundle/src/main/java/org/onap/appc/seqgen/impl/SequenceGeneratorFactory.java @@ -47,7 +47,9 @@ public class SequenceGeneratorFactory { return new StartSequenceGenerator(); case Stop: return new StopSequenceGenerator(); - default: + case Restart: + return new RestartSequenceGenerator(); + default: throw new APPCException("Sequence Generator does not support operation " + operation.name()); } } diff --git a/appc-sequence-generator/appc-sequence-generator-bundle/src/main/java/org/onap/appc/seqgen/impl/StartSequenceGenerator.java b/appc-sequence-generator/appc-sequence-generator-bundle/src/main/java/org/onap/appc/seqgen/impl/StartSequenceGenerator.java index dcffaafd8..9c9ba8dd8 100644 --- a/appc-sequence-generator/appc-sequence-generator-bundle/src/main/java/org/onap/appc/seqgen/impl/StartSequenceGenerator.java +++ b/appc-sequence-generator/appc-sequence-generator-bundle/src/main/java/org/onap/appc/seqgen/impl/StartSequenceGenerator.java @@ -24,6 +24,7 @@ import com.att.eelf.configuration.EELFLogger; import com.att.eelf.configuration.EELFManager; import org.apache.commons.lang3.StringUtils; import org.onap.appc.dg.flowbuilder.FlowBuilder; +import org.onap.appc.dg.flowbuilder.exception.InvalidDependencyModelException; import org.onap.appc.dg.flowbuilder.impl.FlowBuilderFactory; import org.onap.appc.dg.objects.FlowStrategies; import org.onap.appc.dg.objects.InventoryModel; @@ -33,11 +34,30 @@ import org.onap.appc.domainmodel.Vnfc; import org.onap.appc.domainmodel.Vserver; import org.onap.appc.exceptions.APPCException; import org.onap.appc.seqgen.SequenceGenerator; -import org.onap.appc.seqgen.objects.*; +import org.onap.appc.seqgen.objects.ActionIdentifier; +import org.onap.appc.seqgen.objects.Constants; +import org.onap.appc.seqgen.objects.PreCheckOption; +import org.onap.appc.seqgen.objects.Response; +import org.onap.appc.seqgen.objects.SequenceGeneratorInput; +import org.onap.appc.seqgen.objects.Transaction; -import java.util.*; +import java.util.HashMap; +import java.util.Iterator; +import java.util.LinkedList; +import java.util.List; +import java.util.Map; -import static org.onap.appc.seqgen.objects.Constants.*; +import static org.onap.appc.seqgen.objects.Constants.Action; +import static org.onap.appc.seqgen.objects.Constants.ActionLevel; +import static org.onap.appc.seqgen.objects.Constants.ResponseAction; +import static org.onap.appc.seqgen.objects.Constants.ResponseMessage; +import static org.onap.appc.seqgen.objects.Constants.PreCheckOperator; +import static org.onap.appc.seqgen.objects.Constants.Capabilties; +import static org.onap.appc.seqgen.objects.Constants.CapabilityLevel; +import static org.onap.appc.seqgen.objects.Constants.RETRY_COUNT_VALUE; +import static org.onap.appc.seqgen.objects.Constants.WAIT_TIME; +import static org.onap.appc.seqgen.objects.Constants.RETRY_COUNT; +import static org.onap.appc.seqgen.objects.Constants.WAIT_TIME_VALUE;; public class StartSequenceGenerator implements SequenceGenerator { @@ -47,27 +67,27 @@ public class StartSequenceGenerator implements SequenceGenerator { List<Transaction> transactionList = new LinkedList<>(); Integer transactionId = 1; - List<Vnfc> invVnfcList = input.getInventoryModel().getVnf().getVnfcs(); - boolean singleTransaction=checkSingleTransaction(invVnfcList); - for (Vnfc vnfc : invVnfcList) { - List<Vserver> vms = vnfc.getVserverList(); - List<Integer> transactionIds = new LinkedList<>(); - for (Vserver vm : vms) { - Transaction transaction = new Transaction(); - transaction.setTransactionId(transactionId); - transactionIds.add(transactionId++); - transaction.setAction(Action.START.getActionType()); - transaction.setActionLevel(ActionLevel.VM.getAction()); - ActionIdentifier actionIdentifier = new ActionIdentifier(); - actionIdentifier.setvServerId(vm.getId()); - transaction.setActionIdentifier(actionIdentifier); - transaction.setPayload(input.getRequestInfo().getPayload()); - if(!singleTransaction){ - updateResponse(transaction); - } - - transactionList.add(transaction); + List<Vserver> vservers = input.getInventoryModel().getVnf().getVservers(); + List<Integer> transactionIds = new LinkedList<>(); + for (Vserver vm : vservers) { + Transaction transaction = new Transaction(); + transaction.setTransactionId(transactionId); + transactionIds.add(transactionId++); + transaction.setAction(Action.START.getActionType()); + transaction.setActionLevel(ActionLevel.VM.getAction()); + ActionIdentifier actionIdentifier = new ActionIdentifier(); + actionIdentifier.setvServerId(vm.getId()); + transaction.setActionIdentifier(actionIdentifier); + transaction.setPayload(input.getRequestInfo().getPayload()); + if(vservers.size()>1){ + Response ignoreResponse = new Response(); + ignoreResponse.setResponseMessage(ResponseMessage.FAILURE.getResponse()); + Map<String, String> ignoreAction = new HashMap<>(); + ignoreAction.put(ResponseAction.IGNORE.getAction(), Boolean.TRUE.toString()); + ignoreResponse.setResponseAction(ignoreAction); + transaction.addResponse(ignoreResponse); } + transactionList.add(transaction); } return transactionList; } @@ -112,7 +132,12 @@ public class StartSequenceGenerator implements SequenceGenerator { actionIdentifier.setvServerId(vm.getId()); transaction.setActionIdentifier(actionIdentifier); transaction.setPayload(input.getRequestInfo().getPayload()); - updateResponse(transaction); + Response ignoreResponse = new Response(); + ignoreResponse.setResponseMessage(ResponseMessage.FAILURE.getResponse()); + Map<String, String> ignoreAction = new HashMap<>(); + ignoreAction.put(ResponseAction.IGNORE.getAction(), Boolean.TRUE.toString()); + ignoreResponse.setResponseAction(ignoreAction); + transaction.addResponse(ignoreResponse); transactionList.add(transaction); } boolean startApplicationSupported = readApplicationStartCapability(input); @@ -126,10 +151,7 @@ public class StartSequenceGenerator implements SequenceGenerator { startAppTransaction.setActionIdentifier(startActionIdentifier); startAppTransaction.setPayload(input.getRequestInfo().getPayload()); - List<PreCheckOption> preCheckOptions = new LinkedList<>(); - for (Integer vmTransactionId : transactionIds) { - setPreCheckOptions(preCheckOptions, vmTransactionId); - } + List<PreCheckOption> preCheckOptions = buildPreCheckOptions(transactionIds); startAppTransaction.setPreCheckOperator(PreCheckOperator.ANY.getOperator()); startAppTransaction.setPrecheckOptions(preCheckOptions); transactionList.add(startAppTransaction); @@ -174,32 +196,42 @@ public class StartSequenceGenerator implements SequenceGenerator { return transactionList; } - private void setPreCheckOptions(List<PreCheckOption> preCheckOptions, Integer vmTransactionId) { - PreCheckOption option = new PreCheckOption(); - option.setPreTransactionId(vmTransactionId); - option.setParamName("status"); - option.setParamValue("success"); - preCheckOptions.add(option); + private List<PreCheckOption> buildPreCheckOptions(List<Integer> transactionIds) { + List<PreCheckOption> preCheckOptions = new LinkedList<>(); + for (Integer vmTransactionId : transactionIds) { + PreCheckOption option = new PreCheckOption(); + option.setPreTransactionId(vmTransactionId); + option.setParamName("status"); + option.setParamValue("success"); + preCheckOptions.add(option); + } + return preCheckOptions; } @Override public List<Transaction> generateSequence(SequenceGeneratorInput input) throws APPCException { - if(input.getRequestInfo().getActionLevel().equals(ActionLevel.VM.getAction())||input.getRequestInfo().getActionLevel().equals(ActionLevel.VNFC.getAction())|| - input.getRequestInfo().getActionLevel().equals(ActionLevel.VNF.getAction())||input.getRequestInfo().getActionLevel().equals(ActionLevel.VF_MODULE.getAction())) { if (input.getRequestInfo().getActionLevel().equals(ActionLevel.VNF.getAction()) && input.getDependencyModel() != null) { - FlowStrategies flowStrategy = readStartFlowStrategy(input); - VnfcFlowModel flowModel = buildFlowModel(input.getInventoryModel() - , input.getDependencyModel(), flowStrategy); - logger.debug("Flow Model " + flowModel); - return generateSequenceWithDependencyModel(flowModel, input); + if(isVnfcPresent(input)) { + FlowStrategies flowStrategy = readFlowStrategy(input); + VnfcFlowModel flowModel = null; + try { + flowModel = buildFlowModel(input.getInventoryModel() + , input.getDependencyModel(), flowStrategy); + } catch (InvalidDependencyModelException invalidDependencyModelException) { + logger.error("Error Generating Sequence", invalidDependencyModelException); + throw new APPCException(invalidDependencyModelException.getMessage(), invalidDependencyModelException); + } + logger.debug("Flow Model " + flowModel); + return generateSequenceWithDependencyModel(flowModel, input); + } + else throw new APPCException("Vnfc details is missing in the input"); } else { logger.info("Generating sequence without dependency model"); return generateSequenceWithOutDependency(input); } - }throw new APPCException("Invalid action level "+input.getRequestInfo().getActionLevel()); } - private VnfcFlowModel buildFlowModel(InventoryModel inventoryModel, VnfcDependencyModel dependencyModel, FlowStrategies flowStrategy) throws APPCException { + private VnfcFlowModel buildFlowModel(InventoryModel inventoryModel, VnfcDependencyModel dependencyModel, FlowStrategies flowStrategy) throws APPCException, InvalidDependencyModelException { FlowBuilder flowBuilder = FlowBuilderFactory.getInstance().getFlowBuilder(flowStrategy); if (flowBuilder == null) { throw new APPCException("Flow Strategy not supported " + flowStrategy); @@ -207,22 +239,17 @@ public class StartSequenceGenerator implements SequenceGenerator { return flowBuilder.buildFlowModel(dependencyModel, inventoryModel); } - private FlowStrategies readStartFlowStrategy(SequenceGeneratorInput sequenceGeneratorInput) throws APPCException { + private FlowStrategies readFlowStrategy(SequenceGeneratorInput sequenceGeneratorInput) { Map<String, String> tunableParams = sequenceGeneratorInput.getTunableParams(); - FlowStrategies strategy; + FlowStrategies strategy=null; String strategyStr = null; if (tunableParams != null) { strategyStr = tunableParams.get(Constants.STRATEGY); - if (StringUtils.isBlank(strategyStr)) { - return FlowStrategies.FORWARD; - } - strategy = FlowStrategies.findByString(strategyStr); - if (strategy != null) { - return strategy; - } } - throw new APPCException("Invalid Strategy " + strategyStr); + if (strategy == null) + strategy= FlowStrategies.FORWARD; + return strategy; } private boolean readHealthCheckCapabilites(Map<String, List<String>> capabilities) { @@ -259,6 +286,17 @@ public class StartSequenceGenerator implements SequenceGenerator { } } + private boolean isVnfcPresent(SequenceGeneratorInput input){ + boolean vnfcPresent=true; + List<Vserver> vservers = input.getInventoryModel().getVnf().getVservers(); + for (Vserver vm : vservers) { + if(!(vm.getVnfc()!=null&& vm.getVnfc().getVnfcType()!=null&& vm.getVnfc().getVnfcName()!=null)){ + vnfcPresent=false;break; + } + } + return vnfcPresent; + } + private Integer readWaitTime(SequenceGeneratorInput input) throws APPCException { String paramValStr = input.getTunableParams().get(WAIT_TIME); if (StringUtils.isEmpty(paramValStr)) { diff --git a/appc-sequence-generator/appc-sequence-generator-bundle/src/main/java/org/onap/appc/seqgen/impl/StopSequenceGenerator.java b/appc-sequence-generator/appc-sequence-generator-bundle/src/main/java/org/onap/appc/seqgen/impl/StopSequenceGenerator.java index 77bee6b83..dcbdd8949 100644 --- a/appc-sequence-generator/appc-sequence-generator-bundle/src/main/java/org/onap/appc/seqgen/impl/StopSequenceGenerator.java +++ b/appc-sequence-generator/appc-sequence-generator-bundle/src/main/java/org/onap/appc/seqgen/impl/StopSequenceGenerator.java @@ -23,6 +23,7 @@ package org.onap.appc.seqgen.impl; import org.apache.commons.lang3.StringUtils; import org.onap.appc.dg.flowbuilder.FlowBuilder; import org.onap.appc.dg.flowbuilder.impl.FlowBuilderFactory; +import org.onap.appc.dg.flowbuilder.exception.InvalidDependencyModelException; import org.onap.appc.dg.objects.FlowStrategies; import org.onap.appc.dg.objects.InventoryModel; import org.onap.appc.dg.objects.VnfcDependencyModel; @@ -31,77 +32,78 @@ import org.onap.appc.domainmodel.Vnfc; import org.onap.appc.domainmodel.Vserver; import org.onap.appc.exceptions.APPCException; import org.onap.appc.seqgen.SequenceGenerator; -import org.onap.appc.seqgen.objects.*; import com.att.eelf.configuration.EELFLogger; import com.att.eelf.configuration.EELFManager; +import org.onap.appc.seqgen.objects.ActionIdentifier; +import org.onap.appc.seqgen.objects.Constants; +import org.onap.appc.seqgen.objects.Response; +import org.onap.appc.seqgen.objects.SequenceGeneratorInput; +import org.onap.appc.seqgen.objects.Transaction; -import java.util.*; +import java.util.HashMap; +import java.util.Iterator; +import java.util.LinkedList; +import java.util.List; +import java.util.Map; -import static org.onap.appc.seqgen.objects.Constants.*; +import static org.onap.appc.seqgen.objects.Constants.Action; +import static org.onap.appc.seqgen.objects.Constants.ActionLevel; +import static org.onap.appc.seqgen.objects.Constants.ResponseAction; +import static org.onap.appc.seqgen.objects.Constants.ResponseMessage; +import static org.onap.appc.seqgen.objects.Constants.Capabilties; public class StopSequenceGenerator implements SequenceGenerator { - private static final EELFLogger logger = EELFManager.getInstance().getLogger(StartSequenceGenerator.class); + private static final EELFLogger logger = EELFManager.getInstance().getLogger(StopSequenceGenerator.class); @Override public List<Transaction> generateSequence(SequenceGeneratorInput input) throws APPCException { - if(input.getRequestInfo().getActionLevel().equals(ActionLevel.VM.getAction())||input.getRequestInfo().getActionLevel().equals(ActionLevel.VNFC.getAction())|| - input.getRequestInfo().getActionLevel().equals(ActionLevel.VNF.getAction())||input.getRequestInfo().getActionLevel().equals(ActionLevel.VF_MODULE.getAction())) { - if (input.getRequestInfo().getActionLevel().equals(ActionLevel.VNF.getAction()) && input.getDependencyModel() != null) { - FlowStrategies flowStrategy = readStopFlowStrategy(input); - VnfcFlowModel flowModel = buildFlowModel(input.getInventoryModel() - , input.getDependencyModel(), flowStrategy); + if (input.getRequestInfo().getActionLevel().equals(ActionLevel.VNF.getAction()) && input.getDependencyModel() != null ) { + if(isVnfcPresent(input)) { + FlowStrategies flowStrategy = readFlowStrategy(input); + VnfcFlowModel flowModel = null; + try { + flowModel = buildFlowModel(input.getInventoryModel(), input.getDependencyModel(), flowStrategy); + } catch (InvalidDependencyModelException invalidDependencyModelException) { + logger.error("Error Generating Sequence", invalidDependencyModelException); + throw new APPCException(invalidDependencyModelException.getMessage(), invalidDependencyModelException); + } logger.debug("Flow Model " + flowModel); return generateSequenceWithDependencyModel(flowModel, input); + } + else throw new APPCException("Vnfc details missing in the input"); } else { logger.info("Generating sequence without dependency model"); return generateSequenceWithOutDependency(input); } - }throw new APPCException("Invalid action level "+input.getRequestInfo().getActionLevel()); - } + private List<Transaction> generateSequenceWithOutDependency(SequenceGeneratorInput input){ List<Transaction> transactionList = new LinkedList<>(); Integer transactionId = 1; + List<Vserver> vservers = input.getInventoryModel().getVnf().getVservers(); List<Integer> transactionIds = new LinkedList<>(); - List<Vnfc> invVnfcList = input.getInventoryModel().getVnf().getVnfcs(); - boolean singleTransaction=checkSingleTransaction(invVnfcList); - for (Vnfc vnfc : invVnfcList) { - List<Vserver> vms = vnfc.getVserverList(); - for(Vserver vm:vms){ - Transaction transaction = new Transaction(); - transaction.setTransactionId(transactionId); - transactionIds.add(transactionId++); - transaction.setAction(Action.STOP.getActionType()); - transaction.setActionLevel(ActionLevel.VM.getAction()); - ActionIdentifier actionIdentifier = new ActionIdentifier(); - actionIdentifier.setvServerId(vm.getId()); - transaction.setActionIdentifier(actionIdentifier); - transaction.setPayload(input.getRequestInfo().getPayload()); - if(!singleTransaction){ - updateStopResponse(transaction); - } - transactionList.add(transaction); - } + for (Vserver vm : vservers) { + Transaction transaction = new Transaction(); + transaction.setTransactionId(transactionId); + transactionIds.add(transactionId++); + transaction.setAction(Action.STOP.getActionType()); + transaction.setActionLevel(ActionLevel.VM.getAction()); + ActionIdentifier actionIdentifier = new ActionIdentifier(); + actionIdentifier.setvServerId(vm.getId()); + transaction.setActionIdentifier(actionIdentifier); + transaction.setPayload(input.getRequestInfo().getPayload()); + if(vservers.size()>1){ + Response failureResponse = new Response(); + failureResponse.setResponseMessage(ResponseMessage.FAILURE.getResponse()); + Map<String,String> failureAction = new HashMap<>(); + failureAction.put(ResponseAction.IGNORE.getAction(),Boolean.TRUE.toString()); + failureResponse.setResponseAction(failureAction); + transaction.addResponse(failureResponse); } - return transactionList; - } - - private void updateStopResponse(Transaction transaction) { - Response failureResponse = new Response(); - failureResponse.setResponseMessage(ResponseMessage.FAILURE.getResponse()); - Map<String,String> failureAction = new HashMap<>(); - failureAction.put(ResponseAction.IGNORE.getAction(),Boolean.TRUE.toString()); - failureResponse.setResponseAction(failureAction); - transaction.addResponse(failureResponse); - } - private boolean checkSingleTransaction(List<Vnfc> invVnfcList) { - int vServerCount=0; - for(Vnfc vnfc : invVnfcList) { - List<Vserver> vms = vnfc.getVserverList(); - vServerCount=vServerCount+vms.size(); - } - return vServerCount <= 1; + transactionList.add(transaction); + } + return transactionList; } private List<Transaction> generateSequenceWithDependencyModel(VnfcFlowModel flowModel,SequenceGeneratorInput input){ @@ -122,7 +124,12 @@ public class StopSequenceGenerator implements SequenceGenerator { stopActionIdentifier .setVnfcName(vnfc.getVnfcName()); stopAppTransaction.setActionIdentifier(stopActionIdentifier ); stopAppTransaction.setPayload(input.getRequestInfo().getPayload()); - updateStopResponse(stopAppTransaction); + Response failureResponse = new Response(); + failureResponse.setResponseMessage(ResponseMessage.FAILURE.getResponse()); + Map<String,String> failureAction = new HashMap<>(); + failureAction.put(ResponseAction.IGNORE.getAction(),Boolean.TRUE.toString()); + failureResponse.setResponseAction(failureAction); + stopAppTransaction.addResponse(failureResponse); transactionList.add(stopAppTransaction); } List<Vserver> vms = vnfc.getVserverList(); @@ -136,8 +143,12 @@ public class StopSequenceGenerator implements SequenceGenerator { actionIdentifier.setvServerId(vm.getId()); transaction.setActionIdentifier(actionIdentifier); transaction.setPayload(input.getRequestInfo().getPayload()); - - updateStopResponse(transaction); + Response failureResponse = new Response(); + failureResponse.setResponseMessage(ResponseMessage.FAILURE.getResponse()); + Map<String,String> failureAction = new HashMap<>(); + failureAction.put(ResponseAction.IGNORE.getAction(),Boolean.TRUE.toString()); + failureResponse.setResponseAction(failureAction); + transaction.addResponse(failureResponse); transactionList.add(transaction); } } @@ -145,7 +156,7 @@ public class StopSequenceGenerator implements SequenceGenerator { return transactionList; } - private VnfcFlowModel buildFlowModel(InventoryModel inventoryModel, VnfcDependencyModel dependencyModel, FlowStrategies flowStrategy) throws APPCException { + private VnfcFlowModel buildFlowModel(InventoryModel inventoryModel, VnfcDependencyModel dependencyModel, FlowStrategies flowStrategy) throws APPCException, InvalidDependencyModelException { FlowBuilder flowBuilder = FlowBuilderFactory.getInstance().getFlowBuilder(flowStrategy); if (flowBuilder == null) { throw new APPCException("Flow Strategy not supported " + flowStrategy); @@ -153,22 +164,30 @@ public class StopSequenceGenerator implements SequenceGenerator { return flowBuilder.buildFlowModel(dependencyModel, inventoryModel); } - private FlowStrategies readStopFlowStrategy(SequenceGeneratorInput sequenceGeneratorInput) throws APPCException { + private FlowStrategies readFlowStrategy(SequenceGeneratorInput sequenceGeneratorInput) { Map<String, String> tunableParams = sequenceGeneratorInput.getTunableParams(); - FlowStrategies strategy; + FlowStrategies strategy = null; String strategyStr = null; if (tunableParams != null) { strategyStr = tunableParams.get(Constants.STRATEGY); - if (StringUtils.isBlank(strategyStr)) { - return FlowStrategies.REVERSE; - } strategy = FlowStrategies.findByString(strategyStr); - if (strategy != null) { - return strategy; + } + if (strategy == null) + strategy= FlowStrategies.REVERSE; + return strategy; + } + + private boolean isVnfcPresent(SequenceGeneratorInput input){ + boolean vnfcPresent=true; + List<Vserver> vservers = input.getInventoryModel().getVnf().getVservers(); + for (Vserver vm : vservers) { + if(!(vm.getVnfc()!=null&& vm.getVnfc().getVnfcType()!=null&& vm.getVnfc().getVnfcName()!=null)){ + vnfcPresent=false;break; } } - throw new APPCException("Invalid Strategy " + strategyStr); + return vnfcPresent; } + private boolean readApplicationStopCapability(SequenceGeneratorInput input) { Map<String,List<String>> capability = input.getCapability(); if(capability!= null){ diff --git a/appc-sequence-generator/appc-sequence-generator-bundle/src/main/java/org/onap/appc/seqgen/objects/Constants.java b/appc-sequence-generator/appc-sequence-generator-bundle/src/main/java/org/onap/appc/seqgen/objects/Constants.java index 476c5b718..c648c973c 100644 --- a/appc-sequence-generator/appc-sequence-generator-bundle/src/main/java/org/onap/appc/seqgen/objects/Constants.java +++ b/appc-sequence-generator/appc-sequence-generator-bundle/src/main/java/org/onap/appc/seqgen/objects/Constants.java @@ -67,7 +67,7 @@ public class Constants { } public enum ResponseAction{ - STOP("stop"),RETRY("retry"),IGNORE("ignore"),WAIT("wait"),CONTINUE("Continue"); + STOP("stop"),RETRY("retry"),IGNORE("ignore"),WAIT("wait"),CONTINUE("Continue"),JUMP("jump"); ResponseAction(String action) { this.action=action; @@ -101,9 +101,18 @@ public class Constants { ActionLevel(String action){ this.action=action; } + public String getAction() { return action; } + + public static ActionLevel findByString(String actoinLevel) { + for (ActionLevel acnlevel : ActionLevel.values()) { + if (acnlevel.name().equals(actoinLevel)) + return acnlevel; + } + return null; + } } public enum PreCheckOperator{ diff --git a/appc-sequence-generator/appc-sequence-generator-bundle/src/main/java/org/onap/appc/seqgen/provider/SequenceGeneratorProvider.java b/appc-sequence-generator/appc-sequence-generator-bundle/src/main/java/org/onap/appc/seqgen/provider/SequenceGeneratorProvider.java index ad9a68705..26e9f899a 100644 --- a/appc-sequence-generator/appc-sequence-generator-bundle/src/main/java/org/onap/appc/seqgen/provider/SequenceGeneratorProvider.java +++ b/appc-sequence-generator/appc-sequence-generator-bundle/src/main/java/org/onap/appc/seqgen/provider/SequenceGeneratorProvider.java @@ -46,14 +46,26 @@ import org.onap.appc.dg.objects.InventoryModel; import org.onap.appc.dg.objects.Node; import org.onap.appc.dg.objects.VnfcDependencyModel; import org.onap.appc.domainmodel.Vnf; +import org.onap.appc.domainmodel.Vnfc; import org.onap.appc.domainmodel.Vserver; import org.onap.appc.domainmodel.lcm.VNFOperation; import org.onap.appc.exceptions.APPCException; import org.onap.appc.seqgen.SequenceGenerator; import org.onap.appc.seqgen.impl.SequenceGeneratorFactory; -import org.onap.appc.seqgen.objects.*; - -import java.util.*; +import org.onap.appc.seqgen.objects.Constants; +import org.onap.appc.seqgen.objects.PreCheckOption; +import org.onap.appc.seqgen.objects.RequestInfo; +import org.onap.appc.seqgen.objects.RequestInfoBuilder; +import org.onap.appc.seqgen.objects.Response; +import org.onap.appc.seqgen.objects.SequenceGeneratorInput; +import org.onap.appc.seqgen.objects.SequenceGeneratorInputBuilder; +import org.onap.appc.seqgen.objects.Transaction; +import java.util.HashMap; +import java.util.HashSet; +import java.util.LinkedList; +import java.util.List; +import java.util.Map; +import java.util.Set; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import java.util.concurrent.Future; @@ -100,6 +112,9 @@ public class SequenceGeneratorProvider implements AutoCloseable,SequenceGenerato RpcResult<GenerateSequenceOutput> rpcResult=null; log.debug("Received input = " + input ); try { + if(input.getRequestInfo()==null){ + throw new APPCException("Request info is missing in the input"); + } SequenceGenerator seqGenerator = SequenceGeneratorFactory.getInstance() .createSequenceGenerator(VNFOperation.findByString(input.getRequestInfo().getAction().name())); SequenceGeneratorInput seqGenInput = buildSeqGenInput(input); @@ -113,33 +128,12 @@ public class SequenceGeneratorProvider implements AutoCloseable,SequenceGenerato } private RpcResult<GenerateSequenceOutput> buildSuccessResponse(List<Transaction> transactions) { - + log.info("Building response from the list of transactions"); List<Transactions> transactionList = new LinkedList<>(); for(Transaction transaction:transactions){ - ActionIdentifier actionIdentifier = null; - if(transaction.getActionIdentifier() != null){ - actionIdentifier = new ActionIdentifierBuilder() - .setVnfId(transaction.getActionIdentifier().getVnfId()) - .setVnfcName(transaction.getActionIdentifier().getVnfcName()) - .setVserverId(transaction.getActionIdentifier().getvServerId()) - .build(); - } - - List<PrecheckOptions> precheckOptions = new LinkedList<>(); - if(transaction.getPrecheckOptions()!=null){ - for(PreCheckOption option:transaction.getPrecheckOptions()){ - PrecheckOptions precheckOption = new PrecheckOptionsBuilder() - .setParamName(option.getParamName()) - .setParamValue(option.getParamValue()) - .setPreTransactionId(option.getPreTransactionId()) - .setRule(option.getRule()) - .build(); - precheckOptions.add(precheckOption); - } - } - + ActionIdentifier actionIdentifier = buildActionIdentifierForResponse(transaction); + List<PrecheckOptions> precheckOptions = buildPrecheckOptionsForResponse(transaction); List<Responses> responseList = getResponses(transaction); - Transactions transactionObj = new TransactionsBuilder() .setActionIdentifier(actionIdentifier) @@ -162,6 +156,35 @@ public class SequenceGeneratorProvider implements AutoCloseable,SequenceGenerato .withResult(builder.build()).build(); } + private ActionIdentifier buildActionIdentifierForResponse(Transaction transaction) { + log.info("Adding action identifiers to response."); + ActionIdentifier actionIdentifier = null; + if(transaction.getActionIdentifier() != null){ + actionIdentifier = new ActionIdentifierBuilder() + .setVnfId(transaction.getActionIdentifier().getVnfId()) + .setVnfcName(transaction.getActionIdentifier().getVnfcName()) + .setVserverId(transaction.getActionIdentifier().getvServerId()) + .build(); + } + return actionIdentifier; + } + + private List<PrecheckOptions> buildPrecheckOptionsForResponse(Transaction transaction) { + log.info("Adding Precheck options to response"); + List<PrecheckOptions> precheckOptions = new LinkedList<>(); + if(transaction.getPrecheckOptions()!=null){ + for(PreCheckOption option:transaction.getPrecheckOptions()){ + PrecheckOptions precheckOption = new PrecheckOptionsBuilder() + .setParamName(option.getParamName()) + .setParamValue(option.getParamValue()) + .setPreTransactionId(option.getPreTransactionId()) + .setRule(option.getRule()) + .build(); + precheckOptions.add(precheckOption); + } + } + return precheckOptions; + } private List<Responses> getResponses(Transaction transaction) { List<Responses> responseList = new LinkedList<>(); for(Response resp : transaction.getResponses()){ @@ -183,6 +206,9 @@ public class SequenceGeneratorProvider implements AutoCloseable,SequenceGenerato if(responseActions.get(Constants.ResponseAction.STOP.getAction()) !=null){ responseActionBuilder = responseActionBuilder.setStop(Boolean.parseBoolean(responseActions.get(Constants.ResponseAction.STOP.getAction()))); } + if(responseActions.get(Constants.ResponseAction.JUMP.getAction()) !=null){ + responseActionBuilder = responseActionBuilder.setJump(Integer.parseInt(responseActions.get(Constants.ResponseAction.JUMP.getAction()))); + } Responses response = new ResponsesBuilder() .setResponseMessage(resp.getResponseMessage()) .setResponseAction(responseActionBuilder.build()) @@ -194,32 +220,43 @@ public class SequenceGeneratorProvider implements AutoCloseable,SequenceGenerato private SequenceGeneratorInput buildSeqGenInput(GenerateSequenceInput input) throws APPCException { + log.info("Building SequenceGeneratorInput from Yang object GenerateSequenceInput."); validateMandatory(input); - RequestInfoBuilder requestInfobuilder = new RequestInfoBuilder() - .action(input.getRequestInfo().getAction().name()) - .actionLevel(input.getRequestInfo().getActionLevel().getName().toLowerCase()) - .payload(input.getRequestInfo().getPayload()); - - if(input.getRequestInfo().getActionIdentifier() !=null){ - requestInfobuilder = requestInfobuilder - .actionIdentifier() - .vnfId(input.getRequestInfo().getActionIdentifier().getVnfId()) - .vnfcName(input.getRequestInfo().getActionIdentifier().getVnfcName()) - .vServerId(input.getRequestInfo().getActionIdentifier().getVserverId()); - } - - RequestInfo requestInfo = requestInfobuilder.build(); - + RequestInfo requestInfo = buildRequestInfoForSeqGenInput(input); InventoryModel inventoryModel = readInventoryModel(input); VnfcDependencyModel dependencyModel = readDependencyModel(input); + if(dependencyModel!=null){ + validateInventoryModelWithDependencyModel(dependencyModel,inventoryModel); + } SequenceGeneratorInputBuilder builder = new SequenceGeneratorInputBuilder() .requestInfo(requestInfo) .inventoryModel(inventoryModel) .dependendcyModel(dependencyModel); + builder = buildCapabilitiesForSeqGenInput(input, builder); + + builder = buildTunableParamsForSeqGenInput(input, builder); + + return builder.build(); + } + + private SequenceGeneratorInputBuilder buildTunableParamsForSeqGenInput(GenerateSequenceInput input, SequenceGeneratorInputBuilder builder) { + log.info("Initializing Tunable Parameters based on YANG object."); + if(input.getTunableParameters() != null){ + builder = builder.tunableParameter(Constants.RETRY_COUNT,String.valueOf(input.getTunableParameters().getRetryCount())) + .tunableParameter(Constants.WAIT_TIME,String.valueOf(input.getTunableParameters().getWaitTime())); + if(input.getTunableParameters().getStrategy() !=null){ + builder = builder.tunableParameter(Constants.STRATEGY,input.getTunableParameters().getStrategy().name()); + } + } + return builder; + } + + private SequenceGeneratorInputBuilder buildCapabilitiesForSeqGenInput(GenerateSequenceInput input, SequenceGeneratorInputBuilder builder) { + log.info("Initializing capabilities based on YANG object."); if(input.getCapabilities() !=null){ if(input.getCapabilities().getVnf()!=null){ builder = builder.capability("vnf",input.getCapabilities().getVnf()); @@ -235,16 +272,73 @@ public class SequenceGeneratorProvider implements AutoCloseable,SequenceGenerato } } - if(input.getTunableParameters() != null){ - builder = builder.tunableParameter(Constants.RETRY_COUNT,String.valueOf(input.getTunableParameters().getRetryCount())) - .tunableParameter(Constants.WAIT_TIME,String.valueOf(input.getTunableParameters().getWaitTime())); - if(input.getTunableParameters().getStrategy() !=null){ - builder = builder.tunableParameter(Constants.STRATEGY,input.getTunableParameters().getStrategy().name()); + return builder; + } + + private void validateInventoryModelWithDependencyModel(VnfcDependencyModel dependencyModel, InventoryModel inventoryModel) throws APPCException { + Set<String> dependencyModelVnfcSet = new HashSet<>(); + Set<String> dependencyModelMandatoryVnfcSet = new HashSet<>(); + Set<String> inventoryModelVnfcsSet = new HashSet<>(); + + for (Node<Vnfc> node : dependencyModel.getDependencies()) { + dependencyModelVnfcSet.add(node.getChild().getVnfcType().toLowerCase()); + if (node.getChild().isMandatory()) { + dependencyModelMandatoryVnfcSet.add(node.getChild().getVnfcType().toLowerCase()); } } - return builder.build(); + + for (Vnfc vnfc : inventoryModel.getVnf().getVnfcs()) { + inventoryModelVnfcsSet.add(vnfc.getVnfcType().toLowerCase()); + } + + // if dependency model and inventory model contains same set of VNFCs, validation succeed and hence return + if (dependencyModelVnfcSet.equals(inventoryModelVnfcsSet)) { + return; + } + + if (inventoryModelVnfcsSet.size() >= dependencyModelVnfcSet.size()) { + Set<String> difference = new HashSet<>(inventoryModelVnfcsSet); + difference.removeAll(dependencyModelVnfcSet); + log.error("Dependency model is missing following vnfc type(s): " + difference); + throw new APPCException("Dependency model is missing following vnfc type(s): " + difference); + } else { + Set<String> difference = new HashSet<>(dependencyModelMandatoryVnfcSet); + difference.removeAll(inventoryModelVnfcsSet); + if (difference.size() > 0) { + log.error("Inventory model is missing following mandatory vnfc type(s): " + difference); + throw new APPCException("VMs missing for the mandatory VNFC : " + difference); + } + } + } + + private RequestInfo buildRequestInfoForSeqGenInput(GenerateSequenceInput input) { + log.info("Building RequestInfo from Yang object"); + RequestInfoBuilder requestInfobuilder = buildRequestInformation(input); + + if(input.getRequestInfo().getActionIdentifier() !=null){ + requestInfobuilder = buildActionIdentifiers(input, requestInfobuilder); + } + + return requestInfobuilder.build(); } + private RequestInfoBuilder buildActionIdentifiers(GenerateSequenceInput input, RequestInfoBuilder requestInfobuilder) { + log.info("Initializing actionIdentifier for RequestInfo"); + requestInfobuilder = requestInfobuilder + .actionIdentifier() + .vnfId(input.getRequestInfo().getActionIdentifier().getVnfId()) + .vnfcName(input.getRequestInfo().getActionIdentifier().getVnfcName()) + .vServerId(input.getRequestInfo().getActionIdentifier().getVserverId()); + return requestInfobuilder; + } + + private RequestInfoBuilder buildRequestInformation(GenerateSequenceInput input) { + log.info("Initializing action, actionLevel and payload for RequestInfo"); + return new RequestInfoBuilder() + .action(input.getRequestInfo().getAction().name()) + .actionLevel(input.getRequestInfo().getActionLevel().getName().toLowerCase()) + .payload(input.getRequestInfo().getPayload()); + } private void validateMandatory(GenerateSequenceInput input) throws APPCException { if(input.getRequestInfo() ==null){ @@ -256,30 +350,39 @@ public class SequenceGeneratorProvider implements AutoCloseable,SequenceGenerato if(input.getInventoryInfo() ==null){ throw new APPCException("inventoryInfo is not provided in the input"); } + if (input.getInventoryInfo().getVnfInfo()== null) { + log.error("vnfInfo is null in the input"); + throw new APPCException("vnfInfo is missing in the input"); + } + if(input.getInventoryInfo().getVnfInfo().getVm().isEmpty()){ + log.error("Null vm information in input."); + throw new APPCException("VnfInfo is missing in the input"); + } + log.info("Mandatory information present in the request."); } - private VnfcDependencyModel readDependencyModel(GenerateSequenceInput input) { + private VnfcDependencyModel readDependencyModel(GenerateSequenceInput input) throws APPCException{ + log.info("Initializing DependencyModel from YANG model."); if(input.getDependencyInfo() == null || input.getDependencyInfo().getVnfcs() ==null || input.getDependencyInfo().getVnfcs().isEmpty()){ + log.info("No dependency model information is present for the request."); return null; } List<Vnfcs> vnfcs = input.getDependencyInfo().getVnfcs(); Set<Node<org.onap.appc.domainmodel.Vnfc>> dependencies = new HashSet<>(); + Set<String> parentVnfcs=new HashSet<>(); + Set<String> allVnfcTypes=new HashSet<>(); for(Vnfcs vnfcObj:vnfcs){ - org.onap.appc.domainmodel.Vnfc vnfc; - Node<org.onap.appc.domainmodel.Vnfc> currentNode = readNode(vnfcObj.getVnfcType(),dependencies); - if(currentNode == null){ - vnfc = new org.onap.appc.domainmodel.Vnfc(vnfcObj.getVnfcType(),vnfcObj.getResilience()); - currentNode = new Node<>(vnfc); - dependencies.add(currentNode); - } - else{ - currentNode.getChild().setResilienceType(vnfcObj.getResilience()); - currentNode.getChild().setMandatory(vnfcObj.isMandatory()); - } + org.onap.appc.domainmodel.Vnfc vnfc = new org.onap.appc.domainmodel.Vnfc(); + vnfc.setVnfcType(vnfcObj.getVnfcType()); + allVnfcTypes.add(vnfcObj.getVnfcType()); + vnfc.setResilienceType(vnfcObj.getResilience()); + Node<Vnfc> currentNode = buildVnfcNodeForDependenyInfo(dependencies, vnfcObj, vnfc); for(String parentVnfcType:vnfcObj.getParents()){ - Node<org.onap.appc.domainmodel.Vnfc> parentNode = readNode(parentVnfcType,dependencies); + parentVnfcs.add(parentVnfcType); + Node<Vnfc> parentNode = readNode(parentVnfcType,dependencies); if(parentNode == null){ - org.onap.appc.domainmodel.Vnfc parentVnfc = new org.onap.appc.domainmodel.Vnfc(parentVnfcType,null); + Vnfc parentVnfc = new Vnfc(); + parentVnfc.setVnfcType(parentVnfcType); parentNode = new Node<>(parentVnfc); currentNode.addParent(parentVnfc); dependencies.add(parentNode); @@ -289,9 +392,27 @@ public class SequenceGeneratorProvider implements AutoCloseable,SequenceGenerato } } } + for(String parent:parentVnfcs){ + if(!allVnfcTypes.contains(parent)){ + throw new APPCException("Dependency model missing vnfc type "+parent); + } + } return new VnfcDependencyModel(dependencies); } + private Node<Vnfc> buildVnfcNodeForDependenyInfo(Set<Node<Vnfc>> dependencies, Vnfcs vnfcObj, Vnfc vnfc) { + Node<Vnfc> currentNode = readNode(vnfcObj.getVnfcType(),dependencies); + if(currentNode == null){ + currentNode = new Node<>(vnfc); + dependencies.add(currentNode); + } + else{ + currentNode.getChild().setResilienceType(vnfcObj.getResilience()); + currentNode.getChild().setMandatory(vnfcObj.isMandatory()); + } + return currentNode; + } + private Node<org.onap.appc.domainmodel.Vnfc> readNode(String vnfcType, Set<Node<org.onap.appc.domainmodel.Vnfc>> dependencies) { for(Node<org.onap.appc.domainmodel.Vnfc> node : dependencies){ if(node.getChild().getVnfcType().equalsIgnoreCase(vnfcType)){ @@ -302,40 +423,52 @@ public class SequenceGeneratorProvider implements AutoCloseable,SequenceGenerato } private InventoryModel readInventoryModel(GenerateSequenceInput input) throws APPCException { - if (input.getInventoryInfo().getVnfInfo()== null) { - throw new APPCException("vnfInfo is not provided in the input"); - } - - Vnf vnf = new Vnf(input.getInventoryInfo().getVnfInfo().getVnfId(), - input.getInventoryInfo().getVnfInfo().getVnfType(),null); + log.info("Initializing InventoryModel from Yang input model"); + Vnf vnf = createVnfForInventoryModel(input); Map<org.onap.appc.domainmodel.Vnfc,List<Vserver>> map = new HashMap<>(); + buildVserverDetailsForInventoryModel(input, vnf, map); + for(Map.Entry<org.onap.appc.domainmodel.Vnfc,List<Vserver>> entry:map.entrySet()){ + org.onap.appc.domainmodel.Vnfc vnfc = entry.getKey(); + List<Vserver> vmList = entry.getValue(); + vnfc.addVservers(vmList); + } + return new InventoryModel(vnf); + } + + private void buildVserverDetailsForInventoryModel(GenerateSequenceInput input, Vnf vnf, Map<Vnfc, List<Vserver>> map) throws APPCException { + if(input.getInventoryInfo().getVnfInfo().getVm().size()<1){ + throw new APPCException("vnfInfo is missing in the input"); + } for(Vm vm:input.getInventoryInfo().getVnfInfo().getVm()){ if(StringUtils.isBlank(vm.getVserverId())){ throw new APPCException("vserver-id not found "); } - if(StringUtils.isBlank(vm.getVnfc().getVnfcType())){ - throw new APPCException("vnfc-type not found for vserver " + vm.getVserverId()); - } - if(StringUtils.isBlank(vm.getVnfc().getVnfcName())){ - throw new APPCException("vnfc-name not found for vserver " + vm.getVserverId()); + Vserver vserver=new Vserver(); + vserver.setId(vm.getVserverId()); + if(!StringUtils.isBlank(vm.getVnfc().getVnfcName()) && + !StringUtils.isBlank(vm.getVnfc().getVnfcType())){ + Vnfc vfc = new Vnfc(); + vfc.setVnfcName(vm.getVnfc().getVnfcName()); + vfc.setVnfcType(vm.getVnfc().getVnfcType()); + vserver.setVnfc(vfc); + List<Vserver> vms = map.get(vfc); + if(vms ==null){ + vms = new LinkedList<>(); + map.put(vfc,vms); + } + vms.add(vserver); } + vnf.addVserver(vserver); + } + } - org.onap.appc.domainmodel.Vnfc vnfc = new org.onap.appc.domainmodel.Vnfc(vm.getVnfc().getVnfcType(),null,vm.getVnfc().getVnfcName()); - List<Vserver> vms = map.get(vnfc); - if(vms ==null){ - vms = new LinkedList<>(); - map.put(vnfc,vms); - } - vms.add(new Vserver(null,null,vm.getVserverId(),null,null)); - } - for(Map.Entry<org.onap.appc.domainmodel.Vnfc,List<Vserver>> entry:map.entrySet()){ - org.onap.appc.domainmodel.Vnfc vnfc = entry.getKey(); - List<Vserver> vmList = entry.getValue(); - vnfc.addVms(vmList); - vnf.addVnfc(vnfc); - } - return new InventoryModel(vnf); + private Vnf createVnfForInventoryModel(GenerateSequenceInput input) { + log.info("Setting VnfId and VnfType values for Vnf Inventory Model "); + Vnf vnf=new Vnf(); + vnf.setVnfId(input.getInventoryInfo().getVnfInfo().getVnfId()); + vnf.setVnfType(input.getInventoryInfo().getVnfInfo().getVnfType()); + return vnf; } private RpcResult<GenerateSequenceOutput> buildFailureResponse(String errorMessage){ diff --git a/appc-sequence-generator/appc-sequence-generator-bundle/src/test/java/org/onap/appc/seqgen/TestSequenceGeneratorPlugin.java b/appc-sequence-generator/appc-sequence-generator-bundle/src/test/java/org/onap/appc/seqgen/TestSequenceGeneratorPlugin.java index 748773a21..1fde88831 100644 --- a/appc-sequence-generator/appc-sequence-generator-bundle/src/test/java/org/onap/appc/seqgen/TestSequenceGeneratorPlugin.java +++ b/appc-sequence-generator/appc-sequence-generator-bundle/src/test/java/org/onap/appc/seqgen/TestSequenceGeneratorPlugin.java @@ -51,15 +51,29 @@ public class TestSequenceGeneratorPlugin { plugin.generateSequence(params,context); String outputJSON = context.getAttribute("output"); - String actualOutput = readOutput("/output/start.json"); + String actualOutput = readOutput("/output/Start.json"); Assert.assertEquals(outputJSON.trim(),actualOutput.trim()); } + @Test + public void testGenerateSequenceWODependencyInfo()throws URISyntaxException, IOException { + String inputJSON = readInput("/input/start-withoutDependency.json"); + Map<String,String> params = new HashMap<>(); + SvcLogicContext context = new SvcLogicContext(); + context.setAttribute("inputJSON",inputJSON); + + SequenceGeneratorPlugin plugin = new SequenceGeneratorPluginImpl(); + plugin.generateSequence(params,context); + + String outputJSON = context.getAttribute("output"); + String actualOutput = readOutput("/output/start-withoutDependency.json"); + Assert.assertEquals(outputJSON.trim(),actualOutput.trim()); + } @Test public void testGenerateSequenceSingleVM()throws URISyntaxException, IOException { - String inputJSON = readInput("/input/start-single-vm.json"); + String inputJSON = readInput("/input/start-singleVM-.json"); Map<String,String> params = new HashMap<>(); SvcLogicContext context = new SvcLogicContext(); @@ -69,7 +83,7 @@ public class TestSequenceGeneratorPlugin { plugin.generateSequence(params,context); String outputJSON = context.getAttribute("output"); - String actualOutput = readOutput("/output/start-single-vm.json"); + String actualOutput = readOutput("/output/start-singleVM-.json"); Assert.assertEquals(outputJSON.trim(),actualOutput.trim()); } @@ -85,7 +99,7 @@ public class TestSequenceGeneratorPlugin { plugin.generateSequence(params,context); String outputJSON = context.getAttribute("output"); - String actualOutput = readOutput("/output/start.json"); + String actualOutput = readOutput("/output/Start.json"); Assert.assertEquals(outputJSON.trim(),actualOutput.trim()); } @@ -102,7 +116,7 @@ public class TestSequenceGeneratorPlugin { plugin.generateSequence(params,context); String outputJSON = context.getAttribute("output"); - String actualOutput = readOutput("/output/stop.json"); + String actualOutput = readOutput("/output/Output-stop.json"); Assert.assertEquals(outputJSON.trim(),actualOutput.trim()); } @@ -144,7 +158,6 @@ public class TestSequenceGeneratorPlugin { Assert.assertEquals(errorMessage,"Error generating sequence There seems to be no Root/Independent node for Vnfc dependencies"); } - @Test public void testGenerateSequenceWrongAction() throws URISyntaxException, IOException { String inputJSON = readInput("/input/wrongaction.json"); @@ -184,7 +197,7 @@ public class TestSequenceGeneratorPlugin { @Test public void testGenerateSequenceStopSingleVM() throws URISyntaxException, IOException{ - String inputJSON = readInput("/input/stop-single-vm.json"); + String inputJSON = readInput("/input/stop-singleVM.json"); Map<String,String> params = new HashMap<>(); SvcLogicContext context = new SvcLogicContext(); @@ -194,13 +207,29 @@ public class TestSequenceGeneratorPlugin { plugin.generateSequence(params,context); String outputJSON = context.getAttribute("output"); - String actualOutput = readOutput("/output/stop-single-vm.json"); + String actualOutput = readOutput("/output/stop-singleVM.json"); Assert.assertEquals(outputJSON.trim(),actualOutput.trim()); } @Test public void testGenerateSequenceStopSingleVmPerVnfc() throws URISyntaxException, IOException{ - String inputJSON = readInput("/input/stop-single-vm-per-vnfc.json"); + String inputJSON = readInput("/input/stop-singleVmPerVnfc.json"); + + Map<String,String> params = new HashMap<>(); + SvcLogicContext context = new SvcLogicContext(); + context.setAttribute("inputJSON",inputJSON); + + SequenceGeneratorPlugin plugin = new SequenceGeneratorPluginImpl(); + plugin.generateSequence(params,context); + + String outputJSON = context.getAttribute("output"); + String actualOutput = readOutput("/output/stop-singleVmPerVnfc.json"); + Assert.assertEquals(outputJSON.trim(),actualOutput.trim()); + } + + @Test + public void testGenerateSequenceRestartNoDep() throws URISyntaxException, IOException { + String inputJSON = readInput("/input/restartNodep.json"); Map<String,String> params = new HashMap<>(); SvcLogicContext context = new SvcLogicContext(); @@ -210,13 +239,30 @@ public class TestSequenceGeneratorPlugin { plugin.generateSequence(params,context); String outputJSON = context.getAttribute("output"); - String actualOutput = readOutput("/output/stop-single-vm-per-vnfc.json"); + String actualOutput = readInput("/output/restart-NoDep.json"); + outputJSON.trim(); + Assert.assertEquals(outputJSON.trim(),actualOutput.trim()); + } + + @Test + public void testGenerateSequenceRestartNoDepSingleVM() throws URISyntaxException, IOException { + String inputJSON = readInput("/input/NoDep-SingleVM.json"); + + Map<String,String> params = new HashMap<>(); + SvcLogicContext context = new SvcLogicContext(); + context.setAttribute("inputJSON",inputJSON); + + SequenceGeneratorPlugin plugin = new SequenceGeneratorPluginImpl(); + plugin.generateSequence(params,context); + + String outputJSON = context.getAttribute("output"); + String actualOutput = readInput("/output/restart-Nodep-SingleVM.json"); Assert.assertEquals(outputJSON.trim(),actualOutput.trim()); } @Test public void testGenerateSequenceStartSingleVmPerVnfc() throws URISyntaxException, IOException{ - String inputJSON = readInput("/input/start-single-vm-per-vnfc.json"); + String inputJSON = readInput("/input/start-singleVmPerVnfc-.json"); Map<String,String> params = new HashMap<>(); SvcLogicContext context = new SvcLogicContext(); @@ -226,7 +272,24 @@ public class TestSequenceGeneratorPlugin { plugin.generateSequence(params,context); String outputJSON = context.getAttribute("output"); - String actualOutput = readOutput("/output/start-single-vm-per-vnfc.json"); + String actualOutput = readOutput("/output/start-singleVmPerVnfc.json"); + Assert.assertEquals(outputJSON.trim(),actualOutput.trim()); + } + + @Test + public void testGenerateSequenceStopWithoutDep() throws URISyntaxException,IOException{ + String inputJSON = readInput("/input/stop-WithoutDep.json"); + + Map<String,String> params = new HashMap<>(); + SvcLogicContext context = new SvcLogicContext(); + context.setAttribute("inputJSON",inputJSON); + + SequenceGeneratorPlugin plugin = new SequenceGeneratorPluginImpl(); + plugin.generateSequence(params,context); + + String outputJSON = context.getAttribute("output"); + String actualOutput = readOutput("/output/stop-WithoutDep.json"); + Assert.assertEquals(outputJSON.trim(),actualOutput.trim()); } @@ -246,6 +309,60 @@ public class TestSequenceGeneratorPlugin { Assert.assertEquals(outputJSON.trim(),actualOutput.trim()); } + @Test + public void testGenerateSequenceCheckMandatoryVnfc() throws URISyntaxException, IOException { + String inputJSON = readInput("/input/CheckMandatoryVnfc.json"); + + Map<String,String> params = new HashMap<>(); + SvcLogicContext context = new SvcLogicContext(); + context.setAttribute("inputJSON",inputJSON); + + SequenceGeneratorPlugin plugin = new SequenceGeneratorPluginImpl(); + plugin.generateSequence(params,context); + + String errorCode = context.getAttribute("error-code"); + String errorMessage = context.getAttribute("error-message"); + logger.debug("errorCode = " + errorCode); + Assert.assertEquals(errorCode,"401"); + Assert.assertEquals(errorMessage,"Error generating sequence VMs missing for the mandatory VNFC : [smp]"); + } + + @Test + public void testGenerateSequenceCheckMissingDependencyInfo() throws URISyntaxException, IOException { + String inputJSON = readInput("/input/MissingDependencyInfo.json"); + + Map<String,String> params = new HashMap<>(); + SvcLogicContext context = new SvcLogicContext(); + context.setAttribute("inputJSON",inputJSON); + + SequenceGeneratorPlugin plugin = new SequenceGeneratorPluginImpl(); + plugin.generateSequence(params,context); + + String errorCode = context.getAttribute("error-code"); + String errorMessage = context.getAttribute("error-message"); + logger.debug("errorCode = " + errorCode); + Assert.assertEquals(errorCode,"401"); + Assert.assertEquals(errorMessage,"Error generating sequence Dependency model is missing following vnfc type(s): [smp]"); + } + + @Test + public void testGenerateSequenceExtraVnfcInDependency() throws URISyntaxException, IOException { + String inputJSON = readInput("/input/WrongDependencyModel.json"); + + Map<String,String> params = new HashMap<>(); + SvcLogicContext context = new SvcLogicContext(); + context.setAttribute("inputJSON",inputJSON); + + SequenceGeneratorPlugin plugin = new SequenceGeneratorPluginImpl(); + plugin.generateSequence(params,context); + + String errorCode = context.getAttribute("error-code"); + String errorMessage = context.getAttribute("error-message"); + logger.debug("errorCode = " + errorCode); + Assert.assertEquals(errorCode,"401"); + Assert.assertEquals(errorMessage,"Error generating sequence Dependency model missing vnfc type SMP"); + } + private String readInput(String inputFile) throws URISyntaxException, IOException { File file = new File(this.getClass().getResource(inputFile).toURI()); @@ -262,11 +379,10 @@ public class TestSequenceGeneratorPlugin { FileInputStream fileInputStream = new FileInputStream(file); fileInputStream.read(bFile); fileInputStream.close(); - String output=new String(bFile); int start=output.indexOf("["); - int last=output.length(); - return output.substring(start,last); + return output.substring(start,output.length()); } } + diff --git a/appc-sequence-generator/appc-sequence-generator-bundle/src/test/resources/input/CheckMandatoryVnfc.json b/appc-sequence-generator/appc-sequence-generator-bundle/src/test/resources/input/CheckMandatoryVnfc.json new file mode 100644 index 000000000..8af3e7332 --- /dev/null +++ b/appc-sequence-generator/appc-sequence-generator-bundle/src/test/resources/input/CheckMandatoryVnfc.json @@ -0,0 +1,124 @@ +{ + "request-info": { + "action": "Start", + "action-level": "vnf", + "action-identifier": { + "vnf-id": "dbgx0001v" + }, + "payload": "ABC" + }, + "inventory-info": { + "vnf-info": { + "vnf-id" : "abc", + "vnf-name": "vSCP", + "vnf-type": "vSCP", + "vnf-version" : "1.0", + "vm": [ + { + "vserver-id" : "be_vserverid1", + "vnfc": + { + "vnfc-type": "BE", + "vnfc-name": "BE - Name" + } + + }, + { + "vserver-id" : "fe_vserverid1", + "vnfc": + { + "vnfc-type": "FE", + "vnfc-name": "FE - Name" + } + + }, + { + "vserver-id" : "fe_vserverid2", + "vnfc": + { + "vnfc-type": "FE", + "vnfc-name": "FE - Name" + } + + }, + { + "vserver-id" : "be_vserverid2", + "vnfc": + { + "vnfc-type": "BE", + "vnfc-name": "BE - Name" + } + + }, + { + "vserver-id" : "be_vserverid3", + "vnfc": + { + "vnfc-type": "BE", + "vnfc-name": "BE - Name" + } + + }, + { + "vserver-id" : "be_vserverid4", + "vnfc": + { + "vnfc-type": "BE", + "vnfc-name": "BE - Name" + } + + }, + { + "vserver-id" : "be_vserverid5", + "vnfc": + { + "vnfc-type": "BE", + "vnfc-name": "BE - Name" + } + + } + ] + } + }, + "dependency-info": { + "vnfcs" : [ + { + "vnfc-type" : "BE", + "mandatory" : "true", + "resilience": "Active-Active", + "parents" : [ + "SMP" + ] + }, + { + "vnfc-type" : "FE", + "mandatory" : "true", + "resilience": "Active-Active", + "parents" : [ + "BE" + ] + }, + { + "vnfc-type" : "SMP", + "mandatory" : "true", + "resilience": "Active-Passive", + "parents" : [ + + ] + } + + ] + }, + "tunable-parameters": { + "strategy" : "FORWARD", + "wait-time": "120", + "retry-count": "5" + }, + "capabilities" : { + "vnf": ["Stop", "Start", "StartApplication","StopApplication"], + "vf-module": ["Stop", "Start"], + "vm" : ["Stop", "Start"], + "vnfc": ["StopApplication", "StartApplication","HealthCheck"] + } +} + diff --git a/appc-sequence-generator/appc-sequence-generator-bundle/src/test/resources/input/MissingDependencyInfo.json b/appc-sequence-generator/appc-sequence-generator-bundle/src/test/resources/input/MissingDependencyInfo.json new file mode 100644 index 000000000..667565d0a --- /dev/null +++ b/appc-sequence-generator/appc-sequence-generator-bundle/src/test/resources/input/MissingDependencyInfo.json @@ -0,0 +1,133 @@ +{ + "request-info": { + "action": "Start", + "action-level": "vnf", + "action-identifier": { + "vnf-id": "dbgx0001v" + }, + "payload": "ABC" + }, + "inventory-info": { + "vnf-info": { + "vnf-id" : "abc", + "vnf-name": "vSCP", + "vnf-type": "vSCP", + "vnf-version" : "1.0", + "vm": [ + { + "vserver-id" : "be_vserverid1", + "vnfc": + { + "vnfc-type": "BE", + "vnfc-name": "BE - Name" + } + + }, + { + "vserver-id" : "fe_vserverid1", + "vnfc": + { + "vnfc-type": "FE", + "vnfc-name": "FE - Name" + } + + }, + { + "vserver-id" : "fe_vserverid2", + "vnfc": + { + "vnfc-type": "FE", + "vnfc-name": "FE - Name" + } + + }, + { + "vserver-id" : "be_vserverid2", + "vnfc": + { + "vnfc-type": "BE", + "vnfc-name": "BE - Name" + } + + }, + { + "vserver-id" : "be_vserverid3", + "vnfc": + { + "vnfc-type": "BE", + "vnfc-name": "BE - Name" + } + + }, + { + "vserver-id" : "smp_vserverid1", + "vnfc": + { + "vnfc-type": "SMP", + "vnfc-name": "SMP - Name" + } + + }, + { + "vserver-id" : "smp_vserverid2", + "vnfc": + { + "vnfc-type": "SMP", + "vnfc-name": "SMP - Name" + } + + }, + { + "vserver-id" : "be_vserverid4", + "vnfc": + { + "vnfc-type": "BE", + "vnfc-name": "BE - Name" + } + + }, + { + "vserver-id" : "be_vserverid5", + "vnfc": + { + "vnfc-type": "BE", + "vnfc-name": "BE - Name" + } + + } + ] + } + }, + "dependency-info": { + "vnfcs" : [ + { + "vnfc-type" : "BE", + "mandatory" : "true", + "resilience": "Active-Active", + "parents" : [ + + ] + }, + { + "vnfc-type" : "FE", + "mandatory" : "true", + "resilience": "Active-Active", + "parents" : [ + "BE" + ] + } + + ] + }, + "tunable-parameters": { + "strategy" : "FORWARD", + "wait-time": "120", + "retry-count": "5" + }, + "capabilities" : { + "vnf": ["Stop", "Start", "StartApplication","StopApplication"], + "vf-module": ["Stop", "Start"], + "vm" : ["Stop", "Start"], + "vnfc": ["StopApplication", "StartApplication","HealthCheck"] + } +}
\ No newline at end of file diff --git a/appc-sequence-generator/appc-sequence-generator-bundle/src/test/resources/input/NoDep-SingleVM.json b/appc-sequence-generator/appc-sequence-generator-bundle/src/test/resources/input/NoDep-SingleVM.json new file mode 100755 index 000000000..e1475ef6c --- /dev/null +++ b/appc-sequence-generator/appc-sequence-generator-bundle/src/test/resources/input/NoDep-SingleVM.json @@ -0,0 +1,38 @@ + + + +{ + "request-info": { + "action": "Restart", + "action-level": "vm", + "action-identifier": { + "vserver-id": "dbgx0001v" + }, + "payload": "ABC" + }, + "inventory-info": { + "vnf-info": { + "vnf-id" : "abc", + "vnf-name": "vSCP", + "vnf-type": "vSCP", + "vnf-version" : "1.0", + "vm": [ + { + "vserver-id" : "be_vserverid1" + } + ] + } + }, + "dependency-info" : { + + }, + "tunable-parameters" : { + + }, + "capabilities" : { + "vm" : ["Stop", "Start"], + "vnfc": ["StopApplication", "StartApplication","HealthCheck"] + } +} + + diff --git a/appc-sequence-generator/appc-sequence-generator-bundle/src/test/resources/input/WrongDependencyModel.json b/appc-sequence-generator/appc-sequence-generator-bundle/src/test/resources/input/WrongDependencyModel.json new file mode 100755 index 000000000..984128f9d --- /dev/null +++ b/appc-sequence-generator/appc-sequence-generator-bundle/src/test/resources/input/WrongDependencyModel.json @@ -0,0 +1,117 @@ +{ + "request-info": { + "action": "Start", + "action-level": "vnf", + "action-identifier": { + "vnf-id": "dbgx0001v" + }, + "payload": "ABC" + }, + "inventory-info": { + "vnf-info": { + "vnf-id" : "abc", + "vnf-name": "vSCP", + "vnf-type": "vSCP", + "vnf-version" : "1.0", + "vm": [ + { + "vserver-id" : "be_vserverid1", + "vnfc": + { + "vnfc-type": "BE", + "vnfc-name": "BE - Name" + } + + }, + { + "vserver-id" : "fe_vserverid1", + "vnfc": + { + "vnfc-type": "FE", + "vnfc-name": "FE - Name" + } + + }, + { + "vserver-id" : "fe_vserverid2", + "vnfc": + { + "vnfc-type": "FE", + "vnfc-name": "FE - Name" + } + + }, + { + "vserver-id" : "be_vserverid2", + "vnfc": + { + "vnfc-type": "BE", + "vnfc-name": "BE - Name" + } + + }, + { + "vserver-id" : "be_vserverid3", + "vnfc": + { + "vnfc-type": "BE", + "vnfc-name": "BE - Name" + } + + }, + + { + "vserver-id" : "be_vserverid4", + "vnfc": + { + "vnfc-type": "BE", + "vnfc-name": "BE - Name" + } + + }, + { + "vserver-id" : "be_vserverid5", + "vnfc": + { + "vnfc-type": "BE", + "vnfc-name": "BE - Name" + } + + } + ] + } + }, + "dependency-info": { + "vnfcs" : [ + { + "vnfc-type" : "BE", + "mandatory" : "true", + "resilience": "Active-Active", + "parents" : [ + "SMP" + ] + }, + { + "vnfc-type" : "FE", + "mandatory" : "true", + "resilience": "Active-Active", + "parents" : [ + "BE" + ] + } + + ] + }, + "tunable-parameters": { + "strategy" : "FORWARD", + "wait-time": "120", + "retry-count": "5" + }, + "capabilities" : { + "vnf": ["Stop", "Start", "StartApplication","StopApplication"], + "vf-module": ["Stop", "Start"], + "vm" : ["Stop", "Start"], + "vnfc": ["StopApplication", "StartApplication","HealthCheck"] + } +} + diff --git a/appc-sequence-generator/appc-sequence-generator-bundle/src/test/resources/input/cyclic.json b/appc-sequence-generator/appc-sequence-generator-bundle/src/test/resources/input/cyclic.json index 522b99692..312c0f542 100644 --- a/appc-sequence-generator/appc-sequence-generator-bundle/src/test/resources/input/cyclic.json +++ b/appc-sequence-generator/appc-sequence-generator-bundle/src/test/resources/input/cyclic.json @@ -1,197 +1,140 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP : APPC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Copyright (C) 2017 Amdocs - * ============================================================================= - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * ============LICENSE_END========================================================= - */ - - { - "request-info": - { + "request-info": { "action": "Start", "action-level": "vnf", - "action-identifier": - { + "action-identifier": { "vnf-id": "dbgx0001v" }, "payload": "ABC" }, - "inventory-info": - { - "vnf-info": - { + "inventory-info": { + "vnf-info": { "vnf-id" : "abc", - "vnf-name": "vVNF", - "vnf-type": "vVNF", + "vnf-name": "vSCP", + "vnf-type": "vSCP", "vnf-version" : "1.0", "vm": [ { - "vserver-id" : "vnfc2_vserverid1", + "vserver-id" : "be_vserverid1", "vnfc": { - "vnfc-type": "VNFC2", - "vnfc-name": "VNFC2 - Name" + "vnfc-type": "BE", + "vnfc-name": "BE - Name" } }, { - "vserver-id" : "vnfc3_vserverid1", + "vserver-id" : "fe_vserverid1", "vnfc": { - "vnfc-type": "VNFC3", - "vnfc-name": "VNFC3 - Name" + "vnfc-type": "FE", + "vnfc-name": "FE - Name" } }, { - "vserver-id" : "vnfc3_vserverid2", + "vserver-id" : "fe_vserverid2", "vnfc": { - "vnfc-type": "VNFC3", - "vnfc-name": "VNFC3 - Name" + "vnfc-type": "FE", + "vnfc-name": "FE - Name" } }, { - "vserver-id" : "vnfc2_vserverid2", + "vserver-id" : "be_vserverid2", "vnfc": { - "vnfc-type": "VNFC2", - "vnfc-name": "VNFC2 - Name" + "vnfc-type": "BE", + "vnfc-name": "BE - Name" } }, { - "vserver-id" : "vnfc2_vserverid3", + "vserver-id" : "be_vserverid3", "vnfc": { - "vnfc-type": "VNFC2", - "vnfc-name": "VNFC2 - Name" + "vnfc-type": "BE", + "vnfc-name": "BE - Name" } }, { - "vserver-id" : "vnfc1_vserverid1", + "vserver-id" : "smp_vserverid1", "vnfc": { - "vnfc-type": "VNFC1", - "vnfc-name": "VNFC1 - Name" + "vnfc-type": "SMP", + "vnfc-name": "SMP - Name" } }, { - "vserver-id" : "vnfc1_vserverid2", + "vserver-id" : "smp_vserverid2", "vnfc": { - "vnfc-type": "VNFC1", - "vnfc-name": "VNFC1 - Name" + "vnfc-type": "SMP", + "vnfc-name": "SMP - Name" } }, { - "vserver-id" : "vnfc2_vserverid4", + "vserver-id" : "be_vserverid4", "vnfc": { - "vnfc-type": "VNFC2", - "vnfc-name": "VNFC2 - Name" + "vnfc-type": "BE", + "vnfc-name": "BE - Name" } }, { - "vserver-id" : "vnfc2_vserverid5", + "vserver-id" : "be_vserverid5", "vnfc": { - "vnfc-type": "VNFC2", - "vnfc-name": "VNFC2 - Name" + "vnfc-type": "BE", + "vnfc-name": "BE - Name" } } ] } }, - "dependency-info" : - { - "vnfcs" : - [ + "dependency-info" : { + "vnfcs" : [ { - "vnfc-type" : "VNFC2", + "vnfc-type" : "BE", "mandatory" : "true", "resilience": "Active-Active", - "parents" : - [ - "VNFC1" + "parents" : [ + "SMP" ] }, { - "vnfc-type" : "VNFC3", + "vnfc-type" : "FE", "mandatory" : "true", "resilience": "Active-Active", - "parents" : - [ - "VNFC2" + "parents" : [ + "BE" ] }, { - "vnfc-type" : "VNFC1", + "vnfc-type" : "SMP", "mandatory" : "true", "resilience": "Active-Passive", - "parents" : - [ - "VNFC3" - ] + "parents" : ["FE"] } ] }, - "tunable-parameters" : - { + "tunable-parameters" : { "strategy" : "FORWARD", "wait-time" : "120", "retry-count" : "5" }, - "capabilities" : - { - "vnf": - [ - "Stop", - "Start", - "StartApplication", - "StopApplication" - ], - "vf-module": - [ - "Stop", - "Start" - ], - "vm" : - [ - "Stop", - "Start" - ], - "vnfc": - [ - "StopApplication", - "StartApplication", - "HealthCheck" - ] + "capabilities" : { + "vnf": ["Stop", "Start", "StartApplication","StopApplication"], + "vf-module": ["Stop", "Start"], + "vm" : ["Stop", "Start"], + "vnfc": ["StopApplication", "StartApplication","HealthCheck"] } } diff --git a/appc-sequence-generator/appc-sequence-generator-bundle/src/test/resources/input/missingrequestinfo.json b/appc-sequence-generator/appc-sequence-generator-bundle/src/test/resources/input/missingrequestinfo.json index c5bc7ead2..80c9ff501 100644 --- a/appc-sequence-generator/appc-sequence-generator-bundle/src/test/resources/input/missingrequestinfo.json +++ b/appc-sequence-generator/appc-sequence-generator-bundle/src/test/resources/input/missingrequestinfo.json @@ -1,185 +1,132 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP : APPC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Copyright (C) 2017 Amdocs - * ============================================================================= - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * ============LICENSE_END========================================================= - */ - - { - "inventory-info": - { - "vnf-info": - { + "inventory-info": { + "vnf-info": { "vnf-id" : "abc", - "vnf-name": "vVNF", - "vnf-type": "vVNF", + "vnf-name": "vSCP", + "vnf-type": "vSCP", "vnf-version" : "1.0", - "vm": - [ + "vm": [ { - "vserver-id" : "vnfc2_vserverid1", + "vserver-id" : "be_vserverid1", "vnfc": { - "vnfc-type": "VNFC2", - "vnfc-name": "VNFC2 - Name" + "vnfc-type": "BE", + "vnfc-name": "BE - Name" } }, { - "vserver-id" : "vnfc3_vserverid1", + "vserver-id" : "fe_vserverid1", "vnfc": { - "vnfc-type": "VNFC3", - "vnfc-name": "VNFC3 - Name" + "vnfc-type": "FE", + "vnfc-name": "FE - Name" } }, { - "vserver-id" : "vnfc3_vserverid2", + "vserver-id" : "fe_vserverid2", "vnfc": { - "vnfc-type": "VNFC3", - "vnfc-name": "VNFC3 - Name" + "vnfc-type": "FE", + "vnfc-name": "FE - Name" } }, { - "vserver-id" : "vnfc2_vserverid2", + "vserver-id" : "be_vserverid2", "vnfc": { - "vnfc-type": "VNFC2", - "vnfc-name": "VNFC2 - Name" + "vnfc-type": "BE", + "vnfc-name": "BE - Name" } }, { - "vserver-id" : "vnfc2_vserverid3", + "vserver-id" : "be_vserverid3", "vnfc": { - "vnfc-type": "VNFC2", - "vnfc-name": "VNFC2 - Name" + "vnfc-type": "BE", + "vnfc-name": "BE - Name" } }, { - "vserver-id" : "vnfc1_vserverid1", + "vserver-id" : "smp_vserverid1", "vnfc": { - "vnfc-type": "VNFC1", - "vnfc-name": "VNFC1 - Name" + "vnfc-type": "SMP", + "vnfc-name": "SMP - Name" } }, { - "vserver-id" : "vnfc1_vserverid2", + "vserver-id" : "smp_vserverid2", "vnfc": { - "vnfc-type": "VNFC1", - "vnfc-name": "VNFC1 - Name" + "vnfc-type": "SMP", + "vnfc-name": "SMP - Name" } }, { - "vserver-id" : "vnfc2_vserverid4", + "vserver-id" : "be_vserverid4", "vnfc": { - "vnfc-type": "VNFC2", - "vnfc-name": "VNFC2 - Name" + "vnfc-type": "BE", + "vnfc-name": "BE - Name" } }, { - "vserver-id" : "vnfc2_vserverid5", + "vserver-id" : "be_vserverid5", "vnfc": { - "vnfc-type": "VNFC2", - "vnfc-name": "VNFC2 - Name" + "vnfc-type": "BE", + "vnfc-name": "BE - Name" } } ] } }, - "dependency-info": - { - "vnfcs" : - [ + "dependency-info": { + "vnfcs" : [ { - "vnfc-type" : "VNFC2", + "vnfc-type" : "BE", "mandatory" : "true", "resilience": "Active-Active", - "parents" : - [ - "VNFC1" + "parents" : [ + "SMP" ] }, { - "vnfc-type" : "VNFC3", + "vnfc-type" : "FE", "mandatory" : "true", "resilience": "Active-Active", - "parents" : - [ - "VNFC2" + "parents" : [ + "BE" ] }, { - "vnfc-type" : "VNFC1", + "vnfc-type" : "SMP", "mandatory" : "true", "resilience": "Active-Passive", "parents" : [] } ] }, - "tunable-parameters": - { + "tunable-parameters": { "strategy" : "FORWARD", "wait-time": "120", "retry-count": "5" }, - "capabilities" : - { - "vnf": - [ - "Stop", - "Start", - "StartApplication", - "StopApplication" - ], - "vf-module": - [ - "Stop", - "Start" - ], - "vm" : - [ - "Stop", - "Start" - ], - "vnfc": - [ - "StopApplication", - "StartApplication", - "HealthCheck" - ] + "capabilities" : { + "vnf": ["Stop", "Start", "StartApplication","StopApplication"], + "vf-module": ["Stop", "Start"], + "vm" : ["Stop", "Start"], + "vnfc": ["StopApplication", "StartApplication","HealthCheck"] } } diff --git a/appc-sequence-generator/appc-sequence-generator-bundle/src/test/resources/input/no-strategy.json b/appc-sequence-generator/appc-sequence-generator-bundle/src/test/resources/input/no-strategy.json index 1371d2273..1b5ee9477 100644 --- a/appc-sequence-generator/appc-sequence-generator-bundle/src/test/resources/input/no-strategy.json +++ b/appc-sequence-generator/appc-sequence-generator-bundle/src/test/resources/input/no-strategy.json @@ -1,194 +1,140 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP : APPC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Copyright (C) 2017 Amdocs - * ============================================================================= - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * ============LICENSE_END========================================================= - */ - - { - "request-info": - { + "request-info": { "action": "Start", "action-level": "vnf", - "action-identifier": - { + "action-identifier": { "vnf-id": "dbgx0001v" }, "payload": "ABC" }, - "inventory-info": - { - "vnf-info": - { + "inventory-info": { + "vnf-info": { "vnf-id" : "abc", - "vnf-name": "vVNF", - "vnf-type": "vVNF", + "vnf-name": "vSCP", + "vnf-type": "vSCP", "vnf-version" : "1.0", "vm": [ { - "vserver-id" : "vnfc2_vserverid1", + "vserver-id" : "be_vserverid1", "vnfc": { - "vnfc-type": "VNFC2", - "vnfc-name": "VNFC2 - Name" + "vnfc-type": "BE", + "vnfc-name": "BE - Name" } }, { - "vserver-id" : "vnfc3_vserverid1", + "vserver-id" : "fe_vserverid1", "vnfc": { - "vnfc-type": "VNFC3", - "vnfc-name": "VNFC3 - Name" + "vnfc-type": "FE", + "vnfc-name": "FE - Name" } }, { - "vserver-id" : "vnfc3_vserverid2", + "vserver-id" : "fe_vserverid2", "vnfc": { - "vnfc-type": "VNFC3", - "vnfc-name": "VNFC3 - Name" + "vnfc-type": "FE", + "vnfc-name": "FE - Name" } }, { - "vserver-id" : "vnfc2_vserverid2", + "vserver-id" : "be_vserverid2", "vnfc": { - "vnfc-type": "VNFC2", - "vnfc-name": "VNFC2 - Name" + "vnfc-type": "BE", + "vnfc-name": "BE - Name" } }, { - "vserver-id" : "vnfc2_vserverid3", + "vserver-id" : "be_vserverid3", "vnfc": { - "vnfc-type": "VNFC2", - "vnfc-name": "VNFC2 - Name" + "vnfc-type": "BE", + "vnfc-name": "BE - Name" } }, { - "vserver-id" : "vnfc1_vserverid1", + "vserver-id" : "smp_vserverid1", "vnfc": { - "vnfc-type": "VNFC1", - "vnfc-name": "VNFC1 - Name" + "vnfc-type": "SMP", + "vnfc-name": "SMP - Name" } }, { - "vserver-id" : "vnfc1_vserverid2", + "vserver-id" : "smp_vserverid2", "vnfc": { - "vnfc-type": "VNFC1", - "vnfc-name": "VNFC1 - Name" + "vnfc-type": "SMP", + "vnfc-name": "SMP - Name" } }, { - "vserver-id" : "vnfc2_vserverid4", + "vserver-id" : "be_vserverid4", "vnfc": { - "vnfc-type": "VNFC2", - "vnfc-name": "VNFC2 - Name" + "vnfc-type": "BE", + "vnfc-name": "BE - Name" } }, { - "vserver-id" : "vnfc2_vserverid5", + "vserver-id" : "be_vserverid5", "vnfc": { - "vnfc-type": "VNFC2", - "vnfc-name": "VNFC2 - Name" + "vnfc-type": "BE", + "vnfc-name": "BE - Name" } } ] } }, - "dependency-info": - { - "vnfcs" : - [ + "dependency-info": { + "vnfcs" : [ { - "vnfc-type" : "VNFC2", + "vnfc-type" : "BE", "mandatory" : "true", "resilience": "Active-Active", - "parents" : - [ - "VNFC1" + "parents" : [ + "SMP" ] }, { - "vnfc-type" : "VNFC3", + "vnfc-type" : "FE", "mandatory" : "true", "resilience": "Active-Active", - "parents" : - [ - "VNFC2" + "parents" : [ + "BE" ] }, { - "vnfc-type" : "VNFC1", + "vnfc-type" : "SMP", "mandatory" : "true", "resilience": "Active-Passive", "parents" : [] } ] }, - "tunable-parameters": - { + "tunable-parameters": { "strategy" : "", "wait-time": "120", "retry-count": "5" }, - "capabilities" : - { - "vnf": - [ - "Stop", - "Start", - "StartApplication", - "StopApplication" - ], - "vf-module": - [ - "Stop", - "Start" - ], - "vm" : - [ - "Stop", - "Start" - ], - "vnfc": - [ - "StopApplication", - "StartApplication", - "HealthCheck" - ] + "capabilities" : { + "vnf": ["Stop", "Start", "StartApplication","StopApplication"], + "vf-module": ["Stop", "Start"], + "vm" : ["Stop", "Start"], + "vnfc": ["StopApplication", "StartApplication","HealthCheck"] } } diff --git a/appc-sequence-generator/appc-sequence-generator-bundle/src/test/resources/input/restartNodep.json b/appc-sequence-generator/appc-sequence-generator-bundle/src/test/resources/input/restartNodep.json new file mode 100755 index 000000000..5b44097ff --- /dev/null +++ b/appc-sequence-generator/appc-sequence-generator-bundle/src/test/resources/input/restartNodep.json @@ -0,0 +1,97 @@ + + +{ + "request-info": { + "action": "Restart", + "action-level": "vm", + "action-identifier": { + "vnf-id": "dbgx0001v" + }, + "payload": " {\"vnf-host-ip-address\": \"10.147.124.163\" }" + + }, + "inventory-info": { + "vnf-info": { + "vnf-id" : "abc", + "vnf-name": "vSCP", + "vnf-type": "vSCP", + "vnf-version" : "1.0", + "vm": [ + { + "vserver-id" : "smp_vserverid2", + "vnfc": + { + "vnfc-type": "SMP", + "vnfc-name": "SMP - Name" + } + }, + { + "vserver-id" : "be_vserverid2", + "vnfc": + { + "vnfc-type": "FE", + "vnfc-name": "FE - Name" + } + + }, + { + "vserver-id" : "fe_vserverid2", + "vnfc": + { + "vnfc-type": "BE", + "vnfc-name": "BE - Name" + } + + }, + { + "vserver-id" : "be_vserverid5", + "vnfc": + { + "vnfc-type": "BE", + "vnfc-name": "BE - Name" + } + + } + ] + } + }, + "dependency-info" : { + "vnfcs" : [ + { + "vnfc-type" : "BE", + "mandatory" : "true", + "resilience": "Active-Active", + "parents" : [ + "SMP" + ] + }, + { + "vnfc-type" : "FE", + "mandatory" : "true", + "resilience": "Active-Active", + "parents" : [ + "BE" + ] + }, + { + "vnfc-type" : "SMP", + "mandatory" : "true", + "resilience": "Active-Passive", + "parents" : [] + } + ] + }, + "tunable-parameters" : { + "strategy" : "FORWARD", + "waitTime" : "120", + "retryCount" : "5" + }, + "capabilities" : { + "vnf": ["Stop", "Start", "StartApplication","StopApplication"], + "vf-module": ["Stop", "Start"], + "vm" : ["Stop", "Start"], + "vnfc": ["StopApplication", "StartApplication","HealthCheck"] + } +} + + diff --git a/appc-sequence-generator/appc-sequence-generator-bundle/src/test/resources/input/start-singleVM-.json b/appc-sequence-generator/appc-sequence-generator-bundle/src/test/resources/input/start-singleVM-.json new file mode 100755 index 000000000..acc6b9c02 --- /dev/null +++ b/appc-sequence-generator/appc-sequence-generator-bundle/src/test/resources/input/start-singleVM-.json @@ -0,0 +1,42 @@ + + +{ + "request-info": { + "action": "Start", + "action-level": "vm", + "action-identifier": { + "vserver-id": "dbgx0001v" + }, + "payload": "ABC" + }, + "inventory-info": { + "vnf-info": { + "vnf-id" : "abc", + "vnf-name": "vSCP", + "vnf-type": "vSCP", + "vnf-version" : "1.0", + "vm": [ + { + "vserver-id" : "be_vserverid1", + "vnfc": + { + "vnfc-type": "BE", + "vnfc-name": "BE - Name" + } + } + ] + } + }, + "dependency-info": { + + }, + "tunable-parameters": { + + }, + "capabilities" : { + "vm" : ["Stop", "Start"], + "vnfc": ["StopApplication", "StartApplication","HealthCheck"] + } +} + + diff --git a/appc-sequence-generator/appc-sequence-generator-bundle/src/test/resources/input/start-singleVmPerVnfc-.json b/appc-sequence-generator/appc-sequence-generator-bundle/src/test/resources/input/start-singleVmPerVnfc-.json new file mode 100755 index 000000000..4ec59c245 --- /dev/null +++ b/appc-sequence-generator/appc-sequence-generator-bundle/src/test/resources/input/start-singleVmPerVnfc-.json @@ -0,0 +1,51 @@ + + +{ + "request-info": { + "action": "Start", + "action-level": "vm", + "action-identifier": { + "vserver-id": "dbgx0001v" + }, + "payload": "ABC" + }, + "inventory-info": { + "vnf-info": { + "vnf-id" : "abc", + "vnf-name": "vSCP", + "vnf-type": "vSCP", + "vnf-version" : "1.0", + "vm": [ + { + "vserver-id" : "be_vserverid1", + "vnfc": + { + "vnfc-type": "BE", + "vnfc-name": "BE - Name" + } + }, + { + "vserver-id" : "smp_vserverid1", + "vnfc": + { + "vnfc-type": "SMP", + "vnfc-name": "SMP - Name" + } + + } + ] + } + }, + "dependency-info": { + + }, + "tunable-parameters": { + + }, + "capabilities" : { + "vm" : ["Stop", "Start"], + "vnfc": ["StopApplication", "StartApplication","HealthCheck"] + } +} + + diff --git a/appc-sequence-generator/appc-sequence-generator-bundle/src/test/resources/input/start-withoutDependency.json b/appc-sequence-generator/appc-sequence-generator-bundle/src/test/resources/input/start-withoutDependency.json new file mode 100755 index 000000000..b1a58e3a1 --- /dev/null +++ b/appc-sequence-generator/appc-sequence-generator-bundle/src/test/resources/input/start-withoutDependency.json @@ -0,0 +1,114 @@ + + +{ + "request-info": { + "action": "Start", + "action-level": "vm", + "action-identifier": { + "vnf-id": "dbgx0001v" + }, + "payload": "ABC" + }, + "inventory-info": { + "vnf-info": { + "vnf-id" : "abc", + "vnf-name": "vSCP", + "vnf-type": "vSCP", + "vnf-version" : "1.0", + "vm": [ + { + "vserver-id" : "be_vserverid1", + "vnfc": + { + "vnfc-type": "BE", + "vnfc-name": "BE - Name" + } + + }, + { + "vserver-id" : "fe_vserverid1", + "vnfc": + { + "vnfc-type": "FE", + "vnfc-name": "FE - Name" + } + + }, + { + "vserver-id" : "fe_vserverid2", + "vnfc": + { + "vnfc-type": "FE", + "vnfc-name": "FE - Name" + } + + }, + { + "vserver-id" : "be_vserverid2", + "vnfc": + { + "vnfc-type": "BE", + "vnfc-name": "BE - Name" + } + + }, + { + "vserver-id" : "be_vserverid3", + "vnfc": + { + "vnfc-type": "BE", + "vnfc-name": "BE - Name" + } + + }, + { + "vserver-id" : "smp_vserverid1", + "vnfc": + { + "vnfc-type": "SMP", + "vnfc-name": "SMP - Name" + } + + }, + { + "vserver-id" : "smp_vserverid2", + "vnfc": + { + "vnfc-type": "SMP", + "vnfc-name": "SMP - Name" + } + }, + { + "vserver-id" : "be_vserverid4", + "vnfc": + { + "vnfc-type": "BE", + "vnfc-name": "BE - Name" + } + + }, + { + "vserver-id" : "be_vserverid5", + "vnfc": + { + "vnfc-type": "BE", + "vnfc-name": "BE - Name" + } + + } + ] + } + }, + "dependency-info": { + + }, + "tunable-parameters": { + + }, + "capabilities" : { + "vm" : ["Stop", "Start"], + "vnfc": ["StopApplication", "StartApplication","HealthCheck"] + } +} + + diff --git a/appc-sequence-generator/appc-sequence-generator-bundle/src/test/resources/input/start.json b/appc-sequence-generator/appc-sequence-generator-bundle/src/test/resources/input/start.json index 143b41d23..5dc584d4d 100644 --- a/appc-sequence-generator/appc-sequence-generator-bundle/src/test/resources/input/start.json +++ b/appc-sequence-generator/appc-sequence-generator-bundle/src/test/resources/input/start.json @@ -1,196 +1,142 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP : APPC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Copyright (C) 2017 Amdocs - * ============================================================================= - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * ============LICENSE_END========================================================= - */ - - { - "request-info": - { - "action": "Start", - "action-level": "vnf", - "action-identifier": - { - "vnf-id": "dbgx0001v" - }, - "payload": "ABC" - }, - "inventory-info": - { - "vnf-info": - { - "vnf-id" : "abc", - "vnf-name": "vVNF", - "vnf-type": "vVNF", - "vnf-version" : "1.0", - "vm": - [ - { - "vserver-id" : "vnfc2_vserverid1", - "vnfc": - { - "vnfc-type": "VNFC2", - "vnfc-name": "VNFC2 - Name" - } + "request-info": { + "action": "Start", + "action-level": "vnf", + "action-identifier": { + "vnf-id": "dbgx0001v" + }, + "payload": "ABC" + + }, + "inventory-info": { + "vnf-info": { + "vnf-id" : "abc", + "vnf-name": "vSCP", + "vnf-type": "vSCP", + "vnf-version" : "1.0", + "vm": [ + { + "vserver-id" : "be_vserverid1", + "vnfc": + { + "vnfc-type": "BE", + "vnfc-name": "BE - Name" + } - }, - { - "vserver-id" : "vnfc3_vserverid1", - "vnfc": - { - "vnfc-type": "VNFC3", - "vnfc-name": "VNFC3 - Name" - } + }, + { + "vserver-id" : "fe_vserverid1", + "vnfc": + { + "vnfc-type": "FE", + "vnfc-name": "FE - Name" + } - }, - { - "vserver-id" : "vnfc3_vserverid2", - "vnfc": - { - "vnfc-type": "VNFC3", - "vnfc-name": "VNFC3 - Name" - } + }, + { + "vserver-id" : "fe_vserverid2", + "vnfc": + { + "vnfc-type": "FE", + "vnfc-name": "FE - Name" + } - }, - { - "vserver-id" : "vnfc2_vserverid2", - "vnfc": - { - "vnfc-type": "VNFC2", - "vnfc-name": "VNFC2 - Name" - } + }, + { + "vserver-id" : "be_vserverid2", + "vnfc": + { + "vnfc-type": "BE", + "vnfc-name": "BE - Name" + } - }, - { - "vserver-id" : "vnfc2_vserverid3", - "vnfc": - { - "vnfc-type": "VNFC2", - "vnfc-name": "VNFC2 - Name" - } + }, + { + "vserver-id" : "be_vserverid3", + "vnfc": + { + "vnfc-type": "BE", + "vnfc-name": "BE - Name" + } - }, - { - "vserver-id" : "vnfc1_vserverid1", - "vnfc": - { - "vnfc-type": "VNFC1", - "vnfc-name": "VNFC1 - Name" - } + }, + { + "vserver-id" : "smp_vserverid1", + "vnfc": + { + "vnfc-type": "SMP", + "vnfc-name": "SMP - Name" + } - }, - { - "vserver-id" : "vnfc1_vserverid2", - "vnfc": - { - "vnfc-type": "VNFC1", - "vnfc-name": "VNFC1 - Name" - } - }, - { - "vserver-id" : "vnfc2_vserverid4", - "vnfc": - { - "vnfc-type": "VNFC2", - "vnfc-name": "VNFC2 - Name" - } + }, + { + "vserver-id" : "smp_vserverid2", + "vnfc": + { + "vnfc-type": "SMP", + "vnfc-name": "SMP - Name" + } + }, + { + "vserver-id" : "be_vserverid4", + "vnfc": + { + "vnfc-type": "BE", + "vnfc-name": "BE - Name" + } - }, - { - "vserver-id" : "vnfc2_vserverid5", - "vnfc": - { - "vnfc-type": "VNFC2", - "vnfc-name": "VNFC2 - Name" - } + }, + { + "vserver-id" : "be_vserverid5", + "vnfc": + { + "vnfc-type": "BE", + "vnfc-name": "BE - Name" + } - } - ] - } - }, - "dependency-info" : - { - "vnfcs" : - [ - { - "vnfc-type" : "VNFC2", - "mandatory" : "true", - "resilience": "Active-Active", - "parents" : - [ - "VNFC1" - ] - }, - { - "vnfc-type" : "VNFC3", - "mandatory" : "true", - "resilience": "Active-Active", - "parents" : - [ - "VNFC2" - ] - }, - { - "vnfc-type" : "VNFC1", - "mandatory" : "true", - "resilience": "Active-Passive", - "parents" : [] - } - ] - }, - "tunable-parameters" : - { - "strategy" : "FORWARD", - "wait-time" : "120", - "retry-count" : "5" - }, - "capabilities" : - { - "vnf": - [ - "Stop", - "Start", - "StartApplication", - "StopApplication" - ], - "vf-module": - [ - "Stop", - "Start" - ], - "vm" : - [ - "Stop", - "Start" - ], - "vnfc": - [ - "StopApplication", - "StartApplication", - "HealthCheck" - ] - } + } + ] + } + }, + "dependency-info": { + "vnfcs" : [ + { + "vnfc-type" : "BE", + "mandatory" : "true", + "resilience": "Active-Active", + "parents" : [ + "SMP" + ] + }, + { + "vnfc-type" : "FE", + "mandatory" : "true", + "resilience": "Active-Active", + "parents" : [ + "BE" + ] + }, + { + "vnfc-type" : "SMP", + "mandatory" : "true", + "resilience": "Active-Passive", + "parents" : [] + } + ] + }, + "tunable-parameters": { + "strategy" : "FORWARD", + "wait-time": "120", + "retry-count": "5" + }, + "capabilities" : { + "vnf": ["Stop", "Start", "StartApplication","StopApplication"], + "vf-module": ["Stop", "Start"], + "vm" : ["Stop", "Start"], + "vnfc": ["StopApplication", "StartApplication","HealthCheck"] + } } diff --git a/appc-sequence-generator/appc-sequence-generator-bundle/src/test/resources/input/stop-WithoutDep.json b/appc-sequence-generator/appc-sequence-generator-bundle/src/test/resources/input/stop-WithoutDep.json new file mode 100755 index 000000000..137a67c19 --- /dev/null +++ b/appc-sequence-generator/appc-sequence-generator-bundle/src/test/resources/input/stop-WithoutDep.json @@ -0,0 +1,142 @@ + + +{ + "request-info": { + "action": "Stop", + "action-level": "vm", + "action-identifier": { + "vnf-id": "dbgx0001v" + }, + "payload": " {\"vnf-host-ip-address\": \"10.147.124.163\" }" + + }, + "inventory-info": { + "vnf-info": { + "vnf-id" : "abc", + "vnf-name": "vSCP", + "vnf-type": "vSCP", + "vnf-version" : "1.0", + "vm": [ + { + "vserver-id" : "be_vserverid1", + "vnfc": + { + "vnfc-type": "BE", + "vnfc-name": "BE - Name" + } + + }, + { + "vserver-id" : "fe_vserverid1", + "vnfc": + { + "vnfc-type": "FE", + "vnfc-name": "FE - Name" + } + + }, + { + "vserver-id" : "fe_vserverid2", + "vnfc": + { + "vnfc-type": "FE", + "vnfc-name": "FE - Name" + } + + }, + { + "vserver-id" : "be_vserverid2", + "vnfc": + { + "vnfc-type": "BE", + "vnfc-name": "BE - Name" + } + + }, + { + "vserver-id" : "be_vserverid3", + "vnfc": + { + "vnfc-type": "BE", + "vnfc-name": "BE - Name" + } + + }, + { + "vserver-id" : "smp_vserverid1", + "vnfc": + { + "vnfc-type": "SMP", + "vnfc-name": "SMP - Name" + } + + }, + { + "vserver-id" : "smp_vserverid2", + "vnfc": + { + "vnfc-type": "SMP", + "vnfc-name": "SMP - Name" + } + }, + { + "vserver-id" : "be_vserverid4", + "vnfc": + { + "vnfc-type": "BE", + "vnfc-name": "BE - Name" + } + + }, + { + "vserver-id" : "be_vserverid5", + "vnfc": + { + "vnfc-type": "BE", + "vnfc-name": "BE - Name" + } + + } + ] + } + }, + "dependency-info": { + "vnfcs" : [ + { + "vnfc-type" : "BE", + "mandatory" : "true", + "resilience": "Active-Active", + "parents" : [ + "SMP" + ] + }, + { + "vnfc-type" : "FE", + "mandatory" : "true", + "resilience": "Active-Active", + "parents" : [ + "BE" + ] + }, + { + "vnfc-type" : "SMP", + "mandatory" : "true", + "resilience": "Active-Passive", + "parents" : [] + } + ] + }, + "tunable-parameters": { + "strategy" : "FORWARD", + "wait-time": "120", + "retry-count": "5" + }, + "capabilities" : { + "vnf": ["Stop", "Start", "StartApplication","StopApplication"], + "vf-module": ["Stop", "Start"], + "vm" : ["Stop", "Start"], + "vnfc": ["StopApplication", "StartApplication","HealthCheck"] + } +} + + diff --git a/appc-sequence-generator/appc-sequence-generator-bundle/src/test/resources/input/stop-singleVM.json b/appc-sequence-generator/appc-sequence-generator-bundle/src/test/resources/input/stop-singleVM.json new file mode 100755 index 000000000..30b936585 --- /dev/null +++ b/appc-sequence-generator/appc-sequence-generator-bundle/src/test/resources/input/stop-singleVM.json @@ -0,0 +1,42 @@ + + +{ + "request-info": { + "action": "Stop", + "action-level": "vm", + "action-identifier": { + "vserver-id": "dbgx0001v" + }, + "payload": "ABC" + }, + "inventory-info": { + "vnf-info": { + "vnf-id" : "abc", + "vnf-name": "vSCP", + "vnf-type": "vSCP", + "vnf-version" : "1.0", + "vm": [ + { + "vserver-id" : "be_vserverid1", + "vnfc": + { + "vnfc-type": "BE", + "vnfc-name": "BE - Name" + } + } + ] + } + }, + "dependency-info": { + + }, + "tunable-parameters": { + + }, + "capabilities" : { + "vm" : ["Stop", "Start"], + "vnfc": ["StopApplication", "StartApplication","HealthCheck"] + } +} + + diff --git a/appc-sequence-generator/appc-sequence-generator-bundle/src/test/resources/input/stop-singleVmPerVnfc.json b/appc-sequence-generator/appc-sequence-generator-bundle/src/test/resources/input/stop-singleVmPerVnfc.json new file mode 100755 index 000000000..61d9630ab --- /dev/null +++ b/appc-sequence-generator/appc-sequence-generator-bundle/src/test/resources/input/stop-singleVmPerVnfc.json @@ -0,0 +1,50 @@ + + +{ + "request-info": { + "action": "Stop", + "action-level": "vm", + "action-identifier": { + "vserver-id": "dbgx0001v" + }, + "payload": "ABC" + }, + "inventory-info": { + "vnf-info": { + "vnf-id" : "abc", + "vnf-name": "vSCP", + "vnf-type": "vSCP", + "vnf-version" : "1.0", + "vm": [ + { + "vserver-id" : "be_vserverid1", + "vnfc": + { + "vnfc-type": "BE", + "vnfc-name": "BE - Name" + } + }, + { + "vserver-id" : "smp_vserverid1", + "vnfc": + { + "vnfc-type": "SMP", + "vnfc-name": "SMP - Name" + } + + } + ] + }}, + "dependency-info": { + + }, + "tunable-parameters": { + + }, + "capabilities" : { + "vm" : ["Stop", "Start"], + "vnfc": ["StopApplication", "StartApplication","HealthCheck"] + } +} + + diff --git a/appc-sequence-generator/appc-sequence-generator-bundle/src/test/resources/input/stop.json b/appc-sequence-generator/appc-sequence-generator-bundle/src/test/resources/input/stop.json index 9131a652b..0b7a1a7c1 100644 --- a/appc-sequence-generator/appc-sequence-generator-bundle/src/test/resources/input/stop.json +++ b/appc-sequence-generator/appc-sequence-generator-bundle/src/test/resources/input/stop.json @@ -1,196 +1,141 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP : APPC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Copyright (C) 2017 Amdocs - * ============================================================================= - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * ============LICENSE_END========================================================= - */ - - { - "request-info": - { + "request-info": { "action": "Stop", "action-level": "vnf", - "action-identifier": - { + "action-identifier": { "vnf-id": "dbgx0001v" }, "payload": " {\"vnf-host-ip-address\": \"10.147.124.163\" }" }, - "inventory-info": - { - "vnf-info": - { + "inventory-info": { + "vnf-info": { "vnf-id" : "abc", - "vnf-name": "vVNF", - "vnf-type": "vVNF", + "vnf-name": "vSCP", + "vnf-type": "vSCP", "vnf-version" : "1.0", - "vm": - [ + "vm": [ { - "vserver-id" : "vnfc2_vserverid1", + "vserver-id" : "be_vserverid1", "vnfc": { - "vnfc-type": "VNFC2", - "vnfc-name": "VNFC2 - Name" + "vnfc-type": "BE", + "vnfc-name": "BE - Name" } }, { - "vserver-id" : "vnfc3_vserverid1", + "vserver-id" : "fe_vserverid1", "vnfc": { - "vnfc-type": "VNFC3", - "vnfc-name": "VNFC3 - Name" + "vnfc-type": "FE", + "vnfc-name": "FE - Name" } }, { - "vserver-id" : "vnfc3_vserverid2", + "vserver-id" : "fe_vserverid2", "vnfc": { - "vnfc-type": "VNFC3", - "vnfc-name": "VNFC3 - Name" + "vnfc-type": "FE", + "vnfc-name": "FE - Name" } }, { - "vserver-id" : "vnfc2_vserverid2", + "vserver-id" : "be_vserverid2", "vnfc": { - "vnfc-type": "VNFC2", - "vnfc-name": "VNFC2 - Name" + "vnfc-type": "BE", + "vnfc-name": "BE - Name" } }, { - "vserver-id" : "vnfc2_vserverid3", + "vserver-id" : "be_vserverid3", "vnfc": { - "vnfc-type": "VNFC2", - "vnfc-name": "VNFC2 - Name" + "vnfc-type": "BE", + "vnfc-name": "BE - Name" } }, { - "vserver-id" : "vnfc1_vserverid1", + "vserver-id" : "smp_vserverid1", "vnfc": { - "vnfc-type": "VNFC1", - "vnfc-name": "VNFC1 - Name" + "vnfc-type": "SMP", + "vnfc-name": "SMP - Name" } }, { - "vserver-id" : "vnfc1_vserverid2", + "vserver-id" : "smp_vserverid2", "vnfc": { - "vnfc-type": "VNFC1", - "vnfc-name": "VNFC1 - Name" + "vnfc-type": "SMP", + "vnfc-name": "SMP - Name" } }, { - "vserver-id" : "vnfc2_vserverid4", + "vserver-id" : "be_vserverid4", "vnfc": { - "vnfc-type": "VNFC2", - "vnfc-name": "VNFC2 - Name" + "vnfc-type": "BE", + "vnfc-name": "BE - Name" } }, { - "vserver-id" : "vnfc2_vserverid5", + "vserver-id" : "be_vserverid5", "vnfc": { - "vnfc-type": "VNFC2", - "vnfc-name": "VNFC2 - Name" + "vnfc-type": "BE", + "vnfc-name": "BE - Name" } } ] } }, - "dependency-info": - { - "vnfcs" : - [ + "dependency-info": { + "vnfcs" : [ { - "vnfc-type" : "VNFC2", + "vnfc-type" : "BE", "mandatory" : "true", "resilience": "Active-Active", - "parents" : - [ - "VNFC1" + "parents" : [ + "SMP" ] }, { - "vnfc-type" : "VNFC3", + "vnfc-type" : "FE", "mandatory" : "true", "resilience": "Active-Active", - "parents" : - [ - "VNFC2" + "parents" : [ + "BE" ] }, { - "vnfc-type" : "VNFC1", + "vnfc-type" : "SMP", "mandatory" : "true", "resilience": "Active-Passive", "parents" : [] } ] }, - "tunable-parameters": - { + "tunable-parameters": { "strategy" : "FORWARD", "wait-time": "120", "retry-count": "5" }, - "capabilities" : - { - "vnf": - [ - "Stop", - "Start", - "StartApplication", - "StopApplication" - ], - "vf-module": - [ - "Stop", - "Start" - ], - "vm" : - [ - "Stop", - "Start" - ], - "vnfc": - [ - "StopApplication", - "StartApplication", - "HealthCheck" - ] + "capabilities" : { + "vnf": ["Stop", "Start", "StartApplication","StopApplication"], + "vf-module": ["Stop", "Start"], + "vm" : ["Stop", "Start"], + "vnfc": ["StopApplication", "StartApplication","HealthCheck"] } } diff --git a/appc-sequence-generator/appc-sequence-generator-bundle/src/test/resources/input/wrongaction.json b/appc-sequence-generator/appc-sequence-generator-bundle/src/test/resources/input/wrongaction.json index 72f6ed87f..cd6eaa779 100644 --- a/appc-sequence-generator/appc-sequence-generator-bundle/src/test/resources/input/wrongaction.json +++ b/appc-sequence-generator/appc-sequence-generator-bundle/src/test/resources/input/wrongaction.json @@ -1,196 +1,141 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP : APPC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Copyright (C) 2017 Amdocs - * ============================================================================= - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * ============LICENSE_END========================================================= - */ - - { - "request-info": - { - "action": "start", - "action-level": "vnf", - "action-identifier": - { - "vnf-id": "dbgx0001v" - }, - "payload": "ABC" - }, - "inventory-info": - { - "vnf-info": - { - "vnf-id" : "abc", - "vnf-name": "vVNF", - "vnf-type": "vVNF", - "vnf-version" : "1.0", - "vm": - [ - { - "vserver-id" : "vnfc2_vserverid1", - "vnfc": - { - "vnfc-type": "VNFC2", - "vnfc-name": "VNFC2 - Name" - } - - }, - { - "vserver-id" : "vnfc3_vserverid1", - "vnfc": - { - "vnfc-type": "VNFC3", - "vnfc-name": "VNFC3 - Name" - } - - }, - { - "vserver-id" : "vnfc3_vserverid2", - "vnfc": - { - "vnfc-type": "VNFC3", - "vnfc-name": "VNFC3 - Name" - } - - }, - { - "vserver-id" : "vnfc2_vserverid2", - "vnfc": - { - "vnfc-type": "VNFC2", - "vnfc-name": "VNFC2 - Name" - } - - }, - { - "vserver-id" : "vnfc2_vserverid3", - "vnfc": - { - "vnfc-type": "VNFC2", - "vnfc-name": "VNFC2 - Name" - } - - }, - { - "vserver-id" : "vnfc1_vserverid1", - "vnfc": - { - "vnfc-type": "VNFC1", - "vnfc-name": "VNFC1 - Name" - } - - }, - { - "vserver-id" : "vnfc1_vserverid2", - "vnfc": - { - "vnfc-type": "VNFC1", - "vnfc-name": "VNFC1 - Name" - } - }, - { - "vserver-id" : "vnfc2_vserverid4", - "vnfc": - { - "vnfc-type": "VNFC2", - "vnfc-name": "VNFC2 - Name" - } + "request-info": { + "action": "start", + "action-level": "vnf", + "action-identifier": { + "vnf-id": "dbgx0001v" + }, + "payload": "ABC" + }, + "inventory-info": { + "vnf-info": { + "vnf-id" : "abc", + "vnf-name": "vSCP", + "vnf-type": "vSCP", + "vnf-version" : "1.0", + "vm": [ + { + "vserver-id" : "be_vserverid1", + "vnfc": + { + "vnfc-type": "BE", + "vnfc-name": "BE - Name" + } + + }, + { + "vserver-id" : "fe_vserverid1", + "vnfc": + { + "vnfc-type": "FE", + "vnfc-name": "FE - Name" + } + + }, + { + "vserver-id" : "fe_vserverid2", + "vnfc": + { + "vnfc-type": "FE", + "vnfc-name": "FE - Name" + } + + }, + { + "vserver-id" : "be_vserverid2", + "vnfc": + { + "vnfc-type": "BE", + "vnfc-name": "BE - Name" + } + + }, + { + "vserver-id" : "be_vserverid3", + "vnfc": + { + "vnfc-type": "BE", + "vnfc-name": "BE - Name" + } + + }, + { + "vserver-id" : "smp_vserverid1", + "vnfc": + { + "vnfc-type": "SMP", + "vnfc-name": "SMP - Name" + } + + }, + { + "vserver-id" : "smp_vserverid2", + "vnfc": + { + "vnfc-type": "SMP", + "vnfc-name": "SMP - Name" + } + }, + { + "vserver-id" : "be_vserverid4", + "vnfc": + { + "vnfc-type": "BE", + "vnfc-name": "BE - Name" + } - }, - { - "vserver-id" : "vnfc2_vserverid5", - "vnfc": - { - "vnfc-type": "VNFC2", - "vnfc-name": "VNFC2 - Name" - } + }, + { + "vserver-id" : "be_vserverid5", + "vnfc": + { + "vnfc-type": "BE", + "vnfc-name": "BE - Name" + } - } - ] - } - }, - "dependency-info": - { - "vnfcs" : - [ - { - "vnfc-type" : "VNFC2", - "mandatory" : "true", - "resilience": "Active-Active", - "parents" : - [ - "VNFC1" - ] - }, - { - "vnfc-type" : "VNFC3", - "mandatory" : "true", - "resilience": "Active-Active", - "parents" : - [ - "VNFC2" - ] - }, - { - "vnfc-type" : "VNFC1", - "mandatory" : "true", - "resilience": "Active-Passive", - "parents" : [] - } - ] - }, - "tunable-parameters": - { - "strategy" : "FORWARD", - "wait-time": "120", - "retry-count": "5" - }, - "capabilities" : - { - "vnf": - [ - "Stop", - "Start", - "StartApplication", - "StopApplication" - ], - "vf-module": - [ - "Stop", - "Start" - ], - "vm" : - [ - "Stop", - "Start" - ], - "vnfc": - [ - "StopApplication", - "StartApplication", - "HealthCheck" - ] - } + } + ] + } + }, + "dependency-info": { + "vnfcs" : [ + { + "vnfc-type" : "BE", + "mandatory" : "true", + "resilience": "Active-Active", + "parents" : [ + "SMP" + ] + }, + { + "vnfc-type" : "FE", + "mandatory" : "true", + "resilience": "Active-Active", + "parents" : [ + "BE" + ] + }, + { + "vnfc-type" : "SMP", + "mandatory" : "true", + "resilience": "Active-Passive", + "parents" : [] + } + ] + }, + "tunable-parameters": { + "strategy" : "FORWARD", + "wait-time": "120", + "retry-count": "5" + }, + "capabilities" : { + "vnf": ["Stop", "Start", "StartApplication","StopApplication"], + "vf-module": ["Stop", "Start"], + "vm" : ["Stop", "Start"], + "vnfc": ["StopApplication", "StartApplication","HealthCheck"] + } } diff --git a/appc-sequence-generator/appc-sequence-generator-bundle/src/test/resources/input/wrongnumber.json b/appc-sequence-generator/appc-sequence-generator-bundle/src/test/resources/input/wrongnumber.json index 958df0379..ffdaec28a 100644 --- a/appc-sequence-generator/appc-sequence-generator-bundle/src/test/resources/input/wrongnumber.json +++ b/appc-sequence-generator/appc-sequence-generator-bundle/src/test/resources/input/wrongnumber.json @@ -1,196 +1,141 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP : APPC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Copyright (C) 2017 Amdocs - * ============================================================================= - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * ============LICENSE_END========================================================= - */ - - { - "request-info": - { - "action": "Start", - "action-level": "vnf", - "action-identifier": - { - "vnf-id": "dbgx0001v" - }, - "payload": "ABC" - }, - "inventory-info": - { - "vnf-info": - { - "vnf-id" : "abc", - "vnf-name": "vVNF", - "vnf-type": "vVNF", - "vnf-version" : "1.0", - "vm": - [ - { - "vserver-id" : "vnfc2_vserverid1", - "vnfc": - { - "vnfc-type": "VNFC2", - "vnfc-name": "VNFC2 - Name" - } - - }, - { - "vserver-id" : "vnfc3_vserverid1", - "vnfc": - { - "vnfc-type": "VNFC3", - "vnfc-name": "VNFC3 - Name" - } - - }, - { - "vserver-id" : "vnfc3_vserverid2", - "vnfc": - { - "vnfc-type": "VNFC3", - "vnfc-name": "VNFC3 - Name" - } - - }, - { - "vserver-id" : "vnfc2_vserverid2", - "vnfc": - { - "vnfc-type": "VNFC2", - "vnfc-name": "VNFC2 - Name" - } - - }, - { - "vserver-id" : "vnfc2_vserverid3", - "vnfc": - { - "vnfc-type": "VNFC2", - "vnfc-name": "VNFC2 - Name" - } - - }, - { - "vserver-id" : "vnfc1_vserverid1", - "vnfc": - { - "vnfc-type": "VNFC1", - "vnfc-name": "VNFC1 - Name" - } - - }, - { - "vserver-id" : "vnfc1_vserverid2", - "vnfc": - { - "vnfc-type": "VNFC1", - "vnfc-name": "VNFC1 - Name" - } - }, - { - "vserver-id" : "vnfc2_vserverid4", - "vnfc": - { - "vnfc-type": "VNFC2", - "vnfc-name": "VNFC2 - Name" - } + "request-info": { + "action": "Start", + "action-level": "vnf", + "action-identifier": { + "vnf-id": "dbgx0001v" + }, + "payload": "ABC" + }, + "inventory-info": { + "vnf-info": { + "vnf-id" : "abc", + "vnf-name": "vSCP", + "vnf-type": "vSCP", + "vnf-version" : "1.0", + "vm": [ + { + "vserver-id" : "be_vserverid1", + "vnfc": + { + "vnfc-type": "BE", + "vnfc-name": "BE - Name" + } + + }, + { + "vserver-id" : "fe_vserverid1", + "vnfc": + { + "vnfc-type": "FE", + "vnfc-name": "FE - Name" + } + + }, + { + "vserver-id" : "fe_vserverid2", + "vnfc": + { + "vnfc-type": "FE", + "vnfc-name": "FE - Name" + } + + }, + { + "vserver-id" : "be_vserverid2", + "vnfc": + { + "vnfc-type": "BE", + "vnfc-name": "BE - Name" + } + + }, + { + "vserver-id" : "be_vserverid3", + "vnfc": + { + "vnfc-type": "BE", + "vnfc-name": "BE - Name" + } + + }, + { + "vserver-id" : "smp_vserverid1", + "vnfc": + { + "vnfc-type": "SMP", + "vnfc-name": "SMP - Name" + } + + }, + { + "vserver-id" : "smp_vserverid2", + "vnfc": + { + "vnfc-type": "SMP", + "vnfc-name": "SMP - Name" + } + }, + { + "vserver-id" : "be_vserverid4", + "vnfc": + { + "vnfc-type": "BE", + "vnfc-name": "BE - Name" + } - }, - { - "vserver-id" : "vnfc2_vserverid5", - "vnfc": - { - "vnfc-type": "VNFC2", - "vnfc-name": "VNFC2 - Name" - } + }, + { + "vserver-id" : "be_vserverid5", + "vnfc": + { + "vnfc-type": "BE", + "vnfc-name": "BE - Name" + } - } - ] - } - }, - "dependency-info": - { - "vnfcs" : - [ - { - "vnfc-type" : "VNFC2", - "mandatory" : "true", - "resilience": "Active-Active", - "parents" : - [ - "VNFC1" - ] - }, - { - "vnfc-type" : "VNFC3", - "mandatory" : "true", - "resilience": "Active-Active", - "parents" : - [ - "VNFC2" - ] - }, - { - "vnfc-type" : "VNFC1", - "mandatory" : "true", - "resilience": "Active-Passive", - "parents" : [] - } - ] - }, - "tunable-parameters": - { - "strategy" : "FORWARD", - "wait-time": "6a", - "retry-count": "5" - }, - "capabilities" : - { - "vnf": - [ - "Stop", - "Start", - "StartApplication", - "StopApplication" - ], - "vf-module": - [ - "Stop", - "Start" - ], - "vm" : - [ - "Stop", - "Start" - ], - "vnfc": - [ - "StopApplication", - "StartApplication", - "HealthCheck" - ] - } + } + ] + } + }, + "dependency-info": { + "vnfcs" : [ + { + "vnfc-type" : "BE", + "mandatory" : "true", + "resilience": "Active-Active", + "parents" : [ + "SMP" + ] + }, + { + "vnfc-type" : "FE", + "mandatory" : "true", + "resilience": "Active-Active", + "parents" : [ + "BE" + ] + }, + { + "vnfc-type" : "SMP", + "mandatory" : "true", + "resilience": "Active-Passive", + "parents" : [] + } + ] + }, + "tunable-parameters": { + "strategy" : "FORWARD", + "wait-time": "6a", + "retry-count": "5" + }, + "capabilities" : { + "vnf": ["Stop", "Start", "StartApplication","StopApplication"], + "vf-module": ["Stop", "Start"], + "vm" : ["Stop", "Start"], + "vnfc": ["StopApplication", "StartApplication","HealthCheck"] + } } diff --git a/appc-sequence-generator/appc-sequence-generator-bundle/src/test/resources/output/Output-stop.json b/appc-sequence-generator/appc-sequence-generator-bundle/src/test/resources/output/Output-stop.json new file mode 100755 index 000000000..17aea0d12 --- /dev/null +++ b/appc-sequence-generator/appc-sequence-generator-bundle/src/test/resources/output/Output-stop.json @@ -0,0 +1,3 @@ + + +[{"transactionId":1,"action":"StopApplication","action-level":"vnfc","action-identifier":{"vnfc-name":"SMP - Name"},"payload":" {\"vnf-host-ip-address\": \"10.147.124.163\" }","responses":[{"response-message":"failure","response-action":{"ignore":"true"}}]},{"transactionId":2,"action":"Stop","action-level":"vm","action-identifier":{"vserver-id":"smp_vserverid1"},"payload":" {\"vnf-host-ip-address\": \"10.147.124.163\" }","responses":[{"response-message":"failure","response-action":{"ignore":"true"}}]},{"transactionId":3,"action":"Stop","action-level":"vm","action-identifier":{"vserver-id":"smp_vserverid2"},"payload":" {\"vnf-host-ip-address\": \"10.147.124.163\" }","responses":[{"response-message":"failure","response-action":{"ignore":"true"}}]},{"transactionId":4,"action":"StopApplication","action-level":"vnfc","action-identifier":{"vnfc-name":"BE - Name"},"payload":" {\"vnf-host-ip-address\": \"10.147.124.163\" }","responses":[{"response-message":"failure","response-action":{"ignore":"true"}}]},{"transactionId":5,"action":"Stop","action-level":"vm","action-identifier":{"vserver-id":"be_vserverid1"},"payload":" {\"vnf-host-ip-address\": \"10.147.124.163\" }","responses":[{"response-message":"failure","response-action":{"ignore":"true"}}]},{"transactionId":6,"action":"Stop","action-level":"vm","action-identifier":{"vserver-id":"be_vserverid2"},"payload":" {\"vnf-host-ip-address\": \"10.147.124.163\" }","responses":[{"response-message":"failure","response-action":{"ignore":"true"}}]},{"transactionId":7,"action":"Stop","action-level":"vm","action-identifier":{"vserver-id":"be_vserverid3"},"payload":" {\"vnf-host-ip-address\": \"10.147.124.163\" }","responses":[{"response-message":"failure","response-action":{"ignore":"true"}}]},{"transactionId":8,"action":"Stop","action-level":"vm","action-identifier":{"vserver-id":"be_vserverid4"},"payload":" {\"vnf-host-ip-address\": \"10.147.124.163\" }","responses":[{"response-message":"failure","response-action":{"ignore":"true"}}]},{"transactionId":9,"action":"Stop","action-level":"vm","action-identifier":{"vserver-id":"be_vserverid5"},"payload":" {\"vnf-host-ip-address\": \"10.147.124.163\" }","responses":[{"response-message":"failure","response-action":{"ignore":"true"}}]},{"transactionId":10,"action":"StopApplication","action-level":"vnfc","action-identifier":{"vnfc-name":"FE - Name"},"payload":" {\"vnf-host-ip-address\": \"10.147.124.163\" }","responses":[{"response-message":"failure","response-action":{"ignore":"true"}}]},{"transactionId":11,"action":"Stop","action-level":"vm","action-identifier":{"vserver-id":"fe_vserverid1"},"payload":" {\"vnf-host-ip-address\": \"10.147.124.163\" }","responses":[{"response-message":"failure","response-action":{"ignore":"true"}}]},{"transactionId":12,"action":"Stop","action-level":"vm","action-identifier":{"vserver-id":"fe_vserverid2"},"payload":" {\"vnf-host-ip-address\": \"10.147.124.163\" }","responses":[{"response-message":"failure","response-action":{"ignore":"true"}}]}] diff --git a/appc-sequence-generator/appc-sequence-generator-bundle/src/test/resources/output/Start.json b/appc-sequence-generator/appc-sequence-generator-bundle/src/test/resources/output/Start.json new file mode 100644 index 000000000..e67f22f56 --- /dev/null +++ b/appc-sequence-generator/appc-sequence-generator-bundle/src/test/resources/output/Start.json @@ -0,0 +1,2 @@ + +[{"transactionId":1,"action":"Start","action-level":"vm","action-identifier":{"vserver-id":"smp_vserverid1"},"payload":"ABC","responses":[{"response-message":"failure","response-action":{"ignore":"true"}}]},{"transactionId":2,"action":"Start","action-level":"vm","action-identifier":{"vserver-id":"smp_vserverid2"},"payload":"ABC","responses":[{"response-message":"failure","response-action":{"ignore":"true"}}]},{"transactionId":3,"action":"StartApplication","action-level":"vnfc","action-identifier":{"vnfc-name":"SMP - Name"},"payload":"ABC","precheck-operator":"any","precheck-options":[{"pre-transactionID":1,"param-name":"status","param-value":"success"},{"pre-transactionID":2,"param-name":"status","param-value":"success"}],"responses":[]},{"transactionId":4,"action":"HealthCheck","action-level":"vnfc","action-identifier":{"vnfc-name":"SMP - Name"},"payload":"ABC","responses":[{"response-message":"unhealthy","response-action":{"wait":"120","retry":"5"}},{"response-message":"healthy","response-action":{"continue":"true"}},{"response-message":"failure","response-action":{"stop":"true"}}]},{"transactionId":5,"action":"Start","action-level":"vm","action-identifier":{"vserver-id":"be_vserverid1"},"payload":"ABC","responses":[{"response-message":"failure","response-action":{"ignore":"true"}}]},{"transactionId":6,"action":"Start","action-level":"vm","action-identifier":{"vserver-id":"be_vserverid2"},"payload":"ABC","responses":[{"response-message":"failure","response-action":{"ignore":"true"}}]},{"transactionId":7,"action":"Start","action-level":"vm","action-identifier":{"vserver-id":"be_vserverid3"},"payload":"ABC","responses":[{"response-message":"failure","response-action":{"ignore":"true"}}]},{"transactionId":8,"action":"Start","action-level":"vm","action-identifier":{"vserver-id":"be_vserverid4"},"payload":"ABC","responses":[{"response-message":"failure","response-action":{"ignore":"true"}}]},{"transactionId":9,"action":"Start","action-level":"vm","action-identifier":{"vserver-id":"be_vserverid5"},"payload":"ABC","responses":[{"response-message":"failure","response-action":{"ignore":"true"}}]},{"transactionId":10,"action":"StartApplication","action-level":"vnfc","action-identifier":{"vnfc-name":"BE - Name"},"payload":"ABC","precheck-operator":"any","precheck-options":[{"pre-transactionID":5,"param-name":"status","param-value":"success"},{"pre-transactionID":6,"param-name":"status","param-value":"success"},{"pre-transactionID":7,"param-name":"status","param-value":"success"},{"pre-transactionID":8,"param-name":"status","param-value":"success"},{"pre-transactionID":9,"param-name":"status","param-value":"success"}],"responses":[]},{"transactionId":11,"action":"HealthCheck","action-level":"vnfc","action-identifier":{"vnfc-name":"BE - Name"},"payload":"ABC","responses":[{"response-message":"unhealthy","response-action":{"wait":"120","retry":"5"}},{"response-message":"healthy","response-action":{"continue":"true"}},{"response-message":"failure","response-action":{"stop":"true"}}]},{"transactionId":12,"action":"Start","action-level":"vm","action-identifier":{"vserver-id":"fe_vserverid1"},"payload":"ABC","responses":[{"response-message":"failure","response-action":{"ignore":"true"}}]},{"transactionId":13,"action":"Start","action-level":"vm","action-identifier":{"vserver-id":"fe_vserverid2"},"payload":"ABC","responses":[{"response-message":"failure","response-action":{"ignore":"true"}}]},{"transactionId":14,"action":"StartApplication","action-level":"vnfc","action-identifier":{"vnfc-name":"FE - Name"},"payload":"ABC","precheck-operator":"any","precheck-options":[{"pre-transactionID":12,"param-name":"status","param-value":"success"},{"pre-transactionID":13,"param-name":"status","param-value":"success"}],"responses":[]},{"transactionId":15,"action":"HealthCheck","action-level":"vnfc","action-identifier":{"vnfc-name":"FE - Name"},"payload":"ABC","responses":[{"response-message":"unhealthy","response-action":{"wait":"120","retry":"5"}},{"response-message":"healthy","response-action":{"continue":"true"}},{"response-message":"failure","response-action":{"stop":"true"}}]}] diff --git a/appc-sequence-generator/appc-sequence-generator-bundle/src/test/resources/output/restart-NoDep.json b/appc-sequence-generator/appc-sequence-generator-bundle/src/test/resources/output/restart-NoDep.json new file mode 100755 index 000000000..df6f7b93d --- /dev/null +++ b/appc-sequence-generator/appc-sequence-generator-bundle/src/test/resources/output/restart-NoDep.json @@ -0,0 +1 @@ +[{"transactionId":1,"action":"Stop","action-level":"vm","action-identifier":{"vserver-id":"smp_vserverid2"},"payload":" {\"vnf-host-ip-address\": \"10.147.124.163\" }","responses":[{"response-message":"failure","response-action":{"jump":"3"}}]},{"transactionId":2,"action":"Start","action-level":"vm","action-identifier":{"vserver-id":"smp_vserverid2"},"payload":" {\"vnf-host-ip-address\": \"10.147.124.163\" }","responses":[{"response-message":"failure","response-action":{"jump":"3"}}]},{"transactionId":3,"action":"Stop","action-level":"vm","action-identifier":{"vserver-id":"be_vserverid2"},"payload":" {\"vnf-host-ip-address\": \"10.147.124.163\" }","responses":[{"response-message":"failure","response-action":{"jump":"5"}}]},{"transactionId":4,"action":"Start","action-level":"vm","action-identifier":{"vserver-id":"be_vserverid2"},"payload":" {\"vnf-host-ip-address\": \"10.147.124.163\" }","responses":[{"response-message":"failure","response-action":{"jump":"5"}}]},{"transactionId":5,"action":"Stop","action-level":"vm","action-identifier":{"vserver-id":"fe_vserverid2"},"payload":" {\"vnf-host-ip-address\": \"10.147.124.163\" }","responses":[{"response-message":"failure","response-action":{"jump":"7"}}]},{"transactionId":6,"action":"Start","action-level":"vm","action-identifier":{"vserver-id":"fe_vserverid2"},"payload":" {\"vnf-host-ip-address\": \"10.147.124.163\" }","responses":[{"response-message":"failure","response-action":{"jump":"7"}}]},{"transactionId":7,"action":"Stop","action-level":"vm","action-identifier":{"vserver-id":"be_vserverid5"},"payload":" {\"vnf-host-ip-address\": \"10.147.124.163\" }","responses":[]},{"transactionId":8,"action":"Start","action-level":"vm","action-identifier":{"vserver-id":"be_vserverid5"},"payload":" {\"vnf-host-ip-address\": \"10.147.124.163\" }","responses":[]}]
\ No newline at end of file diff --git a/appc-sequence-generator/appc-sequence-generator-bundle/src/test/resources/output/restart-Nodep-SingleVM.json b/appc-sequence-generator/appc-sequence-generator-bundle/src/test/resources/output/restart-Nodep-SingleVM.json new file mode 100755 index 000000000..c3e2a7449 --- /dev/null +++ b/appc-sequence-generator/appc-sequence-generator-bundle/src/test/resources/output/restart-Nodep-SingleVM.json @@ -0,0 +1,4 @@ + + + +[{"transactionId":1,"action":"Stop","action-level":"vm","action-identifier":{"vserver-id":"be_vserverid1"},"payload":"ABC","responses":[]},{"transactionId":2,"action":"Start","action-level":"vm","action-identifier":{"vserver-id":"be_vserverid1"},"payload":"ABC","responses":[]}] diff --git a/appc-sequence-generator/appc-sequence-generator-bundle/src/test/resources/output/start-singleVM-.json b/appc-sequence-generator/appc-sequence-generator-bundle/src/test/resources/output/start-singleVM-.json new file mode 100755 index 000000000..dbacc77d8 --- /dev/null +++ b/appc-sequence-generator/appc-sequence-generator-bundle/src/test/resources/output/start-singleVM-.json @@ -0,0 +1,3 @@ + + +[{"transactionId":1,"action":"Start","action-level":"vm","action-identifier":{"vserver-id":"be_vserverid1"},"payload":"ABC","responses":[]}] diff --git a/appc-sequence-generator/appc-sequence-generator-bundle/src/test/resources/output/start-singleVmPerVnfc.json b/appc-sequence-generator/appc-sequence-generator-bundle/src/test/resources/output/start-singleVmPerVnfc.json new file mode 100755 index 000000000..5d43c4b7b --- /dev/null +++ b/appc-sequence-generator/appc-sequence-generator-bundle/src/test/resources/output/start-singleVmPerVnfc.json @@ -0,0 +1,3 @@ + + +[{"transactionId":1,"action":"Start","action-level":"vm","action-identifier":{"vserver-id":"be_vserverid1"},"payload":"ABC","responses":[{"response-message":"failure","response-action":{"ignore":"true"}}]},{"transactionId":2,"action":"Start","action-level":"vm","action-identifier":{"vserver-id":"smp_vserverid1"},"payload":"ABC","responses":[{"response-message":"failure","response-action":{"ignore":"true"}}]}] diff --git a/appc-sequence-generator/appc-sequence-generator-bundle/src/test/resources/output/start-withoutDependency.json b/appc-sequence-generator/appc-sequence-generator-bundle/src/test/resources/output/start-withoutDependency.json new file mode 100755 index 000000000..64f9f467f --- /dev/null +++ b/appc-sequence-generator/appc-sequence-generator-bundle/src/test/resources/output/start-withoutDependency.json @@ -0,0 +1 @@ +[{"transactionId":1,"action":"Start","action-level":"vm","action-identifier":{"vserver-id":"be_vserverid1"},"payload":"ABC","responses":[{"response-message":"failure","response-action":{"ignore":"true"}}]},{"transactionId":2,"action":"Start","action-level":"vm","action-identifier":{"vserver-id":"fe_vserverid1"},"payload":"ABC","responses":[{"response-message":"failure","response-action":{"ignore":"true"}}]},{"transactionId":3,"action":"Start","action-level":"vm","action-identifier":{"vserver-id":"fe_vserverid2"},"payload":"ABC","responses":[{"response-message":"failure","response-action":{"ignore":"true"}}]},{"transactionId":4,"action":"Start","action-level":"vm","action-identifier":{"vserver-id":"be_vserverid2"},"payload":"ABC","responses":[{"response-message":"failure","response-action":{"ignore":"true"}}]},{"transactionId":5,"action":"Start","action-level":"vm","action-identifier":{"vserver-id":"be_vserverid3"},"payload":"ABC","responses":[{"response-message":"failure","response-action":{"ignore":"true"}}]},{"transactionId":6,"action":"Start","action-level":"vm","action-identifier":{"vserver-id":"smp_vserverid1"},"payload":"ABC","responses":[{"response-message":"failure","response-action":{"ignore":"true"}}]},{"transactionId":7,"action":"Start","action-level":"vm","action-identifier":{"vserver-id":"smp_vserverid2"},"payload":"ABC","responses":[{"response-message":"failure","response-action":{"ignore":"true"}}]},{"transactionId":8,"action":"Start","action-level":"vm","action-identifier":{"vserver-id":"be_vserverid4"},"payload":"ABC","responses":[{"response-message":"failure","response-action":{"ignore":"true"}}]},{"transactionId":9,"action":"Start","action-level":"vm","action-identifier":{"vserver-id":"be_vserverid5"},"payload":"ABC","responses":[{"response-message":"failure","response-action":{"ignore":"true"}}]}]
\ No newline at end of file diff --git a/appc-sequence-generator/appc-sequence-generator-bundle/src/test/resources/output/stop-WithoutDep.json b/appc-sequence-generator/appc-sequence-generator-bundle/src/test/resources/output/stop-WithoutDep.json new file mode 100755 index 000000000..f35e58c1b --- /dev/null +++ b/appc-sequence-generator/appc-sequence-generator-bundle/src/test/resources/output/stop-WithoutDep.json @@ -0,0 +1,3 @@ + + +[{"transactionId":1,"action":"Stop","action-level":"vm","action-identifier":{"vserver-id":"be_vserverid1"},"payload":" {\"vnf-host-ip-address\": \"10.147.124.163\" }","responses":[{"response-message":"failure","response-action":{"ignore":"true"}}]},{"transactionId":2,"action":"Stop","action-level":"vm","action-identifier":{"vserver-id":"fe_vserverid1"},"payload":" {\"vnf-host-ip-address\": \"10.147.124.163\" }","responses":[{"response-message":"failure","response-action":{"ignore":"true"}}]},{"transactionId":3,"action":"Stop","action-level":"vm","action-identifier":{"vserver-id":"fe_vserverid2"},"payload":" {\"vnf-host-ip-address\": \"10.147.124.163\" }","responses":[{"response-message":"failure","response-action":{"ignore":"true"}}]},{"transactionId":4,"action":"Stop","action-level":"vm","action-identifier":{"vserver-id":"be_vserverid2"},"payload":" {\"vnf-host-ip-address\": \"10.147.124.163\" }","responses":[{"response-message":"failure","response-action":{"ignore":"true"}}]},{"transactionId":5,"action":"Stop","action-level":"vm","action-identifier":{"vserver-id":"be_vserverid3"},"payload":" {\"vnf-host-ip-address\": \"10.147.124.163\" }","responses":[{"response-message":"failure","response-action":{"ignore":"true"}}]},{"transactionId":6,"action":"Stop","action-level":"vm","action-identifier":{"vserver-id":"smp_vserverid1"},"payload":" {\"vnf-host-ip-address\": \"10.147.124.163\" }","responses":[{"response-message":"failure","response-action":{"ignore":"true"}}]},{"transactionId":7,"action":"Stop","action-level":"vm","action-identifier":{"vserver-id":"smp_vserverid2"},"payload":" {\"vnf-host-ip-address\": \"10.147.124.163\" }","responses":[{"response-message":"failure","response-action":{"ignore":"true"}}]},{"transactionId":8,"action":"Stop","action-level":"vm","action-identifier":{"vserver-id":"be_vserverid4"},"payload":" {\"vnf-host-ip-address\": \"10.147.124.163\" }","responses":[{"response-message":"failure","response-action":{"ignore":"true"}}]},{"transactionId":9,"action":"Stop","action-level":"vm","action-identifier":{"vserver-id":"be_vserverid5"},"payload":" {\"vnf-host-ip-address\": \"10.147.124.163\" }","responses":[{"response-message":"failure","response-action":{"ignore":"true"}}]}] diff --git a/appc-sequence-generator/appc-sequence-generator-bundle/src/test/resources/output/stop-singleVM.json b/appc-sequence-generator/appc-sequence-generator-bundle/src/test/resources/output/stop-singleVM.json new file mode 100755 index 000000000..50447feca --- /dev/null +++ b/appc-sequence-generator/appc-sequence-generator-bundle/src/test/resources/output/stop-singleVM.json @@ -0,0 +1,3 @@ + + +[{"transactionId":1,"action":"Stop","action-level":"vm","action-identifier":{"vserver-id":"be_vserverid1"},"payload":"ABC","responses":[]}] diff --git a/appc-sequence-generator/appc-sequence-generator-bundle/src/test/resources/output/stop-singleVmPerVnfc.json b/appc-sequence-generator/appc-sequence-generator-bundle/src/test/resources/output/stop-singleVmPerVnfc.json new file mode 100755 index 000000000..8830c0955 --- /dev/null +++ b/appc-sequence-generator/appc-sequence-generator-bundle/src/test/resources/output/stop-singleVmPerVnfc.json @@ -0,0 +1,3 @@ + + +[{"transactionId":1,"action":"Stop","action-level":"vm","action-identifier":{"vserver-id":"be_vserverid1"},"payload":"ABC","responses":[{"response-message":"failure","response-action":{"ignore":"true"}}]},{"transactionId":2,"action":"Stop","action-level":"vm","action-identifier":{"vserver-id":"smp_vserverid1"},"payload":"ABC","responses":[{"response-message":"failure","response-action":{"ignore":"true"}}]}] diff --git a/appc-sequence-generator/appc-sequence-generator-model/src/main/yang/sequence-generator.yang b/appc-sequence-generator/appc-sequence-generator-model/src/main/yang/sequence-generator.yang index 49c1551d0..6da825195 100644 --- a/appc-sequence-generator/appc-sequence-generator-model/src/main/yang/sequence-generator.yang +++ b/appc-sequence-generator/appc-sequence-generator-model/src/main/yang/sequence-generator.yang @@ -1,3 +1,27 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : APPC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Copyright (C) 2017 Amdocs + * ============================================================================= + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * ECOMP is a trademark and service mark of AT&T Intellectual Property. + * ============LICENSE_END========================================================= + */ + module sequence-generator { yang-version 1; @@ -18,6 +42,7 @@ module sequence-generator { type enumeration { enum "Start"; enum "Stop"; + enum "Restart"; } } leaf action-level { @@ -62,6 +87,7 @@ module sequence-generator { type string; } list vm { + ordered-by user; key "vserver-id"; leaf vserver-id { type string; @@ -118,8 +144,8 @@ module sequence-generator { grouping capabilities { container capabilities { leaf-list vnf { - type string; - } + type string; + } leaf-list vf-module { type string; } @@ -142,6 +168,7 @@ module sequence-generator { } } list transactions{ + ordered-by user; key "transaction-id"; leaf transaction-id{ type uint16; @@ -203,6 +230,9 @@ module sequence-generator { leaf ignore{ type boolean; } + leaf jump{ + type uint16; + } } } } @@ -220,4 +250,4 @@ module sequence-generator { uses response; } } - }
\ No newline at end of file + } @@ -66,7 +66,7 @@ ECOMP is a trademark and service mark of AT&T Intellectual Property. <antlr.version>4.5.1</antlr.version> <logback.version>1.1.1</logback.version> <toscalib.version>1.1.0</toscalib.version> - <sdc-client.version>1.1.32</sdc-client.version> + <sdc-client.version>1.2.2</sdc-client.version> <jackson.yml.version>2.3.2</jackson.yml.version> <!-- SONAR --> |