aboutsummaryrefslogtreecommitdiffstats
path: root/participant/participant-impl
diff options
context:
space:
mode:
Diffstat (limited to 'participant/participant-impl')
-rwxr-xr-xparticipant/participant-impl/participant-impl-simulator/pom.xml1
-rwxr-xr-xparticipant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/acm/participant/sim/main/handler/AutomationCompositionElementHandler.java24
-rwxr-xr-x[-rw-r--r--]participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/acm/participant/sim/model/SimConfig.java4
-rwxr-xr-xparticipant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/acm/participant/sim/rest/SimulatorController.java7
-rwxr-xr-xparticipant/participant-impl/participant-impl-simulator/src/main/resources/openapi/openapi.yaml51
-rwxr-xr-xparticipant/participant-impl/participant-impl-simulator/src/test/java/org/onap/policy/clamp/acm/participant/sim/main/handler/AutomationCompositionElementHandlerTest.java33
6 files changed, 116 insertions, 4 deletions
diff --git a/participant/participant-impl/participant-impl-simulator/pom.xml b/participant/participant-impl/participant-impl-simulator/pom.xml
index 13b8ec302..912c1a7b3 100755
--- a/participant/participant-impl/participant-impl-simulator/pom.xml
+++ b/participant/participant-impl/participant-impl-simulator/pom.xml
@@ -51,6 +51,7 @@
<generateSupportingFiles>false</generateSupportingFiles>
<importMappings>
AutomationCompositions=org.onap.policy.clamp.models.acm.concepts.AutomationCompositions,
+ AutomationComposition=org.onap.policy.clamp.models.acm.concepts.AutomationComposition,
InternalDatas=org.onap.policy.clamp.acm.participant.sim.model.InternalDatas,
InternalData=org.onap.policy.clamp.acm.participant.sim.model.InternalData,
SimConfig=org.onap.policy.clamp.acm.participant.sim.model.SimConfig
diff --git a/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/acm/participant/sim/main/handler/AutomationCompositionElementHandler.java b/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/acm/participant/sim/main/handler/AutomationCompositionElementHandler.java
index a1564b2f7..7409c1137 100755
--- a/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/acm/participant/sim/main/handler/AutomationCompositionElementHandler.java
+++ b/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/acm/participant/sim/main/handler/AutomationCompositionElementHandler.java
@@ -35,6 +35,7 @@ import org.onap.policy.clamp.acm.participant.sim.model.InternalDatas;
import org.onap.policy.clamp.acm.participant.sim.model.SimConfig;
import org.onap.policy.clamp.models.acm.concepts.AcElementDeploy;
import org.onap.policy.clamp.models.acm.concepts.AcTypeState;
+import org.onap.policy.clamp.models.acm.concepts.AutomationComposition;
import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionElementDefinition;
import org.onap.policy.clamp.models.acm.concepts.AutomationCompositions;
import org.onap.policy.clamp.models.acm.concepts.DeployState;
@@ -217,6 +218,10 @@ public class AutomationCompositionElementHandler implements AutomationCompositio
return result;
}
+ public AutomationComposition getAutomationComposition(UUID instanceId) {
+ return intermediaryApi.getAutomationComposition(instanceId);
+ }
+
/**
* Set OutProperties.
*
@@ -280,6 +285,7 @@ public class AutomationCompositionElementHandler implements AutomationCompositio
for (var instance : map.values()) {
for (var element : instance.getElements().values()) {
var data = new InternalData();
+ data.setCompositionId(instance.getCompositionId());
data.setAutomationCompositionId(instance.getInstanceId());
data.setAutomationCompositionElementId(element.getId());
data.setIntProperties(element.getProperties());
@@ -375,8 +381,20 @@ public class AutomationCompositionElementHandler implements AutomationCompositio
@Override
public void migrate(UUID automationCompositionId, AcElementDeploy element, UUID compositionTargetId,
- Map<String, Object> properties) throws PfModelException {
- intermediaryApi.updateAutomationCompositionElementState(automationCompositionId, element.getId(),
- DeployState.DEPLOYED, null, StateChangeResult.NO_ERROR, "Migrated");
+ Map<String, Object> properties) throws PfModelException {
+ LOGGER.debug("migrate call");
+
+ if (!execution(config.getMigrateTimerMs(), "Current Thread migrate is Interrupted during execution {}",
+ element.getId())) {
+ return;
+ }
+
+ if (config.isMigrateSuccess()) {
+ intermediaryApi.updateAutomationCompositionElementState(automationCompositionId, element.getId(),
+ DeployState.DEPLOYED, null, StateChangeResult.NO_ERROR, "Migrated");
+ } else {
+ intermediaryApi.updateAutomationCompositionElementState(automationCompositionId, element.getId(),
+ DeployState.DEPLOYED, null, StateChangeResult.FAILED, "Migrate failed!");
+ }
}
}
diff --git a/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/acm/participant/sim/model/SimConfig.java b/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/acm/participant/sim/model/SimConfig.java
index cf216c1e8..f4d4c6e2e 100644..100755
--- a/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/acm/participant/sim/model/SimConfig.java
+++ b/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/acm/participant/sim/model/SimConfig.java
@@ -36,6 +36,8 @@ public class SimConfig {
private boolean updateSuccess = true;
+ private boolean migrateSuccess = true;
+
private boolean primeSuccess = true;
private boolean deprimeSuccess = true;
@@ -50,6 +52,8 @@ public class SimConfig {
private int updateTimerMs = 100;
+ private int migrateTimerMs = 100;
+
private int deleteTimerMs = 100;
private int primeTimerMs = 100;
diff --git a/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/acm/participant/sim/rest/SimulatorController.java b/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/acm/participant/sim/rest/SimulatorController.java
index 445a2a111..cf4ac8eb7 100755
--- a/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/acm/participant/sim/rest/SimulatorController.java
+++ b/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/acm/participant/sim/rest/SimulatorController.java
@@ -29,6 +29,7 @@ import org.onap.policy.clamp.acm.participant.sim.main.handler.AutomationComposit
import org.onap.policy.clamp.acm.participant.sim.model.InternalData;
import org.onap.policy.clamp.acm.participant.sim.model.InternalDatas;
import org.onap.policy.clamp.acm.participant.sim.model.SimConfig;
+import org.onap.policy.clamp.models.acm.concepts.AutomationComposition;
import org.onap.policy.clamp.models.acm.concepts.AutomationCompositions;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
@@ -60,6 +61,12 @@ public class SimulatorController implements SimulatorParticipantControllerApi {
}
@Override
+ public ResponseEntity<AutomationComposition> getAutomationComposition(UUID instanceId, UUID xonapRequestId) {
+ return new ResponseEntity<>(automationCompositionElementHandler.getAutomationComposition(instanceId),
+ HttpStatus.OK);
+ }
+
+ @Override
public ResponseEntity<InternalDatas> getDatas(UUID xonapRequestId) {
return new ResponseEntity<>(automationCompositionElementHandler.getDataList(), HttpStatus.OK);
}
diff --git a/participant/participant-impl/participant-impl-simulator/src/main/resources/openapi/openapi.yaml b/participant/participant-impl/participant-impl-simulator/src/main/resources/openapi/openapi.yaml
index c3b02e412..197e3cbca 100755
--- a/participant/participant-impl/participant-impl-simulator/src/main/resources/openapi/openapi.yaml
+++ b/participant/participant-impl/participant-impl-simulator/src/main/resources/openapi/openapi.yaml
@@ -170,6 +170,54 @@ paths:
description: Internal Server Error
security:
- basicAuth: []
+ /instances/{instanceId}:
+ get:
+ tags:
+ - Simulator-participant-controller
+ summary: Get automation composition instance details.
+ description: Get details of the requested automation composition instance.
+ operationId: getAutomationComposition
+ parameters:
+ - name : instanceId
+ in: path
+ description: The UUID of the automation composition instance to get
+ required: true
+ schema:
+ type: string
+ format: uuid
+ - name: X-onap-RequestId
+ in: header
+ description: RequestID for http transaction
+ schema:
+ type: string
+ format: uuid
+ responses:
+ 200:
+ description: Serialised instance of
+ [AutomationComposition](https://github.com/onap/policy-clamp/blob/master/models/src/main/java/org/onap/policy/clamp/models/acm/concepts/AutomationComposition.java)
+ containing the automation composition instance
+ headers:
+ X-LatestVersion:
+ $ref: '#/components/headers/X-LatestVersion'
+ X-PatchVersion:
+ $ref: '#/components/headers/X-PatchVersion'
+ X-MinorVersion:
+ $ref: '#/components/headers/X-MinorVersion'
+ X-onap-RequestId:
+ $ref: '#/components/headers/X-onap-RequestId'
+ content:
+ application/json:
+ schema:
+ $ref: '#/components/schemas/AutomationComposition'
+ application/yaml:
+ schema:
+ $ref: '#/components/schemas/AutomationComposition'
+ 401:
+ description: Authorization Error
+ 500:
+ description: Internal Server Error
+ security:
+ - basicAuth: []
/datas:
get:
tags:
@@ -353,6 +401,9 @@ components:
AutomationCompositions:
title: AutomationCompositions
type: object
+ AutomationComposition:
+ title: AutomationComposition
+ type: object
InternalDatas:
title: InternalDatas
type: object
diff --git a/participant/participant-impl/participant-impl-simulator/src/test/java/org/onap/policy/clamp/acm/participant/sim/main/handler/AutomationCompositionElementHandlerTest.java b/participant/participant-impl/participant-impl-simulator/src/test/java/org/onap/policy/clamp/acm/participant/sim/main/handler/AutomationCompositionElementHandlerTest.java
index ed3f0745b..d7c9e17ad 100755
--- a/participant/participant-impl/participant-impl-simulator/src/test/java/org/onap/policy/clamp/acm/participant/sim/main/handler/AutomationCompositionElementHandlerTest.java
+++ b/participant/participant-impl/participant-impl-simulator/src/test/java/org/onap/policy/clamp/acm/participant/sim/main/handler/AutomationCompositionElementHandlerTest.java
@@ -162,7 +162,7 @@ class AutomationCompositionElementHandlerTest {
}
@Test
- void testgetAutomationComposition() throws PfModelException {
+ void testgetAutomationCompositions() throws PfModelException {
var intermediaryApi = mock(ParticipantIntermediaryApi.class);
var acElementHandler = new AutomationCompositionElementHandler(intermediaryApi);
@@ -173,6 +173,17 @@ class AutomationCompositionElementHandlerTest {
}
@Test
+ void testgetAutomationComposition() throws PfModelException {
+ var intermediaryApi = mock(ParticipantIntermediaryApi.class);
+ var acElementHandler = new AutomationCompositionElementHandler(intermediaryApi);
+
+ var instance = CommonTestData.getTestAutomationCompositionMap().values().iterator().next();
+ when(intermediaryApi.getAutomationComposition(instance.getInstanceId())).thenReturn(instance);
+ var result = acElementHandler.getAutomationComposition(instance.getInstanceId());
+ assertEquals(instance, result);
+ }
+
+ @Test
void testsetOutProperties() {
var intermediaryApi = mock(ParticipantIntermediaryApi.class);
var acElementHandler = new AutomationCompositionElementHandler(intermediaryApi);
@@ -334,4 +345,24 @@ class AutomationCompositionElementHandlerTest {
acElementHandler.setCompositionOutProperties(compositionId, null, Map.of());
verify(intermediaryApi).sendAcDefinitionInfo(compositionId, null, Map.of());
}
+
+ @Test
+ void testMigrate() throws PfModelException {
+ var config = new SimConfig();
+ config.setUpdateTimerMs(1);
+ var intermediaryApi = mock(ParticipantIntermediaryApi.class);
+ var acElementHandler = new AutomationCompositionElementHandler(intermediaryApi);
+ acElementHandler.setConfig(config);
+ var instanceId = UUID.randomUUID();
+ var element = new AcElementDeploy();
+ element.setId(UUID.randomUUID());
+ acElementHandler.migrate(instanceId, element, UUID.randomUUID(), Map.of());
+ verify(intermediaryApi).updateAutomationCompositionElementState(instanceId, element.getId(),
+ DeployState.DEPLOYED, null, StateChangeResult.NO_ERROR, "Migrated");
+
+ config.setMigrateSuccess(false);
+ acElementHandler.migrate(instanceId, element, UUID.randomUUID(), Map.of());
+ verify(intermediaryApi).updateAutomationCompositionElementState(instanceId, element.getId(),
+ DeployState.DEPLOYED, null, StateChangeResult.FAILED, "Migrate failed!");
+ }
}