mirror of
https://github.com/opennetworkinglab/onos.git
synced 2025-10-24 22:01:02 +02:00
ONOS-6080
Dynamic Config Svc : Demo1 end to end integration and dry runs Change-Id: Ied90252fe786fc6331b710c3ae977f9b9016232c
This commit is contained in:
parent
e2bd115395
commit
bda8250596
@ -28,17 +28,17 @@ import org.onosproject.yang.model.ResourceId;
|
||||
/**
|
||||
* 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 @@ public final class ResourceIdParser {
|
||||
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 @@ public final class ResourceIdParser {
|
||||
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 @@ public final class ResourceIdParser {
|
||||
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)),
|
||||
|
||||
@ -249,7 +249,7 @@ public class DistributedDynamicConfigStore
|
||||
//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 @@ public class DistributedDynamicConfigStore
|
||||
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 @@ public class DistributedDynamicConfigStore
|
||||
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);
|
||||
|
||||
@ -34,6 +34,7 @@ import org.onosproject.netconf.client.NetconfTranslator;
|
||||
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 @@ public class NetconfActiveComponent implements DynamicConfigListener {
|
||||
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 @@ public class NetconfActiveComponent implements DynamicConfigListener {
|
||||
|
||||
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 @@ public class NetconfActiveComponent implements DynamicConfigListener {
|
||||
* @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 @@ public class NetconfActiveComponent implements DynamicConfigListener {
|
||||
}
|
||||
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"));
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user