ONOS-6080
Dynamic Config Svc : Demo1 end to end integration and dry runs
Change-Id: Ied90252fe786fc6331b710c3ae977f9b9016232c
diff --git a/apps/config/src/main/java/org/onosproject/config/ResourceIdParser.java b/apps/config/src/main/java/org/onosproject/config/ResourceIdParser.java
index 089aeff..f993550 100755
--- a/apps/config/src/main/java/org/onosproject/config/ResourceIdParser.java
+++ b/apps/config/src/main/java/org/onosproject/config/ResourceIdParser.java
@@ -28,17 +28,17 @@
/**
* Utilities to work on the ResourceId.
*/
-
+//FIXME add javadocs
public final class ResourceIdParser {
public static final String ROOT = "root";
public static final String NM_SEP = "#";
public static final String VAL_SEP = "@";
public static final String KEY_SEP = "$";
- public static final String EL_SEP = ".";
+ public static final String EL_SEP = "|";
public static final String VAL_CHK = "\\@";
public static final String KEY_CHK = "\\$";
-
+ public static final String NM_CHK = "\\#";
private ResourceIdParser() {
@@ -100,7 +100,6 @@
return (path + EL_SEP + key);
}
- //DONE
public static String appendKeyLeaf(String path, KeyLeaf key) {
StringBuilder bldr = new StringBuilder();
bldr.append(key.leafSchema().name());
@@ -187,7 +186,6 @@
bldr.append(key.schemaId().name());
bldr.append(NM_SEP);
bldr.append(key.schemaId().namespace());
- bldr.append(NM_SEP);
Iterator<KeyLeaf> iter = key.keyLeafs().iterator();
KeyLeaf next;
while (iter.hasNext()) {
@@ -218,14 +216,16 @@
name.substring(name.indexOf(NM_SEP) + 1, name.indexOf(VAL_SEP)),
name.substring(name.indexOf(VAL_SEP) + 1));
} else if (name.contains(KEY_SEP)) {
- resBldr.addBranchPointSchema(name.substring(0, name.indexOf(NM_SEP)),
- name.substring(name.indexOf(NM_SEP) + 1, name.indexOf(KEY_SEP)));
- String[] keys = name.split(KEY_SEP);
+ String[] keys = name.split(KEY_CHK);
+ String[] nm = keys[0].split(NM_CHK);
+ resBldr.addBranchPointSchema(nm[0], nm[1]);
for (int i = 1; i < keys.length; i++) {
String key = keys[i];
- resBldr.addKeyLeaf(key.substring(0, key.indexOf(NM_SEP)),
- key.substring(key.indexOf(NM_SEP) + 1, key.lastIndexOf(NM_SEP)),
- key.substring(name.lastIndexOf(NM_SEP) + 1));
+ String[] el = keys[i].split(NM_CHK);
+ if (el.length != 3) {
+ throw new FailedException("Malformed event subject, cannot parse");
+ }
+ resBldr.addKeyLeaf(el[0], el[1], el[2]);
}
} else {
resBldr.addBranchPointSchema(name.substring(0, name.indexOf(NM_SEP)),
diff --git a/apps/config/src/main/java/org/onosproject/config/impl/DistributedDynamicConfigStore.java b/apps/config/src/main/java/org/onosproject/config/impl/DistributedDynamicConfigStore.java
index 11dce6b..e4fcb0e 100644
--- a/apps/config/src/main/java/org/onosproject/config/impl/DistributedDynamicConfigStore.java
+++ b/apps/config/src/main/java/org/onosproject/config/impl/DistributedDynamicConfigStore.java
@@ -249,7 +249,7 @@
//String tempPath = ResourceIdParser.appendKeyLeaf(spath, keyLeaf);
//LeafNode lfnd = readLeaf(tempPath);
superBldr.addKeyLeaf(keyLeaf.leafSchema().name(),
- keyLeaf.leafSchema().namespace(), keyLeaf.leafValue());
+ keyLeaf.leafSchema().namespace(), String.valueOf(keyLeaf.leafValue()));
}
readInner(superBldr, spath);
retVal = superBldr.build();
@@ -273,7 +273,7 @@
throw new FailedException("Inner node cannot have empty children map");
}
entries.forEach((k, v) -> {
- String[] names = k.split(ResourceIdParser.NM_SEP);
+ String[] names = k.split(ResourceIdParser.NM_CHK);
String name = names[0];
String nmSpc = ResourceIdParser.getNamespace(names[1]);
String keyVal = ResourceIdParser.getKeyVal(names[1]);
@@ -303,7 +303,7 @@
for (int i = 1; i < keys.length; i++) {
//String curKey = ResourceIdParser.appendKeyLeaf(tempPath, keys[i]);
//LeafNode lfnd = readLeaf(curKey);
- String[] keydata = keys[i].split(ResourceIdParser.NM_SEP);
+ String[] keydata = keys[i].split(ResourceIdParser.NM_CHK);
tempBldr.addKeyLeaf(keydata[0], keydata[1], keydata[2]);
}
readInner(tempBldr, tempPath);
diff --git a/apps/netconf/client/src/main/java/org/onosproject/netconf/client/impl/NetconfActiveComponent.java b/apps/netconf/client/src/main/java/org/onosproject/netconf/client/impl/NetconfActiveComponent.java
index 287f871..ac7735e 100644
--- a/apps/netconf/client/src/main/java/org/onosproject/netconf/client/impl/NetconfActiveComponent.java
+++ b/apps/netconf/client/src/main/java/org/onosproject/netconf/client/impl/NetconfActiveComponent.java
@@ -34,6 +34,7 @@
import org.onosproject.netconf.client.NetconfTranslator.OperationType;
import org.onosproject.yang.model.DataNode;
import org.onosproject.yang.model.LeafNode;
+import org.onosproject.yang.model.ListKey;
import org.onosproject.yang.model.ResourceId;
import org.onosproject.yang.runtime.DefaultResourceData;
import org.slf4j.Logger;
@@ -51,7 +52,7 @@
private static final Logger log = LoggerFactory.getLogger(NetconfActiveComponent.class);
@Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
protected DynamicConfigService cfgService;
- public static final String DEVNMSPACE = "namespace1";
+ public static final String DEVNMSPACE = "ne-l3vpn-api";
@Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
protected NetconfTranslator netconfTranslator;
@@ -64,6 +65,8 @@
private ResourceId resId = new ResourceId.Builder()
.addBranchPointSchema("device", DEVNMSPACE)
+ .addBranchPointSchema("device", DEVNMSPACE)
+ .addKeyLeaf("deviceid", DEVNMSPACE, "netconf:172.16.5.11:22")
.build();
@Activate
@@ -171,6 +174,7 @@
* @param node the node associated with the event
* @return the deviceId of the effected device
*/
+ @Beta
public DeviceId getDeviceId(DataNode node) {
String[] temp;
String ip, port;
@@ -181,6 +185,14 @@
}
ip = temp[1];
port = temp[2];
+ } else if (node.type() == DataNode.Type.MULTI_INSTANCE_NODE) {
+ ListKey key = (ListKey) node.key();
+ temp = key.keyLeafs().get(0).leafValAsString().split("\\:");
+ if (temp.length != 3) {
+ throw new RuntimeException(new NetconfException("Invalid device id form, cannot apply"));
+ }
+ ip = temp[1];
+ port = temp[2];
} else {
throw new RuntimeException(new NetconfException("Invalid device id type, cannot apply"));
}