# Create Control Loop Instance by CLAMP ###### tags: `ONAP` Once the service model is distributed, users can design the closed loop from CLAMP, using the GUI at [https://clamp.api.simpledemo.onap.org:30258](https://clamp.api.simpledemo.onap.org:30258) ## A Certificate must be added in the browser and is required to login properly ### [org.onap.clamp.p12 (from master)](https://gerrit.onap.org/r/gitweb?p=clamp.git;a=blob_plain;f=src/main/resources/clds/aaf/org.onap.clamp.p12;hb=refs/heads/master) ### Password: "China in the Spring" ## Create a new loop instance 1. Use the "Loop Instance" link to create a closed loop using a distributed model and click "Create" ![](https://i.imgur.com/XnTKrwa.png) 2. Select a templetem, input your model name "demo-vLB_Test", and click the "Create" button. ![](https://i.imgur.com/rUHTITi.png) 3. You can see the new instance on the main page ## Create a configuration policy 1. Next, click on the "tcagen2" box to create a configuration policy. From the pop-up window, click "Edit JSON" and paste the following JSON into the textfield, then click the "SAVE" button to complete. ``` { "tca.policy": { "domain": "measurementsForVfScaling", "metricsPerEventName": [ { "policyScope": "DCAE", "thresholds": [ { "version": "1.0.2", "severity": "MAJOR", "thresholdValue": 300, "closedLoopEventStatus": "ONSET", "closedLoopControlName": "LOOP_vLB_CDS", "direction": "LESS_OR_EQUAL", "fieldPath": "$.event.measurementsForVfScalingFields.vNicPerformanceArray[*].receivedTotalPacketsDelta" } ], "eventName": "vLoadBalancer", "policyVersion": "v0.0.1", "controlLoopSchemaType": "VM", "policyName": "DCAE.Config_tca-hi-lo" } ] } } ``` ![](https://i.imgur.com/5Q9i2PH.png) 2. Once the policy item has been created, you can define a threshold that will be used at runtime to evaluate telemetry reported by the vLB. ![](https://i.imgur.com/McVqMs1.png) 3. The "closedLoopControlName" field must be the same as the loop name just you created. Select the field "Pdp Group Info" to be "defaultGroup" and "xacml", then clikc the "Save Changes" button. ![](https://i.imgur.com/AA9BSnc.png) ## Create new Policy Model of type: Drools 1. Next, create the operational policy, which the Policy Engine uses to determine which actions and parameters should be used during closed loop. From the "Loop Instance" tab, you can select "Modify" to add a new Policy Model of type Drools. ![](https://i.imgur.com/IQlihMM.png) 2. From the pop-up window, select the "20 rows" to display more Policy Model Type items, then click the "onap.policies.controlloop.operational.common.Drools" policy and click the "Add" button at the bottom. ![](https://i.imgur.com/0spMxCd.png) 3. Click the "Drools" box on the main page. From the pop-up window, click "Edit JSON" and paste the following JSON into the textfield, then click the "SAVE" button to complete. ![](https://i.imgur.com/BCmiXzz.png) ``` { "abatement": false, "operations": [ { "failure_retries": "final_failure_retries", "id": "scaleout-test", "failure_timeout": "final_failure_timeout", "failure": "final_failure", "operation": { "payload": { "requestParameters": "{\"usePreload\":true,\"userParams\":[]}", "configurationParameters": "[{\"ip-addr\":\"$.vf-module-topology.vf-module-parameters.param[16]\",\"oam-ip-addr\":\"$.vf-module-topology.vf-module-parameters.param[30]\"}]" }, "target": { "entityIds": { "resourceID": "VdnsCdsSoftwareProduct..vdns..module-3", "modelInvariantId": "a224db16-adc5-483a-9390-e7504e9faedb", "modelVersionId": "fab5be21-5fb0-42e5-a914-8357c757ec2b", "modelName": "VdnsCdsSoftwareProduct..vdns..module-3", "modelVersion": "1", "modelCustomizationId": "8835ff6f-23c6-460c-a772-b50929170646" }, "targetType": "VFMODULE" }, "actor": "SO", "operation": "VF Module Create" }, "failure_guard": "final_failure_guard", "retries": 0, "timeout": 60, "failure_exception": "final_failure_exception", "description": "Test", "success": "final_success" } ], "trigger": "scaleout-test", "timeout": 600, "id": "LOOP_vLB_CDS" } ``` 4. Make sure the "id" field must be the same as the control loop id just you created. ![](https://i.imgur.com/B2fe2gh.png) 5. Scroll the pop-up window to the end. Assign the PDP group to be "defaultGroup" and "drools", then click the "Save Changes" button. ![](https://i.imgur.com/TGdfXeE.png) ## Create new Policy Model of type: Frequency Limiter 1. For what regards guard policies, either "Frequency Limiter", or "MinMax", or both can be used for the scale out use case. They can be added using the "Modify" item in the "Loop Instance" tab, then click the "onap.policies.controlloop.guard.common.FrequencyLimiter" policy and click the "Add" button at the bottom. ![](https://i.imgur.com/VCG5gqE.png) 2. Click the "FrquencyLimiter" box on the main page. From the pop-up window, click "Edit JSON" and paste the following JSON into the textfield, then click the "SAVE" button to complete. ``` { "id": "LOOP_vLB_CDS", "actor": "SO", "operation": "VF Module Create", "timeRange": { "start_time": "00:00:00Z", "end_time": "23:59:59Z" }, "limit": 1, "timeWindow": 10, "timeUnits": "minute" } ``` 3. Make sure the "id" field must be the same as the control loop id just you created. Assign the PDP group to be "defaultGroup" and "xacml", then click the "Save Changes" button. ![](https://i.imgur.com/eBorIOp.png) 4. Once the operational policy design is completed, you can submit and then deploy the closed loop clicking the "Submit" and "Deploy" buttons from the "Loop Operations" tab, as shown below. ![](https://i.imgur.com/iWOzWRX.png) ![](https://i.imgur.com/6WFy7oz.png) ## Check out the component state of Policy and DCAE 1. Check out the loop status on the top of main page. ![](https://i.imgur.com/q7axocm.png)