use of org.onosproject.net.driver.DriverHandler in project onos by opennetworkinglab.
the class FujitsuVoltOnuOperConfig method loopbackEthOnu.
@Override
public String loopbackEthOnu(String target) {
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;
String[] data = null;
String[] ethId = null;
if (!mastershipService.isLocalMaster(ncDeviceId)) {
log.warn("Not master for {} Use {} to execute command", ncDeviceId, mastershipService.getMasterFor(ncDeviceId));
return null;
}
data = target.split(COLON);
if (data.length > TWO) {
log.error("Invalid number of parameters {}", target);
return null;
}
ethId = checkIdString(data[FIRST_PART], THREE);
if (ethId == null) {
log.error("Invalid ETH port identifier {}", data[FIRST_PART]);
return null;
}
if (data.length > ONE) {
if (!LOOPBACKMODES.contains(data[SECOND_PART])) {
log.error("Unsupported parameter: {}", data[SECOND_PART]);
return null;
}
}
try {
StringBuilder request = new StringBuilder();
request.append(ANGLE_LEFT + ONU_ETHPORT_LOOPBACK + SPACE);
request.append(VOLT_NE_NAMESPACE + ANGLE_RIGHT + NEW_LINE);
request.append(buildStartTag(PONLINK_ID, false)).append(ethId[FIRST_PART]).append(buildEndTag(PONLINK_ID)).append(buildStartTag(ONU_ID, false)).append(ethId[SECOND_PART]).append(buildEndTag(ONU_ID)).append(buildStartTag(ETHPORT_ID, false)).append(ethId[THIRD_PART]).append(buildEndTag(ETHPORT_ID));
if (data.length > ONE) {
request.append(buildStartTag(LOOPBACK_MODE, false)).append(data[SECOND_PART]).append(buildEndTag(LOOPBACK_MODE));
}
request.append(buildEndTag(ONU_ETHPORT_LOOPBACK));
reply = controller.getDevicesMap().get(ncDeviceId).getSession().doWrappedRpc(request.toString());
} 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 FujitsuVoltOnuOperConfig method rebootOnu.
@Override
public String rebootOnu(String target) {
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;
String[] onuId = null;
if (!mastershipService.isLocalMaster(ncDeviceId)) {
log.warn("Not master for {} Use {} to execute command", ncDeviceId, mastershipService.getMasterFor(ncDeviceId));
return null;
}
onuId = checkIdString(target, TWO);
if (onuId == null) {
log.error("Invalid ONU identifier {}", target);
return null;
}
try {
StringBuilder request = new StringBuilder();
request.append(ANGLE_LEFT + ONU_REBOOT + SPACE);
request.append(VOLT_NE_NAMESPACE + ANGLE_RIGHT + NEW_LINE);
request.append(buildStartTag(PONLINK_ID, false)).append(onuId[FIRST_PART]).append(buildEndTag(PONLINK_ID)).append(buildStartTag(ONU_ID, false)).append(onuId[SECOND_PART]).append(buildEndTag(ONU_ID)).append(buildEndTag(ONU_REBOOT));
reply = controller.getDevicesMap().get(ncDeviceId).getSession().doWrappedRpc(request.toString());
} 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 FujitsuVoltPonLinkConfig method setPonLink.
@Override
public boolean setPonLink(String target) {
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");
if (!mastershipService.isLocalMaster(ncDeviceId)) {
log.warn("Not master for {} Use {} to execute command", ncDeviceId, mastershipService.getMasterFor(ncDeviceId));
return false;
}
String[] data = checkSetInput(target);
if (data == null) {
log.error("Failed to check input: {}", target);
return false;
}
boolean result = false;
try {
StringBuilder request = new StringBuilder();
request.append(VOLT_NE_OPEN + VOLT_NE_NAMESPACE);
request.append(ANGLE_RIGHT + NEW_LINE);
request.append(buildStartTag(VOLT_PORTS)).append(buildStartTag(GPON_PONLINK_PORTS)).append(buildStartTag(GPON_PONLINK_PORT)).append(buildStartTag(PONLINK_ID, false)).append(data[FIRST_PART]).append(buildEndTag(PONLINK_ID)).append(buildStartTag(data[SECOND_PART], false)).append(data[THIRD_PART]).append(buildEndTag(data[SECOND_PART])).append(buildEndTag(GPON_PONLINK_PORT)).append(buildEndTag(GPON_PONLINK_PORTS)).append(buildEndTag(VOLT_PORTS)).append(VOLT_NE_CLOSE);
result = controller.getDevicesMap().get(ncDeviceId).getSession().editConfig(RUNNING, null, request.toString());
} catch (NetconfException e) {
log.error("Cannot communicate to device {} exception {}", ncDeviceId, e);
}
return result;
}
use of org.onosproject.net.driver.DriverHandler in project onos by opennetworkinglab.
the class VoltEthLoopbackCommand method doExecute.
@Override
protected void doExecute() {
DriverService service = get(DriverService.class);
deviceId = DeviceId.deviceId(uri);
DriverHandler h = service.createHandler(deviceId);
VoltOnuOperConfig volt = h.behaviour(VoltOnuOperConfig.class);
String reply = volt.loopbackEthOnu(target);
if (reply != null) {
print("%s", reply);
} else {
print("No reply from %s", deviceId.toString());
}
}
use of org.onosproject.net.driver.DriverHandler in project onos by opennetworkinglab.
the class VoltGetAlertFilterCommand method doExecute.
@Override
protected void doExecute() {
DriverService service = get(DriverService.class);
deviceId = DeviceId.deviceId(uri);
DriverHandler h = service.createHandler(deviceId);
VoltAlertConfig voltNe = h.behaviour(VoltAlertConfig.class);
String reply = voltNe.getAlertFilter();
if (reply != null) {
print("%s", reply);
} else {
print("No reply from %s", deviceId.toString());
}
}
Aggregations