From 0326973296025087c96b70523003cceae1e47837 Mon Sep 17 00:00:00 2001 From: George Tziavas Date: Mon, 16 Dec 2024 09:32:50 +0200 Subject: [PATCH 01/14] new file: .bpmn/src/main/resources/processes/ServiceCreationProcess.bpmn2d new file: .bpmn/src/main/resources/processes/TerminateScheduledServices.bpmn2d modified: src/main/java/org/etsi/osl/osom/management/AutomationCheck.java new file: src/main/java/org/etsi/osl/osom/management/MetricoOrchestrationService.java modified: src/main/resources/processes/ServiceCreationProcess.bpmn --- .../processes/ServiceCreationProcess.bpmn2d | 947 ++++++++++++++++++ .../TerminateScheduledServices.bpmn2d | 6 + .../osl/osom/management/AutomationCheck.java | 6 +- .../MetricoOrchestrationService.java | 50 + .../processes/ServiceCreationProcess.bpmn | 42 +- 5 files changed, 1036 insertions(+), 15 deletions(-) create mode 100644 .bpmn/src/main/resources/processes/ServiceCreationProcess.bpmn2d create mode 100644 .bpmn/src/main/resources/processes/TerminateScheduledServices.bpmn2d create mode 100644 src/main/java/org/etsi/osl/osom/management/MetricoOrchestrationService.java diff --git a/.bpmn/src/main/resources/processes/ServiceCreationProcess.bpmn2d b/.bpmn/src/main/resources/processes/ServiceCreationProcess.bpmn2d new file mode 100644 index 0000000..fb33f5d --- /dev/null +++ b/.bpmn/src/main/resources/processes/ServiceCreationProcess.bpmn2d @@ -0,0 +1,947 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/.bpmn/src/main/resources/processes/TerminateScheduledServices.bpmn2d b/.bpmn/src/main/resources/processes/TerminateScheduledServices.bpmn2d new file mode 100644 index 0000000..396e2bf --- /dev/null +++ b/.bpmn/src/main/resources/processes/TerminateScheduledServices.bpmn2d @@ -0,0 +1,6 @@ + + + + + + diff --git a/src/main/java/org/etsi/osl/osom/management/AutomationCheck.java b/src/main/java/org/etsi/osl/osom/management/AutomationCheck.java index e55f373..272a3ea 100644 --- a/src/main/java/org/etsi/osl/osom/management/AutomationCheck.java +++ b/src/main/java/org/etsi/osl/osom/management/AutomationCheck.java @@ -88,8 +88,10 @@ public class AutomationCheck implements JavaDelegate { } else if ( spec.getType().equals("ResourceFacingServiceSpecification") && ( spec.findSpecCharacteristicByName( "OSM_NSDCATALOGID" ) != null ) ) { execution.setVariable("brokeActivity", "RFS_OSM" ); } else if ( spec.getType().equals("ResourceFacingServiceSpecification") && ( spec.findSpecCharacteristicByName( "_CR_SPEC" ) != null ) ) { - execution.setVariable("brokeActivity", "RFS_CRSPEC" ); - } else if ( spec.getType().equals("ResourceFacingServiceSpecification") ) { + execution.setVariable("brokeActivity", "RFS_CRSPEC" ); + } else if ( spec.getType().equals("ResourceFacingServiceSpecification") && ( spec.findSpecCharacteristicByName( "_MT_" ) != null ) ) { + execution.setVariable("brokeActivity", "RFS_MTSPEC" ); + } else if ( spec.getType().equals("ResourceFacingServiceSpecification") ) { execution.setVariable("brokeActivity", "GRSPEC" ); } } diff --git a/src/main/java/org/etsi/osl/osom/management/MetricoOrchestrationService.java b/src/main/java/org/etsi/osl/osom/management/MetricoOrchestrationService.java new file mode 100644 index 0000000..60f6395 --- /dev/null +++ b/src/main/java/org/etsi/osl/osom/management/MetricoOrchestrationService.java @@ -0,0 +1,50 @@ +package org.etsi.osl.osom.management; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.etsi.osl.tmf.sim638.model.Service; +import org.etsi.osl.tmf.sim638.model.ServiceUpdate; +import org.flowable.engine.delegate.DelegateExecution; +import org.flowable.engine.delegate.JavaDelegate; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.stereotype.Component; + +@Component(value = "metricoOrchestrationService") +public class MetricoOrchestrationService implements JavaDelegate { + private static final transient Log logger = LogFactory.getLog(MetricoOrchestrationService.class.getName()); + + @Value("${spring.application.name}") + private String compname; + + @Autowired + private ServiceOrderManager serviceOrderManager; + + @Override + public void execute(DelegateExecution execution) { + + logger.info( "MetricoOrchestrationService" ); + logger.info( execution.getVariableNames().toString() ); + + if ( execution.getVariable("contextServiceId") == null) { + + logger.error( "Variable contextServiceId is NULL!" ); + execution.setVariable("serviceDeploymentFinished", Boolean.TRUE ); + return; + } + Service aService = serviceOrderManager.retrieveService( (String) execution.getVariable("contextServiceId") ); + + if ( aService == null ) { + logger.info( "aService is null for contextServiceId = " +(String) execution.getVariable("contextServiceId") ); + execution.setVariable("serviceDeploymentFinished", Boolean.TRUE ); + return; + } + + execution.setVariable("serviceDeploymentFinished", Boolean.FALSE ); + + ServiceUpdate supd = new ServiceUpdate(); + boolean propagateToSO = false; + + + } +} diff --git a/src/main/resources/processes/ServiceCreationProcess.bpmn b/src/main/resources/processes/ServiceCreationProcess.bpmn index 1fb3993..e296d3d 100644 --- a/src/main/resources/processes/ServiceCreationProcess.bpmn +++ b/src/main/resources/processes/ServiceCreationProcess.bpmn @@ -85,6 +85,9 @@ + + + @@ -148,6 +151,9 @@ + + + @@ -164,7 +170,7 @@ - + @@ -176,7 +182,7 @@ - + @@ -192,7 +198,7 @@ - + @@ -200,7 +206,7 @@ - + @@ -208,7 +214,7 @@ - + @@ -216,7 +222,7 @@ - + @@ -228,7 +234,7 @@ - + @@ -241,7 +247,7 @@ - + @@ -264,14 +270,14 @@ - + - + @@ -284,7 +290,7 @@ - + @@ -297,7 +303,7 @@ - + @@ -309,7 +315,7 @@ - + @@ -317,6 +323,16 @@ + + + + + + + + + + \ No newline at end of file -- GitLab From be6efda96404927d044a42c19819c4a282957354 Mon Sep 17 00:00:00 2001 From: George Tziavas Date: Mon, 16 Dec 2024 15:36:34 +0200 Subject: [PATCH 02/14] added one more action to service creation process --- .../processes/ServiceCreationProcess.bpmn2d | 947 ------------------ .../TerminateScheduledServices.bpmn2d | 6 - .../osl/osom/management/AutomationCheck.java | 2 +- ...coOrchestrationCheckDeploymentService.java | 50 + .../MetricoOrchestrationService.java | 61 +- .../processes/ServiceCreationProcess.bpmn | 7 +- 6 files changed, 87 insertions(+), 986 deletions(-) delete mode 100644 .bpmn/src/main/resources/processes/ServiceCreationProcess.bpmn2d delete mode 100644 .bpmn/src/main/resources/processes/TerminateScheduledServices.bpmn2d create mode 100644 src/main/java/org/etsi/osl/osom/management/MetricoOrchestrationCheckDeploymentService.java diff --git a/.bpmn/src/main/resources/processes/ServiceCreationProcess.bpmn2d b/.bpmn/src/main/resources/processes/ServiceCreationProcess.bpmn2d deleted file mode 100644 index fb33f5d..0000000 --- a/.bpmn/src/main/resources/processes/ServiceCreationProcess.bpmn2d +++ /dev/null @@ -1,947 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/.bpmn/src/main/resources/processes/TerminateScheduledServices.bpmn2d b/.bpmn/src/main/resources/processes/TerminateScheduledServices.bpmn2d deleted file mode 100644 index 396e2bf..0000000 --- a/.bpmn/src/main/resources/processes/TerminateScheduledServices.bpmn2d +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - diff --git a/src/main/java/org/etsi/osl/osom/management/AutomationCheck.java b/src/main/java/org/etsi/osl/osom/management/AutomationCheck.java index 272a3ea..0f5d875 100644 --- a/src/main/java/org/etsi/osl/osom/management/AutomationCheck.java +++ b/src/main/java/org/etsi/osl/osom/management/AutomationCheck.java @@ -89,7 +89,7 @@ public class AutomationCheck implements JavaDelegate { execution.setVariable("brokeActivity", "RFS_OSM" ); } else if ( spec.getType().equals("ResourceFacingServiceSpecification") && ( spec.findSpecCharacteristicByName( "_CR_SPEC" ) != null ) ) { execution.setVariable("brokeActivity", "RFS_CRSPEC" ); - } else if ( spec.getType().equals("ResourceFacingServiceSpecification") && ( spec.findSpecCharacteristicByName( "_MT_" ) != null ) ) { + } else if ( spec.getType().equals("ResourceFacingServiceSpecification") && ( spec.findSpecCharacteristicByName( "_MT_QUERY" ) != null ) ) { execution.setVariable("brokeActivity", "RFS_MTSPEC" ); } else if ( spec.getType().equals("ResourceFacingServiceSpecification") ) { execution.setVariable("brokeActivity", "GRSPEC" ); diff --git a/src/main/java/org/etsi/osl/osom/management/MetricoOrchestrationCheckDeploymentService.java b/src/main/java/org/etsi/osl/osom/management/MetricoOrchestrationCheckDeploymentService.java new file mode 100644 index 0000000..356f8c3 --- /dev/null +++ b/src/main/java/org/etsi/osl/osom/management/MetricoOrchestrationCheckDeploymentService.java @@ -0,0 +1,50 @@ +package org.etsi.osl.osom.management; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.etsi.osl.tmf.sim638.model.Service; +import org.etsi.osl.tmf.sim638.model.ServiceUpdate; +import org.flowable.engine.delegate.DelegateExecution; +import org.flowable.engine.delegate.JavaDelegate; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.stereotype.Component; + +@Component(value = "metricoOrchestrationCheckDeploymentService") +public class MetricoOrchestrationCheckDeploymentService implements JavaDelegate { + private static final transient Log logger = LogFactory.getLog(MetricoOrchestrationCheckDeploymentService.class.getName()); + + @Value("${spring.application.name}") + private String compname; + + @Autowired + private ServiceOrderManager serviceOrderManager; + + @Override + public void execute(DelegateExecution execution) { + + logger.info( "MetricoOrchestrationService" ); + logger.info( execution.getVariableNames().toString() ); + + if ( execution.getVariable("contextServiceId") == null) { + + logger.error( "Variable contextServiceId is NULL!" ); + execution.setVariable("serviceDeploymentFinished", Boolean.TRUE ); + return; + } + Service aService = serviceOrderManager.retrieveService( (String) execution.getVariable("contextServiceId") ); + + if ( aService == null ) { + logger.info( "aService is null for contextServiceId = " +(String) execution.getVariable("contextServiceId") ); + execution.setVariable("serviceDeploymentFinished", Boolean.TRUE ); + return; + } + + execution.setVariable("serviceDeploymentFinished", Boolean.FALSE ); + + ServiceUpdate supd = new ServiceUpdate(); + boolean propagateToSO = false; + + + } +} diff --git a/src/main/java/org/etsi/osl/osom/management/MetricoOrchestrationService.java b/src/main/java/org/etsi/osl/osom/management/MetricoOrchestrationService.java index 60f6395..a8e8ca2 100644 --- a/src/main/java/org/etsi/osl/osom/management/MetricoOrchestrationService.java +++ b/src/main/java/org/etsi/osl/osom/management/MetricoOrchestrationService.java @@ -2,49 +2,48 @@ package org.etsi.osl.osom.management; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.etsi.osl.tmf.scm633.model.ServiceSpecCharacteristic; +import org.etsi.osl.tmf.scm633.model.ServiceSpecification; import org.etsi.osl.tmf.sim638.model.Service; -import org.etsi.osl.tmf.sim638.model.ServiceUpdate; +import org.etsi.osl.tmf.so641.model.ServiceOrder; import org.flowable.engine.delegate.DelegateExecution; import org.flowable.engine.delegate.JavaDelegate; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Component; -@Component(value = "metricoOrchestrationService") +@Component(value = "metricoOrchestrationService") //bean name public class MetricoOrchestrationService implements JavaDelegate { - private static final transient Log logger = LogFactory.getLog(MetricoOrchestrationService.class.getName()); - @Value("${spring.application.name}") - private String compname; + private static final transient Log logger = LogFactory.getLog(NFVOrchestrationService.class.getName()); - @Autowired - private ServiceOrderManager serviceOrderManager; + + @Value("${spring.application.name}") + private String compname; + + + @Autowired + private ServiceOrderManager serviceOrderManager; + @Override public void execute(DelegateExecution execution) { - - logger.info( "MetricoOrchestrationService" ); - logger.info( execution.getVariableNames().toString() ); - - if ( execution.getVariable("contextServiceId") == null) { - - logger.error( "Variable contextServiceId is NULL!" ); - execution.setVariable("serviceDeploymentFinished", Boolean.TRUE ); - return; - } - Service aService = serviceOrderManager.retrieveService( (String) execution.getVariable("contextServiceId") ); - - if ( aService == null ) { - logger.info( "aService is null for contextServiceId = " +(String) execution.getVariable("contextServiceId") ); - execution.setVariable("serviceDeploymentFinished", Boolean.TRUE ); - return; - } - - execution.setVariable("serviceDeploymentFinished", Boolean.FALSE ); - - ServiceUpdate supd = new ServiceUpdate(); - boolean propagateToSO = false; - - + ServiceOrder sorder = serviceOrderManager.retrieveServiceOrder( execution.getVariable("orderid").toString() ); + Service aService = serviceOrderManager.retrieveService( (String) execution.getVariable("contextServiceId") ); + logger.info("Service name:" + aService.getName() ); + logger.info("Service state:" + aService.getState() ); + logger.info("Request to TMF628 for Service: " + aService.getId() ); + + //we need to retrieve here the Service Spec of this service that we send to the NFVO + + ServiceSpecification spec = serviceOrderManager.retrieveServiceSpec( aService.getServiceSpecificationRef().getId() ); + + if ( spec!=null ) { + + ServiceSpecCharacteristic c = spec.getServiceSpecCharacteristicByName( "NSDID" ); + + + } + } diff --git a/src/main/resources/processes/ServiceCreationProcess.bpmn b/src/main/resources/processes/ServiceCreationProcess.bpmn index e296d3d..2d53ce4 100644 --- a/src/main/resources/processes/ServiceCreationProcess.bpmn +++ b/src/main/resources/processes/ServiceCreationProcess.bpmn @@ -87,7 +87,9 @@ - + + + @@ -332,6 +334,9 @@ + + + -- GitLab From 3a46ee9919a041f0d542d40133ae8dc6600f4eea Mon Sep 17 00:00:00 2001 From: George Tziavas Date: Thu, 19 Dec 2024 14:56:00 +0200 Subject: [PATCH 03/14] Metrico Orchestration updates --- ...coOrchestrationCheckDeploymentService.java | 55 +++- .../MetricoOrchestrationService.java | 267 ++++++++++++++++-- src/main/resources/application.yml | 6 +- 3 files changed, 304 insertions(+), 24 deletions(-) diff --git a/src/main/java/org/etsi/osl/osom/management/MetricoOrchestrationCheckDeploymentService.java b/src/main/java/org/etsi/osl/osom/management/MetricoOrchestrationCheckDeploymentService.java index 356f8c3..08ded0b 100644 --- a/src/main/java/org/etsi/osl/osom/management/MetricoOrchestrationCheckDeploymentService.java +++ b/src/main/java/org/etsi/osl/osom/management/MetricoOrchestrationCheckDeploymentService.java @@ -1,7 +1,12 @@ package org.etsi.osl.osom.management; +import jakarta.validation.Valid; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.etsi.osl.tmf.common.model.service.Note; +import org.etsi.osl.tmf.common.model.service.ResourceRef; +import org.etsi.osl.tmf.common.model.service.ServiceStateType; +import org.etsi.osl.tmf.ri639.model.Resource; import org.etsi.osl.tmf.sim638.model.Service; import org.etsi.osl.tmf.sim638.model.ServiceUpdate; import org.flowable.engine.delegate.DelegateExecution; @@ -10,20 +15,26 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Component; +import java.time.OffsetDateTime; +import java.time.ZoneOffset; +import java.util.ArrayList; +import java.util.List; + @Component(value = "metricoOrchestrationCheckDeploymentService") public class MetricoOrchestrationCheckDeploymentService implements JavaDelegate { private static final transient Log logger = LogFactory.getLog(MetricoOrchestrationCheckDeploymentService.class.getName()); - @Value("${spring.application.name}") - private String compname; - @Autowired private ServiceOrderManager serviceOrderManager; + + @Value("${spring.application.name}") + private String compname; + @Override public void execute(DelegateExecution execution) { - logger.info( "MetricoOrchestrationService" ); + logger.info( "MetricoOrchestrationCheckDeploymentService" ); logger.info( execution.getVariableNames().toString() ); if ( execution.getVariable("contextServiceId") == null) { @@ -41,10 +52,44 @@ public class MetricoOrchestrationCheckDeploymentService implements JavaDelegate } execution.setVariable("serviceDeploymentFinished", Boolean.FALSE ); - ServiceUpdate supd = new ServiceUpdate(); boolean propagateToSO = false; + List rlist = new ArrayList(); + for (ResourceRef rref : aService.getSupportingResource()) { + Resource res = serviceOrderManager.retrieveResource(rref.getId()); + + if ( res == null ) { + supd.setState( ServiceStateType.TERMINATED); + execution.setVariable("serviceDeploymentFinished", Boolean.TRUE); + Service serviceResult = serviceOrderManager.updateService( aService.getId(), supd, propagateToSO ); + return; + } + rlist.add(res); + } + @Valid + ServiceStateType currentState = aService.getState(); + ServiceStateType nextState = aService.findNextStateBasedOnSupportingResources(rlist); + if (!currentState.equals(nextState)) { + supd.setState( nextState ); + Note n = new Note(); + n.setText("Service Status Changed to: " + nextState); + n.setAuthor(compname); + n.setDate(OffsetDateTime.now(ZoneOffset.UTC).toString()); + supd.addNoteItem(n); + aService = serviceOrderManager.updateService( aService.getId(), supd, propagateToSO ); + } + + if ( aService!= null ) { + if ( aService.getState().equals(ServiceStateType.ACTIVE) + || aService.getState().equals(ServiceStateType.TERMINATED)) { + + logger.info("Deployment Status OK. Service state = " + aService.getState() ); + execution.setVariable("serviceDeploymentFinished", Boolean.TRUE); + return; + } + } + logger.info("Wait For Deployment Status. "); } } diff --git a/src/main/java/org/etsi/osl/osom/management/MetricoOrchestrationService.java b/src/main/java/org/etsi/osl/osom/management/MetricoOrchestrationService.java index a8e8ca2..4df3ee4 100644 --- a/src/main/java/org/etsi/osl/osom/management/MetricoOrchestrationService.java +++ b/src/main/java/org/etsi/osl/osom/management/MetricoOrchestrationService.java @@ -1,22 +1,52 @@ package org.etsi.osl.osom.management; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; +import org.apache.camel.ProducerTemplate; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.etsi.osl.tmf.scm633.model.ServiceSpecCharacteristic; +import org.etsi.osl.tmf.common.model.service.Characteristic; +import org.etsi.osl.tmf.common.model.service.Note; +import org.etsi.osl.tmf.common.model.service.ResourceRef; +import org.etsi.osl.tmf.common.model.service.ServiceStateType; +import org.etsi.osl.tmf.pm628.model.*; +import org.etsi.osl.tmf.rcm634.model.ResourceSpecificationRef; +import org.etsi.osl.tmf.ri639.model.Resource; +import org.etsi.osl.tmf.ri639.model.ResourceCreate; import org.etsi.osl.tmf.scm633.model.ServiceSpecification; import org.etsi.osl.tmf.sim638.model.Service; +import org.etsi.osl.tmf.sim638.model.ServiceUpdate; import org.etsi.osl.tmf.so641.model.ServiceOrder; import org.flowable.engine.delegate.DelegateExecution; import org.flowable.engine.delegate.JavaDelegate; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; +import org.springframework.format.annotation.DateTimeFormat; import org.springframework.stereotype.Component; +import java.io.IOException; +import java.net.URI; +import java.net.URISyntaxException; +import java.time.OffsetDateTime; +import java.time.ZoneOffset; +import java.time.format.DateTimeFormatter; +import java.time.format.DateTimeParseException; +import java.util.ArrayList; +import java.util.List; + @Component(value = "metricoOrchestrationService") //bean name public class MetricoOrchestrationService implements JavaDelegate { private static final transient Log logger = LogFactory.getLog(NFVOrchestrationService.class.getName()); + @Autowired + private ProducerTemplate producerTemplate; + @Value("{PM_MEASUREMENT_COLLECTION_JOB_ADD}") + private String PM_MEASUREMENT_COLLECTION_JOB_ADD = ""; + + @Value("{PM_MEASUREMENT_COLLECTION_JOB_CREATED}") + private String PM_MEASUREMENT_COLLECTION_JOB_CREATED = ""; @Value("${spring.application.name}") private String compname; @@ -28,22 +58,223 @@ public class MetricoOrchestrationService implements JavaDelegate { @Override public void execute(DelegateExecution execution) { - ServiceOrder sorder = serviceOrderManager.retrieveServiceOrder( execution.getVariable("orderid").toString() ); - Service aService = serviceOrderManager.retrieveService( (String) execution.getVariable("contextServiceId") ); - logger.info("Service name:" + aService.getName() ); - logger.info("Service state:" + aService.getState() ); - logger.info("Request to TMF628 for Service: " + aService.getId() ); - - //we need to retrieve here the Service Spec of this service that we send to the NFVO - - ServiceSpecification spec = serviceOrderManager.retrieveServiceSpec( aService.getServiceSpecificationRef().getId() ); - - if ( spec!=null ) { - - ServiceSpecCharacteristic c = spec.getServiceSpecCharacteristicByName( "NSDID" ); - - - - } + ServiceOrder sorder = serviceOrderManager.retrieveServiceOrder(execution.getVariable("orderid").toString()); + ServiceUpdate su = new ServiceUpdate();// the object to update the service + Service aService = serviceOrderManager.retrieveService((String) execution.getVariable("contextServiceId")); + logger.info("Service name:" + aService.getName()); + logger.info("Service state:" + aService.getState()); + logger.info("Request to TMF628 for Service: " + aService.getId()); + + + ServiceSpecification spec = serviceOrderManager.retrieveServiceSpec(aService.getServiceSpecificationRef().getId()); + + if (spec != null) { + + Characteristic serviceCharacteristic; + MeasurementCollectionJobFVO mcjFVO = new MeasurementCollectionJobFVO(); + mcjFVO.setProducingApplicationId(aService.getId()); + + serviceCharacteristic = aService.getServiceCharacteristicByName("_MT_CHARACTERISTIC_NAME"); + String characteristicName = String.valueOf(serviceCharacteristic.getValue()); + mcjFVO.setOutputFormat(characteristicName); + + serviceCharacteristic = aService.getServiceCharacteristicByName("_MT_SERVICEUUID"); + String cfs_id = String.valueOf(serviceCharacteristic.getValue()); + mcjFVO.setConsumingApplicationId(cfs_id); + + serviceCharacteristic = aService.getServiceCharacteristicByName("_MT_END_TIME"); + String endTimeString = String.valueOf(serviceCharacteristic.getValue()); + ScheduleDefinitionFVO scheduleDefinition = new ScheduleDefinitionFVO(); + if (endTimeString != null) { + OffsetDateTime endTime = convertStringToOffsetDateTime(endTimeString, DateTimeFormat.ISO.DATE_TIME ); + scheduleDefinition.setScheduleDefinitionEndTime(endTime); + } else{ + OffsetDateTime endTime = OffsetDateTime.now().plusHours(1); + scheduleDefinition.setScheduleDefinitionEndTime(endTime); + } + + serviceCharacteristic = aService.getServiceCharacteristicByName("_MT_START_TIME"); + String startTimeString = String.valueOf(serviceCharacteristic.getValue()); + if (endTimeString != null) { + OffsetDateTime startTime = convertStringToOffsetDateTime(startTimeString, DateTimeFormat.ISO.DATE_TIME ); + scheduleDefinition.setScheduleDefinitionEndTime(startTime); + } else{ + OffsetDateTime startTime = OffsetDateTime.now(); + scheduleDefinition.setScheduleDefinitionStartTime(startTime); + } + List scheduleDefinitions = new ArrayList<>(); + scheduleDefinitions.add(scheduleDefinition); + mcjFVO.setScheduleDefinition(scheduleDefinitions); + + serviceCharacteristic = aService.getServiceCharacteristicByName("_MT_RECURRING_INTERVAL"); + String recurringIntervalString = String.valueOf(serviceCharacteristic.getValue()); + if (recurringIntervalString != null) { + if (Granularity.contains(recurringIntervalString)){ + Granularity recurringInterval = Granularity.valueOf(recurringIntervalString); + mcjFVO.setGranularity(recurringInterval); + } else { + logger.error("Invalid _MT_RECURRING_INTERVAL value. Valid values are:" + Granularity.getPossibleValues() + " It will be set to 1 minute."); + Granularity recurringInterval = Granularity.G_1M; + mcjFVO.setGranularity(recurringInterval); + } + } else { + Granularity recurringInterval = Granularity.G_1M; + mcjFVO.setGranularity(recurringInterval); + } + + serviceCharacteristic = aService.getServiceCharacteristicByName("_MT_TYPE"); + String monitoringType = String.valueOf(serviceCharacteristic.getValue()); + DataAccessEndpointFVO dataAccessEndpoint = new DataAccessEndpointFVO(); + dataAccessEndpoint.setType(monitoringType); + + serviceCharacteristic = aService.getServiceCharacteristicByName("_MT_QUERY"); + String monitoringQuery = String.valueOf(serviceCharacteristic.getValue()); + serviceCharacteristic = aService.getServiceCharacteristicByName("_MT_URL"); + String monitoringURL = String.valueOf(serviceCharacteristic.getValue()); + try { + URI monitoringURI = createUri(monitoringURL, monitoringQuery); + dataAccessEndpoint.setUri(monitoringURI); + } catch (URISyntaxException e) { + throw new RuntimeException(e); + } + + List dataAccessEndpoints = new ArrayList<>(); + dataAccessEndpoints.add(dataAccessEndpoint); + mcjFVO.setDataAccessEndpoint(dataAccessEndpoints); + + MeasurementCollectionJob mcj = addMeasurementCollectionJob(mcjFVO); + + if (mcj != null){ + publishEventMeasurementCollectionJobCreated( mcj.getUuid() ); + + ResourceSpecificationRef resourceSpecificationRef = spec.getResourceSpecification().stream().findFirst().get(); + Resource resourceMT = createRelatedResource( resourceSpecificationRef, sorder, aService ); + ResourceRef resourceRef = new ResourceRef(); + + resourceRef.setId( resourceMT.getId() ); + resourceRef.setName( resourceMT.getName()); + resourceRef.setType( resourceMT.getType()); + su.addSupportingResourceItem( resourceRef ); + su.setState(ServiceStateType.RESERVED); + Note successNoteItem = new Note(); + successNoteItem.setText(String.format("Requesting METRICO to create a new monitoring job")); + successNoteItem.setDate(OffsetDateTime.now(ZoneOffset.UTC).toString()); + successNoteItem.setAuthor(compname); + su.addNoteItem(successNoteItem); + Service supd = serviceOrderManager.updateService(aService.getId(), su, false); + + } else { + logger.error("Measurement Collection Job was not created."); + } + + + + } + } + + + + + +// Methods created to use in this class + public static OffsetDateTime convertStringToOffsetDateTime(String dateTimeString, DateTimeFormat.ISO pattern) { + DateTimeFormatter formatter; + switch (pattern) { + case DATE: + formatter = DateTimeFormatter.ISO_DATE; + break; + case TIME: + formatter = DateTimeFormatter.ISO_TIME; + break; + case DATE_TIME: + formatter = DateTimeFormatter.ISO_DATE_TIME; + break; + default: + throw new IllegalArgumentException("Unsupported DateTimeFormat.ISO pattern"); + } + try { + OffsetDateTime.parse(dateTimeString, formatter); + return OffsetDateTime.parse(dateTimeString, formatter); + } catch (DateTimeParseException e) { + logger.error(e.getMessage()); + return null; + } + + } + + public static URI createUri(String url, String query) throws URISyntaxException { + return new URI(url + "?" + query); + } + + public static T toJsonObj(String content, Class valueType) throws IOException { + ObjectMapper mapper = new ObjectMapper(); + mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL); + return mapper.readValue( content, valueType); + } + + public static String toJsonString(T object) { + ObjectMapper mapper = new ObjectMapper(); + mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL); + try { + return mapper.writeValueAsString(object); + } catch (JsonProcessingException e) { + e.printStackTrace(); + return null; + } + } + + public MeasurementCollectionJob addMeasurementCollectionJob(MeasurementCollectionJobFVO mcjFVO) { + + logger.debug("Will create a new Measurement Collection Job"); + try { + Object response = producerTemplate. + requestBody( PM_MEASUREMENT_COLLECTION_JOB_ADD, mcjFVO); + if ( !(response instanceof String)) { + logger.error("Measurement Collection Job object is wrong."); + return null; + } + logger.debug("retrieveMeasurementCollectionJobById response is: " + response); + MeasurementCollectionJob mcj = toJsonObj( (String)response, MeasurementCollectionJob.class); + return mcj; + }catch (Exception e) { + logger.error("Cannot create a new Measurement Collection Job. " + e.toString()); + } + return null; + } + + public void publishEventMeasurementCollectionJobCreated(String uuid) { + logger.debug("Publishing event for Measurement Collection Job Created with UUID: " + uuid); + try { + producerTemplate.sendBody(PM_MEASUREMENT_COLLECTION_JOB_CREATED, uuid); + } catch (Exception e) { + logger.error("Failed to publish event for Measurement Collection Job Created. " + e.toString()); + } + } + + /** + * + * THe resource has a temporary name. + * later on the name and its characteristics are updated via cridge + * @param rSpecRef + * @param sOrder + * @param aService + * @return + */ + private Resource createRelatedResource(ResourceSpecificationRef rSpecRef, ServiceOrder sOrder, Service aService) { + + ResourceCreate resCreate = new ResourceCreate(); + resCreate.setName( "_cr_tmpname_service_" + aService.getId() ); + resCreate.setStartOperatingDate( aService.getStartDate() ); + resCreate.setEndOperatingDate(aService.getEndDate()); + ResourceSpecificationRef rSpecRefObj = new ResourceSpecificationRef() ; + rSpecRefObj.id(rSpecRef.getId()) + .name( rSpecRef.getName()) + .setType(rSpecRef.getType()); + resCreate.setResourceSpecification(rSpecRefObj); + return serviceOrderManager.createResource( resCreate, sOrder, rSpecRef.getId() ); + + + + } } diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index 5e09475..af1510b 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -124,4 +124,8 @@ CATALOG_GET_RESOURCESPEC_BY_NAME_CATEGORY: "jms:queue:CATALOG.GET.RESOURCESPEC_B #CRD ACTIONS CRD_DEPLOY_CR_REQ: "jms:queue:CRD.DEPLOY.CR_REQ" CRD_DELETE_CR_REQ: "jms:queue:CRD.DELETE.CR_REQ" -CRD_PATCH_CR_REQ: "jms:queue:CRD.PATCH.CR_REQ" \ No newline at end of file +CRD_PATCH_CR_REQ: "jms:queue:CRD.PATCH.CR_REQ" + +#TMF628 ACTIONS +PM_MEASUREMENT_COLLECTION_JOB_ADD: "jms:queue:PM.MEASUREMENTCOLLECTIONJOB.ADD" +EVENT_MEASUREMENT_COLLECTION_JOB_CREATED: "jms:topic:EVENT.MEASUREMENTCOLLECTIONJOB.CREATED" \ No newline at end of file -- GitLab From 1d4f8224889cfc16e27b77f4bd9fd5f272273cf2 Mon Sep 17 00:00:00 2001 From: George Tziavas Date: Sat, 21 Dec 2024 20:48:26 +0200 Subject: [PATCH 04/14] modified: src/main/java/org/etsi/osl/osom/management/MetricoOrchestrationCheckDeploymentService.java --- .../management/MetricoOrchestrationCheckDeploymentService.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/org/etsi/osl/osom/management/MetricoOrchestrationCheckDeploymentService.java b/src/main/java/org/etsi/osl/osom/management/MetricoOrchestrationCheckDeploymentService.java index 08ded0b..286db4b 100644 --- a/src/main/java/org/etsi/osl/osom/management/MetricoOrchestrationCheckDeploymentService.java +++ b/src/main/java/org/etsi/osl/osom/management/MetricoOrchestrationCheckDeploymentService.java @@ -30,7 +30,7 @@ public class MetricoOrchestrationCheckDeploymentService implements JavaDelegate @Value("${spring.application.name}") private String compname; - + @Override public void execute(DelegateExecution execution) { -- GitLab From d2eb7370c2bbe55018681baaa091b7831f6fc18e Mon Sep 17 00:00:00 2001 From: George Tziavas Date: Mon, 23 Dec 2024 13:02:22 +0200 Subject: [PATCH 05/14] finished: src/main/java/org/etsi/osl/osom/management/MetricoOrchestrationCheckDeploymentService.java --- .../management/MetricoOrchestrationCheckDeploymentService.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/org/etsi/osl/osom/management/MetricoOrchestrationCheckDeploymentService.java b/src/main/java/org/etsi/osl/osom/management/MetricoOrchestrationCheckDeploymentService.java index 286db4b..8809c08 100644 --- a/src/main/java/org/etsi/osl/osom/management/MetricoOrchestrationCheckDeploymentService.java +++ b/src/main/java/org/etsi/osl/osom/management/MetricoOrchestrationCheckDeploymentService.java @@ -69,7 +69,7 @@ public class MetricoOrchestrationCheckDeploymentService implements JavaDelegate } @Valid ServiceStateType currentState = aService.getState(); - ServiceStateType nextState = aService.findNextStateBasedOnSupportingResources(rlist); + ServiceStateType nextState = aService.findNextStateBasedOnResourceList(rlist); if (!currentState.equals(nextState)) { supd.setState( nextState ); -- GitLab From 9dcbe8bb9f7821bc57bfd3a76260cd2e12cc4ead Mon Sep 17 00:00:00 2001 From: George Tziavas Date: Mon, 23 Dec 2024 13:48:02 +0200 Subject: [PATCH 06/14] new file: src/main/resources/processes/MetricoDeploymentReq.bpmn --- .../processes/MetricoDeploymentReq.bpmn | 71 +++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100644 src/main/resources/processes/MetricoDeploymentReq.bpmn diff --git a/src/main/resources/processes/MetricoDeploymentReq.bpmn b/src/main/resources/processes/MetricoDeploymentReq.bpmn new file mode 100644 index 0000000..c931982 --- /dev/null +++ b/src/main/resources/processes/MetricoDeploymentReq.bpmn @@ -0,0 +1,71 @@ + + + + + + + + + + PT30S + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file -- GitLab From 42b911247f8ff924814730b873cb533bb0ea4b68 Mon Sep 17 00:00:00 2001 From: Kostis Trantzas Date: Fri, 10 Jan 2025 12:59:39 +0200 Subject: [PATCH 07/14] fix for #29: - updates on created ResourceRef --- .../MetricoOrchestrationService.java | 29 ++++++++++++++----- 1 file changed, 22 insertions(+), 7 deletions(-) diff --git a/src/main/java/org/etsi/osl/osom/management/MetricoOrchestrationService.java b/src/main/java/org/etsi/osl/osom/management/MetricoOrchestrationService.java index 4df3ee4..8b40bfc 100644 --- a/src/main/java/org/etsi/osl/osom/management/MetricoOrchestrationService.java +++ b/src/main/java/org/etsi/osl/osom/management/MetricoOrchestrationService.java @@ -10,10 +10,12 @@ import org.etsi.osl.tmf.common.model.service.Characteristic; import org.etsi.osl.tmf.common.model.service.Note; import org.etsi.osl.tmf.common.model.service.ResourceRef; import org.etsi.osl.tmf.common.model.service.ServiceStateType; +import org.etsi.osl.tmf.common.model.Any; import org.etsi.osl.tmf.pm628.model.*; import org.etsi.osl.tmf.rcm634.model.ResourceSpecificationRef; import org.etsi.osl.tmf.ri639.model.Resource; import org.etsi.osl.tmf.ri639.model.ResourceCreate; +import org.etsi.osl.tmf.ri639.model.ResourceStatusType; import org.etsi.osl.tmf.scm633.model.ServiceSpecification; import org.etsi.osl.tmf.sim638.model.Service; import org.etsi.osl.tmf.sim638.model.ServiceUpdate; @@ -145,10 +147,9 @@ public class MetricoOrchestrationService implements JavaDelegate { MeasurementCollectionJob mcj = addMeasurementCollectionJob(mcjFVO); if (mcj != null){ - publishEventMeasurementCollectionJobCreated( mcj.getUuid() ); ResourceSpecificationRef resourceSpecificationRef = spec.getResourceSpecification().stream().findFirst().get(); - Resource resourceMT = createRelatedResource( resourceSpecificationRef, sorder, aService ); + Resource resourceMT = createRelatedResource( resourceSpecificationRef, sorder, aService, mcj ); ResourceRef resourceRef = new ResourceRef(); resourceRef.setId( resourceMT.getId() ); @@ -163,6 +164,8 @@ public class MetricoOrchestrationService implements JavaDelegate { su.addNoteItem(successNoteItem); Service supd = serviceOrderManager.updateService(aService.getId(), su, false); + publishEventMeasurementCollectionJobCreated( mcj.getUuid() ); + } else { logger.error("Measurement Collection Job was not created."); } @@ -253,28 +256,40 @@ public class MetricoOrchestrationService implements JavaDelegate { /** * - * THe resource has a temporary name. - * later on the name and its characteristics are updated via cridge + * The resource maps the created MCJ * @param rSpecRef * @param sOrder * @param aService * @return */ - private Resource createRelatedResource(ResourceSpecificationRef rSpecRef, ServiceOrder sOrder, Service aService) { + private Resource createRelatedResource(ResourceSpecificationRef rSpecRef, ServiceOrder sOrder, Service aService, MeasurementCollectionJob mcj) { ResourceCreate resCreate = new ResourceCreate(); - resCreate.setName( "_cr_tmpname_service_" + aService.getId() ); + resCreate.setName( rSpecRef.getName() + "-" + aService.getId() ); resCreate.setStartOperatingDate( aService.getStartDate() ); resCreate.setEndOperatingDate(aService.getEndDate()); + resCreate.setResourceStatus (ResourceStatusType.RESERVED); + ResourceSpecificationRef rSpecRefObj = new ResourceSpecificationRef() ; rSpecRefObj.id(rSpecRef.getId()) .name( rSpecRef.getName()) .setType(rSpecRef.getType()); resCreate.setResourceSpecification(rSpecRefObj); - return serviceOrderManager.createResource( resCreate, sOrder, rSpecRef.getId() ); + + org.etsi.osl.tmf.ri639.model.Characteristic resCharacteristicItem = new org.etsi.osl.tmf.ri639.model.Characteristic(); + resCharacteristicItem.setName( "_MT_MCJ_REF" ); + resCharacteristicItem.setValueType( "TEXT" ); + Any val = new Any(); + val.setValue( mcj.getUuid() ); + val.setAlias( mcj.getUuid() ); + resCharacteristicItem.setValue( val ); + resCreate.addResourceCharacteristicItem( resCharacteristicItem ); + // 1) need to copy the characteristics of the Resource Specification (use this instead of @param rSpecRef) and populate them with value from the aService (see GCOrchestrationService) + // 2) also need to populate the characteristic _MT_MCJ_REF with the UUID of the created MCJ / pass it as @param mcj + return serviceOrderManager.createResource( resCreate, sOrder, rSpecRef.getId() ); } } -- GitLab From be41d677fb84701222d071bdb35eb933eae22a7a Mon Sep 17 00:00:00 2001 From: Christos Tranoris Date: Fri, 10 Jan 2025 13:23:52 +0200 Subject: [PATCH 08/14] remove PM_MEASUREMENT_COLLECTION_JOB_CREATED event --- .../management/MetricoOrchestrationService.java | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/src/main/java/org/etsi/osl/osom/management/MetricoOrchestrationService.java b/src/main/java/org/etsi/osl/osom/management/MetricoOrchestrationService.java index 8b40bfc..c2d7297 100644 --- a/src/main/java/org/etsi/osl/osom/management/MetricoOrchestrationService.java +++ b/src/main/java/org/etsi/osl/osom/management/MetricoOrchestrationService.java @@ -47,9 +47,6 @@ public class MetricoOrchestrationService implements JavaDelegate { @Value("{PM_MEASUREMENT_COLLECTION_JOB_ADD}") private String PM_MEASUREMENT_COLLECTION_JOB_ADD = ""; - @Value("{PM_MEASUREMENT_COLLECTION_JOB_CREATED}") - private String PM_MEASUREMENT_COLLECTION_JOB_CREATED = ""; - @Value("${spring.application.name}") private String compname; @@ -164,8 +161,6 @@ public class MetricoOrchestrationService implements JavaDelegate { su.addNoteItem(successNoteItem); Service supd = serviceOrderManager.updateService(aService.getId(), su, false); - publishEventMeasurementCollectionJobCreated( mcj.getUuid() ); - } else { logger.error("Measurement Collection Job was not created."); } @@ -245,14 +240,6 @@ public class MetricoOrchestrationService implements JavaDelegate { return null; } - public void publishEventMeasurementCollectionJobCreated(String uuid) { - logger.debug("Publishing event for Measurement Collection Job Created with UUID: " + uuid); - try { - producerTemplate.sendBody(PM_MEASUREMENT_COLLECTION_JOB_CREATED, uuid); - } catch (Exception e) { - logger.error("Failed to publish event for Measurement Collection Job Created. " + e.toString()); - } - } /** * -- GitLab From 99437cf9cb6177455b7cc2dd63e9ea0e78bfb77f Mon Sep 17 00:00:00 2001 From: Christos Tranoris Date: Fri, 10 Jan 2025 13:25:29 +0200 Subject: [PATCH 09/14] remove event --- src/main/resources/application.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index af1510b..55f42c5 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -127,5 +127,4 @@ CRD_DELETE_CR_REQ: "jms:queue:CRD.DELETE.CR_REQ" CRD_PATCH_CR_REQ: "jms:queue:CRD.PATCH.CR_REQ" #TMF628 ACTIONS -PM_MEASUREMENT_COLLECTION_JOB_ADD: "jms:queue:PM.MEASUREMENTCOLLECTIONJOB.ADD" -EVENT_MEASUREMENT_COLLECTION_JOB_CREATED: "jms:topic:EVENT.MEASUREMENTCOLLECTIONJOB.CREATED" \ No newline at end of file +PM_MEASUREMENT_COLLECTION_JOB_ADD: "jms:queue:PM.MEASUREMENTCOLLECTIONJOB.ADD" \ No newline at end of file -- GitLab From b248db9f426d428c34a7164ae32a5848ab30e288 Mon Sep 17 00:00:00 2001 From: trantzas Date: Fri, 10 Jan 2025 16:10:46 +0000 Subject: [PATCH 10/14] Metrico Deployment Request process need to inherit variables --- src/main/resources/processes/ServiceCreationProcess.bpmn | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/resources/processes/ServiceCreationProcess.bpmn b/src/main/resources/processes/ServiceCreationProcess.bpmn index 2d53ce4..c2b30e7 100644 --- a/src/main/resources/processes/ServiceCreationProcess.bpmn +++ b/src/main/resources/processes/ServiceCreationProcess.bpmn @@ -85,7 +85,7 @@ - + -- GitLab From 9a9bf05978a4dab761e54302d2b44ed554d03822 Mon Sep 17 00:00:00 2001 From: Kostis Trantzas Date: Fri, 10 Jan 2025 18:43:59 +0200 Subject: [PATCH 11/14] fix for #29: - Fixed the setting of ScheduleDefinitionEndTime from reading the startTimeString --- .../etsi/osl/osom/management/MetricoOrchestrationService.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/etsi/osl/osom/management/MetricoOrchestrationService.java b/src/main/java/org/etsi/osl/osom/management/MetricoOrchestrationService.java index c2d7297..2c6cd2e 100644 --- a/src/main/java/org/etsi/osl/osom/management/MetricoOrchestrationService.java +++ b/src/main/java/org/etsi/osl/osom/management/MetricoOrchestrationService.java @@ -94,9 +94,9 @@ public class MetricoOrchestrationService implements JavaDelegate { serviceCharacteristic = aService.getServiceCharacteristicByName("_MT_START_TIME"); String startTimeString = String.valueOf(serviceCharacteristic.getValue()); - if (endTimeString != null) { + if (startTimeString != null) { OffsetDateTime startTime = convertStringToOffsetDateTime(startTimeString, DateTimeFormat.ISO.DATE_TIME ); - scheduleDefinition.setScheduleDefinitionEndTime(startTime); + scheduleDefinition.setScheduleDefinitionStartTime(startTime); } else{ OffsetDateTime startTime = OffsetDateTime.now(); scheduleDefinition.setScheduleDefinitionStartTime(startTime); -- GitLab From 9077c21828669a0013ff00f25803182f5c9cf490 Mon Sep 17 00:00:00 2001 From: Kostis Trantzas Date: Fri, 10 Jan 2025 19:04:22 +0200 Subject: [PATCH 12/14] fix for #29: - In the creation of MCJ, changed dataAccessEndpoint.setType(monitoringType) to dataAccessEndpoint.setApiType(monitoringType) to match what the mapper expects at METRICO --- .../etsi/osl/osom/management/MetricoOrchestrationService.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/org/etsi/osl/osom/management/MetricoOrchestrationService.java b/src/main/java/org/etsi/osl/osom/management/MetricoOrchestrationService.java index 2c6cd2e..32661e7 100644 --- a/src/main/java/org/etsi/osl/osom/management/MetricoOrchestrationService.java +++ b/src/main/java/org/etsi/osl/osom/management/MetricoOrchestrationService.java @@ -124,7 +124,7 @@ public class MetricoOrchestrationService implements JavaDelegate { serviceCharacteristic = aService.getServiceCharacteristicByName("_MT_TYPE"); String monitoringType = String.valueOf(serviceCharacteristic.getValue()); DataAccessEndpointFVO dataAccessEndpoint = new DataAccessEndpointFVO(); - dataAccessEndpoint.setType(monitoringType); + dataAccessEndpoint.setApiType(monitoringType); serviceCharacteristic = aService.getServiceCharacteristicByName("_MT_QUERY"); String monitoringQuery = String.valueOf(serviceCharacteristic.getValue()); -- GitLab From 3e2d403a6a504905916ff36147486e30b9281230 Mon Sep 17 00:00:00 2001 From: Christos Tranoris Date: Sat, 11 Jan 2025 18:51:35 +0200 Subject: [PATCH 13/14] fixes for metrico events --- .../MetricoOrchestrationService.java | 58 +++++++------------ .../osom/management/ServiceOrderManager.java | 29 +++++++++- 2 files changed, 49 insertions(+), 38 deletions(-) diff --git a/src/main/java/org/etsi/osl/osom/management/MetricoOrchestrationService.java b/src/main/java/org/etsi/osl/osom/management/MetricoOrchestrationService.java index 32661e7..ca3fcbf 100644 --- a/src/main/java/org/etsi/osl/osom/management/MetricoOrchestrationService.java +++ b/src/main/java/org/etsi/osl/osom/management/MetricoOrchestrationService.java @@ -40,13 +40,10 @@ import java.util.List; @Component(value = "metricoOrchestrationService") //bean name public class MetricoOrchestrationService implements JavaDelegate { - private static final transient Log logger = LogFactory.getLog(NFVOrchestrationService.class.getName()); - - @Autowired - private ProducerTemplate producerTemplate; - @Value("{PM_MEASUREMENT_COLLECTION_JOB_ADD}") - private String PM_MEASUREMENT_COLLECTION_JOB_ADD = ""; + private static final transient Log logger = LogFactory.getLog(MetricoOrchestrationService.class.getName()); + + @Value("${spring.application.name}") private String compname; @@ -71,20 +68,23 @@ public class MetricoOrchestrationService implements JavaDelegate { Characteristic serviceCharacteristic; MeasurementCollectionJobFVO mcjFVO = new MeasurementCollectionJobFVO(); + mcjFVO.setCreationTime( OffsetDateTime.now()); + mcjFVO.setLastModifiedTime( OffsetDateTime.now()); + mcjFVO.setProducingApplicationId(aService.getId()); serviceCharacteristic = aService.getServiceCharacteristicByName("_MT_CHARACTERISTIC_NAME"); - String characteristicName = String.valueOf(serviceCharacteristic.getValue()); + String characteristicName = String.valueOf(serviceCharacteristic.getValue().getValue()); mcjFVO.setOutputFormat(characteristicName); serviceCharacteristic = aService.getServiceCharacteristicByName("_MT_SERVICEUUID"); - String cfs_id = String.valueOf(serviceCharacteristic.getValue()); + String cfs_id = String.valueOf(serviceCharacteristic.getValue().getValue()); mcjFVO.setConsumingApplicationId(cfs_id); serviceCharacteristic = aService.getServiceCharacteristicByName("_MT_END_TIME"); - String endTimeString = String.valueOf(serviceCharacteristic.getValue()); + String endTimeString = String.valueOf(serviceCharacteristic.getValue().getValue()); ScheduleDefinitionFVO scheduleDefinition = new ScheduleDefinitionFVO(); - if (endTimeString != null) { + if (endTimeString != null && !endTimeString.equals("")) { OffsetDateTime endTime = convertStringToOffsetDateTime(endTimeString, DateTimeFormat.ISO.DATE_TIME ); scheduleDefinition.setScheduleDefinitionEndTime(endTime); } else{ @@ -93,8 +93,8 @@ public class MetricoOrchestrationService implements JavaDelegate { } serviceCharacteristic = aService.getServiceCharacteristicByName("_MT_START_TIME"); - String startTimeString = String.valueOf(serviceCharacteristic.getValue()); - if (startTimeString != null) { + String startTimeString = String.valueOf(serviceCharacteristic.getValue().getValue()); + if (startTimeString != null&& !startTimeString.equals("")) { OffsetDateTime startTime = convertStringToOffsetDateTime(startTimeString, DateTimeFormat.ISO.DATE_TIME ); scheduleDefinition.setScheduleDefinitionStartTime(startTime); } else{ @@ -106,10 +106,10 @@ public class MetricoOrchestrationService implements JavaDelegate { mcjFVO.setScheduleDefinition(scheduleDefinitions); serviceCharacteristic = aService.getServiceCharacteristicByName("_MT_RECURRING_INTERVAL"); - String recurringIntervalString = String.valueOf(serviceCharacteristic.getValue()); + String recurringIntervalString = String.valueOf(serviceCharacteristic.getValue().getValue()); if (recurringIntervalString != null) { if (Granularity.contains(recurringIntervalString)){ - Granularity recurringInterval = Granularity.valueOf(recurringIntervalString); + Granularity recurringInterval = Granularity.valueOf(recurringIntervalString.toUpperCase()); mcjFVO.setGranularity(recurringInterval); } else { logger.error("Invalid _MT_RECURRING_INTERVAL value. Valid values are:" + Granularity.getPossibleValues() + " It will be set to 1 minute."); @@ -122,14 +122,14 @@ public class MetricoOrchestrationService implements JavaDelegate { } serviceCharacteristic = aService.getServiceCharacteristicByName("_MT_TYPE"); - String monitoringType = String.valueOf(serviceCharacteristic.getValue()); + String monitoringType = String.valueOf(serviceCharacteristic.getValue().getValue()); DataAccessEndpointFVO dataAccessEndpoint = new DataAccessEndpointFVO(); dataAccessEndpoint.setApiType(monitoringType); serviceCharacteristic = aService.getServiceCharacteristicByName("_MT_QUERY"); - String monitoringQuery = String.valueOf(serviceCharacteristic.getValue()); + String monitoringQuery = String.valueOf(serviceCharacteristic.getValue().getValue()); serviceCharacteristic = aService.getServiceCharacteristicByName("_MT_URL"); - String monitoringURL = String.valueOf(serviceCharacteristic.getValue()); + String monitoringURL = String.valueOf(serviceCharacteristic.getValue().getValue()); try { URI monitoringURI = createUri(monitoringURL, monitoringQuery); dataAccessEndpoint.setUri(monitoringURI); @@ -141,7 +141,7 @@ public class MetricoOrchestrationService implements JavaDelegate { dataAccessEndpoints.add(dataAccessEndpoint); mcjFVO.setDataAccessEndpoint(dataAccessEndpoints); - MeasurementCollectionJob mcj = addMeasurementCollectionJob(mcjFVO); + MeasurementCollectionJob mcj = serviceOrderManager.addMeasurementCollectionJob(mcjFVO); if (mcj != null){ @@ -159,12 +159,14 @@ public class MetricoOrchestrationService implements JavaDelegate { successNoteItem.setDate(OffsetDateTime.now(ZoneOffset.UTC).toString()); successNoteItem.setAuthor(compname); su.addNoteItem(successNoteItem); - Service supd = serviceOrderManager.updateService(aService.getId(), su, false); } else { logger.error("Measurement Collection Job was not created."); + su.setState(ServiceStateType.TERMINATED); } + Service supd = serviceOrderManager.updateService(aService.getId(), su, false); + } @@ -221,24 +223,6 @@ public class MetricoOrchestrationService implements JavaDelegate { } } - public MeasurementCollectionJob addMeasurementCollectionJob(MeasurementCollectionJobFVO mcjFVO) { - - logger.debug("Will create a new Measurement Collection Job"); - try { - Object response = producerTemplate. - requestBody( PM_MEASUREMENT_COLLECTION_JOB_ADD, mcjFVO); - if ( !(response instanceof String)) { - logger.error("Measurement Collection Job object is wrong."); - return null; - } - logger.debug("retrieveMeasurementCollectionJobById response is: " + response); - MeasurementCollectionJob mcj = toJsonObj( (String)response, MeasurementCollectionJob.class); - return mcj; - }catch (Exception e) { - logger.error("Cannot create a new Measurement Collection Job. " + e.toString()); - } - return null; - } /** 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 4d79409..54bc509 100644 --- a/src/main/java/org/etsi/osl/osom/management/ServiceOrderManager.java +++ b/src/main/java/org/etsi/osl/osom/management/ServiceOrderManager.java @@ -35,6 +35,8 @@ import org.etsi.osl.model.nfv.DeploymentDescriptor; import org.etsi.osl.model.nfv.NetworkServiceDescriptor; import org.etsi.osl.model.nfv.ScaleDescriptor; import org.etsi.osl.osom.serviceactions.NSActionRequestPayload; +import org.etsi.osl.tmf.pm628.model.MeasurementCollectionJob; +import org.etsi.osl.tmf.pm628.model.MeasurementCollectionJobFVO; import org.etsi.osl.tmf.pm632.model.Organization; import org.etsi.osl.tmf.rcm634.model.LogicalResourceSpecification; import org.etsi.osl.tmf.rcm634.model.ResourceSpecification; @@ -194,7 +196,11 @@ public class ServiceOrderManager { @Value("${CATALOG_GET_RESOURCESPEC_BY_ID}") private String CATALOG_GET_RESOURCESPEC_BY_ID = ""; - + + @Value("${PM_MEASUREMENT_COLLECTION_JOB_ADD}") + private String PM_MEASUREMENT_COLLECTION_JOB_ADD = ""; + + @Transactional public void processOrder(ServiceOrder serviceOrder) { @@ -1141,6 +1147,27 @@ public class ServiceOrderManager { return null; } + + public MeasurementCollectionJob addMeasurementCollectionJob(MeasurementCollectionJobFVO mcjFVO) { + + logger.debug("Will create a new Measurement Collection Job"); + try { + Object response = template. + requestBody( PM_MEASUREMENT_COLLECTION_JOB_ADD, toJsonString(mcjFVO)); + if ( !(response instanceof String)) { + logger.error("Measurement Collection Job object is wrong."); + return null; + } + logger.debug("retrieveMeasurementCollectionJobById response is: " + response); + MeasurementCollectionJob mcj = toJsonObj( (String)response, MeasurementCollectionJob.class); + return mcj; + }catch (Exception e) { + logger.error("Cannot create a new Measurement Collection Job. " + e.toString()); + } + return null; +} + + -- GitLab From 6e99fe6aeeb84f40aeb46ed210495ac580aa004b Mon Sep 17 00:00:00 2001 From: Kostis Trantzas Date: Sat, 11 Jan 2025 19:11:47 +0200 Subject: [PATCH 14/14] Changing the default values for recurringInterval from G_1M (month) to G_1MN (minute) in MetricoOrchestrationService.java --- .../etsi/osl/osom/management/MetricoOrchestrationService.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/etsi/osl/osom/management/MetricoOrchestrationService.java b/src/main/java/org/etsi/osl/osom/management/MetricoOrchestrationService.java index ca3fcbf..5aeac40 100644 --- a/src/main/java/org/etsi/osl/osom/management/MetricoOrchestrationService.java +++ b/src/main/java/org/etsi/osl/osom/management/MetricoOrchestrationService.java @@ -113,11 +113,11 @@ public class MetricoOrchestrationService implements JavaDelegate { mcjFVO.setGranularity(recurringInterval); } else { logger.error("Invalid _MT_RECURRING_INTERVAL value. Valid values are:" + Granularity.getPossibleValues() + " It will be set to 1 minute."); - Granularity recurringInterval = Granularity.G_1M; + Granularity recurringInterval = Granularity.G_1MN; mcjFVO.setGranularity(recurringInterval); } } else { - Granularity recurringInterval = Granularity.G_1M; + Granularity recurringInterval = Granularity.G_1MN; mcjFVO.setGranularity(recurringInterval); } -- GitLab