Use of different version in composition definition element
it will be log a WARN if the version of the target composition element is not compatible to the composition element version.
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
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
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();
Migration precheck
Assumptions:
- Only the participants can execute a precheck.
- Precheck is executed before the migration, if it fail the migration will be not executed.
- User needs to receive the result of the precheck.
- Acm-runtime needs to handle the precheck fail in a different way it handles migration fail.
Solution 1: change the current flow of migration
User can send the action migration POST as before. The migration flow will be not backwards-compatible.
- User send migration action
- Acm-runtime stores the migration data (instance properties and composition target) in secondary table. the instance will be in "MIGRATING-PRECHECK" state
- Acm-runtime sends migration-precheck message to participants
- Participant receives migration-precheck message and executes the precheck and sends the result
- Acm-runtime receives precheck-result messages from all participants
- If all precheck result are OK for all participants, Acm-runtime update properties and composition target from secondary table and sends migration-execution message to participants. The instance will be in "MIGRATING" state
- If there is a precheck result failed, Acm-runtime has to show this result into the instance, deployState will be in "DEPLOYED" state, (instance properties will be as before). Data in secondary table will be cleaned.
Solution 2: create a new flow for migration-precheck.
User can send the action migration-precheck POST. The user can do the action migration POST after that. The migration flow is still backwards-compatible.
- User send migration-precheck action
- Acm-runtime set the instance in "MIGRATING-PRECHECK" state
- Acm-runtime sends migration-precheck message to participants
- Participant receives migration-precheck message and executes the precheck and sends the result
- Acm-runtime receives precheck-result messages from all participants
- Acm-runtime shows this result into the instance and deployState will be in "DEPLOYED" state