From 2ea04318ded1aaca0cf2ab8df59d4433c4e328e4 Mon Sep 17 00:00:00 2001 From: "Determe, Sebastien (sd378r)" Date: Tue, 17 Apr 2018 17:31:37 +0200 Subject: Fix Sdc Controller Fix the name for policy push because the model name was containing . for version and that was not accepted by policy. Issue-ID: CLAMP-153 Change-Id: I768b765f42385bc93c4e77e1dc5c469908ad031f Signed-off-by: Determe, Sebastien (sd378r) --- .../onap/clamp/clds/sdc/controller/installer/CsarInstallerImpl.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/main/java/org/onap/clamp/clds/sdc/controller/installer/CsarInstallerImpl.java b/src/main/java/org/onap/clamp/clds/sdc/controller/installer/CsarInstallerImpl.java index 5a00a8280..2d94bc369 100644 --- a/src/main/java/org/onap/clamp/clds/sdc/controller/installer/CsarInstallerImpl.java +++ b/src/main/java/org/onap/clamp/clds/sdc/controller/installer/CsarInstallerImpl.java @@ -93,8 +93,8 @@ public class CsarInstallerImpl implements CsarInstaller { } public static String buildModelName(CsarHandler csar) { - return csar.getSdcCsarHelper().getServiceMetadata().getValue("name") + " v" - + csar.getSdcNotification().getServiceVersion(); + return csar.getSdcCsarHelper().getServiceMetadata().getValue("name") + "_v" + + csar.getSdcNotification().getServiceVersion().replace('.', '_'); } @Override -- cgit 1.2.3-korg From d39df764cb90d28ddfd6787c953062e19fc6ec3a Mon Sep 17 00:00:00 2001 From: "Determe, Sebastien (sd378r)" Date: Wed, 18 Apr 2018 17:51:30 +0200 Subject: Flexible Policy code Add more flexibility to the pattern used for GetConfig policy Issue-ID: CLAMP-153 Change-Id: I7fa79a6c3a6402ada451e07c851e4e3d78925334 Signed-off-by: Determe, Sebastien (sd378r) --- .../clamp/clds/client/req/policy/PolicyClient.java | 21 ++++++++++++--------- src/main/resources/application.properties | 20 +++++++++++--------- src/test/resources/application.properties | 3 ++- 3 files changed, 25 insertions(+), 19 deletions(-) (limited to 'src') diff --git a/src/main/java/org/onap/clamp/clds/client/req/policy/PolicyClient.java b/src/main/java/org/onap/clamp/clds/client/req/policy/PolicyClient.java index 5c68f00b9..9c72d2efa 100644 --- a/src/main/java/org/onap/clamp/clds/client/req/policy/PolicyClient.java +++ b/src/main/java/org/onap/clamp/clds/client/req/policy/PolicyClient.java @@ -64,12 +64,15 @@ import org.springframework.stereotype.Component; @Component public class PolicyClient { - protected static final String POLICY_PREFIX_BASE = "Config_"; protected static final String LOG_POLICY_PREFIX = "Response is "; protected static final EELFLogger logger = EELFManager.getInstance().getLogger(PolicyClient.class); protected static final EELFLogger metricsLogger = EELFManager.getInstance().getMetricsLogger(); - protected static final String POLICY_MSTYPE_PROPERTY_NAME = "policy.ms.type"; - protected static final String POLICY_ONAPNAME_PROPERTY_NAME = "policy.onap.name"; + public static final String POLICY_MSTYPE_PROPERTY_NAME = "policy.ms.type"; + public static final String POLICY_ONAPNAME_PROPERTY_NAME = "policy.onap.name"; + public static final String POLICY_BASENAME_PREFIX_PROPERTY_NAME = "policy.base.policyNamePrefix"; + public static final String POLICY_OP_NAME_PREFIX_PROPERTY_NAME = "policy.op.policyNamePrefix"; + public static final String POLICY_MS_NAME_PREFIX_PROPERTY_NAME = "policy.ms.policyNamePrefix"; + public static final String POLICY_OP_TYPE_PROPERTY_NAME = "policy.op.type"; @Autowired protected ApplicationContext appContext; @Autowired @@ -102,9 +105,9 @@ public class PolicyClient { policyParameters.setAttributes(attributes); // Set a random UUID(Mandatory) policyParameters.setRequestID(UUID.fromString(policyRequestUuid)); - String policyNamePrefix = refProp.getStringValue("policy.op.policyNamePrefix"); + String policyNamePrefix = refProp.getStringValue(POLICY_OP_NAME_PREFIX_PROPERTY_NAME); String rtnMsg = send(policyParameters, prop, policyNamePrefix); - String policyType = refProp.getStringValue("policy.op.type"); + String policyType = refProp.getStringValue(POLICY_OP_TYPE_PROPERTY_NAME); push(policyType, prop); return rtnMsg; } @@ -129,7 +132,7 @@ public class PolicyClient { policyParameters.setConfigBody(policyJson); policyParameters.setConfigBodyType(PolicyType.JSON); policyParameters.setRequestID(UUID.fromString(policyRequestUuid)); - String policyNamePrefix = refProp.getStringValue("policy.ms.policyNamePrefix"); + String policyNamePrefix = refProp.getStringValue(POLICY_MS_NAME_PREFIX_PROPERTY_NAME); // Adding this line to clear the policy id from policy name while // pushing to policy engine prop.setPolicyUniqueId(""); @@ -168,7 +171,7 @@ public class PolicyClient { // Adding this line to clear the policy id from policy name while // pushing to policy engine prop.setPolicyUniqueId(""); - String rtnMsg = send(policyParameters, prop, POLICY_PREFIX_BASE); + String rtnMsg = send(policyParameters, prop, refProp.getStringValue(POLICY_BASENAME_PREFIX_PROPERTY_NAME)); push(PolicyConfigType.Base.toString(), prop); return rtnMsg; } @@ -189,7 +192,7 @@ public class PolicyClient { policyParameters.setOnapName(refProp.getStringValue(POLICY_ONAPNAME_PROPERTY_NAME)); policyParameters.setPolicyName(prop.getCurrentPolicyScopeAndPolicyName()); policyParameters.setConfigBody(configBody); - String policyNamePrefix = refProp.getStringValue("policy.ms.policyNamePrefix"); + String policyNamePrefix = refProp.getStringValue(POLICY_MS_NAME_PREFIX_PROPERTY_NAME); // Adding this line to clear the policy id from policy name while // pushing to policy engine prop.setPolicyUniqueId(""); @@ -390,7 +393,7 @@ public class PolicyClient { * @return The response message from policy */ public String deleteBrms(ModelProperties prop) { - String policyType = refProp.getStringValue("policy.op.type"); + String policyType = refProp.getStringValue(POLICY_OP_TYPE_PROPERTY_NAME); return deletePolicy(prop, policyType); } diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index 0d58350e7..5b9a105b9 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -125,9 +125,9 @@ clamp.config.sdc.decode.service_ids=classpath:/clds/templates/sdc-decode-service # # # Configuration Settings for Policy Engine Components -clamp.config.policy.pdpUrl1=http://vm1.policy.simpledemo.onap.org:8081/pdp/ , testpdp, alpha123 -clamp.config.policy.pdpUrl2=http://vm1.policy.simpledemo.onap.org:8081/pdp/ , testpdp, alpha123 -clamp.config.policy.papUrl=http://vm1.policy.simpledemo.onap.org:8081/pap/ , testpap, alpha123 +clamp.config.policy.pdpUrl1=http://localhost:8085/pdp/ , testpdp, alpha123 +clamp.config.policy.pdpUrl2=http://vlocalhost:8085/pdp/ , testpdp, alpha123 +clamp.config.policy.papUrl=http://localhost:8085/pap/ , testpap, alpha123 clamp.config.policy.notificationType=websocket clamp.config.policy.notificationUebServers=localhost clamp.config.policy.notificationTopic= @@ -145,8 +145,10 @@ clamp.config.policy.onap.name=DCAE clamp.config.policy.pdp.group=default clamp.config.policy.ms.type=MicroService clamp.config.policy.ms.policyNamePrefix=Config_MS_ -clamp.config.policy.op.type=BRMS_Param clamp.config.policy.op.policyNamePrefix=Config_BRMS_Param_ +clamp.config.policy.base.policyNamePrefix=Config_ +clamp.config.policy.op.type=BRMS_Param + # TCA MicroService Policy request build properties # @@ -179,9 +181,9 @@ clamp.config.op.eNodeB.limit=2 clamp.config.op.eNodeB.period=10s # # Sdc service properties -clamp.config.sdc.catalog.url=http://sdc.api.simpledemo.onap.org:8080/sdc/v1/catalog/ -clamp.config.sdc.hostUrl=http://sdc.api.simpledemo.onap.org:8080 -clamp.config.sdc.serviceUrl=http://sdc.api.simpledemo.onap.org:8080/sdc/v1/catalog/services +clamp.config.sdc.catalog.url=http://localhost:8085/sdc/v1/catalog/ +clamp.config.sdc.hostUrl=http://localhost:8085 +clamp.config.sdc.serviceUrl=http://localhost:8085/sdc/v1/catalog/services clamp.config.sdc.serviceUsername=clamp clamp.config.sdc.servicePassword=b7acccda32b98c5bb7acccda32b98c5b05D511BD6D93626E90D18E9D24D9B78CD34C7EE8012F0A189A28763E82271E50A5D4EC10C7D93E06E0A2D27CAE66B981 clamp.config.sdc.artifactLabel=blueprintclampcockpit @@ -205,12 +207,12 @@ clamp.config.action.insert.test.event=false clamp.config.clds.service.cache.invalidate.after.seconds=120 #DCAE Inventory Url Properties -clamp.config.dcae.inventory.url=http://dcae.api.simpledemo.onap.org:8080 +clamp.config.dcae.inventory.url=http://localhost:8085 clamp.config.dcae.intentory.retry.interval=10000 clamp.config.dcae.intentory.retry.limit=3 #DCAE Dispatcher Url Properties -clamp.config.dcae.dispatcher.url=http://dcae.api.simpledemo.onap.org:8080 +clamp.config.dcae.dispatcher.url=http://localhost:8085 clamp.config.dcae.header.requestId = X-ECOMP-RequestID #Define user permission related parameters, the permission type can be changed but MUST be redefined in clds-users.properties in that case ! diff --git a/src/test/resources/application.properties b/src/test/resources/application.properties index 676c5b9ac..e0775ec67 100644 --- a/src/test/resources/application.properties +++ b/src/test/resources/application.properties @@ -144,8 +144,9 @@ clamp.config.policy.onap.name=DCAE clamp.config.policy.pdp.group=default clamp.config.policy.ms.type=MicroService clamp.config.policy.ms.policyNamePrefix=Config_MS_ -clamp.config.policy.op.type=BRMS_Param clamp.config.policy.op.policyNamePrefix=Config_BRMS_Param_ +clamp.config.policy.base.policyNamePrefix=Config_ +clamp.config.policy.op.type=BRMS_Param # TCA MicroService Policy request build properties # -- cgit 1.2.3-korg From f79bc3eee77fedfa4f42b49f722418f50ade88b5 Mon Sep 17 00:00:00 2001 From: "Determe, Sebastien (sd378r)" Date: Wed, 18 Apr 2018 17:53:21 +0200 Subject: Add Prefix to ModelName Add a "CLAMP" prefix to model name as this is used by clamp to generate the policy Scope. This prefix will be used by DCAE to filter clamp policies Issue-ID: CLAMP-153 Change-Id: I0c2e7e064df1be0de3c7e12d6e853956a70bbe64 Signed-off-by: Determe, Sebastien (sd378r) --- .../clamp/clds/sdc/controller/installer/CsarInstallerImpl.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/main/java/org/onap/clamp/clds/sdc/controller/installer/CsarInstallerImpl.java b/src/main/java/org/onap/clamp/clds/sdc/controller/installer/CsarInstallerImpl.java index 2d94bc369..10a7cd556 100644 --- a/src/main/java/org/onap/clamp/clds/sdc/controller/installer/CsarInstallerImpl.java +++ b/src/main/java/org/onap/clamp/clds/sdc/controller/installer/CsarInstallerImpl.java @@ -62,8 +62,10 @@ public class CsarInstallerImpl implements CsarInstaller { private static final EELFLogger logger = EELFManager.getInstance().getLogger(CsarInstallerImpl.class); private Map bpmnMapping = new HashMap<>(); public static final String TEMPLATE_NAME_PREFIX = "DCAE-Designer-ClosedLoopTemplate-"; - public static final String MODEL_NAME_PREFIX = "ClosedLoop-"; + public static final String CONTROL_NAME_PREFIX = "ClosedLoop-"; public static final String GET_INPUT_BLUEPRINT_PARAM = "get_input"; + // This will be used later as the policy scope + public static final String MODEL_NAME_PREFIX = "CLAMP"; /** * The file name that will be loaded by Spring. */ @@ -93,7 +95,7 @@ public class CsarInstallerImpl implements CsarInstaller { } public static String buildModelName(CsarHandler csar) { - return csar.getSdcCsarHelper().getServiceMetadata().getValue("name") + "_v" + return MODEL_NAME_PREFIX + csar.getSdcCsarHelper().getServiceMetadata().getValue("name") + "_v" + csar.getSdcNotification().getServiceVersion().replace('.', '_'); } @@ -201,7 +203,7 @@ public class CsarInstallerImpl implements CsarInstaller { // It's a filter must add a specific prefix cldsModel.setControlNamePrefix(policyName); } else { - cldsModel.setControlNamePrefix(MODEL_NAME_PREFIX); + cldsModel.setControlNamePrefix(CONTROL_NAME_PREFIX); } cldsModel.setName(buildModelName(csar)); cldsModel.setBlueprintText(blueprintArtifact.getDcaeBlueprint()); -- cgit 1.2.3-korg