mirror of
https://github.com/opennetworkinglab/onos.git
synced 2026-01-07 01:22:05 +01:00
DynamicConfig netconf rpc update
- use new NETCONF RPC API - Cleaned up debug logs Change-Id: Ibc365bb144466d4815f02e0ecfe2f9f7bc207310
This commit is contained in:
parent
45b2418571
commit
9285d971ae
1
.gitignore
vendored
1
.gitignore
vendored
@ -19,6 +19,7 @@ buck-out
|
||||
bucklets/plugins/
|
||||
.watchmanconfig
|
||||
.vscode
|
||||
*.fxs
|
||||
|
||||
/bin/
|
||||
lib/yang
|
||||
|
||||
@ -63,7 +63,6 @@ import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
|
||||
import static org.onosproject.config.DynamicConfigEvent.Type.NODE_ADDED;
|
||||
import static org.onosproject.config.DynamicConfigEvent.Type.NODE_DELETED;
|
||||
import static org.onosproject.config.DynamicConfigEvent.Type.NODE_UPDATED;
|
||||
@ -228,13 +227,12 @@ public class DistributedDynamicConfigStore
|
||||
log.trace("dpath={}", dpath);
|
||||
// FIXME Not atomic, should probably use create or replace
|
||||
if (completeVersioned(keystore.get(dpath)) != null) {
|
||||
log.trace(" keystore.set({}, {})", dpath, type);
|
||||
completeVersioned(keystore.set(dpath, type));
|
||||
log.trace("true");
|
||||
return true;
|
||||
}
|
||||
log.trace(" keystore.create({}, {})", dpath, type);
|
||||
Boolean result = complete(keystore.create(dpath, type));
|
||||
log.trace("{}", result);
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -298,6 +296,8 @@ public class DistributedDynamicConfigStore
|
||||
DocumentPath.from(spath));
|
||||
Map<String, Versioned<DataNode.Type>> entries = null;
|
||||
entries = complete(ret);
|
||||
log.trace(" keystore.getChildren({})", spath);
|
||||
log.trace(" entries keys:{}", entries.keySet());
|
||||
if ((entries != null) && (!entries.isEmpty())) {
|
||||
entries.forEach((k, v) -> {
|
||||
String[] names = k.split(ResourceIdParser.NM_CHK);
|
||||
@ -429,10 +429,12 @@ public class DistributedDynamicConfigStore
|
||||
}
|
||||
});
|
||||
}
|
||||
log.trace(" keystore.removeNode({})", spath);
|
||||
keystore.removeNode(DocumentPath.from(spath));
|
||||
}
|
||||
|
||||
private void removeLeaf(String path) {
|
||||
log.trace(" keystore.removeNode({})", path);
|
||||
keystore.removeNode(DocumentPath.from(path));
|
||||
objectStore.remove(path);
|
||||
}
|
||||
|
||||
@ -23,8 +23,6 @@ import static org.slf4j.LoggerFactory.getLogger;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
import org.onlab.util.XmlString;
|
||||
import org.onosproject.d.config.ResourceIds;
|
||||
import org.onosproject.d.config.sync.DeviceConfigSynchronizationProvider;
|
||||
@ -47,6 +45,7 @@ import org.onosproject.yang.model.ResourceData;
|
||||
import org.onosproject.yang.model.ResourceId;
|
||||
import org.onosproject.yang.runtime.AnnotatedNodeInfo;
|
||||
import org.onosproject.yang.runtime.Annotation;
|
||||
import org.onosproject.yang.runtime.CompositeData;
|
||||
import org.onosproject.yang.runtime.CompositeStream;
|
||||
import org.onosproject.yang.runtime.DefaultAnnotatedNodeInfo;
|
||||
import org.onosproject.yang.runtime.DefaultAnnotation;
|
||||
@ -93,9 +92,6 @@ public class NetconfDeviceConfigSynchronizerProvider
|
||||
|
||||
private NetconfContext context;
|
||||
|
||||
// FIXME remove and let netconf southbound deal with message-id generation
|
||||
private final AtomicInteger messageId = new AtomicInteger(1);
|
||||
|
||||
protected NetconfDeviceConfigSynchronizerProvider(ProviderId id,
|
||||
NetconfContext context) {
|
||||
super(id);
|
||||
@ -115,8 +111,8 @@ public class NetconfDeviceConfigSynchronizerProvider
|
||||
StringBuilder rpc = new StringBuilder();
|
||||
|
||||
// - Add NETCONF envelope
|
||||
rpc.append("<rpc xmlns=\"").append(NETCONF_1_0_BASE_NAMESPACE).append("\" ")
|
||||
.append("message-id=\"").append(messageId.getAndIncrement()).append("\">");
|
||||
rpc.append("<rpc xmlns=\"").append(NETCONF_1_0_BASE_NAMESPACE).append('"')
|
||||
.append(">");
|
||||
|
||||
rpc.append("<edit-config>");
|
||||
rpc.append("<target>");
|
||||
@ -134,6 +130,7 @@ public class NetconfDeviceConfigSynchronizerProvider
|
||||
|
||||
// Convert change(s) into a DataNode tree
|
||||
for (Change change : request.changes()) {
|
||||
log.trace("change={}", change);
|
||||
|
||||
// TODO switch statement can probably be removed
|
||||
switch (change.op()) {
|
||||
@ -157,7 +154,9 @@ public class NetconfDeviceConfigSynchronizerProvider
|
||||
.setDataFormat(DATAFORMAT_XML)
|
||||
.addAnnotation(XMLNS_XC_ANNOTATION)
|
||||
.build();
|
||||
CompositeStream xml = context.yangRuntime().encode(compositeData.build(),
|
||||
CompositeData cdata = compositeData.build();
|
||||
log.trace("CompositeData:{}", cdata);
|
||||
CompositeStream xml = context.yangRuntime().encode(cdata,
|
||||
yrtContext);
|
||||
try {
|
||||
CharStreams.copy(new InputStreamReader(xml.resourceData(), UTF_8), rpc);
|
||||
@ -191,11 +190,12 @@ public class NetconfDeviceConfigSynchronizerProvider
|
||||
try {
|
||||
// FIXME Netconf async API is currently screwed up, need to fix
|
||||
// NetconfSession, etc.
|
||||
CompletableFuture<String> response = session.request(rpc.toString());
|
||||
log.info("TRACE: request:\n{}", XmlString.prettifyXml(rpc));
|
||||
CompletableFuture<String> response = session.rpc(rpc.toString());
|
||||
log.trace("raw request:\n{}", rpc);
|
||||
log.trace("prettified request:\n{}", XmlString.prettifyXml(rpc));
|
||||
return response.handle((resp, err) -> {
|
||||
if (err == null) {
|
||||
log.info("TRACE: reply:\n{}", XmlString.prettifyXml(resp));
|
||||
log.trace("reply:\n{}", XmlString.prettifyXml(resp));
|
||||
// FIXME check response properly
|
||||
return SetResponse.ok(request);
|
||||
} else {
|
||||
|
||||
@ -165,6 +165,7 @@ public class DynamicDeviceConfigSynchronizer
|
||||
void processEventNonBatch(DynamicConfigEvent event) {
|
||||
ResourceId path = event.subject();
|
||||
if (isUnderDeviceRootNode(path)) {
|
||||
log.trace("processing event:{}", event);
|
||||
|
||||
DeviceId deviceId = DeviceResourceIds.toDeviceId(path);
|
||||
ResourceId deviceRootPath = DeviceResourceIds.toResourceId(deviceId);
|
||||
@ -207,6 +208,8 @@ public class DynamicDeviceConfigSynchronizer
|
||||
log.error("Request to {} failed {}", deviceId, response, e);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
log.warn("Ignored event's ResourceId: {}", event.subject());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user