use of org.onosproject.yang.model.DataNode in project onos by opennetworkinglab.
the class DynamicDeviceConfigServiceViewTest method testReadNode.
@Test
public void testReadNode() {
Filter filter = null;
DataNode returned = view.readNode(relIntf, filter);
assertTrue(ResourceIds.isPrefix(rid, realPath));
// FIXME test realFilter
// TODO do we expect something to happen on returned?
}
use of org.onosproject.yang.model.DataNode in project onos by opennetworkinglab.
the class OdtnTapiHandlersTestCommand method doExecute.
@Override
public void doExecute() {
dcs = get(DynamicConfigService.class);
modelConverter = get(ModelConverter.class);
setupTapiContext();
DataNode data = contextHandler.getDataNode();
ResourceId empty = ResourceId.builder().build();
CharSequence strNode = toCharSequence(toXmlCompositeStream(toCompositeData(toResourceData(empty, data))));
StringBuilder exp = loadXml("/test-tapi-context.xml");
if (XmlString.prettifyXml(strNode).toString().contentEquals(exp)) {
printlog("result: ok");
} else {
printlog("result: failed");
}
}
use of org.onosproject.yang.model.DataNode in project onos by opennetworkinglab.
the class DcsBasedTapiDataProducer method readContextModelObject.
/**
* Get Tapi context modelObject from Dcs.
*
* @return Tapi context modelObject in Dcs store
*/
// FIXME update this method using TapiContextHandler
private DefaultContext readContextModelObject() {
// read DataNode from DCS
ModelObjectId mid = ModelObjectId.builder().addChild(DefaultContext.class).build();
DataNode node = dcs.readNode(getResourceId(mid), Filter.builder().build());
// convert to ModelObject
ResourceData data = DefaultResourceData.builder().addDataNode(node).resourceId(ResourceId.builder().build()).build();
ModelObjectData modelData = modelConverter.createModel(data);
DefaultContext context = (DefaultContext) modelData.modelObjects().get(0);
return context;
}
use of org.onosproject.yang.model.DataNode in project onos by opennetworkinglab.
the class RestconfManager method runGetOperationOnDataResource.
@Override
public ObjectNode runGetOperationOnDataResource(URI uri) throws RestconfException {
DataResourceLocator rl = DataResourceLocator.newInstance(uri);
// TODO: define Filter (if there is any requirement).
Filter filter = Filter.builder().build();
DataNode dataNode;
try {
if (!dynamicConfigService.nodeExist(rl.ridForDynConfig())) {
return null;
}
dataNode = dynamicConfigService.readNode(rl.ridForDynConfig(), filter);
} catch (FailedException e) {
log.error("ERROR: DynamicConfigService: ", e);
throw new RestconfException("ERROR: DynamicConfigService", e, RestconfError.ErrorTag.OPERATION_FAILED, INTERNAL_SERVER_ERROR, Optional.of(uri.getPath()));
}
ObjectNode rootNode = convertDataNodeToJson(rl.ridForYangRuntime(), dataNode);
return rootNode;
}
use of org.onosproject.yang.model.DataNode in project onos by opennetworkinglab.
the class RestconfManager method runPostOperationOnDataResource.
@Override
public void runPostOperationOnDataResource(URI uri, ObjectNode rootNode) throws RestconfException {
DataResourceLocator rl = DataResourceLocator.newInstance(uri);
ResourceData receivedData = convertJsonToDataNode(rl.uriForYangRuntime(), rootNode);
ResourceId rid = receivedData.resourceId();
List<DataNode> dataNodeList = receivedData.dataNodes();
if (dataNodeList == null || dataNodeList.isEmpty()) {
log.warn("There is no one Data Node can be proceed.");
return;
}
if (dataNodeList.size() > 1) {
log.warn("There are more than one Data Node can be proceed: {}", dataNodeList.size());
}
DataNode dataNode = dataNodeList.get(0);
if (rid == null) {
rid = ResourceId.builder().addBranchPointSchema("/", null).build();
dataNode = removeTopNode(dataNode);
}
try {
dynamicConfigService.createNode(rl.ridForDynConfig(), dataNode);
} catch (Exception e) {
if (e.getMessage().startsWith("Requested node already present")) {
throw new RestconfException("Already exists", e, RestconfError.ErrorTag.DATA_EXISTS, CONFLICT, Optional.of(uri.getPath()));
} else {
log.error("ERROR: DynamicConfigService: creating {} with {}", ResourceIds.toInstanceIdentifier(rl.ridForDynConfig()), dataNode, e);
throw new RestconfException("ERROR: DynamicConfigService", e, RestconfError.ErrorTag.OPERATION_FAILED, INTERNAL_SERVER_ERROR, Optional.of(uri.getPath()));
}
}
}
Aggregations