diff options
Diffstat (limited to 'src/main')
4 files changed, 136 insertions, 139 deletions
diff --git a/src/main/java/org/onap/clamp/loop/LoopCsarInstaller.java b/src/main/java/org/onap/clamp/loop/LoopCsarInstaller.java index 0124aa704..ad13ad34d 100644 --- a/src/main/java/org/onap/clamp/loop/LoopCsarInstaller.java +++ b/src/main/java/org/onap/clamp/loop/LoopCsarInstaller.java @@ -25,7 +25,6 @@ package org.onap.clamp.loop; import com.att.eelf.configuration.EELFLogger; import com.att.eelf.configuration.EELFManager; -import com.google.gson.Gson; import com.google.gson.JsonObject; import java.io.IOException; @@ -51,9 +50,13 @@ import org.onap.clamp.clds.util.drawing.SvgFacade; import org.onap.clamp.policy.Policy; import org.onap.clamp.policy.microservice.MicroServicePolicy; import org.onap.clamp.policy.operational.OperationalPolicy; -import org.onap.sdc.tosca.parser.api.ISdcCsarHelper; +import org.onap.sdc.tosca.parser.api.IEntityDetails; +import org.onap.sdc.tosca.parser.elements.queries.EntityQuery; +import org.onap.sdc.tosca.parser.elements.queries.TopologyTemplateQuery; +import org.onap.sdc.tosca.parser.enums.EntityTemplateType; import org.onap.sdc.tosca.parser.enums.SdcTypes; import org.onap.sdc.toscaparser.api.NodeTemplate; +import org.onap.sdc.toscaparser.api.Property; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.stereotype.Component; @@ -183,22 +186,49 @@ public class LoopCsarInstaller implements CsarInstaller { return globalProperties; } - private JsonObject createModelPropertiesJson(CsarHandler csar) { - JsonObject modelProperties = new JsonObject(); - Gson gson = new Gson(); - ISdcCsarHelper csarHelper = csar.getSdcCsarHelper(); - modelProperties.add("serviceDetails", - gson.fromJson(gson.toJson(csarHelper.getServiceMetadataAllProperties()), JsonObject.class)); + private static JsonObject createVfModuleProperties(CsarHandler csar) { + JsonObject vfModuleProps = new JsonObject(); + // Loop on all Groups defined in the service (VFModule entries type: + // org.openecomp.groups.VfModule) + for (IEntityDetails entity : csar.getSdcCsarHelper().getEntity( + EntityQuery.newBuilder(EntityTemplateType.GROUP).build(), + TopologyTemplateQuery.newBuilder(SdcTypes.SERVICE).build(), false)) { + // Get all metadata info + JsonObject allVfProps = (JsonObject) JsonUtils.GSON.toJsonTree(entity.getMetadata().getAllProperties()); + vfModuleProps.add(entity.getMetadata().getAllProperties().get("vfModuleModelName"), allVfProps); + // now append the properties section so that we can also have isBase, + // volume_group, etc ... fields under the VFmodule name + for (Entry<String, Property> additionalProp : entity.getProperties().entrySet()) { + allVfProps.add(additionalProp.getValue().getName(), + JsonUtils.GSON.toJsonTree(additionalProp.getValue().getValue())); + } + } + return vfModuleProps; + } + private static JsonObject createServicePropertiesByType(CsarHandler csar) { JsonObject resourcesProp = new JsonObject(); + // Iterate on all types defined in the tosca lib for (SdcTypes type : SdcTypes.values()) { JsonObject resourcesPropByType = new JsonObject(); - for (NodeTemplate nodeTemplate : csarHelper.getServiceNodeTemplateBySdcType(type)) { - resourcesPropByType.add(nodeTemplate.getName(), JsonUtils.GSON_JPA_MODEL - .fromJson(new Gson().toJson(nodeTemplate.getMetaData().getAllProperties()), JsonObject.class)); + // For each type, get the metadata of each nodetemplate + for (NodeTemplate nodeTemplate : csar.getSdcCsarHelper().getServiceNodeTemplateBySdcType(type)) { + resourcesPropByType.add(nodeTemplate.getName(), + JsonUtils.GSON.toJsonTree(nodeTemplate.getMetaData().getAllProperties())); } resourcesProp.add(type.getValue(), resourcesPropByType); } + return resourcesProp; + } + + private static JsonObject createModelPropertiesJson(CsarHandler csar) { + JsonObject modelProperties = new JsonObject(); + // Add service details + modelProperties.add("serviceDetails", JsonUtils.GSON.fromJson( + JsonUtils.GSON.toJson(csar.getSdcCsarHelper().getServiceMetadataAllProperties()), JsonObject.class)); + // Add properties details for each type, VfModule, VF, VFC, .... + JsonObject resourcesProp = createServicePropertiesByType(csar); + resourcesProp.add("VFModule", createVfModuleProperties(csar)); modelProperties.add("resourceDetails", resourcesProp); return modelProperties; } diff --git a/src/main/resources/META-INF/resources/designer/partials/portfolios/operational_policy_window.html b/src/main/resources/META-INF/resources/designer/partials/portfolios/operational_policy_window.html index b7864eca9..798f18f60 100644 --- a/src/main/resources/META-INF/resources/designer/partials/portfolios/operational_policy_window.html +++ b/src/main/resources/META-INF/resources/designer/partials/portfolios/operational_policy_window.html @@ -2,7 +2,7 @@ ============LICENSE_START======================================================= ONAP CLAMP ================================================================================ - Copyright (C) 2017-2018 AT&T Intellectual Property. All rights + Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved. ================================================================================ Licensed under the Apache License, Version 2.0 (the "License"); @@ -291,7 +291,7 @@ label { Type</label> <div class="col-sm-8"> <select class="form-control" name="type" id="type" - ng-click="initTargetResourceId()" ng-model="type"> + ng-click="initTargetResourceId($event)" ng-model="type"> <option value="">-- choose an option --</option> <option value="VFModule">VFModule</option> <option value="VM">VM</option> @@ -304,10 +304,9 @@ label { Target ResourceId</label> <div class="col-sm-8"> <select class="form-control" name="resourceId" id="resourceId" - enableFilter="true" ng-click="changeTargetResourceId()" + enableFilter="true" ng-click="changeTargetResourceId($event)" ng-model="resourceId"> <option value="">-- choose an option --</option> - <option value="Other:">Other:</option> </select> </div> </div> diff --git a/src/main/resources/META-INF/resources/designer/scripts/OperationalPolicyCtrl.js b/src/main/resources/META-INF/resources/designer/scripts/OperationalPolicyCtrl.js index 2c3f83e41..0cf4c2e3a 100644 --- a/src/main/resources/META-INF/resources/designer/scripts/OperationalPolicyCtrl.js +++ b/src/main/resources/META-INF/resources/designer/scripts/OperationalPolicyCtrl.js @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * ONAP CLAMP * ================================================================================ - * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights + * Copyright (C) 2017-2019 AT&T Intellectual Property. All rights * reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); @@ -55,7 +55,6 @@ app } console.log("No active formId found !"); } - function add_one_more() { console.log("add one more"); @@ -154,10 +153,9 @@ app policiesArray.push(policyProperties); // Now get the Guard if ($("#" + this.id + " #enableGuardPolicy").is(':checked')) { - var guardPolicyBody = serializeElement($("#" + this.id + " .guardProperties")); - var guardPolicyId = guardPolicyBody['id']; - delete guardPolicyBody['id']; - + var guardPolicyBody = serializeElement($("#" + this.id + " .guardProperties")); + var guardPolicyId = guardPolicyBody['id']; + delete guardPolicyBody['id']; allPolicies['guard_policies'][guardPolicyId] = guardPolicyBody; $scope.guard_ids.push(guardPolicyId); } @@ -190,9 +188,14 @@ app var formNum = add_one_more(); $.each($('.policyProperties').find('.form-control'), function(opPolicyPropIndex, opPolicyPropValue) { - $("#formId"+formNum+" .policyProperties").find("#"+opPolicyPropValue.id).val( + $("#formId" + formNum + " .policyProperties").find("#" + opPolicyPropValue.id).val( allPolicies['operational_policy']['policies'][opPolicyElemIndex][opPolicyPropValue.id]); }); + $.each($('.policyTarget').find('.form-control'), function(opPolicyTargetPropIndex, opPolicyTargetPropValue) { + + $("#formId" + formNum + " .policyTarget").find("#" + opPolicyTargetPropValue.id).val( + allPolicies['operational_policy']['policies'][opPolicyElemIndex]['target'][opPolicyTargetPropValue.id]); + }); // update the current tab label $("#go_properties_tab" + formNum).text( allPolicies['operational_policy']['policies'][opPolicyElemIndex]['id']); @@ -201,9 +204,11 @@ app if (guardElemValue.recipe === $($("#formId" + formNum + " #recipe")[0]).val()) { // Found one, set all guard prop - $.each($('.guardProperties').find('.form-control'), function(guardPropElemIndex,guardPropElemValue) { - guardElemValue['id'] = guardElemId; - $("#formId"+formNum+" .guardProperties").find("#"+guardPropElemValue.id).val( + $.each($('.guardProperties').find('.form-control'), function(guardPropElemIndex, + guardPropElemValue) { + + guardElemValue['id'] = guardElemId; + $("#formId" + formNum + " .guardProperties").find("#" + guardPropElemValue.id).val( guardElemValue[guardPropElemValue.id]); }); // And finally enable the flag @@ -212,108 +217,69 @@ app }); }); } - - $scope.initTargetResourceId = function() { - - var recipe = $(event.target).val(); - - var type = $(event.target).val(); - - $("#modelName").val(""); - $("#modelInvariantId").val(""); - $("#modelVersionId").val(""); - $("#modelVersion").val(""); - $("#modelCustomizationId").val(""); - $('#resourceId').empty(); - $("#resourceId") - .append( - $('<option></option>').val("") - .html("-- choose an option --")); - $("#resourceId").append( - $('<option></option>').val("Other:") - .html("Other:")); - if (type == "VM" || type == "" || type == "VNF" ) { - $("#metadata *").prop('disabled',true); - } - - var resourceVnf = getResourceDetailsProperty(); - if (type == "VNF" - && (null !== resourceVnf || undefined !== resourceVnf)) { - for ( var prop in resourceVnf) { - var name = resourceVnf[prop]["name"]; - $("#resourceId").append( - $('<option></option>') - .val(name).html(name)); - } - - } - var resourceVFModule = getResourceDetailsVfModuleProperty(); - if (type == "VFModule" - && (null !== resourceVFModule || undefined !== resourceVFModule)) { - if (recipe == 'VF Module Create' - || recipe == 'VF Module Delete') { - for ( var prop in resourceVFModule) { - if (resourceVFModule[prop]["isBase"] == false) { - var name = resourceVFModule[prop]["name"]; - $("#resourceId").append( - $('<option></option>') - .val(name) - .html(name)); - } - } - } - else - { - for ( var prop in resourceVFModule) { - var name = resourceVFModule[prop]["name"]; - $("#resourceId").append( - $('<option></option>') - .val(name).html(name)); - } - } - } - } - - $scope.changeTargetResourceId = function() { - $("#modelName").val(""); - $("#modelInvariantId").val(""); - $("#modelVersionId").val(""); - $("#modelVersion").val(""); - $("#modelCustomizationId").val(""); - var resourceVFModule = getResourceDetailsVfModuleProperty(); - var type = $("#type").val(); - var recipe = $("#recipe").val(); - vfBaseName = $(event.target).val(); - if (type == "VFModule" - && (null !== resourceVFModule || undefined !== resourceVFModule) - && (recipe == 'VF Module Create' || recipe == 'VF Module Delete')) { - for ( var prop in resourceVFModule) { - var name = resourceVFModule[prop]["name"]; - if (name == vfBaseName) { - var vfModuleModelName = resourceVFModule[prop]["name"]; - $("#modelName").val( - vfModuleModelName); - var vfModuleModelInvariantUUID = resourceVFModule[prop]["invariantUUID"]; - $("#modelInvariantId").val( - vfModuleModelInvariantUUID); - var vfModuleModelUUID = resourceVFModule[prop]["UUID"]; - $("#modelVersionId").val( - vfModuleModelUUID); - var vfModuleModelVersion = resourceVFModule[prop]["version"]; - $("#modelVersion").val( - vfModuleModelVersion); - var vfModuleModelCustomizationUUID = resourceVFModule[prop]["customizationUUID"]; - $("#modelCustomizationId") - .val( - vfModuleModelCustomizationUUID); - } - } - } - else { - $("#metadata *").prop('disabled',true); - } - } - + $scope.initTargetResourceId = function(event) { + var formNum = $(event.target).closest('.formId').attr('id').substring(6); + + var type = $(event.target).val(); + var recipe = $("#formId" + formNum + "#recipe").val(); + $("#formId" + formNum + " #modelName").val(""); + $("#formId" + formNum + " #modelInvariantId").val(""); + $("#formId" + formNum + " #modelVersionId").val(""); + $("#formId" + formNum + " #modelVersion").val(""); + $("#formId" + formNum + " #modelCustomizationId").val(""); + $("#formId" + formNum + " #resourceId").empty(); + $("#formId" + formNum + " #resourceId").append($('<option></option>').val("").html("-- choose an option --")); + if (type == "VM" || type == "" || type == "VNF") { + $("#formId" + formNum + " #metadata *").prop('disabled', true); + } + var resourceVnf = getResourceDetailsVfProperty(); + if (type == "VNF" && (null !== resourceVnf || undefined !== resourceVnf)) { + for ( var prop in resourceVnf) { + var name = resourceVnf[prop]["name"]; + $("#formId" + formNum + " #resourceId").append($('<option></option>').val(name).html(name)); + } + } + var resourceVFModule = getResourceDetailsVfModuleProperty(); + if (type == "VFModule" && (null !== resourceVFModule || undefined !== resourceVFModule)) { + if (recipe == 'VF Module Create' || recipe == 'VF Module Delete') { + for ( var prop in resourceVFModule) { + if (resourceVFModule[prop]["isBase"] == false) { + $("#formId" + formNum + " #resourceId").append($('<option></option>').val(resourceVFModule[prop]["vfModuleModelName"]).html(resourceVFModule[prop]["vfModuleModelName"])); + } + } + } else { + for ( var prop in resourceVFModule) { + $("#formId" + formNum + " #resourceId").append($('<option></option>').val(resourceVFModule[prop]["vfModuleModelName"]).html(resourceVFModule[prop]["vfModuleModelName"])); + } + } + } + } + $scope.changeTargetResourceId = function(event) { + var formNum = $(event.target).closest('.formId').attr('id').substring(6); + $("#formId" + formNum +" #modelName").val(""); + $("#formId" + formNum +" #modelInvariantId").val(""); + $("#formId" + formNum +" #modelVersionId").val(""); + $("#formId" + formNum +" #modelVersion").val(""); + $("#formId" + formNum +" #modelCustomizationId").val(""); + var resourceVFModule = getResourceDetailsVfModuleProperty(); + var type = $("#formId" + formNum +" #type").val(); + var recipe = $("#formId" + formNum +" #recipe").val(); + if (type == "VFModule" && (null !== resourceVFModule || undefined !== resourceVFModule) + && (recipe == 'VF Module Create' || recipe == 'VF Module Delete')) { + for ( var prop in resourceVFModule) { + if (prop == $(event.target).val()) { + $("#formId" + formNum +" #modelName").val(resourceVFModule[prop]["vfModuleModelName"]); + $("#formId" + formNum +" #modelInvariantId").val(resourceVFModule[prop]["vfModuleModelInvariantUUID"]); + $("#formId" + formNum +" #modelVersionId").val(resourceVFModule[prop]["vfModuleModelUUID"]); + $("#formId" + formNum +" #modelVersion").val(resourceVFModule[prop]["vfModuleModelVersion"]); + $("#formId" + formNum +" #modelCustomizationId").val(resourceVFModule[prop]["vfModuleModelCustomizationUUID"]); + $("#formId" + formNum +" #metadata *").prop('disabled', false); + } + } + } else { + $("#formId" + formNum +" #metadata *").prop('disabled', true); + } + } $scope.changeGuardPolicyType = function() { var formItemActive = searchActiveFormId(); @@ -343,7 +309,8 @@ app $scope.init = function() { $(function() { - $scope.clname=getLoopName(); + + $scope.clname = getLoopName(); $("#add_one_more").click(function(event) { console.log("add one more"); @@ -359,17 +326,18 @@ app add_new_policy(); } $("#savePropsBtn").click(function(event) { + console.log("save properties triggered"); savePolicyLocally(); - for(var i = 0; i <= $scope.guard_ids.length; i++) { - for(var j = i; j <= $scope.guard_ids.length; j++) { - if(i != j && $scope.guard_ids[i] == $scope.guard_ids[j]) { - // duplacated guard policy id exist - alert("The guard policy ID should be unique."); - return; - } - } - } + for (var i = 0; i <= $scope.guard_ids.length; i++) { + for (var j = i; j <= $scope.guard_ids.length; j++) { + if (i != j && $scope.guard_ids[i] == $scope.guard_ids[j]) { + // duplacated guard policy id exist + alert("The guard policy ID should be unique."); + return; + } + } + } angular.element(document.getElementById('formSpan')).scope().submitForm(allPolicies); $("#close_button").click(); }); diff --git a/src/main/resources/META-INF/resources/designer/scripts/propertyController.js b/src/main/resources/META-INF/resources/designer/scripts/propertyController.js index 3902cf413..ee602b993 100644 --- a/src/main/resources/META-INF/resources/designer/scripts/propertyController.js +++ b/src/main/resources/META-INF/resources/designer/scripts/propertyController.js @@ -114,7 +114,7 @@ function setDeploymentStatusURL(deploymentStatusURL) { cl_props["dcaeDeploymentStatusUrl"] = deploymentStatusURL; } -function getResourceDetailsProperty() { +function getResourceDetailsVfProperty() { return cl_props["modelPropertiesJson"]["resourceDetails"]["VF"]; } @@ -126,4 +126,4 @@ function getLoopLogsArray() { return cl_props.loopLogs; } -module.exports = { getOperationalPolicyProperty,getGlobalProperty,getMsProperty,getMsUI,getLastUpdatedStatus,getDeploymentID,getDeploymentStatusURL,getResourceDetailsProperty,getResourceDetailsVfModuleProperty };
\ No newline at end of file +module.exports = { getOperationalPolicyProperty,getGlobalProperty,getMsProperty,getMsUI,getLastUpdatedStatus,getDeploymentID,getDeploymentStatusURL,getResourceDetailsVfProperty,getResourceDetailsVfModuleProperty };
\ No newline at end of file |