Migration should allow the update of element definition versions.
Add a flag to support major versioning:
define the flag "migrateMajorVersion" as a property into the new composition definition with default false.
org.onap.policy.clamp.acm.AutomationCompositionElement: version: 1.0.1 derived_from: tosca.nodetypes.Root properties: provider: type: string required: false migrateMajorVersion: type: boolean required: false default: false metadata: common: true description: Allow to migrate to major version startPhase: type: integer required: false constraints: - greater-or-equal: 0 metadata: common: true description: A value indicating the start phase in which this automation composition element will be started, the first start phase is zero. Automation composition elements are started in their start_phase order and stopped in reverse start phase order. Automation composition elements with the same start phase are started and stopped simultaneously
use the property "migrateMajorVersion".
onap.policy.clamp.ac.element.Policy_AutomationCompositionElement: version: 1.2.4 type: org.onap.policy.clamp.acm.PolicyAutomationCompositionElement type_version: 1.0.0 description: Automation composition element for the operational policy for Performance Management Subscription Handling properties: provider: Ericsson startPhase: 0 migrateMajorVersion: false
Versioning Validation:
Composition Element definition | New Composition Element definition | Compatibility | Validation |
---|---|---|---|
Key 1.0.1 | Key 1.0.1 | IDENTICAL | OK |
Key 1.0.1 | Key 1.0.1+build1 | PATCH | OK |
Key 1.0.1 | Key 1.0.2 | PATCH | OK |
Key 1.0.1 | Key 1.1.0 | MINOR | OK |
Key 1.0.1 | Key 2.0.1 | MAJOR | FAIL or OK based on flag and WARN log |
KeyDiff 1.0.1 | Key 1.0.1 | DIFFERENT | FAIL |
Example:
Creation composition "1.2.3" and prime (compositionId):
onap.policy.clamp.ac.element.AutomationCompositionDefinition: version: 1.2.3 type: org.onap.policy.clamp.acm.AutomationComposition type_version: 1.0.1 description: Automation composition for Demo properties: provider: ONAP elements: - name: onap.policy.clamp.ac.element.Policy_AutomationCompositionElement version: 1.2.3
Creation Instance and deploy:
elements: 709c62b3-8918-41b9-a747-d21eb79c6c30: id: 709c62b3-8918-41b9-a747-d21eb79c6c30 definition: name: onap.policy.clamp.ac.element.Policy_AutomationCompositionElement version: 1.2.3
Creation Composition 1.2.4 and prime (compositionTargetId):
onap.policy.clamp.ac.element.AutomationCompositionDefinition: version: 1.2.4 type: org.onap.policy.clamp.acm.AutomationComposition type_version: 1.0.1 description: Automation composition for Demp properties: provider: ONAP elements: - name: onap.policy.clamp.ac.element.Policy_AutomationCompositionElement version: 1.2.4
Migration Instance from 1.2.3 to 1.2.4:
elements: 709c62b3-8918-41b9-a747-d21eb79c6c30: id: 709c62b3-8918-41b9-a747-d21eb79c6c30 definition: name: onap.policy.clamp.ac.element.Policy_AutomationCompositionElement version: 1.2.4
Implementation of the Participant
Participant has to implement the "migrate" method.
public void migrate(UUID instanceId, AcElementDeploy element, UUID compositionTargetId,
Map<String, Object> properties) throws PfModelException {
- Retrieve outProperties from composition 1.2.3 and 1.2.4: The hardcoded values in the code below is intended to show the implication to have different version:
var automationComposition = participantIntermediaryApi.getAutomationComposition(instanceId); var compositionId = automationComposition.getCompositionId(); var acElementDefinition = participantIntermediaryApi.getAcElementDefinition(compositionId, new ToscaConceptIdentifier("onap.policy.clamp.ac.element.Policy_AutomationCompositionElement", "1.2.3")); var outProperties123 = acElementDefinition.getOutProperties(); var acElementDefinition = participantIntermediaryApi.getAcElementDefinition(compositionTargetId, new ToscaConceptIdentifier("onap.policy.clamp.ac.element.Policy_AutomationCompositionElement", "1.2.4")); var outProperties124 = acElementDefinition.getOutProperties();
- Retrieve outProperties in real scenario
var automationComposition = participantIntermediaryApi.getAutomationComposition(instanceId); var compositionId = automationComposition.getCompositionId(); var acElementDefinitionsFrom = participantIntermediaryApi.getAcElementsDefinitions(compositionId); var acElementDefinitionFrom = acElementsDefinitionsFrom.values().stream() .filter(el -> el.getAcElementDefinitionId().getName().equals(element.getDefinition().getName())).findFirst().get(); var outPropertiesFrom = acElementDefinitionFrom.getOutProperties(); var acElementDefinitionTo = participantIntermediaryApi.getAcElementDefinition(compositionTargetId, element.getDefinition()); var outPropertiesTo = acElementDefinitionTo.getOutProperties();
- Refactor the migrate method.
Create two Document Transfer Object (using record) that contains all data:
/** * Migrate a automation composition element. * * @param compositionElement the old composition element, if new element elementDefinitionId will be null * @param compositionElementTarget the composition element target, if removed element elementDefinitionId will be null * @param instanceElement the old instance element, if new element elementId will be null * @param instanceElementMigrate the instance element with removed properties, if new element elementId will be null */ @Override public void migratePrecheck(CompositionElementDto compositionElement, CompositionElementDto compositionElementTarget, InstanceElementDto instanceElement, InstanceElementDto instanceElementMigrate) throws PfModelException { }