diff options
author | FrancescoFioraEst <francesco.fiora@est.tech> | 2024-07-18 11:25:13 +0100 |
---|---|---|
committer | Francesco Fiora <francesco.fiora@est.tech> | 2024-07-18 10:40:22 +0000 |
commit | af4d49da0f35da5d1086f0181b594dcc772e383d (patch) | |
tree | a51ce01b8744ee89cbae1606826edf2fb5725173 /models/src/main/java | |
parent | d1ba3460535f4969b32fc30c61709737e1496471 (diff) |
Add support for Prepare, Review and Migrate pre-check in ACM model
Issue-ID: POLICY-5078
Change-Id: I22edfab66d35958c874f3322e573dec5bf8709d7
Signed-off-by: FrancescoFioraEst <francesco.fiora@est.tech>
Diffstat (limited to 'models/src/main/java')
12 files changed, 178 insertions, 7 deletions
diff --git a/models/src/main/java/org/onap/policy/clamp/models/acm/concepts/AutomationComposition.java b/models/src/main/java/org/onap/policy/clamp/models/acm/concepts/AutomationComposition.java index eb5b6dc9b..005d8a147 100644 --- a/models/src/main/java/org/onap/policy/clamp/models/acm/concepts/AutomationComposition.java +++ b/models/src/main/java/org/onap/policy/clamp/models/acm/concepts/AutomationComposition.java @@ -46,6 +46,8 @@ public class AutomationComposition extends ToscaEntity implements Comparable<Aut private Boolean restarting; + private Boolean precheck; + @NonNull private DeployState deployState = DeployState.UNDEPLOYED; @@ -56,6 +58,9 @@ public class AutomationComposition extends ToscaEntity implements Comparable<Aut private Integer phase; + @NonNull + private SubState subState = SubState.NONE; + private Map<UUID, AutomationCompositionElement> elements; private StateChangeResult stateChangeResult; @@ -71,10 +76,12 @@ public class AutomationComposition extends ToscaEntity implements Comparable<Aut this.compositionId = otherAutomationComposition.compositionId; this.compositionTargetId = otherAutomationComposition.compositionTargetId; this.restarting = otherAutomationComposition.restarting; + this.precheck = otherAutomationComposition.precheck; this.deployState = otherAutomationComposition.deployState; this.lockState = otherAutomationComposition.lockState; this.lastMsg = otherAutomationComposition.lastMsg; this.phase = otherAutomationComposition.phase; + this.subState = otherAutomationComposition.subState; this.elements = PfUtils.mapMap(otherAutomationComposition.elements, AutomationCompositionElement::new); this.stateChangeResult = otherAutomationComposition.stateChangeResult; } diff --git a/models/src/main/java/org/onap/policy/clamp/models/acm/concepts/AutomationCompositionElement.java b/models/src/main/java/org/onap/policy/clamp/models/acm/concepts/AutomationCompositionElement.java index 5afa7e0bb..16398e54b 100644 --- a/models/src/main/java/org/onap/policy/clamp/models/acm/concepts/AutomationCompositionElement.java +++ b/models/src/main/java/org/onap/policy/clamp/models/acm/concepts/AutomationCompositionElement.java @@ -55,6 +55,9 @@ public class AutomationCompositionElement { @NonNull private LockState lockState = LockState.LOCKED; + @NonNull + private SubState subState = SubState.NONE; + private String operationalState; private String useState; private String description; @@ -81,6 +84,7 @@ public class AutomationCompositionElement { this.restarting = otherElement.restarting; this.deployState = otherElement.deployState; this.lockState = otherElement.lockState; + this.subState = otherElement.subState; this.operationalState = otherElement.operationalState; this.useState = otherElement.useState; this.message = otherElement.message; diff --git a/models/src/main/java/org/onap/policy/clamp/models/acm/concepts/SubState.java b/models/src/main/java/org/onap/policy/clamp/models/acm/concepts/SubState.java new file mode 100644 index 000000000..5f979c50f --- /dev/null +++ b/models/src/main/java/org/onap/policy/clamp/models/acm/concepts/SubState.java @@ -0,0 +1,28 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2024 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.concepts; + +public enum SubState { + NONE, + MIGRATION_PRECHECKING, + PREPARING, + REVIEWING +} diff --git a/models/src/main/java/org/onap/policy/clamp/models/acm/messages/kafka/participant/AutomationCompositionMigration.java b/models/src/main/java/org/onap/policy/clamp/models/acm/messages/kafka/participant/AutomationCompositionMigration.java index fb1f1925c..6ae812cf4 100644 --- a/models/src/main/java/org/onap/policy/clamp/models/acm/messages/kafka/participant/AutomationCompositionMigration.java +++ b/models/src/main/java/org/onap/policy/clamp/models/acm/messages/kafka/participant/AutomationCompositionMigration.java @@ -37,6 +37,8 @@ public class AutomationCompositionMigration extends ParticipantMessage { // A list of updates to AC element properties private List<ParticipantDeploy> participantUpdatesList = new ArrayList<>(); + private Boolean precheck = false; + public AutomationCompositionMigration() { super(ParticipantMessageType.AUTOMATION_COMPOSITION_MIGRATION); } diff --git a/models/src/main/java/org/onap/policy/clamp/models/acm/messages/kafka/participant/AutomationCompositionPrepare.java b/models/src/main/java/org/onap/policy/clamp/models/acm/messages/kafka/participant/AutomationCompositionPrepare.java new file mode 100644 index 000000000..343143eed --- /dev/null +++ b/models/src/main/java/org/onap/policy/clamp/models/acm/messages/kafka/participant/AutomationCompositionPrepare.java @@ -0,0 +1,57 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2024 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.kafka.participant; + +import java.util.ArrayList; +import java.util.List; +import lombok.Getter; +import lombok.Setter; +import lombok.ToString; +import org.onap.policy.clamp.models.acm.concepts.ParticipantDeploy; +import org.onap.policy.models.base.PfUtils; + +@Getter +@Setter +@ToString(callSuper = true) +public class AutomationCompositionPrepare extends ParticipantMessage { + + private List<ParticipantDeploy> participantList = new ArrayList<>(); + private boolean preDeploy = true; + + /** + * Constructor for instantiating class with message name. + * + */ + public AutomationCompositionPrepare() { + super(ParticipantMessageType.AUTOMATION_COMPOSITION_PREPARE); + } + + /** + * Constructs the object, making a deep copy. + * + * @param source source from which to copy + */ + public AutomationCompositionPrepare(AutomationCompositionPrepare source) { + super(source); + this.preDeploy = source.preDeploy; + this.participantList = PfUtils.mapList(source.participantList, ParticipantDeploy::new); + } +} diff --git a/models/src/main/java/org/onap/policy/clamp/models/acm/messages/kafka/participant/ParticipantMessageType.java b/models/src/main/java/org/onap/policy/clamp/models/acm/messages/kafka/participant/ParticipantMessageType.java index e6e42e851..7e19f6f79 100644 --- a/models/src/main/java/org/onap/policy/clamp/models/acm/messages/kafka/participant/ParticipantMessageType.java +++ b/models/src/main/java/org/onap/policy/clamp/models/acm/messages/kafka/participant/ParticipantMessageType.java @@ -115,5 +115,10 @@ public enum ParticipantMessageType { /** * Used by runtime to send composition and instances to sync participant replicas. */ - PARTICIPANT_SYNC_MSG + PARTICIPANT_SYNC_MSG, + + /** + * Used by the acm runtime to ask for a preparation check to participants. + */ + AUTOMATION_COMPOSITION_PREPARE } diff --git a/models/src/main/java/org/onap/policy/clamp/models/acm/messages/rest/instantiation/AcInstanceStateUpdate.java b/models/src/main/java/org/onap/policy/clamp/models/acm/messages/rest/instantiation/AcInstanceStateUpdate.java index e47947a02..68c597b32 100644 --- a/models/src/main/java/org/onap/policy/clamp/models/acm/messages/rest/instantiation/AcInstanceStateUpdate.java +++ b/models/src/main/java/org/onap/policy/clamp/models/acm/messages/rest/instantiation/AcInstanceStateUpdate.java @@ -1,6 +1,6 @@ /*- * ============LICENSE_START======================================================= - * Copyright (C) 2021-2022 Nordix Foundation. + * Copyright (C) 2021-2022,2024 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -26,4 +26,5 @@ import lombok.Data; public class AcInstanceStateUpdate { private DeployOrder deployOrder; private LockOrder lockOrder; + private SubOrder subOrder; } diff --git a/models/src/main/java/org/onap/policy/clamp/models/acm/messages/rest/instantiation/SubOrder.java b/models/src/main/java/org/onap/policy/clamp/models/acm/messages/rest/instantiation/SubOrder.java new file mode 100644 index 000000000..9cf7efaa6 --- /dev/null +++ b/models/src/main/java/org/onap/policy/clamp/models/acm/messages/rest/instantiation/SubOrder.java @@ -0,0 +1,28 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2024 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; + +public enum SubOrder { + NONE, + MIGRATE_PRECHECK, + PREPARE, + REVIEW +} diff --git a/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/concepts/JpaAutomationComposition.java b/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/concepts/JpaAutomationComposition.java index 355fcaff0..1f4768ea8 100644 --- a/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/concepts/JpaAutomationComposition.java +++ b/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/concepts/JpaAutomationComposition.java @@ -45,6 +45,7 @@ import org.onap.policy.clamp.models.acm.concepts.AutomationComposition; import org.onap.policy.clamp.models.acm.concepts.DeployState; import org.onap.policy.clamp.models.acm.concepts.LockState; import org.onap.policy.clamp.models.acm.concepts.StateChangeResult; +import org.onap.policy.clamp.models.acm.concepts.SubState; import org.onap.policy.clamp.models.acm.utils.TimestampHelper; import org.onap.policy.common.parameters.annotations.NotNull; import org.onap.policy.common.parameters.annotations.Valid; @@ -97,6 +98,10 @@ public class JpaAutomationComposition extends Validated private LockState lockState; @Column + @NotNull + private SubState subState; + + @Column private StateChangeResult stateChangeResult; @Column @@ -119,7 +124,7 @@ public class JpaAutomationComposition extends Validated */ public JpaAutomationComposition() { this(UUID.randomUUID().toString(), new PfConceptKey(), UUID.randomUUID().toString(), new ArrayList<>(), - DeployState.UNDEPLOYED, LockState.NONE); + DeployState.UNDEPLOYED, LockState.NONE, SubState.NONE); } /** @@ -131,10 +136,12 @@ public class JpaAutomationComposition extends Validated * @param elements the elements of the automation composition in participants * @param deployState the Deploy State * @param lockState the Lock State + * @param subState the Sub State */ public JpaAutomationComposition(@NonNull final String instanceId, @NonNull final PfConceptKey key, @NonNull final String compositionId, @NonNull final List<JpaAutomationCompositionElement> elements, - @NonNull final DeployState deployState, @NonNull final LockState lockState) { + @NonNull final DeployState deployState, @NonNull final LockState lockState, + @NonNull final SubState subState) { this.instanceId = instanceId; this.name = key.getName(); this.version = key.getVersion(); @@ -142,6 +149,7 @@ public class JpaAutomationComposition extends Validated this.deployState = deployState; this.lockState = lockState; this.elements = elements; + this.subState = subState; } /** @@ -160,6 +168,7 @@ public class JpaAutomationComposition extends Validated this.lockState = copyConcept.lockState; this.lastMsg = copyConcept.lastMsg; this.phase = copyConcept.phase; + this.subState = copyConcept.subState; this.description = copyConcept.description; this.stateChangeResult = copyConcept.stateChangeResult; this.elements = PfUtils.mapList(copyConcept.elements, JpaAutomationCompositionElement::new); @@ -190,6 +199,7 @@ public class JpaAutomationComposition extends Validated automationComposition.setLockState(lockState); automationComposition.setLastMsg(lastMsg.toString()); automationComposition.setPhase(phase); + automationComposition.setSubState(subState); automationComposition.setDescription(description); automationComposition.setStateChangeResult(stateChangeResult); automationComposition.setElements(new LinkedHashMap<>(this.elements.size())); @@ -230,6 +240,7 @@ public class JpaAutomationComposition extends Validated this.lockState = automationComposition.getLockState(); this.lastMsg = TimestampHelper.toTimestamp(automationComposition.getLastMsg()); this.phase = automationComposition.getPhase(); + this.subState = automationComposition.getSubState(); this.description = automationComposition.getDescription(); this.stateChangeResult = automationComposition.getStateChangeResult(); } @@ -293,6 +304,11 @@ public class JpaAutomationComposition extends Validated return result; } + result = ObjectUtils.compare(subState, other.subState); + if (result != 0) { + return result; + } + result = ObjectUtils.compare(description, other.description); if (result != 0) { return result; diff --git a/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/concepts/JpaAutomationCompositionElement.java b/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/concepts/JpaAutomationCompositionElement.java index 74426a747..79ca9612e 100644 --- a/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/concepts/JpaAutomationCompositionElement.java +++ b/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/concepts/JpaAutomationCompositionElement.java @@ -1,6 +1,6 @@ /*- * ============LICENSE_START======================================================= - * Copyright (C) 2021-2023 Nordix Foundation. + * Copyright (C) 2021-2024 Nordix Foundation. * ================================================================================ * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved. * ================================================================================ @@ -42,6 +42,7 @@ import org.apache.commons.lang3.ObjectUtils; import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionElement; import org.onap.policy.clamp.models.acm.concepts.DeployState; import org.onap.policy.clamp.models.acm.concepts.LockState; +import org.onap.policy.clamp.models.acm.concepts.SubState; import org.onap.policy.common.parameters.annotations.NotNull; import org.onap.policy.common.parameters.annotations.Valid; import org.onap.policy.models.base.PfAuthorative; @@ -94,6 +95,10 @@ public class JpaAutomationCompositionElement extends Validated private LockState lockState; @Column + @NotNull + private SubState subState; + + @Column private String operationalState; @Column @@ -134,7 +139,7 @@ public class JpaAutomationCompositionElement extends Validated */ public JpaAutomationCompositionElement(@NonNull final String elementId, @NonNull final String instanceId) { this(elementId, instanceId, new PfConceptKey(), - DeployState.UNDEPLOYED, LockState.LOCKED); + DeployState.UNDEPLOYED, LockState.NONE, SubState.NONE); } /** @@ -145,15 +150,18 @@ public class JpaAutomationCompositionElement extends Validated * @param definition the TOSCA definition of the automation composition element * @param deployState the Deploy State of the automation composition * @param lockState the Lock State of the automation composition + * @param subState the Sub State of the automation composition */ public JpaAutomationCompositionElement(@NonNull final String elementId, @NonNull final String instanceId, @NonNull final PfConceptKey definition, - @NonNull final DeployState deployState, @NonNull final LockState lockState) { + @NonNull final DeployState deployState, @NonNull final LockState lockState, + @NonNull final SubState subState) { this.elementId = elementId; this.instanceId = instanceId; this.definition = definition; this.deployState = deployState; this.lockState = lockState; + this.subState = subState; } /** @@ -174,6 +182,7 @@ public class JpaAutomationCompositionElement extends Validated this.restarting = copyConcept.restarting; this.deployState = copyConcept.deployState; this.lockState = copyConcept.lockState; + this.subState = copyConcept.subState; this.operationalState = copyConcept.operationalState; this.useState = copyConcept.useState; this.message = copyConcept.message; @@ -201,6 +210,7 @@ public class JpaAutomationCompositionElement extends Validated element.setRestarting(restarting); element.setDeployState(deployState); element.setLockState(lockState); + element.setSubState(subState); element.setOperationalState(operationalState); element.setUseState(useState); element.setMessage(message); @@ -218,6 +228,7 @@ public class JpaAutomationCompositionElement extends Validated this.restarting = element.getRestarting(); this.deployState = element.getDeployState(); this.lockState = element.getLockState(); + this.subState = element.getSubState(); this.operationalState = element.getOperationalState(); this.useState = element.getUseState(); this.message = element.getMessage(); @@ -267,6 +278,11 @@ public class JpaAutomationCompositionElement extends Validated return result; } + result = ObjectUtils.compare(subState, other.subState); + if (result != 0) { + return result; + } + result = ObjectUtils.compare(useState, other.useState); if (result != 0) { return result; diff --git a/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/provider/AutomationCompositionProvider.java b/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/provider/AutomationCompositionProvider.java index ce258094a..9b736483d 100644 --- a/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/provider/AutomationCompositionProvider.java +++ b/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/provider/AutomationCompositionProvider.java @@ -35,6 +35,7 @@ import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionElement; import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionInfo; import org.onap.policy.clamp.models.acm.concepts.DeployState; import org.onap.policy.clamp.models.acm.concepts.LockState; +import org.onap.policy.clamp.models.acm.concepts.SubState; import org.onap.policy.clamp.models.acm.persistence.concepts.JpaAutomationComposition; import org.onap.policy.clamp.models.acm.persistence.concepts.JpaAutomationCompositionElement; import org.onap.policy.clamp.models.acm.persistence.repository.AutomationCompositionElementRepository; @@ -172,6 +173,8 @@ public class AutomationCompositionProvider { DeployState.UNDEPLOYING, DeployState.DELETING, DeployState.UPDATING, DeployState.MIGRATING)); jpaList.addAll(automationCompositionRepository.findByLockStateIn( List.of(LockState.LOCKING, LockState.UNLOCKING))); + jpaList.addAll(automationCompositionRepository.findBySubStateIn( + List.of(SubState.PREPARING, SubState.MIGRATION_PRECHECKING, SubState.REVIEWING))); return ProviderUtils.asEntityList(jpaList); } @@ -258,6 +261,7 @@ public class AutomationCompositionProvider { jpaAcElement.setUseState(element.getUseState()); jpaAcElement.setDeployState(element.getDeployState()); jpaAcElement.setLockState(element.getLockState()); + jpaAcElement.setSubState(element.getSubState()); jpaAcElement.setRestarting(element.getRestarting()); ProviderUtils.validate(element, jpaAcElement, "AutomationCompositionElement"); diff --git a/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/repository/AutomationCompositionRepository.java b/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/repository/AutomationCompositionRepository.java index d61dfb41b..7a1c61f5a 100644 --- a/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/repository/AutomationCompositionRepository.java +++ b/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/repository/AutomationCompositionRepository.java @@ -24,6 +24,7 @@ import java.util.Collection; import java.util.List; import org.onap.policy.clamp.models.acm.concepts.DeployState; import org.onap.policy.clamp.models.acm.concepts.LockState; +import org.onap.policy.clamp.models.acm.concepts.SubState; import org.onap.policy.clamp.models.acm.persistence.concepts.JpaAutomationComposition; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.stereotype.Repository; @@ -36,4 +37,6 @@ public interface AutomationCompositionRepository extends JpaRepository<JpaAutoma List<JpaAutomationComposition> findByDeployStateIn(Collection<DeployState> deployStates); List<JpaAutomationComposition> findByLockStateIn(Collection<LockState> lockStates); + + List<JpaAutomationComposition> findBySubStateIn(Collection<SubState> subStates); } |