Add documentation of participant composition properties
[policy/parent.git] / docs / clamp / acm / acm-participant-guide.rst
old mode 100644 (file)
new mode 100755 (executable)
index 4ce979e..b2ee244
@@ -90,6 +90,8 @@ AutomationCompositionElementListener:
   6. void update(UUID automationCompositionId, AcElementDeploy element, Map<String, Object> inProperties) throws PfModelException;
   7. void prime(UUID compositionId, List<AutomationCompositionElementDefinition> elementDefinitionList) throws PfModelException;
   8. void deprime(UUID compositionId) throws PfModelException;
+  9. void handleRestartComposition(UUID compositionId, List<AutomationCompositionElementDefinition> elementDefinitionList, AcTypeState state) throws PfModelException;
+  10. void handleRestartInstance(UUID automationCompositionId, AcElementDeploy element, Map<String, Object> properties, DeployState deployState, LockState lockState) throws PfModelException;
 
 These method from the interface are implemented independently as per the user requirement. These methods after handling the
 appropriate requests should also invoke the intermediary's publisher apis to notify the ACM-runtime with the acknowledgement events.
@@ -120,11 +122,34 @@ This following method is invoked to update the AC element state after each opera
 
   1.  void updateAutomationCompositionElementState(UUID automationCompositionId, UUID elementId, DeployState deployState, LockState lockState, StateChangeResult stateChangeResult, String message);
   2.  Map<UUID, AutomationComposition> getAutomationCompositions();
-  3.  void sendAcElementInfo(UUID automationCompositionId, UUID elementId, String useState, String operationalState, Map<String, Object> outProperties);
-  4.  void updateCompositionState(UUID compositionId, AcTypeState state, StateChangeResult stateChangeResult, String message);
+  3.  AutomationComposition getAutomationComposition(UUID automationCompositionId);
+  4.  AutomationCompositionElement getAutomationCompositionElement(UUID automationCompositionId, UUID elementId);
+  5.  Map<UUID, Map<ToscaConceptIdentifier, AutomationCompositionElementDefinition>> getAcElementsDefinitions();
+  6.  Map<ToscaConceptIdentifier, AutomationCompositionElementDefinition> getAcElementsDefinitions(UUID compositionId);
+  7.  AutomationCompositionElementDefinition getAcElementDefinition(UUID compositionId, ToscaConceptIdentifier elementId);
+  8.  void sendAcDefinitionInfo(UUID compositionId, ToscaConceptIdentifier elementId, Map<String, Object> outProperties);
+  9.  void updateCompositionState(UUID compositionId, AcTypeState state, StateChangeResult stateChangeResult, String message);
+  10.  void sendAcElementInfo(UUID automationCompositionId, UUID elementId, String useState, String operationalState, Map<String, Object> outProperties);
+
+In/Out composition Properties
+-----------------------------
+  The 'Common Properties' could be created or updated by ACM-runtime. Participants will receive that Properties during priming events.
 
-In/Out Properties
------------------
+  The 'Out Properties' could be created or updated by participants. ACM-runtime will receive that Properties during ParticipantStatus event.
+  The participant can trigger this event using the method sendAcDefinitionInfo.
+
+  Is allowed to the participant to read all In/Out Properties of all compositions handled by the participant using the method getAcElementsDefinitions.
+  The following code is an example how to update the property 'myProperty' and send to ACM-runtime:
+
+.. code-block:: java
+
+  var acElement = intermediaryApi.getAcElementDefinition(compositionId, elementId);
+  var outProperties = acElement.getOutProperties();
+  outProperties.put("myProperty", myProperty);
+  intermediaryApi.sendAcDefinitionInfo(compositionId, elementId, outProperties);
+
+In/Out instance Properties
+--------------------------
   The 'In Properties' could be created or updated by ACM-runtime. Participants will receive that Properties during deploy and update events.
 
   The 'Out Properties' could be created or updated by participants. ACM-runtime will receive that Properties during ParticipantStatus event.
@@ -136,14 +161,16 @@ In/Out Properties
 
 .. code-block:: java
 
-  var automationCompositions = intermediaryApi.getAutomationCompositions();
-  var automationComposition = automationCompositions.get(automationCompositionId);
-  var acElement = automationComposition.getElements().get(elementId);
+  var acElement = intermediaryApi.getAutomationCompositionElement(automationCompositionId, elementId);
   var outProperties = acElement.getOutProperties();
   outProperties.put("myProperty", myProperty);
   intermediaryApi.sendAcElementInfo(automationCompositionId, elementId, acElement.getUseState(), acElement.getOperationalState(), outProperties);
 
-
+Restart scenario
+----------------
+  Restart methods handle the scenario when participant shut down and restart.
+  The method handleRestartComposition will be called for each composition and will be present the 'state' at the time the participant shut down.
+  The method handleRestartInstance will be called for each instance element and will be present the 'deployState' and the 'lockState' at the time the participant shut down.
 
 In ONAP, the following participants are already implemented in java spring boot for various requirements. The maven modules
 can be referred here:
@@ -356,4 +383,61 @@ The following example shows the Handler implementation and how could be the impl
     }
 
 
+    @Override
+    public void handleRestartComposition(UUID compositionId,
+            List<AutomationCompositionElementDefinition> elementDefinitionList, AcTypeState state)
+            throws PfModelException {
+
+        switch (state) {
+            case PRIMING:
+                prime(compositionId, elementDefinitionList);
+                break;
+
+            case DEPRIMING:
+                // TODO restart process
+
+                deprime(compositionId);
+                break;
+
+            default:
+                // TODO restart process
+
+                intermediaryApi.updateCompositionState(compositionId, state, StateChangeResult.NO_ERROR, "Restarted");
+        }
+    }
+
+    @Override
+    public void handleRestartInstance(UUID automationCompositionId, AcElementDeploy element,
+            Map<String, Object> properties, DeployState deployState, LockState lockState) throws PfModelException {
+
+         // TODO restart process
+
+        if (DeployState.DEPLOYING.equals(deployState)) {
+            deploy(automationCompositionId, element, properties);
+            return;
+        }
+        if (DeployState.UNDEPLOYING.equals(deployState)) {
+            undeploy(automationCompositionId, element.getId());
+            return;
+        }
+        if (DeployState.UPDATING.equals(deployState)) {
+            update(automationCompositionId, element, properties);
+            return;
+        }
+        if (DeployState.DELETING.equals(deployState)) {
+            delete(automationCompositionId, element.getId());
+            return;
+        }
+        if (LockState.LOCKING.equals(lockState)) {
+            lock(automationCompositionId, element.getId());
+            return;
+        }
+        if (LockState.UNLOCKING.equals(lockState)) {
+            unlock(automationCompositionId, element.getId());
+            return;
+        }
+        intermediaryApi.updateAutomationCompositionElementState(automationCompositionId, element.getId(),
+                deployState, lockState, StateChangeResult.NO_ERROR, "Restarted");
+    }
+