aboutsummaryrefslogtreecommitdiffstats
path: root/src/main
diff options
context:
space:
mode:
authorDeterme, Sebastien (sd378r) <sd378r@intl.att.com>2018-03-05 17:46:49 +0100
committerDeterme, Sebastien (sd378r) <sd378r@intl.att.com>2018-03-05 17:46:49 +0100
commit32eaf1e97f17a9d7a7b304fdc2b2be00c5830434 (patch)
tree0406597957b6cac404a8013741b3f5c62869cb8f /src/main
parent35c6bda8ced4143b4fc1731727ee9bbe76b34c96 (diff)
Remove globalClds.properties
Remove the globalClds.properties and merge that to application.properties Issue-ID: CLAMP-136 Change-Id: I9c5bc8745b576ca8fad0cca3bff4c136329515d8 Signed-off-by: Determe, Sebastien (sd378r) <sd378r@intl.att.com>
Diffstat (limited to 'src/main')
-rw-r--r--src/main/java/org/onap/clamp/clds/client/req/sdc/SdcCatalogServices.java22
-rw-r--r--src/main/java/org/onap/clamp/clds/service/CldsService.java34
-rw-r--r--src/main/resources/application.properties2
-rw-r--r--src/main/resources/clds/globalClds.properties24
-rw-r--r--src/main/resources/clds/templates/globalProperties.json105
5 files changed, 116 insertions, 71 deletions
diff --git a/src/main/java/org/onap/clamp/clds/client/req/sdc/SdcCatalogServices.java b/src/main/java/org/onap/clamp/clds/client/req/sdc/SdcCatalogServices.java
index 5664653bf..fd7d096fa 100644
--- a/src/main/java/org/onap/clamp/clds/client/req/sdc/SdcCatalogServices.java
+++ b/src/main/java/org/onap/clamp/clds/client/req/sdc/SdcCatalogServices.java
@@ -72,6 +72,7 @@ import org.onap.clamp.clds.model.sdc.SdcResource;
import org.onap.clamp.clds.model.sdc.SdcResourceBasicInfo;
import org.onap.clamp.clds.model.sdc.SdcServiceDetail;
import org.onap.clamp.clds.model.sdc.SdcServiceInfo;
+import org.onap.clamp.clds.service.CldsService;
import org.onap.clamp.clds.util.CryptoUtils;
import org.onap.clamp.clds.util.LoggingUtils;
import org.springframework.beans.factory.annotation.Autowired;
@@ -840,11 +841,13 @@ public class SdcCatalogServices {
* @param globalProps
* @param cldsServiceData
* @return
+ * @throws IOException
+ * In case of issues during the parsing of the Global Properties
*/
- public String createPropertiesObjectByUUID(String globalProps, CldsServiceData cldsServiceData) {
+ public String createPropertiesObjectByUUID(CldsServiceData cldsServiceData) throws IOException {
String totalPropsStr;
ObjectMapper mapper = new ObjectMapper();
- ObjectNode globalPropsJson;
+ ObjectNode globalPropsJson = (ObjectNode) refProp.getJsonTemplate(CldsService.GLOBAL_PROPERTIES_KEY);
if (cldsServiceData != null && cldsServiceData.getServiceUUID() != null) {
// Objectnode to save all byservice, byvf , byvfc and byalarm nodes
ObjectNode byIdObjectNode = mapper.createObjectNode();
@@ -886,28 +889,13 @@ public class SdcCatalogServices {
"alertDescription");
ObjectNode alertDescObjectNodeByAlert = createAlarmCondObjectNodeByAlarmKey(mapper, allAlertDescriptions);
byIdObjectNode.putPOJO("byAlertDescription", alertDescObjectNodeByAlert);
- globalPropsJson = decodeGlobalProp(globalProps, mapper);
globalPropsJson.putPOJO("shared", byIdObjectNode);
logger.info("Global properties JSON created with SDC info:" + globalPropsJson);
- } else {
- /**
- * to create json with total properties when no serviceUUID passed
- */
- globalPropsJson = decodeGlobalProp(globalProps, mapper);
}
totalPropsStr = globalPropsJson.toString();
return totalPropsStr;
}
- private ObjectNode decodeGlobalProp(String globalProps, ObjectMapper mapper) {
- try {
- return (ObjectNode) mapper.readValue(globalProps, JsonNode.class);
- } catch (IOException e) {
- logger.error("Exception occurred during decoding of the global props, returning an empty objectNode", e);
- return mapper.createObjectNode();
- }
- }
-
/**
* Method to get alarm conditions/alert description from Service Data.
*
diff --git a/src/main/java/org/onap/clamp/clds/service/CldsService.java b/src/main/java/org/onap/clamp/clds/service/CldsService.java
index 3b6bc3778..2968f60a4 100644
--- a/src/main/java/org/onap/clamp/clds/service/CldsService.java
+++ b/src/main/java/org/onap/clamp/clds/service/CldsService.java
@@ -87,7 +87,6 @@ import org.onap.clamp.clds.transform.XslTransformer;
import org.onap.clamp.clds.util.LoggingUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
-import org.springframework.context.ApplicationContext;
import org.springframework.http.HttpStatus;
import org.springframework.stereotype.Component;
import org.springframework.web.client.HttpClientErrorException;
@@ -102,9 +101,8 @@ public class CldsService extends SecureServiceBase {
@Produce(uri = "direct:processSubmit")
private CamelProxy camelProxy;
protected static final EELFLogger securityLogger = EELFManager.getInstance().getSecurityLogger();
- @Autowired
- private ApplicationContext appContext;
private static final String RESOURCE_NAME = "clds-version.properties";
+ public static final String GLOBAL_PROPERTIES_KEY = "files.globalProperties";
@Value("${clamp.config.security.permission.type.cl:permission-type-cl}")
private String cldsPersmissionTypeCl;
@Value("${clamp.config.security.permission.type.cl.manage:permission-type-cl-manage}")
@@ -132,9 +130,6 @@ public class CldsService extends SecureServiceBase {
"update");
}
- @Value("${org.onap.clamp.config.files.globalClds:'classpath:/clds/globalClds.properties'}")
- private String globalClds;
- private Properties globalCldsProperties;
@Autowired
private CldsDao cldsDao;
@Autowired
@@ -585,7 +580,7 @@ public class CldsService extends SecureServiceBase {
@Path("/properties")
@Produces(MediaType.APPLICATION_JSON)
public String getSdcProperties() throws IOException {
- return createPropertiesObjectByUUID(getGlobalCldsString(), "{}");
+ return createPropertiesObjectByUUID("{}");
}
/**
@@ -620,7 +615,7 @@ public class CldsService extends SecureServiceBase {
// filter out VFs the user is not authorized for
cldsServiceData.filterVfs(this);
// format retrieved data into properties json
- String sdcProperties = sdcCatalogServices.createPropertiesObjectByUUID(getGlobalCldsString(), cldsServiceData);
+ String sdcProperties = sdcCatalogServices.createPropertiesObjectByUUID(cldsServiceData);
// audit log
LoggingUtils.setTimeContext(startTime, new Date());
LoggingUtils.setResponseContext("0", "Get sdc properties by uuid success", this.getClass().getName());
@@ -689,10 +684,10 @@ public class CldsService extends SecureServiceBase {
return serviceNode.toString();
}
- private String createPropertiesObjectByUUID(String globalProps, String cldsResponseStr) throws IOException {
+ private String createPropertiesObjectByUUID(String cldsResponseStr) throws IOException {
ObjectMapper mapper = new ObjectMapper();
SdcServiceDetail cldsSdcServiceDetail = mapper.readValue(cldsResponseStr, SdcServiceDetail.class);
- ObjectNode globalPropsJson = null;
+ ObjectNode globalPropsJson = (ObjectNode) refProp.getJsonTemplate(GLOBAL_PROPERTIES_KEY);
if (cldsSdcServiceDetail != null && cldsSdcServiceDetail.getUuid() != null) {
/**
* to create json with vf, alarm and locations
@@ -711,14 +706,8 @@ public class CldsService extends SecureServiceBase {
*/
ObjectNode emptyvfcobjectNode = createByVFCObjectNode(mapper, cldsSdcServiceDetail.getResources());
byServiceBasicObjetNode.putPOJO("byVf", emptyvfcobjectNode);
- globalPropsJson = (ObjectNode) mapper.readValue(globalProps, JsonNode.class);
globalPropsJson.putPOJO("shared", byServiceBasicObjetNode);
logger.info("valuie of objNode: {}", globalPropsJson);
- } else {
- /**
- * to create json with total properties when no serviceUUID passed
- */
- globalPropsJson = (ObjectNode) mapper.readValue(globalProps, JsonNode.class);
}
return globalPropsJson.toString();
}
@@ -903,19 +892,6 @@ public class CldsService extends SecureServiceBase {
return model;
}
- private String getGlobalCldsString() {
- try {
- if (null == globalCldsProperties) {
- globalCldsProperties = new Properties();
- globalCldsProperties.load(appContext.getResource(globalClds).getInputStream());
- }
- return (String) globalCldsProperties.get("globalCldsProps");
- } catch (IOException e) {
- logger.error("Unable to load the globalClds due to an exception", e);
- throw new CldsConfigException("Unable to load the globalClds due to an exception", e);
- }
- }
-
private void checkForDuplicateServiceVf(String modelName, String modelPropText) throws IOException {
JsonNode modelJson = new ObjectMapper().readTree(modelPropText);
JsonNode globalNode = modelJson.get("global");
diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties
index 8c8b1968f..2c3537d58 100644
--- a/src/main/resources/application.properties
+++ b/src/main/resources/application.properties
@@ -108,7 +108,7 @@ async.queue.capacity=500
org.onap.clamp.config.files.cldsPolicyConfig=classpath:/clds/clds-policy-config.properties
org.onap.clamp.config.files.cldsUsers=classpath:/clds/clds-users.json
-org.onap.clamp.config.files.globalClds=classpath:/clds/globalClds.properties
+clamp.config.files.globalProperties=classpath:/clds/templates/globalProperties.json
org.onap.clamp.config.files.sdcController=classpath:/clds/sdc-controllers-config.json
# Properties for Clamp
diff --git a/src/main/resources/clds/globalClds.properties b/src/main/resources/clds/globalClds.properties
deleted file mode 100644
index e83fa6ca7..000000000
--- a/src/main/resources/clds/globalClds.properties
+++ /dev/null
@@ -1,24 +0,0 @@
-###
-# ============LICENSE_START=======================================================
-# ONAP CLAMP
-# ================================================================================
-# Copyright (C) 2017 AT&T Intellectual Property. All rights
-# reserved.
-# ================================================================================
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-# ============LICENSE_END============================================
-# ===================================================================
-# ECOMP is a trademark and service mark of AT&T Intellectual Property.
-###
-
-globalCldsProps ={"tca":{"tname":"New_Set","tcaInt":"1","tcaVio":"1","eventName":{"vCPEvGMUXPacketLoss":"vCPEvGMUXPacketLoss","vLoadBalancer":"vLoadBalancer","vFirewallBroadcastPackets":"vFirewallBroadcastPackets"},"fieldPathM":{"$.event.measurementsForVfScalingFields.vNicPerformanceArray[*].receivedBroadcastPacketsAccumulated":"receivedBroadcastPacketsAccumulated","$.event.measurementsForVfScalingFields.vNicPerformanceArray[*].receivedDiscardedPacketsDelta":"receivedDiscardedPacketsDelta"},"operator":{">":"GREATER",">=":"GREATER_OR_EQUAL","=":"EQUAL","<=":"LESS_OR_EQUAL","<":"LESS"},"opsPolicy":{"POLICY_test_X":"POLICY_test_X","POLICY_test_Y":"POLICY_test_Y"},"controlLoopSchemaType":{"":"","VM":"VM","VNF":"VNF"},"closedLoopEventStatus":{"":"","ONSET":"ONSET","ABATED":"ABATED"}},"global":{"actionSet":{"vnfRecipe":"VNF", "enbRecipe":"eNodeB"},"location":{"DC1":"Data Center 1","DC2":"Data Center 2","DC3":"Data Center 3"}},"policy":{"pname":"0","timeout":345,"vnfRecipe":{"":"","restart":"Restart","rebuild":"Rebuild","migrate":"Migrate","healthCheck":"Health Check"},"enbRecipe":{"":"","reset":"Reset"},"maxRetries":"3","retryTimeLimit":180,"resource":{"vCTS":"vCTS","v3CDB":"v3CDB","vUDR":"vUDR","vCOM":"vCOM","vRAR":"vRAR","vLCS":"vLCS","vUDR-BE":"vUDR-BE","vDBE":"vDBE"},"parentPolicyConditions":{"Failure_Retries":"Failure: Max Retries Exceeded","Failure_Timeout":"Failure: Time Limit Exceeded","Failure_Guard":"Failure: Guard","Failure_Exception":"Failure: Exception","Failure":"Failure: Other","Success":"Success"}},"shared":{"byService":{"":{"vf":{"":""},"location":{"":""},"alarmCondition":{"":""}}},"byVf":{"":{"vfc":{"":""}}}}}
diff --git a/src/main/resources/clds/templates/globalProperties.json b/src/main/resources/clds/templates/globalProperties.json
new file mode 100644
index 000000000..9ac9d9443
--- /dev/null
+++ b/src/main/resources/clds/templates/globalProperties.json
@@ -0,0 +1,105 @@
+{
+ "tca": {
+ "tname": "New_Set",
+ "tcaInt": "1",
+ "tcaVio": "1",
+ "eventName": {
+ "vCPEvGMUXPacketLoss": "vCPEvGMUXPacketLoss",
+ "vLoadBalancer": "vLoadBalancer",
+ "vFirewallBroadcastPackets": "vFirewallBroadcastPackets"
+ },
+ "fieldPathM": {
+ "$.event.measurementsForVfScalingFields.vNicPerformanceArray[*].receivedBroadcastPacketsAccumulated": "receivedBroadcastPacketsAccumulated",
+ "$.event.measurementsForVfScalingFields.vNicPerformanceArray[*].receivedDiscardedPacketsDelta": "receivedDiscardedPacketsDelta"
+ },
+ "operator": {
+ ">": "GREATER",
+ ">=": "GREATER_OR_EQUAL",
+ "=": "EQUAL",
+ "<=": "LESS_OR_EQUAL",
+ "<": "LESS"
+ },
+ "opsPolicy": {
+ "POLICY_test_X": "POLICY_test_X",
+ "POLICY_test_Y": "POLICY_test_Y"
+ },
+ "controlLoopSchemaType": {
+ "": "",
+ "VM": "VM",
+ "VNF": "VNF"
+ },
+ "closedLoopEventStatus": {
+ "": "",
+ "ONSET": "ONSET",
+ "ABATED": "ABATED"
+ }
+ },
+ "global": {
+ "actionSet": {
+ "vnfRecipe": "VNF",
+ "enbRecipe": "eNodeB"
+ },
+ "location": {
+ "DC1": "Data Center 1",
+ "DC2": "Data Center 2",
+ "DC3": "Data Center 3"
+ }
+ },
+ "policy": {
+ "pname": "0",
+ "timeout": 345,
+ "vnfRecipe": {
+ "": "",
+ "restart": "Restart",
+ "rebuild": "Rebuild",
+ "migrate": "Migrate",
+ "healthCheck": "Health Check"
+ },
+ "enbRecipe": {
+ "": "",
+ "reset": "Reset"
+ },
+ "maxRetries": "3",
+ "retryTimeLimit": 180,
+ "resource": {
+ "vCTS": "vCTS",
+ "v3CDB": "v3CDB",
+ "vUDR": "vUDR",
+ "vCOM": "vCOM",
+ "vRAR": "vRAR",
+ "vLCS": "vLCS",
+ "vUDR-BE": "vUDR-BE",
+ "vDBE": "vDBE"
+ },
+ "parentPolicyConditions": {
+ "Failure_Retries": "Failure: Max Retries Exceeded",
+ "Failure_Timeout": "Failure: Time Limit Exceeded",
+ "Failure_Guard": "Failure: Guard",
+ "Failure_Exception": "Failure: Exception",
+ "Failure": "Failure: Other",
+ "Success": "Success"
+ }
+ },
+ "shared": {
+ "byService": {
+ "": {
+ "vf": {
+ "": ""
+ },
+ "location": {
+ "": ""
+ },
+ "alarmCondition": {
+ "": ""
+ }
+ }
+ },
+ "byVf": {
+ "": {
+ "vfc": {
+ "": ""
+ }
+ }
+ }
+ }
+}