Loading src/main/java/org/etsi/osl/osom/lcm/LCMRulesExecutorVariables.java +3 −2 Original line number Diff line number Diff line Loading @@ -28,7 +28,7 @@ public class LCMRulesExecutorVariables { private Service service; private List<String> compileDiagnosticErrors; private ServiceOrderManager serviceOrderManager; private Map<String, String> outParams; private Map<String, Map<String, String> > outParams; /** * @param spec Loading @@ -50,6 +50,7 @@ public class LCMRulesExecutorVariables { this.service = serviceInstance; this.serviceOrderManager = aServiceOrderManager; this.compileDiagnosticErrors = new ArrayList<>(); this.outParams = new HashMap<String,String>(); this.outParams = new HashMap<>(); } } src/main/java/org/etsi/osl/osom/lcm/LcmBaseExecutor.java +3 −2 Original line number Diff line number Diff line Loading @@ -938,7 +938,7 @@ public abstract class LcmBaseExecutor { //createServiceRefIf("Bundle B", getServiceRefPropValue("BundleA", "state", "").equals("active")==true); public boolean createServiceRefIf(String serviceName, boolean b) { public boolean createServiceRefIf(String serviceName, boolean b, HashMap<String, String> charvals) { logger.debug( String.format("createServiceRefwhen serviceName=%s = %s", serviceName, b ) ); Loading @@ -952,7 +952,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; Loading src/main/java/org/etsi/osl/osom/management/CreateReservedService.java +49 −15 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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<String, Map<String,String>> tobeCreatedInitialCharValues = new HashMap<>(); if ( execution.getVariable("serviceSpecsToCreateInitialCharValues") != null ) { tobeCreatedInitialCharValues = (Map<String, Map<String, String>>) 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); Loading Loading @@ -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<String, Map<String, String>> tobeCreatedInitialCharValues) { logger.debug("\tService spec name :" + specrel.getName()); logger.debug("\tService spec type :" + specrel.getType()); Loading @@ -159,23 +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 Loading Loading @@ -231,11 +241,15 @@ public class CreateReservedService implements JavaDelegate { * @param sor * @param soi * @param spec * @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<String, Map<String, String>> tobeCreatedInitialCharValues) { ServiceCreate serviceToCreate = new ServiceCreate(); String servicename = spec.getName(); Loading Loading @@ -282,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<String, String> 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; break; } } 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; } Loading @@ -301,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; } Loading @@ -309,6 +341,8 @@ public class CreateReservedService implements JavaDelegate { } } if ( serviceToCreate.getServiceCharacteristic() == null ) { Loading Loading @@ -383,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() ); Loading src/main/java/org/etsi/osl/osom/management/ProcessCreateServiceRules.java +52 −25 Original line number Diff line number Diff line Loading @@ -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 ) { Loading @@ -69,29 +72,18 @@ public class ProcessCreateServiceRules implements JavaDelegate { * first find all referenced ServiceSpecs of a ServiceSpec to be created */ boolean foundCreatedButNOTACTIVEServices = false; Map<String, Boolean> tobeCreated = new HashMap<>(); for (ServiceSpecRelationship specRels : spec.getServiceSpecRelationship()) { logger.debug("\tService specRelsId:" + specRels.getId()); tobeCreated.put(specRels.getId(), true); } //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<String, Map<String,String>> tobeCreated = new HashMap<>(); for ( ServiceRef serviceRef: contextService.getSupportingService() ) { Service theServiceReferenced = serviceOrderManager.retrieveService( serviceRef.getId() ); if ( tobeCreated.get(theServiceReferenced.getServiceSpecificationRef().getId() ) != null ) { tobeCreated.put( theServiceReferenced.getServiceSpecificationRef().getId(), false); for (ServiceSpecRelationship specRels : spec.getServiceSpecRelationship()) { logger.debug("\tService specRelsId:" + specRels.getId()); tobeCreated.put(specRels.getId(), null); } if ( theServiceReferenced != null ) { if ( theServiceReferenced.getState().equals( ServiceStateType.RESERVED) ) { foundCreatedButNOTACTIVEServices = true; } } } /** Loading Loading @@ -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) ); 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<String, String> myChars = new HashMap< String , String >( vars.getOutParams().get(serviceId) ); tobeCreated.put( serviceId, myChars ); } else { tobeCreated.put( serviceId, false); 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<String> servicesToCreate = new ArrayList<>(); for (String specid : tobeCreated.keySet()) { if ( tobeCreated.get(specid) ) { if ( tobeCreated.get(specid) !=null ) { servicesToCreate.add(specid); allSupportingServicesCreated = false; } Loading @@ -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("serviceSpecsToCreateInitialCharValues", tobeCreated); } Loading Loading
src/main/java/org/etsi/osl/osom/lcm/LCMRulesExecutorVariables.java +3 −2 Original line number Diff line number Diff line Loading @@ -28,7 +28,7 @@ public class LCMRulesExecutorVariables { private Service service; private List<String> compileDiagnosticErrors; private ServiceOrderManager serviceOrderManager; private Map<String, String> outParams; private Map<String, Map<String, String> > outParams; /** * @param spec Loading @@ -50,6 +50,7 @@ public class LCMRulesExecutorVariables { this.service = serviceInstance; this.serviceOrderManager = aServiceOrderManager; this.compileDiagnosticErrors = new ArrayList<>(); this.outParams = new HashMap<String,String>(); this.outParams = new HashMap<>(); } }
src/main/java/org/etsi/osl/osom/lcm/LcmBaseExecutor.java +3 −2 Original line number Diff line number Diff line Loading @@ -938,7 +938,7 @@ public abstract class LcmBaseExecutor { //createServiceRefIf("Bundle B", getServiceRefPropValue("BundleA", "state", "").equals("active")==true); public boolean createServiceRefIf(String serviceName, boolean b) { public boolean createServiceRefIf(String serviceName, boolean b, HashMap<String, String> charvals) { logger.debug( String.format("createServiceRefwhen serviceName=%s = %s", serviceName, b ) ); Loading @@ -952,7 +952,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; Loading
src/main/java/org/etsi/osl/osom/management/CreateReservedService.java +49 −15 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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<String, Map<String,String>> tobeCreatedInitialCharValues = new HashMap<>(); if ( execution.getVariable("serviceSpecsToCreateInitialCharValues") != null ) { tobeCreatedInitialCharValues = (Map<String, Map<String, String>>) 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); Loading Loading @@ -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<String, Map<String, String>> tobeCreatedInitialCharValues) { logger.debug("\tService spec name :" + specrel.getName()); logger.debug("\tService spec type :" + specrel.getType()); Loading @@ -159,23 +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 Loading Loading @@ -231,11 +241,15 @@ public class CreateReservedService implements JavaDelegate { * @param sor * @param soi * @param spec * @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<String, Map<String, String>> tobeCreatedInitialCharValues) { ServiceCreate serviceToCreate = new ServiceCreate(); String servicename = spec.getName(); Loading Loading @@ -282,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<String, String> 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; break; } } 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; } Loading @@ -301,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; } Loading @@ -309,6 +341,8 @@ public class CreateReservedService implements JavaDelegate { } } if ( serviceToCreate.getServiceCharacteristic() == null ) { Loading Loading @@ -383,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() ); Loading
src/main/java/org/etsi/osl/osom/management/ProcessCreateServiceRules.java +52 −25 Original line number Diff line number Diff line Loading @@ -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 ) { Loading @@ -69,29 +72,18 @@ public class ProcessCreateServiceRules implements JavaDelegate { * first find all referenced ServiceSpecs of a ServiceSpec to be created */ boolean foundCreatedButNOTACTIVEServices = false; Map<String, Boolean> tobeCreated = new HashMap<>(); for (ServiceSpecRelationship specRels : spec.getServiceSpecRelationship()) { logger.debug("\tService specRelsId:" + specRels.getId()); tobeCreated.put(specRels.getId(), true); } //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<String, Map<String,String>> tobeCreated = new HashMap<>(); for ( ServiceRef serviceRef: contextService.getSupportingService() ) { Service theServiceReferenced = serviceOrderManager.retrieveService( serviceRef.getId() ); if ( tobeCreated.get(theServiceReferenced.getServiceSpecificationRef().getId() ) != null ) { tobeCreated.put( theServiceReferenced.getServiceSpecificationRef().getId(), false); for (ServiceSpecRelationship specRels : spec.getServiceSpecRelationship()) { logger.debug("\tService specRelsId:" + specRels.getId()); tobeCreated.put(specRels.getId(), null); } if ( theServiceReferenced != null ) { if ( theServiceReferenced.getState().equals( ServiceStateType.RESERVED) ) { foundCreatedButNOTACTIVEServices = true; } } } /** Loading Loading @@ -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) ); 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<String, String> myChars = new HashMap< String , String >( vars.getOutParams().get(serviceId) ); tobeCreated.put( serviceId, myChars ); } else { tobeCreated.put( serviceId, false); 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<String> servicesToCreate = new ArrayList<>(); for (String specid : tobeCreated.keySet()) { if ( tobeCreated.get(specid) ) { if ( tobeCreated.get(specid) !=null ) { servicesToCreate.add(specid); allSupportingServicesCreated = false; } Loading @@ -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("serviceSpecsToCreateInitialCharValues", tobeCreated); } Loading