summaryrefslogtreecommitdiffstats
path: root/models
diff options
context:
space:
mode:
authorFrancescoFioraEst <francesco.fiora@est.tech>2023-02-07 11:06:01 +0000
committerFrancescoFioraEst <francesco.fiora@est.tech>2023-02-08 11:43:43 +0000
commitc1fce9211058bf91b40415022a819d3b410f711e (patch)
tree17dfdfd8e6f3df63c886c406b091becd727f29e0 /models
parentf15329432ee82d48d7ead388ba1866ebbba8efd8 (diff)
Implement AC Element Instance Locking and Unlocking on ACM-R
Issue-ID: POLICY-4509 Change-Id: I8bca27cfa2a417314a27e2bec3938b538f05e346 Signed-off-by: FrancescoFioraEst <francesco.fiora@est.tech>
Diffstat (limited to 'models')
-rw-r--r--models/src/main/java/org/onap/policy/clamp/models/acm/concepts/AcElementDeploy.java5
-rw-r--r--models/src/main/java/org/onap/policy/clamp/models/acm/concepts/AcElementDeployAck.java3
-rw-r--r--models/src/main/java/org/onap/policy/clamp/models/acm/concepts/AutomationCompositionInfo.java8
-rw-r--r--models/src/main/java/org/onap/policy/clamp/models/acm/concepts/ParticipantUtils.java7
-rw-r--r--models/src/main/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/AutomationCompositionDeploy.java2
-rw-r--r--models/src/main/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/AutomationCompositionStateChange.java10
-rw-r--r--models/src/main/java/org/onap/policy/clamp/models/acm/messages/rest/instantiation/InstantiationCommand.java30
-rw-r--r--models/src/test/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/AutomationCompositionDeployAckTest.java2
-rw-r--r--models/src/test/java/org/onap/policy/clamp/models/acm/messages/rest/instantiation/InstantiationCommandTest.java58
9 files changed, 30 insertions, 95 deletions
diff --git a/models/src/main/java/org/onap/policy/clamp/models/acm/concepts/AcElementDeploy.java b/models/src/main/java/org/onap/policy/clamp/models/acm/concepts/AcElementDeploy.java
index 6b6eda319..5408d3179 100644
--- a/models/src/main/java/org/onap/policy/clamp/models/acm/concepts/AcElementDeploy.java
+++ b/models/src/main/java/org/onap/policy/clamp/models/acm/concepts/AcElementDeploy.java
@@ -22,6 +22,7 @@ package org.onap.policy.clamp.models.acm.concepts;
import java.util.LinkedHashMap;
import java.util.Map;
+import java.util.UUID;
import java.util.function.UnaryOperator;
import lombok.Data;
import lombok.NoArgsConstructor;
@@ -42,6 +43,9 @@ import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate;
public class AcElementDeploy {
@NonNull
+ private UUID id = UUID.randomUUID();
+
+ @NonNull
private ToscaConceptIdentifier definition = new ToscaConceptIdentifier(PfConceptKey.getNullKey());
@NonNull
@@ -59,6 +63,7 @@ public class AcElementDeploy {
* @param otherElement the other element to copy from
*/
public AcElementDeploy(final AcElementDeploy otherElement) {
+ this.id = otherElement.id;
this.definition = new ToscaConceptIdentifier(otherElement.definition);
this.orderedState = otherElement.orderedState;
this.toscaServiceTemplateFragment = otherElement.toscaServiceTemplateFragment;
diff --git a/models/src/main/java/org/onap/policy/clamp/models/acm/concepts/AcElementDeployAck.java b/models/src/main/java/org/onap/policy/clamp/models/acm/concepts/AcElementDeployAck.java
index 2db1555bf..afbd61bd1 100644
--- a/models/src/main/java/org/onap/policy/clamp/models/acm/concepts/AcElementDeployAck.java
+++ b/models/src/main/java/org/onap/policy/clamp/models/acm/concepts/AcElementDeployAck.java
@@ -37,6 +37,9 @@ public class AcElementDeployAck {
// State of the AutomationCompositionElement
private DeployState deployState;
+ // State of the AutomationCompositionElement
+ private LockState lockState;
+
// Result: Success/Fail.
private Boolean result;
diff --git a/models/src/main/java/org/onap/policy/clamp/models/acm/concepts/AutomationCompositionInfo.java b/models/src/main/java/org/onap/policy/clamp/models/acm/concepts/AutomationCompositionInfo.java
index c43e4db91..954665bfb 100644
--- a/models/src/main/java/org/onap/policy/clamp/models/acm/concepts/AutomationCompositionInfo.java
+++ b/models/src/main/java/org/onap/policy/clamp/models/acm/concepts/AutomationCompositionInfo.java
@@ -1,6 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2021-2022 Nordix Foundation.
+ * Copyright (C) 2021-2023 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -37,6 +37,10 @@ public class AutomationCompositionInfo {
private AutomationCompositionState state = AutomationCompositionState.UNINITIALISED;
+ private DeployState deployState = DeployState.UNDEPLOYED;
+
+ private LockState lockState = LockState.LOCKED;
+
/**
* Copy constructor, does a deep copy but as all fields here are immutable, it's just a regular copy.
*
@@ -45,5 +49,7 @@ public class AutomationCompositionInfo {
public AutomationCompositionInfo(final AutomationCompositionInfo otherElement) {
this.automationCompositionId = otherElement.automationCompositionId;
this.state = otherElement.state;
+ this.deployState = otherElement.deployState;
+ this.lockState = otherElement.lockState;
}
}
diff --git a/models/src/main/java/org/onap/policy/clamp/models/acm/concepts/ParticipantUtils.java b/models/src/main/java/org/onap/policy/clamp/models/acm/concepts/ParticipantUtils.java
index 57cf2f336..d6079d0e7 100644
--- a/models/src/main/java/org/onap/policy/clamp/models/acm/concepts/ParticipantUtils.java
+++ b/models/src/main/java/org/onap/policy/clamp/models/acm/concepts/ParticipantUtils.java
@@ -23,7 +23,6 @@ package org.onap.policy.clamp.models.acm.concepts;
import java.util.Map;
import lombok.AccessLevel;
import lombok.NoArgsConstructor;
-import org.onap.policy.models.tosca.authorative.concepts.ToscaNodeTemplate;
import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate;
@NoArgsConstructor(access = AccessLevel.PRIVATE)
@@ -43,15 +42,15 @@ public final class ParticipantUtils {
var minStartPhase = 1000;
var maxStartPhase = 0;
for (var element : automationComposition.getElements().values()) {
- ToscaNodeTemplate toscaNodeTemplate = toscaServiceTemplate.getToscaTopologyTemplate().getNodeTemplates()
+ var toscaNodeTemplate = toscaServiceTemplate.getToscaTopologyTemplate().getNodeTemplates()
.get(element.getDefinition().getName());
int startPhase = ParticipantUtils.findStartPhase(toscaNodeTemplate.getProperties());
minStartPhase = Math.min(minStartPhase, startPhase);
maxStartPhase = Math.max(maxStartPhase, startPhase);
}
- return AutomationCompositionState.UNINITIALISED2PASSIVE.equals(automationComposition.getState())
- || AutomationCompositionState.PASSIVE2RUNNING.equals(automationComposition.getState()) ? minStartPhase
+ return DeployState.DEPLOYING.equals(automationComposition.getDeployState())
+ || LockState.UNLOCKING.equals(automationComposition.getLockState()) ? minStartPhase
: maxStartPhase;
}
diff --git a/models/src/main/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/AutomationCompositionDeploy.java b/models/src/main/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/AutomationCompositionDeploy.java
index f0ba43f2a..77d0d349e 100644
--- a/models/src/main/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/AutomationCompositionDeploy.java
+++ b/models/src/main/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/AutomationCompositionDeploy.java
@@ -42,6 +42,7 @@ public class AutomationCompositionDeploy extends ParticipantMessage {
// A list of ParticipantUpdates instances which carries details of an updated participant.
private List<ParticipantDeploy> participantUpdatesList = new ArrayList<>();
private Integer startPhase = 0;
+ private boolean firstStartPhase = true;
/**
* Constructor for instantiating class with message name.
@@ -59,6 +60,7 @@ public class AutomationCompositionDeploy extends ParticipantMessage {
public AutomationCompositionDeploy(AutomationCompositionDeploy source) {
super(source);
this.startPhase = source.startPhase;
+ this.firstStartPhase = source.firstStartPhase;
this.participantUpdatesList = PfUtils.mapList(source.participantUpdatesList, ParticipantDeploy::new);
}
}
diff --git a/models/src/main/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/AutomationCompositionStateChange.java b/models/src/main/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/AutomationCompositionStateChange.java
index f8daa36a9..1694b257b 100644
--- a/models/src/main/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/AutomationCompositionStateChange.java
+++ b/models/src/main/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/AutomationCompositionStateChange.java
@@ -1,6 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2021 Nordix Foundation.
+ * Copyright (C) 2021,2023 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -25,6 +25,8 @@ import lombok.Setter;
import lombok.ToString;
import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionOrderedState;
import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionState;
+import org.onap.policy.clamp.models.acm.messages.rest.instantiation.DeployOrder;
+import org.onap.policy.clamp.models.acm.messages.rest.instantiation.LockOrder;
/**
* Class to represent the AUTOMATION_COMPOSITION_STATE_CHANGE message that the automation composition runtime will send
@@ -36,7 +38,10 @@ import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionState;
public class AutomationCompositionStateChange extends ParticipantMessage {
private AutomationCompositionOrderedState orderedState;
private AutomationCompositionState currentState;
+ private DeployOrder deployOrderedState = DeployOrder.NONE;
+ private LockOrder lockOrderedState = LockOrder.NONE;
private Integer startPhase;
+ private Boolean firstStartPhase = true;
/**
* Constructor for instantiating class with message name.
@@ -56,5 +61,8 @@ public class AutomationCompositionStateChange extends ParticipantMessage {
this.orderedState = source.orderedState;
this.currentState = source.currentState;
+ this.deployOrderedState = source.deployOrderedState;
+ this.lockOrderedState = source.lockOrderedState;
+ this.startPhase = source.startPhase;
}
}
diff --git a/models/src/main/java/org/onap/policy/clamp/models/acm/messages/rest/instantiation/InstantiationCommand.java b/models/src/main/java/org/onap/policy/clamp/models/acm/messages/rest/instantiation/InstantiationCommand.java
deleted file mode 100644
index 48fc8ba7c..000000000
--- a/models/src/main/java/org/onap/policy/clamp/models/acm/messages/rest/instantiation/InstantiationCommand.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * Copyright (C) 2021-2022 Nordix Foundation.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * SPDX-License-Identifier: Apache-2.0
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.policy.clamp.models.acm.messages.rest.instantiation;
-
-import lombok.Data;
-import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionOrderedState;
-
-@Data
-public class InstantiationCommand {
- // The state to which the automation compositions are to be set
- private AutomationCompositionOrderedState orderedState;
-}
diff --git a/models/src/test/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/AutomationCompositionDeployAckTest.java b/models/src/test/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/AutomationCompositionDeployAckTest.java
index 038c140ed..6e5b504af 100644
--- a/models/src/test/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/AutomationCompositionDeployAckTest.java
+++ b/models/src/test/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/AutomationCompositionDeployAckTest.java
@@ -49,7 +49,7 @@ class AutomationCompositionDeployAckTest {
// verify with all values
orig.setAutomationCompositionId(UUID.randomUUID());
orig.setParticipantId(CommonTestData.getParticipantId());
- var acElementResult = new AcElementDeployAck(AutomationCompositionState.UNINITIALISED, null,
+ var acElementResult = new AcElementDeployAck(AutomationCompositionState.UNINITIALISED, null, null,
true, "AutomationCompositionElement result");
final var automationCompositionResultMap = Map.of(UUID.randomUUID(), acElementResult);
orig.setAutomationCompositionResultMap(automationCompositionResultMap);
diff --git a/models/src/test/java/org/onap/policy/clamp/models/acm/messages/rest/instantiation/InstantiationCommandTest.java b/models/src/test/java/org/onap/policy/clamp/models/acm/messages/rest/instantiation/InstantiationCommandTest.java
deleted file mode 100644
index a87f7e042..000000000
--- a/models/src/test/java/org/onap/policy/clamp/models/acm/messages/rest/instantiation/InstantiationCommandTest.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * Copyright (C) 2021-2022 Nordix Foundation.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * SPDX-License-Identifier: Apache-2.0
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.policy.clamp.models.acm.messages.rest.instantiation;
-
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.junit.jupiter.api.Assertions.assertEquals;
-import static org.junit.jupiter.api.Assertions.assertNotEquals;
-import static org.junit.jupiter.api.Assertions.assertNotNull;
-
-import org.junit.jupiter.api.Test;
-import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionOrderedState;
-
-class InstantiationCommandTest {
- @Test
- void testInstantiationCommandLombok() {
- assertNotNull(new InstantiationCommand());
- var ic0 = new InstantiationCommand();
-
- assertThat(ic0.toString()).contains("InstantiationCommand(");
- assertNotEquals(0, ic0.hashCode());
- assertEquals(ic0, ic0);
- assertNotEquals(null, ic0);
-
-
- var ic1 = new InstantiationCommand();
-
- ic1.setOrderedState(AutomationCompositionOrderedState.UNINITIALISED);
-
- assertThat(ic1.toString()).contains("InstantiationCommand(");
- assertNotEquals(0, ic1.hashCode());
- assertNotEquals(ic1, ic0);
- assertNotEquals(null, ic1);
-
- assertNotEquals(ic1, ic0);
-
- var ic2 = new InstantiationCommand();
-
- assertEquals(ic2, ic0);
- }
-}