Search in sources :

Example 1 with ModelObjectData

use of org.onosproject.yang.model.ModelObjectData in project onos by opennetworkinglab.

the class DcsBasedTapiDataProducer method getResourceId.

private ResourceId getResourceId(ModelObjectId modelId) {
    ModelObjectData data = DefaultModelObjectData.builder().identifier(modelId).build();
    ResourceData rnode = modelConverter.createDataNode(data);
    return rnode.resourceId();
}
Also used : ResourceData(org.onosproject.yang.model.ResourceData) DefaultResourceData(org.onosproject.yang.model.DefaultResourceData) DefaultModelObjectData(org.onosproject.yang.model.DefaultModelObjectData) ModelObjectData(org.onosproject.yang.model.ModelObjectData)

Example 2 with ModelObjectData

use of org.onosproject.yang.model.ModelObjectData 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;
}
Also used : ResourceData(org.onosproject.yang.model.ResourceData) DefaultResourceData(org.onosproject.yang.model.DefaultResourceData) DataNode(org.onosproject.yang.model.DataNode) DefaultModelObjectData(org.onosproject.yang.model.DefaultModelObjectData) ModelObjectData(org.onosproject.yang.model.ModelObjectData) DefaultContext(org.onosproject.yang.gen.v1.tapicommon.rev20181210.tapicommon.DefaultContext) ModelObjectId(org.onosproject.yang.model.ModelObjectId)

Example 3 with ModelObjectData

use of org.onosproject.yang.model.ModelObjectData in project onos by opennetworkinglab.

the class TapiObjectHandler method toModelObject.

@SuppressWarnings("unchecked")
protected T toModelObject(DataNode rNode, ResourceId rId) {
    dcsSetup();
    ResourceData rData = toResourceData(rNode, rId);
    ModelObjectData modelObjectData = modelConverter.createModel(rData);
    if (modelObjectData.modelObjects().size() > 1) {
        throw new IllegalStateException("Multiple modelObject found.");
    }
    if (modelObjectData.modelObjects().isEmpty()) {
        throw new IllegalStateException("ModelObject must not be empty.");
    }
    return (T) modelObjectData.modelObjects().get(0);
}
Also used : DefaultResourceData(org.onosproject.yang.model.DefaultResourceData) ResourceData(org.onosproject.yang.model.ResourceData) DefaultModelObjectData(org.onosproject.yang.model.DefaultModelObjectData) ModelObjectData(org.onosproject.yang.model.ModelObjectData)

Example 4 with ModelObjectData

use of org.onosproject.yang.model.ModelObjectData in project onos by opennetworkinglab.

the class OdtnDcsModelCheckCommand method getResourceId.

private ResourceId getResourceId(ModelObjectId modelId) {
    ModelObjectData data = DefaultModelObjectData.builder().identifier(modelId).build();
    ResourceData rnode = modelConverter.createDataNode(data);
    return rnode.resourceId();
}
Also used : YangToolUtil.toResourceData(org.onosproject.odtn.utils.YangToolUtil.toResourceData) ResourceData(org.onosproject.yang.model.ResourceData) DefaultModelObjectData(org.onosproject.yang.model.DefaultModelObjectData) ModelObjectData(org.onosproject.yang.model.ModelObjectData)

Example 5 with ModelObjectData

use of org.onosproject.yang.model.ModelObjectData in project onos by opennetworkinglab.

the class YangToolUtil method toDataNode.

/**
 * Converts ModelObject into a DataNode.
 *
 * @param input ModelOject
 * @return DataNode
 */
public static DataNode toDataNode(ModelObject input) {
    // FIXME this converter will work with root-level nodes only.
    initStaticContext();
    ModelObjectData modelData = DefaultModelObjectData.builder().addModelObject(input).identifier(null).build();
    ResourceData rnode = converter.createDataNode(modelData);
    if (rnode.dataNodes().isEmpty()) {
        log.error("input did not result in any datanode. {}", input);
        return null;
    }
    return rnode.dataNodes().get(0);
}
Also used : ResourceData(org.onosproject.yang.model.ResourceData) DefaultResourceData(org.onosproject.yang.model.DefaultResourceData) DefaultModelObjectData(org.onosproject.yang.model.DefaultModelObjectData) ModelObjectData(org.onosproject.yang.model.ModelObjectData)

Aggregations

DefaultModelObjectData (org.onosproject.yang.model.DefaultModelObjectData)5 ModelObjectData (org.onosproject.yang.model.ModelObjectData)5 ResourceData (org.onosproject.yang.model.ResourceData)5 DefaultResourceData (org.onosproject.yang.model.DefaultResourceData)4 YangToolUtil.toResourceData (org.onosproject.odtn.utils.YangToolUtil.toResourceData)1 DefaultContext (org.onosproject.yang.gen.v1.tapicommon.rev20181210.tapicommon.DefaultContext)1 DataNode (org.onosproject.yang.model.DataNode)1 ModelObjectId (org.onosproject.yang.model.ModelObjectId)1