summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authors00370346 <swarup.nayak1@huawei.com>2019-05-08 18:48:21 +0530
committers00370346 <swarup.nayak1@huawei.com>2019-05-08 18:48:21 +0530
commitfb8ad4d9fb5f08ec500fe972398c984247f96517 (patch)
treebf550c42cbefcf26b53a11d4fb0baa9e6bc7a218
parenta7df4e77c0439e0cce667982691f87a1205e0b87 (diff)
Issue-ID: DCAEGEN2-1472 BBS bugfix(User Data as config)
Change-Id: I8a99637db7c41d6eafb58dfe960b6e29aacb71ff Signed-off-by: s00370346 <swarup.nayak1@huawei.com>
-rw-r--r--dpo/blueprints/k8s-rcc-inputs.yaml2
-rwxr-xr-xdpo/blueprints/k8s-rcc-policy.yaml-template6
-rw-r--r--dpo/spec/rcc_spec.json2
-rwxr-xr-xetc/collector.properties2
-rw-r--r--pom.xml2
-rw-r--r--src/main/java/org/onap/dcae/common/EventProcessor.java39
-rw-r--r--src/main/java/org/onap/dcae/controller/AccessController.java1
-rw-r--r--src/main/java/org/onap/dcae/controller/PersistentEventConnection.java14
-rw-r--r--src/test/java/org/onap/dcae/common/EventProcessorTest.java4
-rw-r--r--version.properties2
10 files changed, 62 insertions, 12 deletions
diff --git a/dpo/blueprints/k8s-rcc-inputs.yaml b/dpo/blueprints/k8s-rcc-inputs.yaml
index 8f61f05..d95a7ea 100644
--- a/dpo/blueprints/k8s-rcc-inputs.yaml
+++ b/dpo/blueprints/k8s-rcc-inputs.yaml
@@ -16,7 +16,7 @@
# limitations under the License.
# ============LICENSE_END=========================================================
-tag_version: nexus.onap.org:10001/org.onap.dcaegen2.collectors.restconfcollector:1.1.0
+tag_version: nexus.onap.org:10001/org.onap.dcaegen2.collectors.restconfcollector:1.2.0
external_port: 30416
diff --git a/dpo/blueprints/k8s-rcc-policy.yaml-template b/dpo/blueprints/k8s-rcc-policy.yaml-template
index b597d4f..1420989 100755
--- a/dpo/blueprints/k8s-rcc-policy.yaml-template
+++ b/dpo/blueprints/k8s-rcc-policy.yaml-template
@@ -24,7 +24,7 @@ description: >
imports:
- http://www.getcloudify.org/spec/cloudify/3.4/types.yaml
- - https://nexus.onap.org/service/local/repositories/raw/content/org.onap.dcaegen2.platform.plugins/R4/k8splugin/1.4.5/k8splugin_types.yaml
+ - https://nexus.onap.org/service/local/repositories/raw/content/org.onap.dcaegen2.platform.plugins/R4/k8splugin/1.4.13/k8splugin_types.yaml
inputs:
dmaap_host:
type: string
@@ -34,7 +34,7 @@ inputs:
default: "3904"
tag_version:
type: string
- default: "nexus3.onap.org:10001/org.onap.dcaegen2.collectors.restconfcollector:1.0.1"
+ default: "nexus3.onap.org:10001/org.onap.dcaegen2.collectors.restconfcollector:1.2.0"
consul_host:
type: string
default: consul-server.onap.svc.cluster.local
@@ -94,7 +94,7 @@ node_templates:
topic_url:
get_input: notification_publish_url
type: message_router
- rcc_policy: '[{"controller_name":"AccessM&C","controller_restapiUrl":"172.30.0.55:26335","controller_restapiUser":"access","controller_restapiPassword":"Huawei@123","controller_accessTokenUrl":"/rest/plat/smapp/v1/oauth/token","controller_accessTokenFile":"./etc/access-token.json","controller_accessTokenMethod":"put","controller_subsMethod":"post","controller_subscriptionUrl":"/restconf/v1/operations/huawei-nce-notification-action:establish-subscription","controller_disableSsl":"true","event_details":[{"event_name":"ONT_registration","event_description":"ONTregistartionevent","event_sseventUrlEmbed":"true","event_sseventsField":"output.url","event_sseventsUrl":"null","event_subscriptionTemplate":"./etc/ont_registartion_subscription_template.json","event_unSubscriptionTemplate":"./etc/ont_registartion_unsubscription_template.json","event_ruleId":"12345678", "modifyData": "true", "modifyMethod": "modifyOntEvent"}]}]'
+ rcc_policy: '[{"controller_name":"AccessM&C","controller_restapiUrl":"172.30.0.55:26335","controller_restapiUser":"access","controller_restapiPassword":"Huawei@123","controller_accessTokenUrl":"/rest/plat/smapp/v1/oauth/token","controller_accessTokenFile":"./etc/access-token.json","controller_accessTokenMethod":"put","controller_subsMethod":"post","controller_subscriptionUrl":"/restconf/v1/operations/huawei-nce-notification-action:establish-subscription","controller_disableSsl":"true","event_details":[{"event_name":"ONT_registration","event_description":"ONTregistartionevent","event_sseventUrlEmbed":"true","event_sseventsField":"output.url","event_sseventsUrl":"null","event_subscriptionTemplate":"./etc/ont_registartion_subscription_template.json","event_unSubscriptionTemplate":"./etc/ont_registartion_unsubscription_template.json","event_ruleId":"12345678", "modifyData": "true", "modifyMethod": "modifyOntEvent", "userData": "remote_id=AC9.0234.0337;svlan=100;cvlan=10;"}]}]'
interfaces:
cloudify.interfaces.lifecycle:
start:
diff --git a/dpo/spec/rcc_spec.json b/dpo/spec/rcc_spec.json
index dbcca67..6281d62 100644
--- a/dpo/spec/rcc_spec.json
+++ b/dpo/spec/rcc_spec.json
@@ -134,7 +134,7 @@
{
"name": "rcc_policy",
"description": "RCC Policy JSON",
- "value":"[{\"controller_name\":\"AccessM&C\",\"controller_restapiUrl\":\"192.167.1.3:8080\",\"controller_restapiUser\":\"access\",\"controller_restapiPassword\":\"Huawei@123\",\"controller_accessTokenUrl\":\"/rest/plat/smapp/v1/oauth/token\",\"controller_accessTokenFile\":\"./etc/access-token.json\",\"controller_accessTokenMethod\":\"put\",\"controller_subsMethod\":\"post\",\"controller_subscriptionUrl\":\"/restconf/v1/operations/huawei-nce-notification-action:establish-subscription\",\"controller_disableSsl\":\"true\",\"event_details\":[{\"event_name\":\"ONT_registration\",\"event_description\":\"ONTregistartionevent\",\"event_sseventUrlEmbed\":\"true\",\"event_sseventsField\":\"output.url\",\"event_sseventsUrl\":\"null\",\"event_subscriptionTemplate\":\"./etc/ont_registartion_subscription_template.json\",\"event_unSubscriptionTemplate\":\"./etc/ont_registartion_unsubscription_template.json\",\"event_ruleId\":\"12345678\", \"modifyData\": \"true\", \"modifyMethod\": \"modifyOntEvent\"}]}]",
+ "value":"[{\"controller_name\":\"AccessM&C\",\"controller_restapiUrl\":\"192.167.1.3:8080\",\"controller_restapiUser\":\"access\",\"controller_restapiPassword\":\"Huawei@123\",\"controller_accessTokenUrl\":\"/rest/plat/smapp/v1/oauth/token\",\"controller_accessTokenFile\":\"./etc/access-token.json\",\"controller_accessTokenMethod\":\"put\",\"controller_subsMethod\":\"post\",\"controller_subscriptionUrl\":\"/restconf/v1/operations/huawei-nce-notification-action:establish-subscription\",\"controller_disableSsl\":\"true\",\"event_details\":[{\"event_name\":\"ONT_registration\",\"event_description\":\"ONTregistartionevent\",\"event_sseventUrlEmbed\":\"true\",\"event_sseventsField\":\"output.url\",\"event_sseventsUrl\":\"null\",\"event_subscriptionTemplate\":\"./etc/ont_registartion_subscription_template.json\",\"event_unSubscriptionTemplate\":\"./etc/ont_registartion_unsubscription_template.json\",\"event_ruleId\":\"12345678\", \"modifyData\": \"true\", \"modifyMethod\": \"modifyOntEvent\", \"userData\": \"remote_id=AC9.0234.0337;svlan=100;cvlan=10;\"}]}]",
"sourced_at_deployment": false,
"policy_editable": true,
"designer_editable": false
diff --git a/etc/collector.properties b/etc/collector.properties
index c66c0df..5397c09 100755
--- a/etc/collector.properties
+++ b/etc/collector.properties
@@ -70,7 +70,7 @@ collector.rcc.inputQueue.maxPending=8096
## List all streamid per domain to be supported. The streamid should match to channel name on dmaapfile
collector.rcc.dmaap.streamid=notification=device-registration
collector.dmaapfile=./etc/DmaapConfig.json
-rcc_policy = [{\"controller_name\":\"AccessM&C\",\"controller_restapiUrl\":\"172.30.0.55:26335\",\"controller_restapiUser\":\"access\",\"controller_restapiPassword\":\"Huawei@123\",\"controller_accessTokenUrl\":\"/rest/plat/smapp/v1/oauth/token\",\"controller_accessTokenFile\":\"./etc/access-token.json\",\"controller_accessTokenMethod\":\"put\",\"controller_subsMethod\":\"post\",\"controller_subscriptionUrl\":\"/restconf/v1/operations/huawei-nce-notification-action:establish-subscription\",\"controller_disableSsl\":\"true\",\"event_details\":[{\"event_name\":\"ONT_registration\",\"event_description\":\"ONTregistartionevent\",\"event_sseventUrlEmbed\":\"true\",\"event_sseventsField\":\"output.url\",\"event_sseventsUrl\":\"null\",\"event_subscriptionTemplate\":\"./etc/ont_registartion_subscription_template.json\",\"event_unSubscriptionTemplate\":\"./etc/ont_registartion_unsubscription_template.json\",\"event_ruleId\":\"777777777\", \"modifyData\": \"true\", \"modifyMethod\": \"modifyOntEvent\"}]}]
+rcc_policy = [{\"controller_name\":\"AccessM&C\",\"controller_restapiUrl\":\"172.30.0.55:26335\",\"controller_restapiUser\":\"access\",\"controller_restapiPassword\":\"Huawei@123\",\"controller_accessTokenUrl\":\"/rest/plat/smapp/v1/oauth/token\",\"controller_accessTokenFile\":\"./etc/access-token.json\",\"controller_accessTokenMethod\":\"put\",\"controller_subsMethod\":\"post\",\"controller_subscriptionUrl\":\"/restconf/v1/operations/huawei-nce-notification-action:establish-subscription\",\"controller_disableSsl\":\"true\",\"event_details\":[{\"event_name\":\"ONT_registration\",\"event_description\":\"ONTregistartionevent\",\"event_sseventUrlEmbed\":\"true\",\"event_sseventsField\":\"output.url\",\"event_sseventsUrl\":\"null\",\"event_subscriptionTemplate\":\"./etc/ont_registartion_subscription_template.json\",\"event_unSubscriptionTemplate\":\"./etc/ont_registartion_unsubscription_template.json\",\"event_ruleId\":\"777777777\", \"modifyData\": \"true\", \"modifyMethod\": \"modifyOntEvent\", \"userData\": \"remote_id=AC9.0234.0337;svlan=100;cvlan=10;\"}]}]
# Describes at what frequency (measured in minutes) should application try to fetch config from CBS
diff --git a/pom.xml b/pom.xml
index 5fc8f3e..5881265 100644
--- a/pom.xml
+++ b/pom.xml
@@ -26,7 +26,7 @@ limitations under the License.
</parent>
<groupId>org.onap.dcaegen2.collectors.restconf</groupId>
<artifactId>restconfcollector</artifactId>
- <version>1.1.0-SNAPSHOT</version>
+ <version>1.2.0-SNAPSHOT</version>
<name>dcaegen2-collectors-restconf</name>
<description>RestConfCollector</description>
<properties>
diff --git a/src/main/java/org/onap/dcae/common/EventProcessor.java b/src/main/java/org/onap/dcae/common/EventProcessor.java
index 259e3b2..1879700 100644
--- a/src/main/java/org/onap/dcae/common/EventProcessor.java
+++ b/src/main/java/org/onap/dcae/common/EventProcessor.java
@@ -85,7 +85,8 @@ public class EventProcessor implements Runnable {
if (ev.getConn().isModifyEvent()){
try {
log.info("Invoking method " + ev.getConn().getModifyMethod() + " isModify " + ev.getConn().isModifyEvent());
- modifiedObj = (JSONObject)(this.getClass().getMethod(ev.getConn().getModifyMethod(), EventData.class).invoke(this, ev));
+ modifiedObj = (JSONObject)(this.getClass().getMethod(ev.getConn().getModifyMethod(),
+ EventData.class, String.class).invoke(this, ev, ev.getConn().getUserData()));
}catch (Exception e) {
log.warn("No such method exist" + e);
}
@@ -118,7 +119,7 @@ public class EventProcessor implements Runnable {
return mergedJSON;
}
- public JSONObject modifyOntEvent(EventData ev) {
+ public JSONObject modifyOntEvent(EventData ev, String userData) {
PersistentEventConnection conn = ev.getConn();
JSONObject json1 = ev.getEventObj();
log.info("modifyOntEvent");
@@ -158,6 +159,28 @@ public class EventProcessor implements Runnable {
JSONObject additionalfields = newJSON.getJSONObject("additionalFields");
String attachment_point = oltName + "-" + olt_slot + "-" + olt_port;
additionalfields.put("attachment-point", attachment_point);
+ if (!userData.isEmpty()) {
+ java.util.Map<String, String> usrDataMap = parseuserDataToDataHashMapping(userData);
+ if (usrDataMap.containsKey("remote_id")) {
+ additionalfields.put("remote-id", usrDataMap.get("remote_id"));
+ }
+
+ if (usrDataMap.containsKey("cvlan")) {
+ additionalfields.put("cvlan", usrDataMap.get("cvlan"));
+ }
+
+ if (usrDataMap.containsKey("svlan")) {
+ additionalfields.put("svlan", usrDataMap.get("svlan"));
+ }
+
+ if (usrDataMap.containsKey("macAddress")) {
+ newJSON.put("macAddress", usrDataMap.get("macAddress"));
+ }
+
+ if (usrDataMap.containsKey("vendorName")) {
+ newJSON.put("vendorName", usrDataMap.get("vendorName"));
+ }
+ }
//additionalfields.put("remote-id", attachment-point);
} catch (Exception e) {
log.info("File reading error " + e);
@@ -167,4 +190,16 @@ public class EventProcessor implements Runnable {
log.info("final obj"+ finalObj.toString());
return finalObj;
}
+
+ public static java.util.Map<String, String> parseuserDataToDataHashMapping(String userData) {
+ java.util.Map<String, String> userDataHash = new HashMap<>();
+ String[] list = userData.split("\\;");
+ for (String aList : list) {
+ String key = aList.split("=")[0];
+ String value = aList.substring(aList.indexOf('=') + 1);
+ userDataHash.put(key, value);
+ log.info("adding key " + key + " value " + value);
+ }
+ return userDataHash;
+ }
}
diff --git a/src/main/java/org/onap/dcae/controller/AccessController.java b/src/main/java/org/onap/dcae/controller/AccessController.java
index bd80d97..b82b757 100644
--- a/src/main/java/org/onap/dcae/controller/AccessController.java
+++ b/src/main/java/org/onap/dcae/controller/AccessController.java
@@ -179,6 +179,7 @@ public class AccessController {
.setEventRuleId(event.get("event_ruleId").toString()).setParentCtrllr(this)
.setModifyEvent(Boolean.parseBoolean(event.get("modifyData").toString()))
.setModifyMethod(event.get("modifyMethod").toString())
+ .setUserData(event.get("userData").toString())
.createPersistentEventConnection();
eventList.put(name, conn);
diff --git a/src/main/java/org/onap/dcae/controller/PersistentEventConnection.java b/src/main/java/org/onap/dcae/controller/PersistentEventConnection.java
index 2fb782f..391da76 100644
--- a/src/main/java/org/onap/dcae/controller/PersistentEventConnection.java
+++ b/src/main/java/org/onap/dcae/controller/PersistentEventConnection.java
@@ -57,7 +57,7 @@ public class PersistentEventConnection implements Runnable {
private static final Logger log = LoggerFactory.getLogger(PersistentEventConnection.class);
private boolean modifyEvent;
private String modifyMethod;
-
+ private String userData;
private RestConfContext ctx;
private AccessController parentCtrllr;
private Map<String, String> eventParaMap;
@@ -75,6 +75,7 @@ public class PersistentEventConnection implements Runnable {
private AccessController parentCtrllr;
private boolean modifyEvent;
private String modifyMethod;
+ private String userData;
public PersistentEventConnectionBuilder setEventName(String event_name) {
this.event_name = event_name;
@@ -130,6 +131,12 @@ public class PersistentEventConnection implements Runnable {
this.modifyMethod = modifyMethod;
return this;
}
+
+ public PersistentEventConnectionBuilder setUserData(String userData) {
+ this.userData = userData;
+ return this;
+ }
+
public PersistentEventConnection createPersistentEventConnection() {
return new PersistentEventConnection(this);
}
@@ -151,6 +158,7 @@ public class PersistentEventConnection implements Runnable {
this.state = EventConnectionState.INIT;
this.modifyEvent = builder.modifyEvent;
this.modifyMethod = builder.modifyMethod;
+ this.userData = builder.userData;
this.ctx = new RestConfContext();
for (String s : builder.parentCtrllr.getCtx().getAttributeKeySet()) {
@@ -283,6 +291,10 @@ public class PersistentEventConnection implements Runnable {
return modifyMethod;
}
+ public String getUserData() {
+ return userData;
+ }
+
public void printEventParamMap() {
log.info("----------------Event Param Map-------------------");
for (String name : eventParaMap.keySet()) {
diff --git a/src/test/java/org/onap/dcae/common/EventProcessorTest.java b/src/test/java/org/onap/dcae/common/EventProcessorTest.java
index 671cad0..eb1037e 100644
--- a/src/test/java/org/onap/dcae/common/EventProcessorTest.java
+++ b/src/test/java/org/onap/dcae/common/EventProcessorTest.java
@@ -94,7 +94,9 @@ public class EventProcessorTest {
PersistentEventConnection p = new PersistentEventConnection.PersistentEventConnectionBuilder().setEventName("")
.setEventDescription("").setEventSseventUrlEmbed(true).setEventSseventsField("").setEventSseventsUrl("")
.setEventSubscriptionTemplate("").setEventUnSubscriptionTemplate("").setEventRuleId("1234646346")
- .setParentCtrllr(acClr).setModifyEvent(true).setModifyMethod("modifyOntEvent").createPersistentEventConnection();
+ .setParentCtrllr(acClr).setModifyEvent(true).setModifyMethod("modifyOntEvent")
+ .setUserData("remote_id=AC9.0234.0337;svlan=1001;macAddress=00:11:22:33:44:55;")
+ .createPersistentEventConnection();
p.getEventParamMapValue("restapiUrl");
p.modifyEventParamMap("restapiUrl", "10.118.191.43:26335");
RestConfCollector.fProcessingInputQueue = new LinkedBlockingQueue<>(4);
diff --git a/version.properties b/version.properties
index 7b8b963..00ef564 100644
--- a/version.properties
+++ b/version.properties
@@ -1,5 +1,5 @@
major=1
-minor=1
+minor=2
patch=0
base_version=${major}.${minor}.${patch}
release_version=${base_version}