Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Migration should allow the update of element definition versions.

...

Solution 1: add a flag in composition definition

The validation is active by default.

To disable the validation:

  • define the flag "migrateMajorVersion" as a property into the new composition definition with default false. 

    Code Block
    languageyml
      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".

    Code Block
    languageyml
        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


Solution 2: add a properties in properties file:

The validation is active by default.

To disable the validation, add migrate.validation.majorversion.enable properties to false in properties file.

Code Block
languageyml
migrate:
  validation:
    majorversion:
      enable: false



Versioning Validation:

Composition Element definitionNew Composition Element definitionCompatibilityValidation
Key 1.0.1Key 1.0.1IDENTICALOK
Key 1.0.1Key 1.0.1+build1PATCHOK
Key 1.0.1Key 1.0.2PATCHOK
Key 1.0.1Key 1.1.0MINOROK
Key 1.0.1Key 2.0.1MAJOR

FAIL

or FAIL or OK based on flag

 and WARN log

KeyDiff 1.0.1Key 1.0.1DIFFERENTFAIL

...

Code Block
languageyml
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 using AcElementListenerV1

Participant has to implement the "migrate" method.

...

Code Block
languagejava
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:

...


Implementation of the Participant using AcElementListenerV2

All data are already available into the respectively Objects.

Code Block
languagejava
/**
 * 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 {
}

...