use of org.onosproject.openstacknode.api.OpenstackNode in project onos by opennetworkinglab.
the class OpenstackNodeListCommand method json.
private String json(List<OpenstackNode> osNodes) {
ObjectMapper mapper = new ObjectMapper();
ArrayNode result = mapper.createArrayNode();
for (OpenstackNode osNode : osNodes) {
result.add(jsonForEntity(osNode, OpenstackNode.class));
}
return prettyJson(mapper, result.toString());
}
use of org.onosproject.openstacknode.api.OpenstackNode in project onos by opennetworkinglab.
the class DefaultOpenstackNodeHandler method cleanPhysicalInterfaces.
private void cleanPhysicalInterfaces(OpenstackNode osNode) {
Device device = deviceService.getDevice(osNode.ovsdb());
BridgeConfig bridgeConfig = device.as(BridgeConfig.class);
Set<String> bridgeNames = bridgeConfig.getBridges().stream().map(BridgeDescription::name).collect(Collectors.toSet());
Set<String> phyNetworkNames = osNode.phyIntfs().stream().map(pi -> BRIDGE_PREFIX + pi.network()).collect(Collectors.toSet());
// we remove existing physical bridges and patch ports, if the physical
// bridges are not defined in openstack node
bridgeNames.forEach(brName -> {
if (!phyNetworkNames.contains(brName) && !brName.equals(INTEGRATION_BRIDGE)) {
removePhysicalPatchPorts(osNode, brName.substring(NETWORK_BEGIN));
removePhysicalBridge(osNode, brName.substring(NETWORK_BEGIN));
}
});
}
use of org.onosproject.openstacknode.api.OpenstackNode in project onos by opennetworkinglab.
the class DefaultOpenstackNodeHandler method isDpdkIntfsCreated.
private boolean isDpdkIntfsCreated(OpenstackNode osNode, Collection<DpdkInterface> dpdkInterfaces) {
OvsdbClientService client = getOvsdbClient(osNode, ovsdbPortNum, ovsdbController);
if (client == null) {
log.info("Failed to get ovsdb client");
return false;
}
Set<OvsdbPort> ports = client.getPorts();
for (DpdkInterface dpdkIntf : dpdkInterfaces) {
Optional<OvsdbPort> port = ports.stream().filter(ovsdbPort -> ovsdbPort.portName().value().equals(dpdkIntf.intf())).findAny();
if (!port.isPresent()) {
return false;
}
Interface intf = client.getInterface(dpdkIntf.intf());
if (intf == null) {
return false;
}
OvsdbSet mtu = (OvsdbSet) intf.getMtuColumn().data();
if (mtu == null) {
return false;
}
OvsdbMap option = (OvsdbMap) intf.getOptionsColumn().data();
if (option == null) {
return false;
}
if (!mtu.set().contains(dpdkIntf.mtu().intValue()) || !option.toString().contains(dpdkIntf.pciAddress())) {
log.trace("The dpdk interface {} was created but mtu or " + "pci address is different from the config.");
return false;
}
}
return true;
}
use of org.onosproject.openstacknode.api.OpenstackNode in project onos by opennetworkinglab.
the class OpenstackNodeManager method createNode.
@Override
public void createNode(OpenstackNode osNode) {
checkNotNull(osNode, ERR_NULL_NODE);
OpenstackNode updatedNode;
if (osNode.intgBridge() == null && osNode.type() != CONTROLLER) {
String deviceIdStr = genDpid(deviceIdCounter.incrementAndGet());
checkNotNull(deviceIdStr, ERR_NULL_DEVICE_ID);
updatedNode = osNode.updateIntbridge(DeviceId.deviceId(deviceIdStr));
checkArgument(!hasIntgBridge(updatedNode.intgBridge(), updatedNode.hostname()), NOT_DUPLICATED_MSG, updatedNode.intgBridge());
} else {
updatedNode = osNode;
checkArgument(!hasIntgBridge(updatedNode.intgBridge(), updatedNode.hostname()), NOT_DUPLICATED_MSG, updatedNode.intgBridge());
}
osNodeStore.createNode(updatedNode);
log.info(String.format(MSG_NODE, osNode.hostname(), MSG_CREATED));
}
use of org.onosproject.openstacknode.api.OpenstackNode in project onos by opennetworkinglab.
the class OpenstackNodeManager method removeNode.
@Override
public OpenstackNode removeNode(String hostname) {
checkArgument(!Strings.isNullOrEmpty(hostname), ERR_NULL_HOSTNAME);
OpenstackNode osNode = osNodeStore.removeNode(hostname);
log.info(String.format(MSG_NODE, hostname, MSG_REMOVED));
return osNode;
}
Aggregations