Skip to content
Snippets Groups Projects
Commit e94f538c authored by tranoris's avatar tranoris
Browse files

changes to support parent child characteristics

parent 60789663
No related branches found
No related tags found
2 merge requests!12Merging 2024Q2_RC into main, creating 2024Q2 Release,!10Parent child characteristics
package org.etsi.osl.osom.lcm; package org.etsi.osl.osom.lcm;
import java.io.IOException; import java.io.IOException;
import java.time.OffsetDateTime;
import java.time.ZoneOffset;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Optional; import java.util.Optional;
import java.util.function.Consumer; import java.util.function.Consumer;
...@@ -27,6 +30,8 @@ import org.etsi.osl.tmf.lcm.model.LCMRuleSpecification; ...@@ -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.prm669.model.RelatedParty;
import org.etsi.osl.tmf.scm633.model.ServiceSpecRelationship; import org.etsi.osl.tmf.scm633.model.ServiceSpecRelationship;
import org.etsi.osl.tmf.sim638.model.Service; 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.ServiceOrder;
import org.etsi.osl.tmf.so641.model.ServiceOrderCreate; import org.etsi.osl.tmf.so641.model.ServiceOrderCreate;
import org.etsi.osl.tmf.so641.model.ServiceOrderItemRelationship; import org.etsi.osl.tmf.so641.model.ServiceOrderItemRelationship;
...@@ -788,10 +793,151 @@ public abstract class LcmBaseExecutor { ...@@ -788,10 +793,151 @@ public abstract class LcmBaseExecutor {
return ""; 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<String, String> 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);
//createServiceRefIf("Bundle B", getServiceRefPropValue("BundleA", "state", "").equals("active")==true);
public boolean createServiceRefIf(String serviceName, boolean b) { public boolean createServiceRefIf(String serviceName, boolean b) {
logger.debug( String.format("createServiceRefwhen serviceName=%s = %s", serviceName, b ) ); logger.debug( String.format("createServiceRefwhen serviceName=%s = %s", serviceName, b ) );
......
...@@ -67,7 +67,7 @@ public class CROrchestrationCheckDeploymentService implements JavaDelegate { ...@@ -67,7 +67,7 @@ public class CROrchestrationCheckDeploymentService implements JavaDelegate {
ServiceUpdate supd = new ServiceUpdate(); ServiceUpdate supd = new ServiceUpdate();
boolean propagateToSO = false; boolean triggerServiceActionQueue = false;
//retrieve the related supporting resource by id and check its status //retrieve the related supporting resource by id and check its status
//ResourceRef supresourceRef = aService.getSupportingResource().stream().findFirst().get();//we assume for now we have only one related resource //ResourceRef supresourceRef = aService.getSupportingResource().stream().findFirst().get();//we assume for now we have only one related resource
...@@ -84,7 +84,7 @@ public class CROrchestrationCheckDeploymentService implements JavaDelegate { ...@@ -84,7 +84,7 @@ public class CROrchestrationCheckDeploymentService implements JavaDelegate {
if ( res == null ) { if ( res == null ) {
supd.setState( ServiceStateType.TERMINATED); supd.setState( ServiceStateType.TERMINATED);
execution.setVariable("serviceDeploymentFinished", Boolean.TRUE); execution.setVariable("serviceDeploymentFinished", Boolean.TRUE);
Service serviceResult = serviceOrderManager.updateService( aService.getId(), supd, propagateToSO ); Service serviceResult = serviceOrderManager.updateService( aService.getId(), supd, triggerServiceActionQueue );
return; return;
} }
...@@ -145,7 +145,7 @@ public class CROrchestrationCheckDeploymentService implements JavaDelegate { ...@@ -145,7 +145,7 @@ public class CROrchestrationCheckDeploymentService implements JavaDelegate {
supd.setState( ServiceStateType.INACTIVE ); supd.setState( ServiceStateType.INACTIVE );
} }
Service serviceResult = serviceOrderManager.updateService( aService.getId(), supd, propagateToSO ); Service serviceResult = serviceOrderManager.updateService( aService.getId(), supd, triggerServiceActionQueue );
if ( serviceResult!= null ) { if ( serviceResult!= null ) {
if ( serviceResult.getState().equals(ServiceStateType.ACTIVE) if ( serviceResult.getState().equals(ServiceStateType.ACTIVE)
......
...@@ -160,8 +160,6 @@ public class CreateReservedService implements JavaDelegate { ...@@ -160,8 +160,6 @@ public class CreateReservedService implements JavaDelegate {
if ( partnerOrg != null ) { if ( partnerOrg != null ) {
createdServ = createServiceByServiceSpec(sor, soi, specrel, EServiceStartMode.AUTOMATICALLY_MANAGED, partnerOrg, parentService); createdServ = createServiceByServiceSpec(sor, soi, specrel, EServiceStartMode.AUTOMATICALLY_MANAGED, partnerOrg, parentService);
} }
else if (specrel.getType().equals("ResourceFacingServiceSpecification")) { 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);
...@@ -329,7 +327,7 @@ public class CreateReservedService implements JavaDelegate { ...@@ -329,7 +327,7 @@ public class CreateReservedService implements JavaDelegate {
} }
} }
} }
//also add parent service as relationship to parent //also add parent service as relationship to parent
ServiceRelationship srelationship = new ServiceRelationship(); ServiceRelationship srelationship = new ServiceRelationship();
......
...@@ -87,7 +87,7 @@ public class NFVOrchestrationCheckDeploymentService implements JavaDelegate { ...@@ -87,7 +87,7 @@ public class NFVOrchestrationCheckDeploymentService implements JavaDelegate {
ServiceUpdate supd = new ServiceUpdate(); ServiceUpdate supd = new ServiceUpdate();
boolean aVNFINDEXREFadded = false; boolean aVNFINDEXREFadded = false;
boolean propagateToSO = false; boolean triggerServiceActionQueue = false;
if ( aService.getServiceCharacteristic() != null ) { if ( aService.getServiceCharacteristic() != null ) {
for (Characteristic c : aService.getServiceCharacteristic()) { for (Characteristic c : aService.getServiceCharacteristic()) {
...@@ -103,17 +103,17 @@ public class NFVOrchestrationCheckDeploymentService implements JavaDelegate { ...@@ -103,17 +103,17 @@ public class NFVOrchestrationCheckDeploymentService implements JavaDelegate {
c.setValue( new Any( dd.getInstanceId() + "" )); c.setValue( new Any( dd.getInstanceId() + "" ));
} else if ( c.getName().equals("NSR")) { } else if ( c.getName().equals("NSR")) {
c.setValue( new Any( dd.getNsr() + "" )); c.setValue( new Any( dd.getNsr() + "" ));
propagateToSO = true; triggerServiceActionQueue = true;
} else if ( c.getName().equals("NSLCM")) { } else if ( c.getName().equals("NSLCM")) {
c.setValue( new Any( dd.getNs_nslcm_details() + "" )); c.setValue( new Any( dd.getNs_nslcm_details() + "" ));
propagateToSO = true; triggerServiceActionQueue = true;
} }
if ( dd.getDeploymentDescriptorVxFInstanceInfo() !=null ) { if ( dd.getDeploymentDescriptorVxFInstanceInfo() !=null ) {
for ( DeploymentDescriptorVxFInstanceInfo vnfinfo : dd.getDeploymentDescriptorVxFInstanceInfo() ) { for ( DeploymentDescriptorVxFInstanceInfo vnfinfo : dd.getDeploymentDescriptorVxFInstanceInfo() ) {
if ( c.getName().equals( "VNFINDEXREF_INFO_" + vnfinfo.getMemberVnfIndexRef() )) { if ( c.getName().equals( "VNFINDEXREF_INFO_" + vnfinfo.getMemberVnfIndexRef() )) {
c.setValue( new Any( vnfinfo.getVxfInstanceInfo() + "" )); c.setValue( new Any( vnfinfo.getVxfInstanceInfo() + "" ));
aVNFINDEXREFadded = true; aVNFINDEXREFadded = true;
propagateToSO = true; triggerServiceActionQueue = true;
} }
} }
...@@ -153,7 +153,7 @@ public class NFVOrchestrationCheckDeploymentService implements JavaDelegate { ...@@ -153,7 +153,7 @@ public class NFVOrchestrationCheckDeploymentService implements JavaDelegate {
supd.setState( ServiceStateType.TERMINATED ); 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!= null ) {
if ( serviceResult.getState().equals(ServiceStateType.ACTIVE) if ( serviceResult.getState().equals(ServiceStateType.ACTIVE)
......
...@@ -448,16 +448,16 @@ public class ServiceOrderManager { ...@@ -448,16 +448,16 @@ public class ServiceOrderManager {
/** /**
* @param serviceId * @param serviceId
* @param s * @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 * 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 * @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 ); logger.info("will update Service : " + serviceId );
try { try {
Map<String, Object> map = new HashMap<>(); Map<String, Object> map = new HashMap<>();
map.put("serviceid", serviceId ); map.put("serviceid", serviceId );
map.put("propagateToSO", propagateToSO ); map.put("triggerServiceActionQueue", triggerServiceActionQueue );
Object response = template.requestBodyAndHeaders( CATALOG_UPD_SERVICE, toJsonString(s), map); Object response = template.requestBodyAndHeaders( CATALOG_UPD_SERVICE, toJsonString(s), map);
......
...@@ -79,7 +79,9 @@ public class ServiceActionCheck implements JavaDelegate { ...@@ -79,7 +79,9 @@ public class ServiceActionCheck implements JavaDelegate {
execution.setVariable("saction", "HandleActiveStateChanged"); execution.setVariable("saction", "HandleActiveStateChanged");
} else if ( item.getAction().equals( ServiceActionQueueAction.EVALUATE_STATE_CHANGE_TOINACTIVE ) ) { } else if ( item.getAction().equals( ServiceActionQueueAction.EVALUATE_STATE_CHANGE_TOINACTIVE ) ) {
execution.setVariable("saction", "HandleInactiveStateChanged"); 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 execution.setVariable("saction", "HandleEvaluateService");// default
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment