Now I'm trying to get TAPI yang-tree under tapi-common:context/tapi-topology:topology like
<context xmlns="urn:onf:otcc:yang:tapi-common">
<topology xmlns="urn:onf:otcc:yang:tapi-topology">
<uuid>00000000-0000-0000-0001-100000000000</uuid>
<node>
<uuid>00000000-0000-1000-0001-100000000000</uuid>
<owned-node-edge-point>
<uuid>00000000-0000-1100-0001-101000000000</uuid>
<layer-protocol-name>DSR</layer-protocol-name>
</owned-node-edge-point>
</node>
</topology>
</context>
This data is already added to DCS store with using this code:
private void setTapiTopology() {
DefaultAugmentedTapiCommonContext topologyContext = new DefaultAugmentedTapiCommonContext();
topologyContext.addToTopology(topology);
ModelObjectId modelObjectId = ModelObjectId.builder().addChild(DefaultContext.class).build();
ModelObjectData modelObjectData = DefaultModelObjectData.builder()
.addModelObject(topologyContext)
.identifier(modelObjectId)
.build();
setToDcs(modelObjectData);
}
private void setToDcs(ModelObjectData input) {
initDcsIfRootNotExist();
ResourceData rnode = modelConverter.createDataNode(input);
CharSequence strNode = toCharSequence(toXmlCompositeStream(toCompositeData(rnode)));
printlog("To be created: {}\n{}", rnode.resourceId().nodeKeys(), strNode);
printlog("XML:\n{}", XmlString.prettifyXml(strNode));
addToDcsStore(rnode);
}
private void addToDcsStore(ResourceData input) {
addToDcsStore(input, input.resourceId());
}
private void addToDcsStore(ResourceData input, ResourceId rid) {
if (input == null || input.dataNodes() == null) {
return;
}
List<DataNode> dataNodes = input.dataNodes();
for (DataNode node : dataNodes) {
dcs.createNode(rid, node);
}
}
so I want to get this data from DCS as ResourceData and convert it to ModelObject, but I cannot do it.
I tried to convert ResourceData including augmented TAPI context(and topology) yang-tree to ModelObject with this kind of code:
DataNode all = dcs.readNode(getResourceId(mid), Filter.builder().build());
log.info("all: {}", all);
ResourceId empty = ResourceId.builder().build();
ResourceData data = DefaultResourceData.builder().addDataNode(all).resourceId(empty).build();
// INFO: augment data might be lost here
ModelObjectData modelData = converter.createModel(data);
log.info("converted: {}", modelData);
for (ModelObject obj : modelData.modelObjects()) {
log.info("obj: {}", obj);
log.info("class: {}", obj.getClass());
if (!(obj instanceof AugmentedTapiCommonContext)) {
continue;
}
// FIXME: cannot go ahead from here because augmented context
org.onosproject.yang.gen.v1.tapitopology.rev20180307.tapitopology.context.DefaultAugmentedTapiCommonContext topologyContext =
(org.onosproject.yang.gen.v1.tapitopology.rev20180307.tapitopology.context.DefaultAugmentedTapiCommonContext) obj;
Topology topology = topologyContext.topology().get(0);
but it failed. It looks like the augmented context yang-tree would be lost by ModelConverter.createModel() method.
Would you let me know how to get augmented context yang-tree data from DCS store as ModelObject?
You can reproduce it with following patch and commands, so please use it if needed:
onos> app activate odtn-api odtn-service odtn-driver
onos> onos:odtn-tapi-setup
send POST to http://localhost:8181/onos/restconf/operations/tapi-connectivity:create-connectivity-service
{
"tapi-connectivity:input":
{
"end-point" : [
{
"layer-protocol-name" : "DSR",
"local-id": "foo",
"service-interface-point": {
"service-interface-point-id" : "00000000-0000-4200-0001-110000000000"
}
}
,
{
"layer-protocol-name" : "DSR",
"local-id": "bar",
"service-interface-point": {
"service-interface-point-id" : "00000000-0000-4200-0001-210000000000"
}
}
]
}
}
Thanks,
Hiroki