Update doc for improvement of participant simulator
[policy/parent.git] / docs / clamp / acm / acm-user-guide.rst
index c2485ec..842032e 100644 (file)
@@ -75,7 +75,9 @@ org.onap.policy.clamp.acm.AutomationCompositionElement:
   the ACM elements.
   Here we are defining various timeout properties and startPhase parameter that are common for all the AC elements.
 
-  Note: This node type value should not be changed as the ACM framework identifies the AC elements based on this type.
+  Note:
+    This node type value can be customised if the user wants to change the default name. Please refer the "Configure custom namings for TOSCA node types"
+    section of the Automation Composition Runtime design and implementation.
 
 org.onap.policy.clamp.acm.K8SMicroserviceAutomationCompositionElement:
   This node type is used to define AC elements that are associated with kubernetes operations. It is further derived from the
@@ -92,7 +94,9 @@ org.onap.policy.clamp.acm.AutomationComposition:
   Primitive node type for defining Automation composition definitions that comprises one or more AC elements in it.
   The AC definition of this type will be created under the Node templates.
 
-  Note: This node type value should not be changed as the ACM framework identifies the AC definitions based on this type.
+  Note:
+    This node type value can be customised if the user wants to change the default name. Please refer the "Configure custom namings for TOSCA node types"
+    section of the Automation Composition Runtime design and implementation.
 
 .. literalinclude:: files/acm-nodetypes.yaml
    :language: yaml
@@ -210,6 +214,24 @@ Request payload
 .. literalinclude:: files/AC-instantiation.json
    :language: json
 
+Update AC instance properties (Optional)
+----------------------------------------
+Before the AC instance is deployed, the user is allowed to update the instance property values if needed. The runtime updates these new values
+in the database.
+
+.. code-block:: bash
+
+  Invoke a POST request
+  'http://policy_runtime_ip:port/onap/policy/clamp/acm/v2/compositions/${compositionId}/instances'
+
+Request Payload
+
+Example payload to update the base url of the http request
+
+.. literalinclude:: files/AC-update.json
+   :language: json
+
+
 Deploy AC instance
 ------------------
 Once the AC instance is created, the user can deploy the instance which in turn activates the corresponding participants to execute the intended operations.
@@ -243,6 +265,38 @@ Once all the AC elements are deployed, there should be a test microservice pod r
 configured to send events on the kafka by the http participant. This can be verified on the test microservice application logs.
 The AC instances can also be undeployed and deleted by the user.
 
+Update AC instance properties after deployment (Optional)
+---------------------------------------------------------
+After the AC instance is deployed, the user can still update the instance property values if needed. In this case, the runtime updates these new values
+in the database and also sends an update event to the participants. The participants has to implement the update method to perform the
+required operation.
+
+.. code-block:: bash
+
+  Invoke a POST request
+  'http://policy_runtime_ip:port/onap/policy/clamp/acm/v2/compositions/${compositionId}/instances'
+
+Note:
+  Please refer the request payload section for updating the instance properties before deployment.
+
+Migrate AC instance
+-------------------
+After the AC instance is deployed, the user can migrate it to other composition definition.
+The target composition have to be primed and have to contain the same element definitions present in the source composition.
+The user can update the instance property values if needed.
+
+.. code-block:: bash
+
+  Invoke a POST request
+  'http://policy_runtime_ip:port/onap/policy/clamp/acm/v2/compositions/${compositionId}/instances'
+
+Request Payload
+
+Example payload to migrate and update the base url of the http request
+
+.. literalinclude:: files/AC-migrate.json
+   :language: json
+
 UnDeploy AutomationComposition
 ------------------------------
 The AC instances can be undeployed from the system by the participants.
@@ -293,4 +347,148 @@ The AC definitions can be deleted if there are no instances are running and it i
 
   Invoke a DELETE request 'http://policy_runtime_ip:port/onap/policy/clamp/acm/v2/compositions/${compositionId}'
 
