use of org.onosproject.netconf.NetconfController in project onos by opennetworkinglab.
the class Ciena5162DeviceDescription method discoverDeviceDetails.
@Override
public DeviceDescription discoverDeviceDetails() {
DeviceId deviceId = handler().data().deviceId();
NetconfController controller = checkNotNull(handler().get(NetconfController.class));
NetconfSession session = controller.getDevicesMap().get(handler().data().deviceId()).getSession();
try {
Node systemInfo = TEMPLATE_MANAGER.doRequest(session, "systemInfo");
Node softwareVersion = TEMPLATE_MANAGER.doRequest(session, "softwareVersion");
XPath xp = XPathFactory.newInstance().newXPath();
String mac = xp.evaluate("components/component/properties/property/state/value/text()", systemInfo).toUpperCase();
return new DefaultDeviceDescription(deviceId.uri(), Device.Type.SWITCH, xp.evaluate("components/component/state/mfg-name/text()", systemInfo), xp.evaluate("components/component/state/name/text()", systemInfo), xp.evaluate("software-state/running-package/package-version/text()", softwareVersion), xp.evaluate("components/component/state/serial-no/text()", systemInfo), new ChassisId(Long.valueOf(mac, 16)));
} catch (XPathExpressionException | NetconfException ne) {
log.error("failed to query system info from device {}", handler().data().deviceId(), ne);
}
return new DefaultDeviceDescription(deviceId.uri(), Device.Type.SWITCH, "Ciena", "5162", "Unknown", "Unknown", new ChassisId());
}
use of org.onosproject.netconf.NetconfController in project onos by opennetworkinglab.
the class InterfaceConfigCiscoIosImpl method addTrunkMode.
/**
* Adds a trunk interface for VLANs.
*
* @param intf the name of the interface
* @param vlanIds the VLAN IDs
* @return the result of operation
*/
@Override
public boolean addTrunkMode(String intf, List<VlanId> vlanIds) {
NetconfController controller = checkNotNull(handler().get(NetconfController.class));
NetconfSession session = controller.getDevicesMap().get(handler().data().deviceId()).getSession();
String reply;
try {
reply = session.requestSync(addTrunkModeBuilder(intf, vlanIds));
} catch (NetconfException e) {
log.error("Failed to configure trunk mode for VLAN ID {} on device {} interface {}.", vlanIds, handler().data().deviceId(), intf, e);
return false;
}
return XmlConfigParser.configSuccess(XmlConfigParser.loadXml(new ByteArrayInputStream(reply.getBytes(StandardCharsets.UTF_8))));
}
use of org.onosproject.netconf.NetconfController in project onos by opennetworkinglab.
the class InterfaceConfigCiscoIosImpl method addAccessMode.
/**
* Adds an access interface to a VLAN.
*
* @param intf the name of the interface
* @param vlanId the VLAN ID
* @return the result of operation
*/
@Override
public boolean addAccessMode(String intf, VlanId vlanId) {
NetconfController controller = checkNotNull(handler().get(NetconfController.class));
NetconfSession session = controller.getDevicesMap().get(handler().data().deviceId()).getSession();
String reply;
try {
reply = session.requestSync(addAccessModeBuilder(intf, vlanId));
} catch (NetconfException e) {
log.error("Failed to configure VLAN ID {} on device {} interface {}.", vlanId, handler().data().deviceId(), intf, e);
return false;
}
return XmlConfigParser.configSuccess(XmlConfigParser.loadXml(new ByteArrayInputStream(reply.getBytes(StandardCharsets.UTF_8))));
}
use of org.onosproject.netconf.NetconfController in project onos by opennetworkinglab.
the class InterfaceConfigCiscoIosImpl method addRateLimit.
/**
* Adds a rate limit on an interface.
*
* @param intf the name of the interface
* @param limit the limit as a percentage
* @return the result of operation
*/
@Override
public boolean addRateLimit(String intf, short limit) {
NetconfController controller = checkNotNull(handler().get(NetconfController.class));
NetconfSession session = controller.getDevicesMap().get(handler().data().deviceId()).getSession();
String reply;
try {
reply = session.requestSync(addRateLimitBuilder(intf, limit));
} catch (NetconfException e) {
log.error("Failed to configure rate limit {}%% on device {} interface {}.", limit, handler().data().deviceId(), intf, e);
return false;
}
return XmlConfigParser.configSuccess(XmlConfigParser.loadXml(new ByteArrayInputStream(reply.getBytes(StandardCharsets.UTF_8))));
}
use of org.onosproject.netconf.NetconfController in project onos by opennetworkinglab.
the class InterfaceConfigCiscoIosImpl method removeTrunkMode.
/**
* Removes trunk mode configuration from an interface.
*
* @param intf the name of the interface
* @return the result of operation
*/
@Override
public boolean removeTrunkMode(String intf) {
NetconfController controller = checkNotNull(handler().get(NetconfController.class));
NetconfSession session = controller.getDevicesMap().get(handler().data().deviceId()).getSession();
String reply;
try {
reply = session.requestSync(removeTrunkModeBuilder(intf));
} catch (NetconfException e) {
log.error("Failed to remove trunk mode from device {} interface {}.", handler().data().deviceId(), intf, e);
return false;
}
return XmlConfigParser.configSuccess(XmlConfigParser.loadXml(new ByteArrayInputStream(reply.getBytes(StandardCharsets.UTF_8))));
}
Aggregations