Merge "Generate API documents"
authorSébastien Determe <sd378r@intl.att.com>
Wed, 23 May 2018 15:52:30 +0000 (15:52 +0000)
committerGerrit Code Review <gerrit@onap.org>
Wed, 23 May 2018 15:52:30 +0000 (15:52 +0000)
14 files changed:
docs/release-notes.rst
pom.xml
src/main/java/org/onap/clamp/clds/client/req/tca/TcaRequestFormatter.java
src/main/java/org/onap/clamp/clds/model/properties/PolicyItem.java
src/main/java/org/onap/clamp/clds/service/CldsService.java
src/main/resources/META-INF/resources/designer/partials/portfolios/PolicyWindow_properties.html
src/main/resources/META-INF/resources/designer/partials/portfolios/deploy_parameters.html
src/main/resources/META-INF/resources/designer/scripts/DeploymentCtrl.js
src/test/resources/example/model-properties/policy/modelBpmnProperties.json
src/test/resources/example/operational-policy/yaml-policy-chain-1.yaml
src/test/resources/example/operational-policy/yaml-policy-chain-2.yaml
src/test/resources/example/tca-policy-req/blueprint-expected.yaml
src/test/resources/example/tca-policy-req/tca-policy-expected.json
version.properties

index 2e6fd47..fa5d8b6 100644 (file)
@@ -5,7 +5,7 @@
 Release Notes
 =============
 
-Version: 2.0.0
+Version: 2.0.1
 --------------
 
 :Release Date: 2018-06-25
diff --git a/pom.xml b/pom.xml
index dcfbcb7..4beb6d6 100644 (file)
--- a/pom.xml
+++ b/pom.xml
@@ -26,7 +26,7 @@
                <modelVersion>4.0.0</modelVersion>
                <groupId>org.onap.clamp</groupId>
                <artifactId>clds</artifactId>
-               <version>2.0.0-SNAPSHOT</version>
+               <version>2.0.1-SNAPSHOT</version>
                <name>clamp</name>
 
                <parent>
