Merge "Update policy model UI"
authorSébastien Determe <sebastien.determe@intl.att.com>
Tue, 17 Mar 2020 19:03:08 +0000 (19:03 +0000)
committerGerrit Code Review <gerrit@onap.org>
Tue, 17 Mar 2020 19:03:08 +0000 (19:03 +0000)
src/main/java/org/onap/clamp/clds/client/PolicyEngineServices.java
src/main/java/org/onap/clamp/policy/microservice/MicroServicePolicy.java
src/main/resources/clds/camel/routes/policy-flows.xml
src/test/resources/http-cache/example/policy/api/v1/policytypes&#63;connectionTimeToLive=5000/.file
src/test/resources/http-cache/example/policy/api/v1/policytypes/onap.policies.controlloop.guard.common.MinMax/versions/1.0.0&#63;connectionTimeToLive=5000/.file [new file with mode: 0644]
src/test/resources/http-cache/example/policy/api/v1/policytypes/onap.policies.controlloop.guard.common.MinMax/versions/1.0.0&#63;connectionTimeToLive=5000/.header [new file with mode: 0644]
ui-react/src/components/dialogs/Policy/PolicyModal.js

index 44abc9d..5e6d9d9 100644 (file)
@@ -27,12 +27,10 @@ import com.att.eelf.configuration.EELFLogger;
 import com.att.eelf.configuration.EELFManager;
 import com.google.gson.JsonArray;
 import com.google.gson.JsonObject;
-import java.util.ArrayList;
 import java.util.Iterator;
 import java.util.LinkedHashMap;
 import java.util.LinkedList;
 import java.util.List;
-import java.util.Map;
 import org.apache.camel.CamelContext;
 import org.apache.camel.Exchange;
 import org.apache.camel.builder.ExchangeBuilder;
@@ -118,15 +116,12 @@ public class PolicyEngineServices {
             return;
         }
 
-        List<LinkedHashMap<String, Object>> policyTypesList = (List<LinkedHashMap<String, Object>>) loadedYaml
+        LinkedHashMap<String, Object> policyTypesMap = (LinkedHashMap<String, Object>) loadedYaml
                 .get("policy_types");
-        policyTypesList.parallelStream().forEach(policyType -> {
-            Map.Entry<String, Object> policyTypeEntry =
-                    (Map.Entry<String, Object>) new ArrayList(policyType.entrySet()).get(0);
-
+        policyTypesMap.entrySet().stream().forEach(entryPolicyType -> {
             policyModelsService.createPolicyInDbIfNeeded(
-                    createPolicyModelFromPolicyEngine(policyTypeEntry.getKey(),
-                            ((String) ((LinkedHashMap<String, Object>) policyTypeEntry.getValue()).get("version"))));
+                    createPolicyModelFromPolicyEngine(entryPolicyType.getKey(),
+                            ((String) ((LinkedHashMap<String, Object>) entryPolicyType.getValue()).get("version"))));
         });
     }
 
