<bad-element>interface</bad-element> error

44 views
Skip to first unread message

Carl Roberts

unread,
Apr 22, 2012, 11:38:27 AM4/22/12
to NetconfX
Hi, I am trying to follow your quick guide but using an existing Yang
model:

In the tree, the Yang model looks like this:

module: mds-interfaces
+--rw interfaces
+--rw interface [name]
+--rw name string
+--rw config

I am doing this in the code (probably wrong but I don't know what to
change):

Element model = XmlUtils.fromXmlFile("mappings.xml");
DataModel dm = new DataModel();
dm.fromXml(model);
DeviceInterface di= new DeviceInterface();
di.setCollection(5000);
di.setMtu(1500);
di.setName("if-test");
Path path = new Path(new PathSegment("com:gemds:mds-
interfaces", "interfaces"));

NetconfUtil nu = new NetconfUtil(dm);
Element root = nu.toXml(path, null, di,
EditOperation.Update);
System.out.println(XmlUtils.toXmlString(root));
client.editConfig("candidate", root);

Here is my mappings.xml:

<?xml version="1.0" encoding="UTF-8"?>
<netconfDataModel>
<class name="netconfxtest.DeviceInterface" xmlPath=""
xmlContainer="" xmlTag="interface" xmlNamespace="com:gemds:mds-
interfaces" keys="name">
<attribute name="name" xmlContainer="" xmlTag="name"
xmlNamespace="com:gemds:mds-interfaces" readOnly="false"
mandatory="false" many="false" />
<attribute name="mtu" xmlContainer="" xmlTag="mtu"
xmlNamespace="com:gemds:mds-interfaces" readOnly="false"
mandatory="false" many="false" />
<attribute name="collections" xmlContainer="" xmlTag="collections"
xmlNamespace="com:gemds:mds-interfaces" readOnly="true"
mandatory="false" many="false" />
</class>
</netconfDataModel>

And here is my pojo:


package netconfxtest;

public class DeviceInterface{
private int mtu;
private int collection;
private String name;
public int getMtu() {
return mtu;
}

public void setMtu(int mtu) {
this.mtu = mtu;
}

public int getCollection() {
return collection;
}

public void setCollection(int collection) {
this.collection = collection;
}

public String getName() {
return name;
}

public void setName(String name) {
this.name = name;
}
}


But I am getting this error:


Apr 22, 2012 11:29:52 AM
com.centeredlogic.net.netconf.exception.NetconfException <clinit>
WARNING: Error loading exception resource:Can't find bundle for base
name com.centeredlogic.net.netconf.exception.exceptionDescriptions,
locale en_US
com.centeredlogic.net.netconf.exception.NetconfException: Error code:
UnknownElementError type: applicationError Message: nullError info: <?
xml version="1.0" encoding="UTF-8"?>
<error-info xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
<bad-element>interface</bad-element>
</error-info>Path:
/rpc/edit-config/config/if:interface

at
com.centeredlogic.net.netconf.exception.NetconfException.fromXml(NetconfException.java:
281)
at com.centeredlogic.net.netconf.Client.unwrapResponse(Client.java:
488)
at com.centeredlogic.net.netconf.Client.send(Client.java:434)
at com.centeredlogic.net.netconf.Client.editConfig(Client.java:281)
at netconfxtest.NetConfXTest.main(NetConfXTest.java:80)


Is there something else that I may need to change? The namespace in
the Yang file is this:

module mds-interfaces {
namespace "com:gemds:mds-interfaces";

And then, we have this:

typedef interface-ref {
type leafref {
path "/if:interfaces/if:interface/if:name";
}
description
"This type is used by data models that need to reference
interfaces.";
}
Reply all
Reply to author
Forward
Message has been deleted
0 new messages