index 35c438d..1478342 100644 (file)
@@ -157,10 +157,9 @@ public class TcaRequestFormatter {
     private static void addThresholds(ClampProperties refProp, String service, ObjectNode appendToNode, TcaItem tcaItem,
             ModelProperties modelProperties) {
         ArrayNode tcaNodes = appendToNode.withArray("thresholds");
-        ObjectNode tcaNode;
         try {
-            tcaNode = (ObjectNode) refProp.getJsonTemplate("tca.thresholds.template", service);
             for (TcaThreshold tcaThreshold : tcaItem.getTcaThresholds()) {
+                ObjectNode tcaNode = (ObjectNode) refProp.getJsonTemplate("tca.thresholds.template", service);
                 tcaNode.put("closedLoopControlName", modelProperties.getControlNameAndPolicyUniqueId());
                 tcaNode.put("fieldPath", tcaThreshold.getFieldPath());
                 tcaNode.put("thresholdValue", tcaThreshold.getThreshold());
index bb14b23..337a976 100644 (file)
@@ -48,17 +48,17 @@ import java.util.List;
  * "targetResourceId","value":["Eace933104d443b496b8.nodes.heat.vpg"]}]]}]
  */
 public class PolicyItem implements Cloneable {
-    protected static final EELFLogger logger      = EELFManager.getInstance().getLogger(PolicyItem.class);
-    protected static final EELFLogger auditLogger = EELFManager.getInstance().getAuditLogger();
 
-    private String                    id;
-    private String                    recipe;
-    private int                       maxRetries;
-    private int                       retryTimeLimit;
-    private String                    parentPolicy;
-    private List<String>              parentPolicyConditions;
-    private String                    actor;
-    private String                    targetResourceId;
+    protected static final EELFLogger logger = EELFManager.getInstance().getLogger(PolicyItem.class);
+    protected static final EELFLogger auditLogger = EELFManager.getInstance().getAuditLogger();
+    private String id;
+    private String recipe;
+    private int maxRetries;
+    private int retryTimeLimit;
+    private String parentPolicy;
+    private List<String> parentPolicyConditions;
+    private String actor;
+    private String targetResourceId;
 
     /**
      * Parse Policy given json node.
@@ -73,7 +73,9 @@ public class PolicyItem implements Cloneable {
         parentPolicy = AbstractModelElement.getValueByName(node, "parentPolicy");
         parentPolicyConditions = AbstractModelElement.getValuesByName(node, "parentPolicyConditions");
         targetResourceId = AbstractModelElement.getValueByName(node, "targetResourceId");
-
+        if (targetResourceId != null && targetResourceId.isEmpty()) {
+            this.setTargetResourceId(null);
+        }
     }
 
     /**
index 888b782..9b68845 100644 (file)
@@ -835,6 +835,10 @@ public class CldsService extends SecureServiceBase {
             fillInCldsModel(model);
             String bpmnJson = cldsBpmnTransformer.doXslTransformToString(model.getBpmnText());
             logger.info("PUT bpmnJson={}", bpmnJson);
+            SecureServicePermission permisionManage = SecureServicePermission.create(cldsPermissionTypeClManage,
+                    cldsPermissionInstance, CldsEvent.ACTION_DEPLOY);
+            isAuthorized(permisionManage);
+            isAuthorizedForVf(model);
             ModelProperties modelProp = new ModelProperties(modelName, model.getControlName(), CldsEvent.ACTION_DEPLOY,
                     false, bpmnJson, model.getPropText());
             checkForDuplicateServiceVf(modelName, model.getPropText());
@@ -890,6 +894,10 @@ public class CldsService extends SecureServiceBase {
         LoggingUtils.setRequestContext("CldsService: Undeploy model", getPrincipalName());
         Boolean errorCase = false;
         try {
+            SecureServicePermission permisionManage = SecureServicePermission.create(cldsPermissionTypeClManage,
+                    cldsPermissionInstance, CldsEvent.ACTION_UNDEPLOY);
+            isAuthorized(permisionManage);
+            isAuthorizedForVf(model);
             String operationStatusUndeployUrl = dcaeDispatcherServices.deleteExistingDeployment(model.getDeploymentId(),
                     model.getTypeId());
             String operationStatus = dcaeDispatcherServices.getOperationStatusWithRetry(operationStatusUndeployUrl);
index 7dd2c4d..83fb337 100644 (file)
@@ -286,9 +286,13 @@ label {
                                                        <label for="targetResourceId" class="col-sm-4 control-label">
                                                                Target ResourceId</label>
                                                        <div class="col-sm-8">
-                                                               <input type="text" class="form-control" id="targetResourceId"
-                                                                       name="targetResourceId"> </input>
+                                                               <select class="form-control" name="targetResourceId" id="targetResourceId" enableFilter="true" onchange="changeTargetResourceIdOther();" >
+                                                                       <option value=""></option>
+                                                                       <option value="Other:">Other:</option>
+                                                               </select>
                                                        </div>
+                                                       <input type="text" style="display:none" class="form-control" id="targetResourceIdOther"
+                                                               name="targetResourceIdOther" value=""></input>
                                                </div>
                                        </div>
                                </form>
@@ -304,6 +308,22 @@ label {
        </div>
 
        <script>
+       
+       function initTargetResourceId() {
+               // Set all the Resource Invariant UUID in the target resource ID list (+Empty and other) 
+               Object.keys(vf_Services["shared"]["byVf"]).forEach(function(key){
+                       $('#targetResourceId').append($('<option></option>').val(key).html(key));
+               });
+       }
+       
+       function changeTargetResourceIdOther() {
+               if ($("#targetResourceId").val()==="Other:") {
+                       $("#targetResourceIdOther").show();
+               } else {
+                       $("#targetResourceIdOther").hide();
+                       $("#targetResourceIdOther").val("");
+               }
+       }
                //Basically this method will add a new form. All forms share the same class. When you want one form to show(active form) the other forms get the 
                // css attribute display:none
                $("#add_one_more").click(function(event) {
@@ -334,7 +354,8 @@ label {
                        }
                }
                $("#pname").val('');            
-               
+               initTargetResourceId();
+
                //load recipes for a chosen policy
                function disperseConfig(policyObj, id){
                        parent_policy={};
@@ -360,7 +381,13 @@ label {
                                                                parent_policy[num]=el[i][j].value 
                                                        if(el[i][j].name==='recipe' && el[i][j].value.toString()!==''){
                                                                $("#go_properties_tab"+num).text(el[i][j].value)
-                                                       }       
+                                                       }
+                                                       if(el[i][j].name==="targetResourceIdOther" && el[i][j].value.toString()!=='') {
+                                                               // Add the entry and set it
+                                                               $('#targetResourceId').append($('<option></option>').val($('#targetResourceIdOther').val()).html($('#targetResourceIdOther').val()));
+                                                               $('#targetResourceId').val($('#targetResourceIdOther').val());
+                                                       }
+                                                       
                                                }
                                        }
                                }
@@ -385,13 +412,14 @@ label {
                                        $("#formId"+k+" #parentPolicy").change();
                                }
                                
+                               // Now load all component with the right value defined in policyObj JSON
                                for (headInd in policyObj[id]){
                                        if (!(policyObj[id][headInd].hasOwnProperty("policyConfigurations"))){
                                                $("#" + policyObj[id][headInd].name).val(policyObj[id][headInd].value);
                                        }
                                }
                        }
-                       
+
                        setMultiSelect();
                        
                        if (readMOnly){
@@ -454,6 +482,10 @@ label {
                }
                
                $("#savePropsBtn").click(function(event) {
+                       if($("#targetResourceIdOther").is(":visible")) {
+                               $('#targetResourceId').append($('<option></option>').val($("#targetResourceIdOther").val()).html($("#targetResourceIdOther").val()))
+                               $("#targetResourceId").val($("#targetResourceIdOther").val());
+                       }
                        $(".idError").hide();
                        if ($("#policyTable .highlight td").html() !== $("#pname").val()){
                                //repeated name
@@ -483,7 +515,7 @@ label {
                                        finalSaveList[tableVal] = allPolicies[tableVal];
                                }
                        });
-                       
+
                        saveProperties(finalSaveList);
                        $("#close_button").click();
                })              
index 5693a87..3fc1b03 100644 (file)
                <button type="button" class="close" ng-click="close()" aria-hidden="true" style="margin-top: -3px">&times;</button>
                <h4>Deployment parameters</h4>
        </div>
-       <div class="modal-body" style="height: 150px">
-                 <div style="height: 30px">
-        Deployment parameters as JSON.
+       <div class="modal-body" style="display:block">
+                 <div style="height: 100%;clear: both;" id="deployPropertiesDiv" name="deployPropertiesDiv" ng-init="load_deploy_parameters()" >
+        Deployment parameters.
       </div>
-      <textarea class="form-control" focus="true" name="deployProperties" id="deployProperties" ng-init="load_deploy_parameters()"/>
+     
        </div>
        <div class="modal-footer">
       <button ng-click="deploy()"  class="btn btn-primary">Deploy</button>
index 950e59c..9350912 100644 (file)
@@ -26,10 +26,18 @@ app.controller('DeploymentCtrl',
        function( $scope,  $rootScope,  $modalInstance,  data,  dialogs,   cldsModelService) {
 
            function validate_and_set_deploy_parameters () {
-                  var parameters = $("#deployProperties").val();
+                  var inputList = document.getElementsByClassName("deployFormId");
+                  var jsonParameters="{";
+                  $.each(inputList, function(key) {
+                          if (jsonParameters !== "{") {
+                                  jsonParameters = jsonParameters+",";
+                          }
+                         jsonParameters = jsonParameters+'"'+inputList[key].id+'":'+'"'+inputList[key].value+'"'
+                  });
+                  jsonParameters = jsonParameters+"}";
                try {
-                   parameters = JSON.parse(parameters);
-                   set_deploy_parameters(parameters);
+                   //Try to validate the json
+                   set_deploy_parameters(JSON.parse(jsonParameters));
                } catch (e) {
                    console.error("Couldn't parse deploy parameters json");
                }
@@ -39,7 +47,6 @@ app.controller('DeploymentCtrl',
                if (!'global' in elementMap) {
                    elementMap["global"] = [];
                }
-
                var index = elementMap["global"].findIndex(function (e) { return (typeof e == "object" && !(e instanceof Array)) && "deployParameters" == e["name"]; }); 
                if (index == -1) { 
                    elementMap["global"].push({"name": "deployParameters", "value": parameters}); 
@@ -50,8 +57,14 @@ app.controller('DeploymentCtrl',
 
            $scope.load_deploy_parameters = function () {
                   var index = elementMap["global"].findIndex(function (e) { return (typeof e == "object" && !(e instanceof Array)) && "deployParameters" == e["name"]; }); 
-               if (index != -1) { 
-                  $('#deployProperties').val(JSON.stringify(elementMap["global"][index]["value"]))
+               if (index != -1) {
+                  $('#deployPropertiesDiv').append($('<br/>'));
+                  $.each(elementMap["global"][index].value, function(key) {
+                          var propertyValue=elementMap["global"][index].value[key];
+                          $('#deployPropertiesDiv').append($('<label class="control-label">'+key+'  </label>'));
+                          $('#deployPropertiesDiv').append($('<input style="width: 100%; clear: both;" class="deployFormId" id="'+key+'"></input>').val(propertyValue).html(propertyValue));
+                          $('#deployPropertiesDiv').append($('<br/>'));
+               });
                }
            }
 
index 5c2214e..0ef3875 100644 (file)
                             "name": "targetResourceId",
                             "value":
                             [
-                                "resource-id"
+                                ""
+                            ]
+                        },
+                        {
+                            "name": "targetResourceIdOther",
+                            "value":
+                            [
+                                ""
                             ]
                         }
                     ],
                             [
                                 "resource-id"
                             ]
+                        },
+                        {
+                            "name": "targetResourceIdOther",
+                            "value":
+                            [
+                                "resource-idOther"
+                            ]
                         }
                     ]
                 ]
                             [
                                 ""
                             ]
-                        },
-                        {
-                            "name": "targetResourceId",
-                            "value":
-                            [
-                                "resource-id"
-                            ]
                         }
                     ],
 
                             [
                                 "resource-id"
                             ]
+                        },
+                        {
+                            "name": "targetResourceIdOther",
+                            "value":
+                            [
+                                "resource-idOther"
+                            ]
                         }
                     ]
                 ]
index fec0e1e..3d0252a 100644 (file)
@@ -31,7 +31,7 @@ policies:
   retry: 3
   success: <generatedId>
   target:
-    resourceID: resource-id
+    resourceID: null
     type: VM
   timeout: 180
 - actor: APPC
index fec0e1e..3d0252a 100644 (file)
@@ -31,7 +31,7 @@ policies:
   retry: 3
   success: <generatedId>
   target:
-    resourceID: resource-id
+    resourceID: null
     type: VM
   timeout: 180
 - actor: APPC
index 4116b97..a35557c 100644 (file)
@@ -30,7 +30,7 @@ node_templates:
         subscriberMessageLimit: '-1', subscriberPollingInterval: '20000', subscriberProtocol: https,
         subscriberTimeoutMS: '-1', subscriberTopicName: org.onap.dcae.dmaap.mtnje2.DcaeTestVESSub,
         subscriberUserName: m00502@tca.af.dcae.onap.org, subscriberUserPassword: Te5021abc,
-        tca_policy: '{"domain":"measurementsForVfScaling","metricsPerEventName":[{"eventName":"vFirewallBroadcastPackets","controlLoopSchemaType":"VNF","policyScope":"DCAE","policyName":"example_model01.ClosedLoop_FRWL_SIG_fad4dcae_e498_11e6_852e_0050568c4ccf_TCA_1jy9to4","policyVersion":"v0.0.1","thresholds":[{"closedLoopControlName":"ClosedLoop_FRWL_SIG_fad4dcae_e498_11e6_852e_0050568c4ccf_null","version":"1.0.2","fieldPath":"$.event.measurementsForVfScalingFields.additionalMeasurements[*].arrayOfFields[0].value","thresholdValue":123,"direction":"GREATER_OR_EQUAL","severity":"MAJOR","closedLoopEventStatus":"ONSET"},{"closedLoopControlName":"ClosedLoop_FRWL_SIG_fad4dcae_e498_11e6_852e_0050568c4ccf_null","version":"1.0.2","fieldPath":"$.event.measurementsForVfScalingFields.additionalMeasurements[*].arrayOfFields[0].value","thresholdValue":123,"direction":"GREATER_OR_EQUAL","severity":"MAJOR","closedLoopEventStatus":"ONSET"}]}]}'}
+        tca_policy: '{"domain":"measurementsForVfScaling","metricsPerEventName":[{"eventName":"vFirewallBroadcastPackets","controlLoopSchemaType":"VNF","policyScope":"DCAE","policyName":"example_model01.ClosedLoop_FRWL_SIG_fad4dcae_e498_11e6_852e_0050568c4ccf_TCA_1jy9to4","policyVersion":"v0.0.1","thresholds":[{"closedLoopControlName":"ClosedLoop_FRWL_SIG_fad4dcae_e498_11e6_852e_0050568c4ccf_null","version":"1.0.2","fieldPath":"$.event.measurementsForVfScalingFields.additionalMeasurements[*].arrayOfFields[0].value","thresholdValue":123,"direction":"LESS_OR_EQUAL","severity":"MAJOR","closedLoopEventStatus":"ABATED"},{"closedLoopControlName":"ClosedLoop_FRWL_SIG_fad4dcae_e498_11e6_852e_0050568c4ccf_null","version":"1.0.2","fieldPath":"$.event.measurementsForVfScalingFields.additionalMeasurements[*].arrayOfFields[0].value","thresholdValue":123,"direction":"GREATER_OR_EQUAL","severity":"MAJOR","closedLoopEventStatus":"ONSET"}]}]}'}
       artifact_name: dcae-analytics-tca
       artifact_version: 1.0.0
       connections:
index 5bf007b..6e302dd 100644 (file)
@@ -28,9 +28,9 @@
               "version": "1.0.2",
               "fieldPath": "$.event.measurementsForVfScalingFields.additionalMeasurements[*].arrayOfFields[0].value",
               "thresholdValue": 123,
-              "direction": "GREATER_OR_EQUAL",
+              "direction": "LESS_OR_EQUAL",
               "severity": "MAJOR",
-              "closedLoopEventStatus": "ONSET"
+              "closedLoopEventStatus": "ABATED"
             },
             {
               "closedLoopControlName": "ClosedLoop_FRWL_SIG_fad4dcae_e498_11e6_852e_0050568c4ccf_0",
index a81893c..93dca4b 100644 (file)
@@ -2,7 +2,7 @@
 # ============LICENSE_START=======================================================
 # ONAP CLAMP
 # ================================================================================
-# Copyright (C) 2017 AT&T Intellectual Property. All rights
+# Copyright (C) 2017-2018 AT&T Intellectual Property. All rights
 #                             reserved.
 # ================================================================================
 # Licensed under the Apache License, Version 2.0 (the "License"); 
@@ -27,7 +27,7 @@
 
 major=2
 minor=0
-patch=0
+patch=1
 
 base_version=${major}.${minor}.${patch}