index 47b3a4f..b3bd7e8 100644 (file)
@@ -152,8 +152,8 @@ public class MicroServicePolicy extends Policy implements Serializable {
 
     @Override
     public void updateJsonRepresentation(ToscaConverterWithDictionarySupport toscaConverter) {
-        toscaConverter.convertToscaToJsonSchemaObject(this.getPolicyModel().getPolicyModelTosca(),
-                this.getPolicyModel().getPolicyModelType());
+        this.setJsonRepresentation(toscaConverter.convertToscaToJsonSchemaObject(this.getPolicyModel().getPolicyModelTosca(),
+                this.getPolicyModel().getPolicyModelType()));
     }
 
     public Boolean getShared() {
index 48e518d..7b52f22 100644 (file)
                                                                </simple>
                                                </setHeader>
                                                <log loggingLevel="INFO"
-                                                               message="Endpoint to get all policy models: {{clamp.config.policy.pap.url}}/policy/api/v1/policytypes"></log>
+                                                               message="Endpoint to get all policy models: {{clamp.config.policy.api.url}}/policy/api/v1/policytypes"></log>
                                                <toD
                                                                uri="{{clamp.config.policy.api.url}}/policy/api/v1/policytypes?bridgeEndpoint=true&amp;useSystemProperties=true&amp;throwExceptionOnFailure=${exchangeProperty[raiseHttpExceptionFlag]}&amp;authMethod=Basic&amp;authUsername={{clamp.config.policy.api.userName}}&amp;authPassword={{clamp.config.policy.api.password}}&amp;connectionTimeToLive=5000&amp;httpClient.connectTimeout=10000&amp;httpClient.socketTimeout=20000&amp;authenticationPreemptive=true&amp;connectionClose=true"/>
                                                <convertBodyTo type="java.lang.String"/>                
                                                                </simple>
                                                </setHeader>
                                                <log loggingLevel="INFO"
-                                                               message="Endpoint to get policy model: {{clamp.config.policy.pap.url}}/policy/api/v1/policytypes/${exchangeProperty[policyModelName]}/versions/${exchangeProperty[policyModelVersion]}"></log>
+                                                               message="Endpoint to get policy model: {{clamp.config.policy.api.url}}/policy/api/v1/policytypes/${exchangeProperty[policyModelName]}/versions/${exchangeProperty[policyModelVersion]}"></log>
                                                <toD
                                                                uri="{{clamp.config.policy.api.url}}/policy/api/v1/policytypes/${exchangeProperty[policyModelName]}/versions/${exchangeProperty[policyModelVersion]}?bridgeEndpoint=true&amp;useSystemProperties=true&amp;throwExceptionOnFailure=${exchangeProperty[raiseHttpExceptionFlag]}&amp;authMethod=Basic&amp;authUsername={{clamp.config.policy.api.userName}}&amp;authPassword={{clamp.config.policy.api.password}}&amp;connectionTimeToLive=5000&amp;httpClient.connectTimeout=10000&amp;httpClient.socketTimeout=20000&amp;authenticationPreemptive=true&amp;connectionClose=true"/>
                                                <convertBodyTo type="java.lang.String"/>
index 0cce9c3..7f5b897 100644 (file)
@@ -1,34 +1,41 @@
-tosca_definitions_version: tosca_simple_yaml_1_0_0
+tosca_definitions_version: tosca_simple_yaml_1_1_0
 policy_types:
-  onap.policies.controlloop.operational.common.Drools:
+  onap.policies.controlloop.operational.common.Drools:
       version: 1.0.0
       description: Operational Policy for Control Loops using the Drools PDP
       derived_from: onapy.policies.controlloop.Operational
       properties:
         # Omitted for brevity, see Section 1
 
-  onap.policies.controlloop.operational.common.Apex:
+  onap.policies.controlloop.operational.common.Apex:
       version: 1.0.0
       description: Operational Policy for Control Loops using the APEX PDP
       derived_from: onap.policies.controlloop.Operational
       properties:
         # Omitted for brevity, see Section 1
 
-  onap.policies.controlloop.guard.common.FrequencyLimiter:
+  onap.policies.controlloop.guard.common.FrequencyLimiter:
       version: 1.0.0
       description: Supports limiting the frequency of actions being taken by a Actor.
       derived_from: onap.policies.controlloop.Guard
       properties:
         # Omitted for brevity, see Section 1
 
-  onap.policies.controlloop.guard.common.Blacklist:
+  onap.policies.controlloop.guard.common.Blacklist:
       version: 1.0.0
       description: Supports blacklist of VNF's from performing control loop actions on.
       derived_from: onap.policies.controlloop.Guard
       properties:
         # Omitted for brevity, see Section 1
 
-  - onap.policies.controlloop.guard.common.MinMax:
+  onap.policies.controlloop.guard.common.MinMax:
+      version: 1.0.0
+      description: Supports Min/Max number of VF Modules
+      derived_from: onap.policies.controlloop.Guard
+      properties:
+        # Omitted for brevity, see Section 1
+
+  onap.policies.controlloop.guard.common.MinMax:
       version: 2.0.0
       description: Supports Min/Max number of VF Modules
       derived_from: onap.policies.controlloop.Guard
diff --git a/src/test/resources/http-cache/example/policy/api/v1/policytypes/onap.policies.controlloop.guard.common.MinMax/versions/1.0.0&#63;connectionTimeToLive=5000/.file b/src/test/resources/http-cache/example/policy/api/v1/policytypes/onap.policies.controlloop.guard.common.MinMax/versions/1.0.0&#63;connectionTimeToLive=5000/.file
new file mode 100644 (file)
index 0000000..778efae
--- /dev/null
@@ -0,0 +1,80 @@
+{
+  "tosca_definitions_version": "tosca_simple_yaml_1_1_0",
+  "policy_types": {
+    "onap.policies.controlloop.guard.Common": {
+      "properties": {
+        "id": {
+          "name": "id",
+          "type": "string",
+          "typeVersion": "0.0.0",
+          "description": "The Control Loop id this applies to.",
+          "required": false,
+          "constraints": [],
+          "metadata": {}
+        },
+        "actor": {
+          "name": "actor",
+          "type": "string",
+          "typeVersion": "0.0.0",
+          "description": "Specifies the Actor the guard applies to.",
+          "required": true,
+          "constraints": [],
+          "metadata": {}
+        },
+        "operation": {
+          "name": "operation",
+          "type": "string",
+          "typeVersion": "0.0.0",
+          "description": "Specified the operation that the actor is performing the guard applies to.",
+          "required": true,
+          "constraints": [],
+          "metadata": {}
+        },
+        "timeRange": {
+          "name": "timeRange",
+          "type": "tosca.datatypes.TimeInterval",
+          "typeVersion": "0.0.0",
+          "description": "An optional range of time during the day the guard policy is valid for.\n",
+          "required": false,
+          "constraints": [],
+          "metadata": {}
+        }
+      },
+      "name": "onap.policies.controlloop.guard.Common",
+      "version": "1.0.0",
+      "derived_from": "tosca.policies.Root",
+      "metadata": {},
+      "description": "This is the base Policy Type for Guard policies that guard the execution of Operational\nPolicies.\n"
+    },
+    "onap.policies.controlloop.guard.common.MinMax": {
+      "properties": {
+        "min": {
+          "name": "min",
+          "type": "integer",
+          "typeVersion": "0.0.0",
+          "description": "The minimum instances of this entity",
+          "required": true,
+          "constraints": [],
+          "metadata": {}
+        },
+        "max": {
+          "name": "max",
+          "type": "integer",
+          "typeVersion": "0.0.0",
+          "description": "The maximum instances of this entity",
+          "required": false,
+          "constraints": [],
+          "metadata": {}
+        }
+      },
+      "name": "onap.policies.controlloop.guard.common.MinMax",
+      "version": "1.0.0",
+      "derived_from": "onap.policies.controlloop.guard.Common",
+      "metadata": {},
+      "description": "Supports Min/Max number of entity for scaling operations"
+    }
+  },
+  "name": "ToscaServiceTemplateSimple",
+  "version": "1.0.0",
+  "metadata": {}
+}
\ No newline at end of file
diff --git a/src/test/resources/http-cache/example/policy/api/v1/policytypes/onap.policies.controlloop.guard.common.MinMax/versions/1.0.0&#63;connectionTimeToLive=5000/.header b/src/test/resources/http-cache/example/policy/api/v1/policytypes/onap.policies.controlloop.guard.common.MinMax/versions/1.0.0&#63;connectionTimeToLive=5000/.header
new file mode 100644 (file)
index 0000000..6a280d9
--- /dev/null
@@ -0,0 +1 @@
+{"Transfer-Encoding": "chunked", "Set-Cookie": "JSESSIONID=158qxkdtdobkd1umr3ikkgrmlx;Path=/", "Expires": "Thu, 01 Jan 1970 00:00:00 GMT", "Server": "Jetty(9.3.21.v20170918)", "Content-Type": "application/json", "X-ECOMP-RequestID": "e2ddb3c8-994f-47df-b4dc-097d4fb55c08"}
\ No newline at end of file
index d78cd6d..8b49d91 100644 (file)
@@ -128,7 +128,7 @@ export default class PolicyModal extends React.Component {
               startval: editorData,
               theme: 'myBootstrap4',
               object_layout: 'grid',
-              disable_properties: true,
+              disable_properties: false,
               disable_edit_json: false,
               disable_array_reorder: true,
               disable_array_delete_last_row: true,