use of org.onosproject.net.DeviceId in project onos by opennetworkinglab.
the class OpenFlowPolicerConfigurable method freePolicerId.
@Override
public void freePolicerId(PolicerId id) {
// Init step
DriverHandler handler = handler();
// First step is to get MeterService
MeterService meterService = handler.get(MeterService.class);
// There was a problem, return none
if (meterService == null) {
log.warn("MeterService is null");
return;
}
// Let's get the device id
DeviceId deviceId = handler.data().deviceId();
// Double check correspondence with device schema
if (!deviceId.uri().getScheme().equals(OF_SCHEME)) {
log.warn("The device {} does not seem to be managed by OpenFlow", deviceId);
return;
}
// Double check correspondence with pid schema
if (!id.uri().getScheme().equals(OF_SCHEME)) {
log.warn("The id {} does not seem to be OpenFlow", id);
return;
}
// Get the meter id
MeterId meterId = getMeterIdFromPolicerId(id);
// Free the meter id
meterService.freeMeterId(deviceId, meterId);
}
use of org.onosproject.net.DeviceId in project onos by opennetworkinglab.
the class DellRestOpenFlowControllerConfig method setControllers.
// Example test with ONOS CLI:
// device-setcontrollers rest:10.251.217.143:8008 tcp:1.2.3.4:2222
// TODO: assumes that of-instance 1 was in "no shutdown" state,
// check previous state
@Override
public void setControllers(List<ControllerInfo> controllers) {
// Dell supports max 2 controllers per of-instance
if (controllers.size() > MAX_CONTROLLERS) {
log.warn("Cannot set more than 2 controllers.");
}
DriverHandler handler = handler();
RestSBController controller = checkNotNull(handler.get(RestSBController.class));
DeviceId deviceId = handler.data().deviceId();
String controllerCommands = getControllerCommands(controllers).stream().reduce(String::concat).orElse("");
InputStream payload = new StringBufferInputStream(String.format(SET_CONTROLLERS_XML, controllerCommands));
String resp = controller.post(deviceId, CLI_REQUEST, payload, MediaType.valueOf("*/*"), String.class);
log.info("{}", resp);
}
use of org.onosproject.net.DeviceId in project onos by opennetworkinglab.
the class FujitsuVoltNniLinkConfig method getNniLinks.
@Override
public String getNniLinks(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;
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).append(ANGLE_RIGHT + NEW_LINE).append(buildStartTag(VOLT_PORTS));
if (target != null) {
int nni;
try {
nni = Integer.parseInt(target);
if (nni <= ZERO) {
log.error("Invalid integer for nnilink-id:{}", target);
return null;
}
} catch (NumberFormatException e) {
log.error("Non-number input for nnilink-id:{}", target);
return null;
}
request.append(buildStartTag(ETH_NNILINK_PORTS)).append(buildStartTag(ETH_NNILINK_PORT)).append(buildStartTag(NNILINK_ID, false)).append(target).append(buildEndTag(NNILINK_ID)).append(buildEndTag(ETH_NNILINK_PORT)).append(buildEndTag(ETH_NNILINK_PORTS));
} else {
request.append(buildEmptyTag(ETH_NNILINK_PORTS));
}
request.append(buildEndTag(VOLT_PORTS)).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.DeviceId in project onos by opennetworkinglab.
the class FujitsuVoltPonLinkConfig method getPonLinks.
@Override
public String getPonLinks(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;
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(buildStartTag(VOLT_PORTS));
if (target != null) {
int pon;
try {
pon = Integer.parseInt(target);
if (pon <= ZERO) {
log.error("Invalid integer for ponlink-id:{}", target);
return null;
}
} catch (NumberFormatException e) {
log.error("Non-number input for ponlink-id:{}", target);
return null;
}
request.append(buildStartTag(GPON_PONLINK_PORTS)).append(buildStartTag(GPON_PONLINK_PORT)).append(buildStartTag(PONLINK_ID, false)).append(target).append(buildEndTag(PONLINK_ID)).append(buildEndTag(GPON_PONLINK_PORT)).append(buildEndTag(GPON_PONLINK_PORTS));
} else {
request.append(buildEmptyTag(GPON_PONLINK_PORTS));
}
request.append(buildEndTag(VOLT_PORTS));
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.DeviceId in project onos by opennetworkinglab.
the class K8sNodeManager method updateNode.
@Override
public void updateNode(K8sNode node) {
checkNotNull(node, ERR_NULL_NODE);
K8sNode intNode;
K8sNode extNode;
K8sNode localNode;
K8sNode tunNode;
K8sNode existingNode = nodeStore.node(node.hostname());
checkNotNull(existingNode, ERR_NULL_NODE);
DeviceId existIntgBridge = nodeStore.node(node.hostname()).intgBridge();
if (node.intgBridge() == null) {
intNode = node.updateIntgBridge(existIntgBridge);
checkArgument(!hasIntgBridge(intNode.intgBridge(), intNode.hostname()), NOT_DUPLICATED_MSG, intNode.intgBridge());
} else {
intNode = node;
checkArgument(!hasIntgBridge(intNode.intgBridge(), intNode.hostname()), NOT_DUPLICATED_MSG, intNode.intgBridge());
}
DeviceId existExtBridge = nodeStore.node(node.hostname()).extBridge();
if (intNode.extBridge() == null) {
extNode = intNode.updateExtBridge(existExtBridge);
checkArgument(!hasExtBridge(extNode.extBridge(), extNode.hostname()), NOT_DUPLICATED_MSG, extNode.extBridge());
} else {
extNode = intNode;
checkArgument(!hasExtBridge(extNode.extBridge(), extNode.hostname()), NOT_DUPLICATED_MSG, extNode.extBridge());
}
DeviceId existLocalBridge = nodeStore.node(node.hostname()).localBridge();
if (extNode.localBridge() == null) {
localNode = extNode.updateLocalBridge(existLocalBridge);
checkArgument(!hasLocalBridge(localNode.localBridge(), localNode.hostname()), NOT_DUPLICATED_MSG, localNode.localBridge());
} else {
localNode = extNode;
checkArgument(!hasLocalBridge(localNode.localBridge(), localNode.hostname()), NOT_DUPLICATED_MSG, localNode.localBridge());
}
if (node.mode() == NORMAL) {
DeviceId existTunBridge = nodeStore.node(node.hostname()).tunBridge();
if (localNode.tunBridge() == null) {
tunNode = localNode.updateTunBridge(existTunBridge);
checkArgument(!hasTunBridge(tunNode.tunBridge(), tunNode.hostname()), NOT_DUPLICATED_MSG, tunNode.tunBridge());
} else {
tunNode = localNode;
checkArgument(!hasTunBridge(tunNode.tunBridge(), tunNode.hostname()), NOT_DUPLICATED_MSG, tunNode.tunBridge());
}
nodeStore.updateNode(tunNode);
} else {
nodeStore.updateNode(localNode);
}
log.info(String.format(MSG_NODE, extNode.hostname(), MSG_UPDATED));
}
Aggregations