-This return a 200 response on a successful deletion operation.
\ No newline at end of file
+This return a 200 response on a successful deletion operation.
+
+Participant simulator
+=====================
+Participant simulator do not execute any particular functionality, and can be used to mock one or more participants in debug tests.
+It should be used to test ACM-runtime and Participant Intermediary in specific scenario that could be difficult to replay in real environment.
+
+Functionality covered:
+
+#. Set participantId and supportedElementType by properties file or by parameter environment.
+#. Set a delay for each operation at runtime by Rest-Api.
+#. Set success or fail for each operation at runtime by Rest-Api.
+#. update composition outProperties and send to ACM-runtime by Rest-Api.
+#. read all AC Definition inProperties/outProperties information by Rest-Api.
+#. update useState, operationalState and outProperties and send to ACM-runtime by Rest-Api.
+#. read all AC instance elements information by Rest-Api.
+#. log of all information for each operation.
+
+Mock a participant using docker-compose
+---------------------------------------
+The follow example show a docker-compose configuration to mock http Participant, where 'onap/policy-clamp-ac-sim-ppnt' is the Participant simulator image:
+
+.. code-block:: yaml
+
+  http-participant:
+    image: onap/policy-clamp-ac-sim-ppnt
+    environment:
+      - participantId=101c62b3-8918-41b9-a747-d21eb79c6c01
+      - supportedElementTypeName=org.onap.policy.clamp.acm.HttpAutomationCompositionElement
+      - SERVER_SSL_ENABLED=false
+      - useHttps=false
+      - SERVER_PORT=8084
+    ports:
+      - "8084:8084"
+
+Set delay and success/fail
+--------------------------
+Parameters like delay and success/fail could be set any time using the following endpoint:
+
+.. code-block:: bash
+
+  Invoke a PUT request 'http://participant_sim_ip:port/onap/policy/clamp/acm/simparticipant/v2/parameters'
+
+The Json below is an example of configuration:
+
+.. code-block:: json
+
+  {
+    "deploySuccess": true,
+    "undeploySuccess": true,
+    "lockSuccess": true,
+    "unlockSuccess": true,
+    "deleteSuccess": true,
+    "updateSuccess": true,
+    "migrateSuccess": true,
+    "primeSuccess": true,
+    "deprimeSuccess": true,
+    "deployTimerMs": 1000,
+    "undeployTimerMs": 1000,
+    "migrateTimerMs": 100,
+    "lockTimerMs": 100,
+    "unlockTimerMs": 100,
+    "updateTimerMs": 100,
+    "deleteTimerMs": 100,
+    "primeTimerMs": 100,
+    "deprimeTimerMs": 100
+  }
+
+Update and send composition outProperites
+-----------------------------------------
+Data like useState operationalState and outProperites could be updated any time using the following endpoint:
+
+.. code-block:: bash
+
+  Invoke a PUT request 'http://participant_sim_ip:port/onap/policy/clamp/acm/simparticipant/v2/compositiondatas'
+
+The Json below is an example of update, where {{compositionId}} is the UUID of the AC Definition
+and ("onap.policy.clamp.ac.element.Http_BridgeAutomationCompositionElement", "1.2.3") is the ToscaConceptIdentifier  of the AC Definition element:
+
+.. code-block:: json
+
+  {
+        "outProperties": {
+            "list": [
+                {"id": 10 },
+                {"id": 20 }
+            ]
+        },
+        "compositionId": "{{compositionId}}",
+        "compositionDefinitionElementId": {
+            "name": "onap.policy.clamp.ac.element.Http_BridgeAutomationCompositionElement",
+            "version": "1.2.3"
+        }
+  }
+
+Read all AC Definition elements information
+-------------------------------------------
+All AC Definition elements information like composition inProperties and outProperties
+could be read using the following endpoint:
+
+.. code-block:: bash
+
+  Invoke a GET request 'http://participant_sim_ip:port/onap/policy/clamp/acm/simparticipant/v2/compositiondatas'
+
+Update and send useState operationalState and instance outProperites
+--------------------------------------------------------------------
+Data like useState operationalState and outProperites could be updated any time using the following endpoint:
+
+.. code-block:: bash
+
+  Invoke a PUT request 'http://participant_sim_ip:port/onap/policy/clamp/acm/simparticipant/v2/datas'
+
+The Json below is an example of update, where {{instanceId}} is the UUID of the AC instance and {{instanceElementId}} is the UUID of the AC instance element:
+
+.. code-block:: json
+
+  {
+        "outProperties": {
+            "Opresult": true,
+            "list": [
+                {"id": 1 },
+                {"id": 2 }
+            ]
+        },
+        "automationCompositionId": "{{instanceId}}",
+        "automationCompositionElementId": "{{instanceElementId}}",
+        "useState": "IDLE",
+        "operationalState": "ENABLED"
+  }
+
+Read all AC instance elements information
+-----------------------------------------
+All AC instance elements information like deployState, lockState, useState, operationalState, inProperties and outProperties
+could be read using the following endpoint:
+
+.. code-block:: bash
+
+  Invoke a GET request 'http://participant_sim_ip:port/onap/policy/clamp/acm/simparticipant/v2/instances'
+
+Log of all information for each operation
+-----------------------------------------
+All information for each operation are logged, so the developer can monitoring what data are passed through the calls. Example of log during deploy.
+
+26-02-2024 09:55:38.547 [pool-4-thread-4] DEBUG  o.o.p.c.a.p.s.m.h.AutomationCompositionElementHandler.deploy **- deploy call**
+**compositionElement: CompositionElementDto[** compositionId=6502ba5e-1939-42b0-8bd2-bf89f0d51be6, elementDefinitionId=onap.policy.clamp.ac.element.Http_StarterAutomationCompositionElement 1.2.3, inProperties={ ... }, outProperties={} **], instanceElement: InstanceElementDto[** instanceId=022b3dee-a878-4b32-8544-de86e67e7335, elementId=2d614898-4945-41c7-9127-947b401aa753, toscaServiceTemplateFragment=ToscaServiceTemplate( ... ), inProperties={ ... }, outProperties={} **]**