use of org.onosproject.net.driver.DriverHandler in project onos by opennetworkinglab.
the class FujitsuVoltNeConfig method getAll.
@Override
public String getAll() {
DriverHandler handler = handler();
NetconfController controller = handler.get(NetconfController.class);
MastershipService mastershipService = handler.get(MastershipService.class);
DeviceId ncDeviceId = handler.data().deviceId();
checkNotNull(controller, "Netconf controller is null");
String reply = null;
if (!mastershipService.isLocalMaster(ncDeviceId)) {
log.warn("Not master for {} Use {} to execute command", ncDeviceId, mastershipService.getMasterFor(ncDeviceId));
return null;
}
try {
StringBuilder request = new StringBuilder();
request.append(VOLT_NE_OPEN + VOLT_NE_NAMESPACE);
request.append(ANGLE_RIGHT + NEW_LINE);
request.append(VOLT_NE_CLOSE);
reply = controller.getDevicesMap().get(ncDeviceId).getSession().get(request.toString(), REPORT_ALL);
} catch (NetconfException e) {
log.error("Cannot communicate to device {} exception {}", ncDeviceId, e);
}
return reply;
}
use of org.onosproject.net.driver.DriverHandler in project onos by opennetworkinglab.
the class OpenFlowPolicerConfigurableTest method testMeterNull.
/**
* Test meter problems.
*/
@Test
public void testMeterNull() {
// Get device handler
DriverHandler driverHandler = driverService.createHandler(ofDid);
// Get policer config behavior
PolicerConfigurable policerConfigurable = driverHandler.behaviour(PolicerConfigurable.class);
// Get policer id
PolicerId policerId = policerConfigurable.allocatePolicerId();
// this works
assertThat(policerId.uri().getScheme(), is(OF_SCHEME));
String hexId = Long.toHexString((mid1.id()));
assertThat(policerId.uri().getSchemeSpecificPart(), is(hexId));
// Get another policer id
policerId = policerConfigurable.allocatePolicerId();
assertThat(policerId.uri().getScheme(), is(OF_SCHEME));
hexId = Long.toHexString((mid10.id()));
assertThat(policerId.uri().getSchemeSpecificPart(), is(hexId));
// Get the last policer id
policerId = policerConfigurable.allocatePolicerId();
assertThat(policerId.uri().getScheme(), is(OF_SCHEME));
hexId = Long.toHexString((mid100.id()));
assertThat(policerId.uri().getSchemeSpecificPart(), is(hexId));
// this does not work
policerId = policerConfigurable.allocatePolicerId();
// Assert that is none
assertThat(policerId, is(PolicerId.NONE));
}
use of org.onosproject.net.driver.DriverHandler in project onos by opennetworkinglab.
the class OpenFlowPolicerConfigurableTest method testFreeId.
/**
* Test free policer id.
*/
@Test
public void testFreeId() {
// Get device handler
DriverHandler driverHandler = driverService.createHandler(ofDid);
// Get policer config behavior
PolicerConfigurable policerConfigurable = driverHandler.behaviour(PolicerConfigurable.class);
// Get policer id
PolicerId policerId = policerConfigurable.allocatePolicerId();
// this works
assertThat(policerId.uri().getScheme(), is(OF_SCHEME));
String hexId = Long.toHexString((mid1.id()));
assertThat(policerId.uri().getSchemeSpecificPart(), is(hexId));
// Verify the allocation before free
assertThat(meterService.availableIds.size(), is(2));
// Let's free the policer id
policerConfigurable.freePolicerId(policerId);
// Verify the availability after free
assertThat(meterService.availableIds.size(), is(3));
}
use of org.onosproject.net.driver.DriverHandler in project onos by opennetworkinglab.
the class DellRestBridgeConfig method addPort.
@Override
public void addPort(BridgeName bridgeName, String portName) {
// bridgeName is not used
checkNotNull(portName);
portName = portNameForCli(portName);
String portAddCommands = String.format(PORT_ADD_COMMANDS, portName);
DriverHandler handler = handler();
RestSBController controller = checkNotNull(handler.get(RestSBController.class));
DeviceId deviceId = handler.data().deviceId();
InputStream payload = new StringBufferInputStream(String.format(CONFIG_COMMANDS, portAddCommands));
String resp = controller.post(deviceId, CLI_REQUEST, payload, MediaType.valueOf("*/*"), String.class);
// TODO Parse resp and if error, return false
log.info("{}", resp);
return;
}
use of org.onosproject.net.driver.DriverHandler in project onos by opennetworkinglab.
the class DellRestBridgeConfig method deletePort.
@Override
public void deletePort(BridgeName bridgeName, String portName) {
// bridgeName is not used
checkNotNull(portName);
portName = portNameForCli(portName);
String portRemoveCommands = String.format(PORT_REMOVE_COMMANDS, portName);
DriverHandler handler = handler();
RestSBController controller = checkNotNull(handler.get(RestSBController.class));
DeviceId deviceId = handler.data().deviceId();
InputStream payload = new StringBufferInputStream(String.format(CONFIG_COMMANDS, portRemoveCommands));
String resp = controller.post(deviceId, CLI_REQUEST, payload, MediaType.valueOf("*/*"), String.class);
log.info("{}", resp);
}
Aggregations