diff options
author | FrancescoFioraEst <francesco.fiora@est.tech> | 2023-02-07 11:06:01 +0000 |
---|---|---|
committer | FrancescoFioraEst <francesco.fiora@est.tech> | 2023-02-08 11:43:43 +0000 |
commit | c1fce9211058bf91b40415022a819d3b410f711e (patch) | |
tree | 17dfdfd8e6f3df63c886c406b091becd727f29e0 /models/src/main/java/org | |
parent | f15329432ee82d48d7ead388ba1866ebbba8efd8 (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/src/main/java/org')
7 files changed, 29 insertions, 36 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; -} |