diff --git a/src/main/java/org/etsi/osl/osom/lcm/LCMRulesExecutor.java b/src/main/java/org/etsi/osl/osom/lcm/LCMRulesExecutor.java index c9a4786395bbc19b4151d84539b10ab808ffe1e2..a157c1d3c1fcea170dc90cf2a975d66d0640dfc4 100644 --- a/src/main/java/org/etsi/osl/osom/lcm/LCMRulesExecutor.java +++ b/src/main/java/org/etsi/osl/osom/lcm/LCMRulesExecutor.java @@ -165,7 +165,7 @@ public class LCMRulesExecutor { ApplicationHome home = new ApplicationHome(LCMRulesExecutor.class); File classesJar = home.getSource(); - if ( classesJar.exists() ) { + if ( classesJar != null && classesJar.exists() ) { optionList.addAll(Arrays.asList("-classpath", classesJar.getAbsoluteFile().toString().replace("-exec", "") )); } logger.debug("classesJar = "+ classesJar); @@ -213,7 +213,7 @@ public class LCMRulesExecutor { URL[] classpath = new URL[] { temp.toUri().toURL() }; - if ( classesJar.exists() ) { + if ( classesJar != null && classesJar.exists() ) { classpath = new URL[] { temp.toUri().toURL(), classesJar.toURI().toURL() }; } logger.debug("classpath = "+ classpath.toString()); diff --git a/src/main/java/org/etsi/osl/osom/lcm/LCMRulesExecutorVariables.java b/src/main/java/org/etsi/osl/osom/lcm/LCMRulesExecutorVariables.java index 198e5b3f1b86c237597c1225990d79515da75029..312490ca7788de280a8e6981a347bf39b050b6af 100644 --- a/src/main/java/org/etsi/osl/osom/lcm/LCMRulesExecutorVariables.java +++ b/src/main/java/org/etsi/osl/osom/lcm/LCMRulesExecutorVariables.java @@ -28,7 +28,7 @@ public class LCMRulesExecutorVariables { private Service service; private List compileDiagnosticErrors; private ServiceOrderManager serviceOrderManager; - private Map outParams; + private Map > outParams; /** * @param spec @@ -50,6 +50,7 @@ public class LCMRulesExecutorVariables { this.service = serviceInstance; this.serviceOrderManager = aServiceOrderManager; this.compileDiagnosticErrors = new ArrayList<>(); - this.outParams = new HashMap(); + + this.outParams = new HashMap<>(); } } diff --git a/src/main/java/org/etsi/osl/osom/lcm/LcmBaseExecutor.java b/src/main/java/org/etsi/osl/osom/lcm/LcmBaseExecutor.java index 585b5d0a700ead4d8cfbac1ff79b362658083150..7e7025a8e3f8afa93637d2e72bb42b33722c70b7 100644 --- a/src/main/java/org/etsi/osl/osom/lcm/LcmBaseExecutor.java +++ b/src/main/java/org/etsi/osl/osom/lcm/LcmBaseExecutor.java @@ -1,7 +1,10 @@ package org.etsi.osl.osom.lcm; import java.io.IOException; +import java.time.OffsetDateTime; +import java.time.ZoneOffset; import java.util.ArrayList; +import java.util.HashMap; import java.util.List; import java.util.Optional; import java.util.function.Consumer; @@ -27,6 +30,8 @@ import org.etsi.osl.tmf.lcm.model.LCMRuleSpecification; import org.etsi.osl.tmf.prm669.model.RelatedParty; import org.etsi.osl.tmf.scm633.model.ServiceSpecRelationship; import org.etsi.osl.tmf.sim638.model.Service; +import org.etsi.osl.tmf.sim638.model.ServiceCreate; +import org.etsi.osl.tmf.sim638.model.ServiceUpdate; import org.etsi.osl.tmf.so641.model.ServiceOrder; import org.etsi.osl.tmf.so641.model.ServiceOrderCreate; import org.etsi.osl.tmf.so641.model.ServiceOrderItemRelationship; @@ -391,8 +396,10 @@ public abstract class LcmBaseExecutor { System.out.println("============================================================================= \n"); - System.out.println("The value length is apayload= \n" + apayload.length()); - System.out.println("The value is apayload= \n" + apayload); + System.out.println("The value is apayload= \n" + apayload); + if (apayload!=null) { + System.out.println("The value length is apayload= \n" + apayload.length()); + } System.out.println("============================================================================= \n"); if (baseurl != null) { @@ -788,11 +795,152 @@ public abstract class LcmBaseExecutor { return ""; } + + + + /** + * Set the value to a characteristics of a referenced service + * @param serviceName the name of the service reference + * @param characteristics map with name.value + * @param value + */ + public void setServiceRefCharacteristicsValues(String serviceName, HashMap charvals) { + + //logger.debug( String.format( "setServiceRefPropValue %s %s %s ", serviceName, characteristicName, value ) ); + logger.debug( String.format( "setServiceRefCharacteristicsValues for %s ", serviceName ) ); + + Service ctxService = this.vars.getService(); + + if (ctxService == null) { + ServiceCreate scre = this.vars.getServiceToCreate(); + if (scre != null) { + for (String charname : charvals.keySet()) { + setCharacteristicOfCurrentService( serviceName + "::" + charname, charvals.get(charname) ); + } + } + return; + } + + @NotNull @Valid ServiceRef refSrvice = null; + + for (ServiceRef sr : ctxService.getSupportingService()) { + if ( sr.getName().equals(serviceName) ) { + refSrvice = sr; + break; + } + } + + + if (refSrvice == null) { + return; + } + + if (this.vars.getServiceOrderManager() != null) { + Service aService = this.vars.getServiceOrderManager().retrieveService(refSrvice.getId()); + if (aService != null) { + + ServiceUpdate supd = new ServiceUpdate(); + Note n = new Note(); + n.setAuthor("LCMRULE " + this.lcmspec.getName()); + n.setDate(OffsetDateTime.now(ZoneOffset.UTC).toString()); + String note = ""; + for (String charname : charvals.keySet()) { + setCharacteristicOfCurrentService( serviceName + "::" + charname, charvals.get(charname) ); + + Characteristic servicecrspecLast = aService.getServiceCharacteristicByName(charname); + if (servicecrspecLast != null) { + servicecrspecLast.getValue().setValue( charvals.get(charname) ); + supd.addServiceCharacteristicItem(servicecrspecLast); + note += charname + "=" + charvals.get(charname)+ ", "; + } + } + + + n.setText( String.format( "New characterisictic values for ServiceRef %s: %s" , serviceName, note )); + supd.addNoteItem(n); + this.vars.getServiceOrderManager().updateService(aService.getId(), supd, true); + + } + + } + + } + +// /** +// * Set the value to a characteristic of a referenced service +// * @param serviceName the name of the service reference +// * @param characteristicName +// * @param value +// */ +// public void setServiceRefPropValue( String serviceName, String characteristicName, String value ) { +// logger.debug( String.format( "setServiceRefPropValue %s %s %s ", serviceName, characteristicName, value ) ); +// Service ctxService = this.vars.getService(); +// +// +// if (ctxService == null) { +// ServiceCreate scre = this.vars.getServiceToCreate(); +// if (scre != null) { +// setCharacteristicOfCurrentService( serviceName + "::" + characteristicName, value); +// } +// return; +// } +// +// +// +// +// +// +// @NotNull @Valid ServiceRef refSrvice = null; +// +// for (ServiceRef sr : ctxService.getSupportingService()) { +// if ( sr.getName().equals(serviceName) ) { +// refSrvice = sr; +// break; +// } +// } +// +// +// setCharacteristicOfCurrentService( serviceName + "::" + characteristicName, value); +// +// if (refSrvice == null) { +// return; +// } +// +// if (this.vars.getServiceOrderManager() != null) { +// Service aService = this.vars.getServiceOrderManager().retrieveService(refSrvice.getId()); +// if (aService != null) { +// +// ServiceUpdate supd = new ServiceUpdate(); +// +// Characteristic servicecrspecLast = +// aService.getServiceCharacteristicByName(characteristicName); +// if (servicecrspecLast != null) { +// servicecrspecLast.getValue().setValue(value); +// supd.addServiceCharacteristicItem(servicecrspecLast); +// Note n = new Note(); +// n.setAuthor("LCMRULE " + this.lcmspec.getName()); +// n.setDate(OffsetDateTime.now(ZoneOffset.UTC).toString()); +// n.setText("Set new value (" + value + ") to ref Service (" + serviceName +// + ") Characteristic: " + characteristicName); +// supd.addNoteItem(n); +// this.vars.getServiceOrderManager().updateService(aService.getId(), supd, true); +// +// +// } +// +// } +// +// } +// +// } - //createServiceRefIf("Bundle B", getServiceRefPropValue("BundleA", "state", "").equals("active")==true); - public boolean createServiceRefIf(String serviceName, boolean b) { + + + + //createServiceRefIf("Bundle B", getServiceRefPropValue("BundleA", "state", "").equals("active")==true); + public boolean createServiceRefIf(String serviceName, boolean b, HashMap charvals) { logger.debug( String.format("createServiceRefwhen serviceName=%s = %s", serviceName, b ) ); @@ -806,7 +954,8 @@ public abstract class LcmBaseExecutor { if (serviceIDToCheckDependcy != null) { - this.vars.getOutParams().put( serviceIDToCheckDependcy, Boolean.toString(b) ); + charvals.put("_CREATESERVICEREF_", Boolean.toString(b)); + this.vars.getOutParams().put( serviceIDToCheckDependcy, charvals ); } return false; diff --git a/src/main/java/org/etsi/osl/osom/management/CROrchestrationCheckDeploymentService.java b/src/main/java/org/etsi/osl/osom/management/CROrchestrationCheckDeploymentService.java index 6c4f15e3b148da713174a840276ab548d85cec85..8d036fe08f7360d1b018579af19d5c4de45e803a 100644 --- a/src/main/java/org/etsi/osl/osom/management/CROrchestrationCheckDeploymentService.java +++ b/src/main/java/org/etsi/osl/osom/management/CROrchestrationCheckDeploymentService.java @@ -95,7 +95,7 @@ public class CROrchestrationCheckDeploymentService implements JavaDelegate { } @Valid - ServiceStateType currentState = aService.getState(); + ServiceStateType currentState = aService.getState(); ServiceStateType nextState = aService.findNextStateBasedOnSupportingResources(rlist); diff --git a/src/main/java/org/etsi/osl/osom/management/CreateReservedService.java b/src/main/java/org/etsi/osl/osom/management/CreateReservedService.java index 9feeb411350468f2d3d123cffa66373089b81cc6..d545ff922ec40dafbf9358a270b0ff2eeee5538c 100644 --- a/src/main/java/org/etsi/osl/osom/management/CreateReservedService.java +++ b/src/main/java/org/etsi/osl/osom/management/CreateReservedService.java @@ -3,7 +3,9 @@ package org.etsi.osl.osom.management; import java.time.OffsetDateTime; import java.time.ZoneOffset; import java.util.ArrayList; +import java.util.HashMap; import java.util.List; +import java.util.Map; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.etsi.osl.osom.lcm.LCMRulesController; @@ -96,9 +98,16 @@ public class CreateReservedService implements JavaDelegate { logger.debug("Retrieved Service ID:" + spec.getId()); logger.debug("Retrieved Service Name:" + spec.getName()); + //this map contains as key the id of the serviceSpecs to be created + //and as value a Map of initial characteristics and their values + Map> tobeCreatedInitialCharValues = new HashMap<>(); + + if ( execution.getVariable("serviceSpecsToCreateInitialCharValues") != null ) { + tobeCreatedInitialCharValues = (Map>) execution.getVariable("serviceSpecsToCreateInitialCharValues"); + } //this is a main underlying service for the requested service (restriction) - Service createdUnderlService = addServicesToVariables( spec, sor, soi, parentService ); + Service createdUnderlService = addServicesToVariables( spec, sor, soi, parentService, tobeCreatedInitialCharValues ); soi.getService().setState( ServiceStateType.RESERVED ); soi.setState(ServiceOrderStateType.INPROGRESS); @@ -145,11 +154,12 @@ public class CreateReservedService implements JavaDelegate { * @param servicesHandledByNFVOAutomated * @param servicesLocallyAutomated * @param parentService + * @param tobeCreatedInitialCharValues * @return */ private Service addServicesToVariables(ServiceSpecification specrel, ServiceOrder sor, ServiceOrderItem soi, - Service parentService) { + Service parentService, Map> tobeCreatedInitialCharValues) { logger.debug("\tService spec name :" + specrel.getName()); logger.debug("\tService spec type :" + specrel.getType()); @@ -159,25 +169,23 @@ public class CreateReservedService implements JavaDelegate { if ( partnerOrg != null ) { - createdServ = createServiceByServiceSpec(sor, soi, specrel, EServiceStartMode.AUTOMATICALLY_MANAGED, partnerOrg, parentService); - - + createdServ = createServiceByServiceSpec(sor, soi, specrel, EServiceStartMode.AUTOMATICALLY_MANAGED, partnerOrg, parentService, tobeCreatedInitialCharValues); } else if (specrel.getType().equals("ResourceFacingServiceSpecification")) { - createdServ = createServiceByServiceSpec(sor, soi, specrel, EServiceStartMode.AUTOMATICALLY_MANAGED, null, parentService); + createdServ = createServiceByServiceSpec(sor, soi, specrel, EServiceStartMode.AUTOMATICALLY_MANAGED, null, parentService, tobeCreatedInitialCharValues); } else if ( specrel.getType().equals("CustomerFacingServiceSpecification") && (specrel.isIsBundle()!=null) && specrel.isIsBundle() ) { - createdServ = createServiceByServiceSpec(sor, soi, specrel, EServiceStartMode.AUTOMATICALLY_MANAGED, null, parentService); + createdServ = createServiceByServiceSpec(sor, soi, specrel, EServiceStartMode.AUTOMATICALLY_MANAGED, null, parentService, tobeCreatedInitialCharValues); } else if ( specrel.getType().equals("CustomerFacingServiceSpecification") && (specrel.findSpecCharacteristicByName("OSAUTOMATED") != null ) ) { - createdServ = createServiceByServiceSpec(sor, soi, specrel, EServiceStartMode.AUTOMATICALLY_MANAGED, null, parentService); + createdServ = createServiceByServiceSpec(sor, soi, specrel, EServiceStartMode.AUTOMATICALLY_MANAGED, null, parentService, tobeCreatedInitialCharValues); } else if ( specrel.getType().equals("CustomerFacingServiceSpecification") && (specrel.findSpecCharacteristicByName("testSpecRef") != null ) ) { - createdServ = createServiceByServiceSpec(sor, soi, specrel, EServiceStartMode.AUTOMATICALLY_MANAGED, null, parentService); + createdServ = createServiceByServiceSpec(sor, soi, specrel, EServiceStartMode.AUTOMATICALLY_MANAGED, null, parentService, tobeCreatedInitialCharValues); } else { - createdServ = createServiceByServiceSpec(sor, soi, specrel, EServiceStartMode.MANUALLY_BY_SERVICE_PROVIDER, null, parentService); + createdServ = createServiceByServiceSpec(sor, soi, specrel, EServiceStartMode.MANUALLY_BY_SERVICE_PROVIDER, null, parentService, tobeCreatedInitialCharValues); } //add now the serviceRef @@ -228,16 +236,20 @@ public class CreateReservedService implements JavaDelegate { } - + /** * @param sor - * @param soi + * @param soi * @param spec - * @return + * @param startMode + * @param partnerOrg + * @param parentService + * @param tobeCreatedInitialCharValues + * @return */ private Service createServiceByServiceSpec(ServiceOrder sor, ServiceOrderItem soi, ServiceSpecification spec, EServiceStartMode startMode, - RelatedParty partnerOrg, Service parentService) { + RelatedParty partnerOrg, Service parentService, Map> tobeCreatedInitialCharValues) { ServiceCreate serviceToCreate = new ServiceCreate(); String servicename = spec.getName(); @@ -284,15 +296,33 @@ public class CreateReservedService implements JavaDelegate { } } + //this map contains as key the id of the serviceSpecs to be created + //and as value a Map of initial characteristics and their values + Map initCharValues = tobeCreatedInitialCharValues.get( spec.getId() ); + //we need to be careful here with the bundle and the related Service Specs, to properly propagate the rules inside //first copy into the newly created service any characteristic values from the order for (ServiceSpecCharacteristic c : spec.getServiceSpecCharacteristic()) { boolean characteristicFound = false; + + //pass any initial value. This has high priority + if ( initCharValues != null ) { + if ( initCharValues.get( c.getName() ) != null ) { + Characteristic orderCharacteristic = new Characteristic() + .value( new Any( initCharValues.get( c.getName() ), initCharValues.get( c.getName() ))) ; + serviceToCreate.addServiceCharacteristicItem( helperCreateCharacteristicItem(c, orderCharacteristic ) ); + characteristicFound = true; + continue; + + } + } + + for (Characteristic orderCharacteristic : soi.getService().getServiceCharacteristic()) { String specCharacteristicToSearch = spec.getName() + "::" +c.getName(); if ( orderCharacteristic.getName().equals( specCharacteristicToSearch )) { //copy only characteristics that are related from the order - serviceToCreate.addServiceCharacteristicItem( addServiceCharacteristicItem(c, orderCharacteristic) ); + serviceToCreate.addServiceCharacteristicItem( helperCreateCharacteristicItem(c, orderCharacteristic) ); characteristicFound = true; break; } @@ -303,7 +333,7 @@ public class CreateReservedService implements JavaDelegate { String specCharacteristicToSearch = c.getName(); if ( orderCharacteristic.getName().equals( specCharacteristicToSearch )) { //copy only characteristics that are related from the order - serviceToCreate.addServiceCharacteristicItem( addServiceCharacteristicItem(c, orderCharacteristic) ); + serviceToCreate.addServiceCharacteristicItem( helperCreateCharacteristicItem(c, orderCharacteristic) ); characteristicFound = true; break; } @@ -311,6 +341,8 @@ public class CreateReservedService implements JavaDelegate { } + + } if ( serviceToCreate.getServiceCharacteristic() == null ) { @@ -329,7 +361,7 @@ public class CreateReservedService implements JavaDelegate { } } } - + //also add parent service as relationship to parent ServiceRelationship srelationship = new ServiceRelationship(); @@ -385,7 +417,7 @@ public class CreateReservedService implements JavaDelegate { return null; } - private Characteristic addServiceCharacteristicItem(ServiceSpecCharacteristic c, Characteristic orderCharacteristic) { + private Characteristic helperCreateCharacteristicItem(ServiceSpecCharacteristic c, Characteristic orderCharacteristic) { Characteristic serviceCharacteristicItem = new Characteristic(); serviceCharacteristicItem.setName( c.getName() ); serviceCharacteristicItem.setValueType( c.getValueType() ); diff --git a/src/main/java/org/etsi/osl/osom/management/NFVOrchestrationCheckDeploymentService.java b/src/main/java/org/etsi/osl/osom/management/NFVOrchestrationCheckDeploymentService.java index e81aab1f84dcc4fd1097f291f4200717c9f038b7..021458906cc013f11966313a0d33d972e2951439 100644 --- a/src/main/java/org/etsi/osl/osom/management/NFVOrchestrationCheckDeploymentService.java +++ b/src/main/java/org/etsi/osl/osom/management/NFVOrchestrationCheckDeploymentService.java @@ -87,7 +87,7 @@ public class NFVOrchestrationCheckDeploymentService implements JavaDelegate { ServiceUpdate supd = new ServiceUpdate(); boolean aVNFINDEXREFadded = false; - boolean propagateToSO = false; + boolean triggerServiceActionQueue = false; if ( aService.getServiceCharacteristic() != null ) { for (Characteristic c : aService.getServiceCharacteristic()) { @@ -103,17 +103,17 @@ public class NFVOrchestrationCheckDeploymentService implements JavaDelegate { c.setValue( new Any( dd.getInstanceId() + "" )); } else if ( c.getName().equals("NSR")) { c.setValue( new Any( dd.getNsr() + "" )); - propagateToSO = true; + triggerServiceActionQueue = true; } else if ( c.getName().equals("NSLCM")) { c.setValue( new Any( dd.getNs_nslcm_details() + "" )); - propagateToSO = true; + triggerServiceActionQueue = true; } if ( dd.getDeploymentDescriptorVxFInstanceInfo() !=null ) { for ( DeploymentDescriptorVxFInstanceInfo vnfinfo : dd.getDeploymentDescriptorVxFInstanceInfo() ) { if ( c.getName().equals( "VNFINDEXREF_INFO_" + vnfinfo.getMemberVnfIndexRef() )) { c.setValue( new Any( vnfinfo.getVxfInstanceInfo() + "" )); aVNFINDEXREFadded = true; - propagateToSO = true; + triggerServiceActionQueue = true; } } @@ -153,7 +153,7 @@ public class NFVOrchestrationCheckDeploymentService implements JavaDelegate { supd.setState( ServiceStateType.TERMINATED ); } - Service serviceResult = serviceOrderManager.updateService( aService.getId(), supd, propagateToSO ); + Service serviceResult = serviceOrderManager.updateService( aService.getId(), supd, triggerServiceActionQueue ); if ( serviceResult!= null ) { if ( serviceResult.getState().equals(ServiceStateType.ACTIVE) diff --git a/src/main/java/org/etsi/osl/osom/management/ProcessCreateServiceRules.java b/src/main/java/org/etsi/osl/osom/management/ProcessCreateServiceRules.java index 872cf39e394606e3455aa4b8142c26cbbd29d082..8aa8166bf849b3dfeea36ce6db582bbb4aad9f81 100644 --- a/src/main/java/org/etsi/osl/osom/management/ProcessCreateServiceRules.java +++ b/src/main/java/org/etsi/osl/osom/management/ProcessCreateServiceRules.java @@ -48,6 +48,9 @@ public class ProcessCreateServiceRules implements JavaDelegate { execution.setVariable("allSupportingServicesCreated", allSupportingServicesCreated ); //by default + + + Service contextService = null; String contextServiceId = (String) execution.getVariable("contextServiceId"); if ( contextServiceId != null ) { @@ -69,29 +72,18 @@ public class ProcessCreateServiceRules implements JavaDelegate { * first find all referenced ServiceSpecs of a ServiceSpec to be created */ boolean foundCreatedButNOTACTIVEServices = false; - Map tobeCreated = new HashMap<>(); + + //this map contains as key the id of the serviceSpecs to be created + //and as value a Map of initial characteristics and their values + Map> tobeCreated = new HashMap<>(); + for (ServiceSpecRelationship specRels : spec.getServiceSpecRelationship()) { logger.debug("\tService specRelsId:" + specRels.getId()); - tobeCreated.put(specRels.getId(), true); + tobeCreated.put(specRels.getId(), null); } - for ( ServiceRef serviceRef: contextService.getSupportingService() ) { - - Service theServiceReferenced = serviceOrderManager.retrieveService( serviceRef.getId() ); - - if ( tobeCreated.get(theServiceReferenced.getServiceSpecificationRef().getId() ) != null ) { - tobeCreated.put( theServiceReferenced.getServiceSpecificationRef().getId(), false); - } - - if ( theServiceReferenced != null ) { - if ( theServiceReferenced.getState().equals( ServiceStateType.RESERVED) ) { - foundCreatedButNOTACTIVEServices = true; - } - } - - } /** @@ -123,20 +115,45 @@ public class ProcessCreateServiceRules implements JavaDelegate { for (String serviceId : vars.getOutParams().keySet()) { if ( vars.getOutParams().get(serviceId) !=null) { - if ( vars.getOutParams().get(serviceId).equals( "true") ) { - tobeCreated.put( serviceId, true && tobeCreated.get(serviceId) ); - } else { - tobeCreated.put( serviceId, false); - allSupportingServicesCreated = false; - } + + + if ( vars.getOutParams().get(serviceId) != null && vars.getOutParams().get(serviceId).get("_CREATESERVICEREF_") !=null) { + + if ( vars.getOutParams().get(serviceId).get("_CREATESERVICEREF_").equals( "true") ) { + vars.getOutParams().get(serviceId).remove( "_CREATESERVICEREF_" ); + HashMap myChars = new HashMap< String , String >( vars.getOutParams().get(serviceId) ); + tobeCreated.put( serviceId, myChars ); + } else { + tobeCreated.remove( serviceId); + allSupportingServicesCreated = false; + } + } + } } + + + //now compare those to be created, with those already created + for ( ServiceRef serviceRef: contextService.getSupportingService() ) { + Service theServiceReferenced = serviceOrderManager.retrieveService( serviceRef.getId() ); + if ( tobeCreated.containsKey(theServiceReferenced.getServiceSpecificationRef().getId() ) ) { + tobeCreated.remove( theServiceReferenced.getServiceSpecificationRef().getId()); + } + + if ( theServiceReferenced != null ) { + if ( theServiceReferenced.getState().equals( ServiceStateType.RESERVED) ) { + foundCreatedButNOTACTIVEServices = true; + } + } + + } + serviceOrderManager.updateService( contextService.getId() , supd, false); //update context service List servicesToCreate = new ArrayList<>(); for (String specid : tobeCreated.keySet()) { - if ( tobeCreated.get(specid) ) { + if ( tobeCreated.containsKey(specid) ) { servicesToCreate.add(specid); allSupportingServicesCreated = false; } @@ -161,11 +178,21 @@ public class ProcessCreateServiceRules implements JavaDelegate { } + if ( contextService.getState().equals( ServiceStateType.INACTIVE ) || contextService.getState().equals( ServiceStateType.TERMINATED ) ) { + allSupportingServicesCreatedAndActive = true; + allSupportingServicesCreated = true; + // this will help us to avoid a deadlock if a failure occurs + } + execution.setVariable("allSupportingServicesCreated", allSupportingServicesCreated ); execution.setVariable("allSupportingServicesCreatedAndActive", allSupportingServicesCreatedAndActive && allSupportingServicesCreated ); //by default execution.setVariable("parentServiceId", contextServiceId); - execution.setVariable("serviceSpecsToCreate", servicesToCreate); + execution.setVariable("serviceSpecsToCreate", servicesToCreate); + execution.setVariable("serviceSpecsToCreateInitialCharValues", tobeCreated); + + + } diff --git a/src/main/java/org/etsi/osl/osom/management/ServiceOrderManager.java b/src/main/java/org/etsi/osl/osom/management/ServiceOrderManager.java index 86fb199ed59521d9af7c64df888d3cb35d1bbf9e..6290743ba0d1e9f690c0fd62db7134e3f611de1e 100644 --- a/src/main/java/org/etsi/osl/osom/management/ServiceOrderManager.java +++ b/src/main/java/org/etsi/osl/osom/management/ServiceOrderManager.java @@ -448,16 +448,16 @@ public class ServiceOrderManager { /** * @param serviceId * @param s - * @param propagateToSO is a cryptic thing. However it is used as follows: if FALSE, to just update the service status in catalog without further taking any action. + * @param triggerServiceActionQueue is a cryptic thing. However it is used as follows: if FALSE, to just update the service status in catalog without further taking any action. * if TRUE then the ServiceUpdate will trigger a ServiceActionQueue to further process the update. So this is needed to avoid these kinds of deadlocks * @return */ - public org.etsi.osl.tmf.sim638.model.Service updateService(String serviceId, ServiceUpdate s, boolean propagateToSO) { + public org.etsi.osl.tmf.sim638.model.Service updateService(String serviceId, ServiceUpdate s, boolean triggerServiceActionQueue) { logger.info("will update Service : " + serviceId ); try { Map map = new HashMap<>(); map.put("serviceid", serviceId ); - map.put("propagateToSO", propagateToSO ); + map.put("triggerServiceActionQueue", triggerServiceActionQueue ); Object response = template.requestBodyAndHeaders( CATALOG_UPD_SERVICE, toJsonString(s), map); diff --git a/src/main/java/org/etsi/osl/osom/serviceactions/ServiceActionCheck.java b/src/main/java/org/etsi/osl/osom/serviceactions/ServiceActionCheck.java index c375e3766d304a751411e8391b8c9e57c55b1959..00269a8028cf3396f7fa0fcae647d740e4030a2d 100644 --- a/src/main/java/org/etsi/osl/osom/serviceactions/ServiceActionCheck.java +++ b/src/main/java/org/etsi/osl/osom/serviceactions/ServiceActionCheck.java @@ -79,7 +79,9 @@ public class ServiceActionCheck implements JavaDelegate { execution.setVariable("saction", "HandleActiveStateChanged"); } else if ( item.getAction().equals( ServiceActionQueueAction.EVALUATE_STATE_CHANGE_TOINACTIVE ) ) { execution.setVariable("saction", "HandleInactiveStateChanged"); - } else if ( item.getAction().equals( ServiceActionQueueAction.EVALUATE_CHARACTERISTIC_CHANGED ) || item.getAction().equals( ServiceActionQueueAction.EVALUATE_CHARACTERISTIC_CHANGED_MANODAY2 ) ) { + } else if ( item.getAction().equals( ServiceActionQueueAction.EVALUATE_CHARACTERISTIC_CHANGED ) + || item.getAction().equals( ServiceActionQueueAction.EVALUATE_CHILD_CHARACTERISTIC_CHANGED ) + || item.getAction().equals( ServiceActionQueueAction.EVALUATE_CHARACTERISTIC_CHANGED_MANODAY2 ) ) { execution.setVariable("saction", "HandleEvaluateService");// default diff --git a/src/main/resources/banner.txt b/src/main/resources/banner.txt new file mode 100644 index 0000000000000000000000000000000000000000..74229cd400fb31f76673214d76c0256f438e4ccc --- /dev/null +++ b/src/main/resources/banner.txt @@ -0,0 +1,11 @@ + ___ ____ _ _ + / _ \ _ __ ___ _ __ / ___|| (_) ___ ___ + | | | | '_ \ / _ \ '_ \\___ \| | |/ __/ _ \ + | |_| | |_) | __/ | | |___) | | | (_| __/ + \___/| .__/ \___|_| |_|____/|_|_|\___\___| + |_| + __ __________________ + / / __ __ / __/_ __/ __/ _/ + / _ \/ // / / _/ / / _\ \_/ / + /_.__/\_, / /___/ /_/ /___/___/ + /___/ \ No newline at end of file diff --git a/src/test/java/org/etsi/osl/osom/ProcessOrderIntegrationTest.java b/src/test/java/org/etsi/osl/osom/ProcessOrderIntegrationTest.java index 2ded0b1244b2803f2b55e216c35a902334970a8f..7ef1c9d633fb72b3140eb9fbb2c7cc46881a8616 100644 --- a/src/test/java/org/etsi/osl/osom/ProcessOrderIntegrationTest.java +++ b/src/test/java/org/etsi/osl/osom/ProcessOrderIntegrationTest.java @@ -181,7 +181,7 @@ public class ProcessOrderIntegrationTest { assertThat(spec).isInstanceOf(ServiceSpecification.class); assertThat(spec.getServiceSpecCharacteristic().size() ).isEqualTo(11); - assertThat(specCirros.getServiceSpecCharacteristic().size() ).isEqualTo(10); + assertThat(specCirros.getServiceSpecCharacteristic().size() ).isEqualTo(12); assertThat(sorder.getOrderItem().stream().findFirst().get().getService().getServiceCharacteristic().size() ).isEqualTo(2); assertThat(repositoryService.createProcessDefinitionQuery().count()).isEqualTo(15); @@ -224,15 +224,17 @@ public class ProcessOrderIntegrationTest { assertThat( aservice ).isNotNull(); assertThat( aservice.getServiceCharacteristic().size() ).isEqualTo(11); assertThat( aserviceCirros ).isNotNull(); - assertThat( aserviceCirros.getServiceCharacteristic().size() ).isEqualTo(10); + assertThat( aserviceCirros.getServiceCharacteristic().size() ).isEqualTo(12); assertThat( aservice.getServiceCharacteristicByName("Quality Class").getValue().getValue() ).isEqualTo( "1" ); assertThat( aservice.getServiceCharacteristicByName("cirros_2vnf_ns::OSM_CONFIG").getValue().getValue() ).contains( "eeeeeeee-8219-4580-9697-bf4a8f0a08f9" ); assertThat( aservice.getServiceCharacteristicByName("cirros_2vnf_ns::SSHKEY").getValue().getValue() ).isEqualTo( "MCKEYTESTINORDERExampleConcatSSHKEY_EnhancedByRule" ); //check that the cirros_2vnf_ns::SSHKEY value from the service order has been passed properly to the related RFS service assertThat( aserviceCirros.getServiceCharacteristicByName("OSM_CONFIG").getValue().getValue() ).contains( "eeeeeeee-8219-4580-9697-bf4a8f0a08f9" ); - assertThat( aserviceCirros.getServiceCharacteristicByName("SSHKEY").getValue().getValue() ).isEqualTo( "MCKEYTESTINORDERExampleConcatSSHKEY_EnhancedByRule" ); - + assertThat( aserviceCirros.getServiceCharacteristicByName("SSHKEY").getValue().getValue() ).isEqualTo( "MCKEYTESTINORDERExampleConcatSSHKEY_EnhancedByRule" ); + assertThat( aserviceCirros.getServiceCharacteristicByName("AProgrammaticChar").getValue().getValue() ).isEqualTo( "AProgrammaticNSDIDValue" ); + assertThat( aserviceCirros.getServiceCharacteristicByName("Another ProgrammaticChar").getValue().getValue() ).isEqualTo( "AnotherValue" ); + //we will further check LCM rules! diff --git a/src/test/java/org/etsi/osl/osom/SCMocked.java b/src/test/java/org/etsi/osl/osom/SCMocked.java index d048d8841828be3f2f2eea12578b86ad884b429b..f4b391d55bef6e916c740f67efdb5c39120cf0b3 100644 --- a/src/test/java/org/etsi/osl/osom/SCMocked.java +++ b/src/test/java/org/etsi/osl/osom/SCMocked.java @@ -222,7 +222,12 @@ public class SCMocked { InputStream in = new FileInputStream( sspec ); sspectext = IOUtils.toString(in, "UTF-8"); return sspectext; - } + } else if ( id.equals("89e027b5-24a9-4db7-b422-a963c9feeb7a") ) { + File sspec = new File( "src/test/resources/LcmCirrosRule1Test_CREATION.json" ); + InputStream in = new FileInputStream( sspec ); + sspectext = IOUtils.toString(in, "UTF-8"); + return sspectext; + } @@ -241,13 +246,24 @@ public class SCMocked { String sspectext = null; - if ( specid.equals("f2b74f90-4140-4895-80d1-ef243398117b") ) { - File sspec = new File( "src/test/resources/LcmRuleListSpecTest.json" ); - InputStream in = new FileInputStream( sspec ); - sspectext = IOUtils.toString(in, "UTF-8"); - return sspectext; - - } + if ( phaseName.equals("PRE_PROVISION") ) { + if ( specid.equals("f2b74f90-4140-4895-80d1-ef243398117b") ) { + File sspec = new File( "src/test/resources/LcmRuleListSpecTest.json" ); + InputStream in = new FileInputStream( sspec ); + sspectext = IOUtils.toString(in, "UTF-8"); + return sspectext; + + } + } else if ( phaseName.equals("CREATION") ) { + if ( specid.equals("f2b74f90-4140-4895-80d1-ef243398117b") ) { + File sspec = new File( "src/test/resources/LcmRuleListSpecTest_CREATION.json" ); + InputStream in = new FileInputStream( sspec ); + sspectext = IOUtils.toString(in, "UTF-8"); + return sspectext; + + + } + } return "[]"; diff --git a/src/test/resources/LcmCirrosRule1Test_CREATION.json b/src/test/resources/LcmCirrosRule1Test_CREATION.json new file mode 100644 index 0000000000000000000000000000000000000000..591a7fddfe5f58dc6508e047a9427f996cfa52d4 --- /dev/null +++ b/src/test/resources/LcmCirrosRule1Test_CREATION.json @@ -0,0 +1,31 @@ +{ + "uuid": "40f027b5-24a9-4db7-b422-a963c9feeb7a", + "lastUpdate": null, + "@baseType": "BaseRootEntity", + "@schemaLocation": null, + "@type": "BaseEntity", + "href": null, + "name": "OSM config depending on class", + "description": "LCM Rule for specification Cirros Test OSM config depending on class", + "lifecycleStatus": "In study", + "version": null, + "validFor": null, + "id": "40f027b5-24a9-4db7-b422-a963c9feeb7a", + "lcmrulephase": "CREATION", + "content": "EQQuality Class2cirros_2vnf_ns::OSM_CONFIG0b6853fc-8219-4580-9697-bf4a8f0a08f9c224eb48-419e-4097-8a1d-11ec1bba087fEQQuality Class1cirros_2vnf_ns::OSM_CONFIGeeeeeeee-8219-4580-9697-bf4a8f0a08f9eeeeeeee-419e-4097-8a1d-11ec1bba087fcirros_2vnf_ns::OSM_CONFIGcccccccc-8219-4580-9697-bf4a8f0a08f9cccccccc-419e-4097-8a1d-11ec1bba087f", + "code": "{\r\n java.util.HashMap charvals = new java.util.HashMap<>();\r\n charvals.put(\"AProgrammaticChar\",\"AProgrammaticNSDIDValue\");\r\n charvals.put(\"Another ProgrammaticChar\",\"AnotherValue\");\r\n createServiceRefIf(\"cirros_2vnf_ns\", !(getCharValFromStringType(\"cirros_2vnf_ns::PackagingFormat\").equals(\"\")==true), charvals);\r\n }", + + "serviceSpecs": [ + { + "@baseType": "BaseEntity", + "@schemaLocation": null, + "@type": null, + "href": null, + "name": "Cirros Test", + "version": null, + "targetServiceSchema": null, + "@referredType": null, + "id": "f2b74f90-4140-4895-80d1-ef243398117b" + } + ] +} \ No newline at end of file diff --git a/src/test/resources/LcmRuleListSpecTest_CREATION.json b/src/test/resources/LcmRuleListSpecTest_CREATION.json new file mode 100644 index 0000000000000000000000000000000000000000..70d831ff9745b75eba91b09121d23755d1fcc4a4 --- /dev/null +++ b/src/test/resources/LcmRuleListSpecTest_CREATION.json @@ -0,0 +1,9 @@ +[ + { + "uuid": "89e027b5-24a9-4db7-b422-a963c9feeb7a", + "id": "89e027b5-24a9-4db7-b422-a963c9feeb7a", + "name": "OSM config depending on class", + "description": "LCM Rule for specification Cirros Test OSM config depending on class", + "lcmrulephase": "CREATION" + } +] \ No newline at end of file diff --git a/src/test/resources/cirros_2vnf_ns_RFS.json b/src/test/resources/cirros_2vnf_ns_RFS.json index 9e6b49f9abc24fb49e8b8c842591331980345e05..1a4aea6710f0a32930970847e752a1d0ca92c1e7 100644 --- a/src/test/resources/cirros_2vnf_ns_RFS.json +++ b/src/test/resources/cirros_2vnf_ns_RFS.json @@ -499,6 +499,100 @@ }, "@valueSchemaLocation": null, "id": "5c50dbe4-42f9-4d12-bed9-987c75b592d6" + }, + { + "uuid": "3a50dbe4-42f9-4d12-bed9-987c75b592d6", + "@baseType": "BaseRootEntity", + "@schemaLocation": null, + "@type": "org.etsi.osl.tmf.scm633.model.ServiceSpecCharacteristic", + "href": null, + "name": "AProgrammaticChar", + "configurable": false, + "description": "AProgrammaticChar dscription", + "extensible": null, + "isUnique": null, + "maxCardinality": 1, + "minCardinality": 1, + "regex": null, + "valueType": "TEXT", + "serviceSpecCharRelationship": [], + "serviceSpecCharacteristicValue": [ + { + "uuid": "54e00574-6d22-4f48-8bd4-17884f895c13", + "@baseType": "BaseEntity", + "@schemaLocation": null, + "@type": null, + "href": null, + "isDefault": true, + "rangeInterval": null, + "regex": null, + "unitOfMeasure": "N/A", + "valueFrom": null, + "valueTo": null, + "valueType": null, + "validFor": { + "endDateTime": "2040-09-06T23:48:24+03:00", + "startDateTime": "2020-09-06T23:48:24+03:00" + }, + "value": { + "value": "xzzx", + "alias": "AliASAProgrammaticChar" + } + } + ], + "validFor": { + "endDateTime": "2040-09-06T23:48:24+03:00", + "startDateTime": "2020-09-06T23:48:24+03:00" + }, + "@valueSchemaLocation": null, + "id": "5c50dbe4-42f9-4d12-bed9-987c75b592d6" + }, + { + "uuid": "3a22dbe4-42f9-4d12-bed9-987c75b592d6", + "@baseType": "BaseRootEntity", + "@schemaLocation": null, + "@type": "org.etsi.osl.tmf.scm633.model.ServiceSpecCharacteristic", + "href": null, + "name": "Another ProgrammaticChar", + "configurable": false, + "description": "Another AProgrammaticChar dscription", + "extensible": null, + "isUnique": null, + "maxCardinality": 1, + "minCardinality": 1, + "regex": null, + "valueType": "TEXT", + "serviceSpecCharRelationship": [], + "serviceSpecCharacteristicValue": [ + { + "uuid": "54e00522-6d22-4f48-8bd4-17884f895c13", + "@baseType": "BaseEntity", + "@schemaLocation": null, + "@type": null, + "href": null, + "isDefault": true, + "rangeInterval": null, + "regex": null, + "unitOfMeasure": "N/A", + "valueFrom": null, + "valueTo": null, + "valueType": null, + "validFor": { + "endDateTime": "2040-09-06T23:48:24+03:00", + "startDateTime": "2020-09-06T23:48:24+03:00" + }, + "value": { + "value": "aawwaa", + "alias": "AliASAProgrammaticChar" + } + } + ], + "validFor": { + "endDateTime": "2040-09-06T23:48:24+03:00", + "startDateTime": "2020-09-06T23:48:24+03:00" + }, + "@valueSchemaLocation": null, + "id": "5c50dbe4-42f9-4d12-bed9-987c75b592d6" } ], "serviceSpecRelationship": [],