use of org.onosproject.openstacknode.api.OpenstackNode in project onos by opennetworkinglab.
the class OpenstackNorthSouthProbeCommand method doExecute.
@Override
protected void doExecute() {
OpenstackTroubleshootService tsService = get(OpenstackTroubleshootService.class);
InstancePortService instPortService = get(InstancePortService.class);
OpenstackNodeService osNodeService = get(OpenstackNodeService.class);
MastershipService mastershipService = get(MastershipService.class);
ClusterService clusterService = get(ClusterService.class);
if (tsService == null || osNodeService == null || instPortService == null || mastershipService == null) {
error("Failed to troubleshoot openstack networking.");
return;
}
if ((!isAll && vmIps == null) || (isAll && vmIps != null)) {
print("Please specify one of VM IP address or -a option.");
return;
}
NodeId localNodeId = clusterService.getLocalNode().id();
for (OpenstackNode gw : osNodeService.completeNodes(GATEWAY)) {
if (!localNodeId.equals(mastershipService.getMasterFor(gw.intgBridge()))) {
error("Current node is not the master for all gateway nodes. " + "Please enforce mastership first using openstack-reset-mastership -c !");
return;
}
}
if (isAll) {
printHeader();
// send ICMP PACKET_OUT to all connect VMs whose instance port state is ACTIVE
instPortService.instancePorts().stream().filter(p -> p.state() == ACTIVE).filter(p -> instPortService.floatingIp(p.portId()) != null).forEach(port -> printReachability(tsService.probeNorthSouth(port)));
} else {
final Set<InstancePort> ports = Sets.newConcurrentHashSet();
for (String ip : vmIps) {
instPortService.instancePorts().stream().filter(p -> p.state().equals(InstancePort.State.ACTIVE)).filter(p -> instPortService.floatingIp(p.portId()) != null).filter(p -> ip.equals(instPortService.floatingIp(p.portId()).toString())).forEach(ports::add);
}
printHeader();
ports.forEach(port -> probeExecutor.execute(() -> printReachability(tsService.probeNorthSouth(port))));
}
}
use of org.onosproject.openstacknode.api.OpenstackNode in project onos by opennetworkinglab.
the class OpenstackConfigArpModeCommand method syncRules.
private void syncRules() {
// All handlers in this application reacts the node complete event and
// tries to re-configure flow rules for the complete node.
OpenstackNodeService osNodeService = get(OpenstackNodeService.class);
OpenstackNodeAdminService osNodeAdminService = get(OpenstackNodeAdminService.class);
if (osNodeService == null) {
error("Failed to re-install flow rules for OpenStack networking.");
return;
}
osNodeService.completeNodes().forEach(osNode -> {
OpenstackNode updated = osNode.updateState(NodeState.INIT);
osNodeAdminService.updateNode(updated);
});
}
use of org.onosproject.openstacknode.api.OpenstackNode in project onos by opennetworkinglab.
the class OpenstackDetachedPortListCommand method doExecute.
@Override
protected void doExecute() {
OpenstackNodeService nodeService = get(OpenstackNodeService.class);
OpenstackNetworkService networkService = get(OpenstackNetworkService.class);
DeviceService deviceService = get(DeviceService.class);
if (isAll) {
hostnames = nodeService.completeNodes().stream().map(OpenstackNode::hostname).toArray(String[]::new);
}
if (hostnames == null) {
print("Please specify one of hostname or --all options.");
return;
}
print(FORMAT, "Hostname", "Integration Bridge", "Detached Port");
for (String hostname : hostnames) {
networkService.ports().forEach(p -> {
if (hostname.equals(p.getHostId())) {
OpenstackNode osNode = nodeService.node(p.getHostId());
if (osNode != null) {
Set<String> detachedPortNames = detachedOvsPort(p, deviceService.getPorts(osNode.intgBridge()));
detachedPortNames.forEach(dp -> print(FORMAT, hostname, osNode.intgBridge().toString(), dp));
}
}
});
}
}
use of org.onosproject.openstacknode.api.OpenstackNode in project onos by opennetworkinglab.
the class OpenstackDirectPortAddCommand method doExecute.
@Override
protected void doExecute() {
OpenstackNetworkService osNetService = get(OpenstackNetworkService.class);
OpenstackNodeService osNodeService = get(OpenstackNodeService.class);
DeviceService deviceService = get(DeviceService.class);
Port port = osNetService.port(portId);
if (port == null) {
log.error("There's no port that matches the port ID {}", portId);
return;
}
Optional<OpenstackNode> osNode = osNodeService.completeNodes(COMPUTE).stream().filter(node -> node.hostname().equals(port.getHostId())).findAny();
if (!osNode.isPresent()) {
log.error("There's no openstackNode that matches hostname {}", port.getHostId());
return;
}
String intfName = getIntfNameFromPciAddress(port);
if (intfName == null) {
log.error("Failed to retrieve interface name from a port {}", portId);
return;
} else if (intfName.equals(UNSUPPORTED_VENDOR)) {
return;
}
if (OpenstackNetworkingUtil.hasIntfAleadyInDevice(osNode.get().intgBridge(), intfName, deviceService)) {
log.error("Interface {} is already added to the device {}", osNode.get().intgBridge());
return;
}
log.info("Adding interface {} to the device {}..", intfName, osNode.get().intgBridge());
osNodeService.addVfPort(osNode.get(), intfName);
}
use of org.onosproject.openstacknode.api.OpenstackNode in project onos by opennetworkinglab.
the class OpenstackFlowTraceCommand method doExecute.
@Override
protected void doExecute() {
OpenstackNodeAdminService osNodeService = get(OpenstackNodeAdminService.class);
InstancePortAdminService instancePortService = get(InstancePortAdminService.class);
OpenstackNetworkAdminService osNetService = get(OpenstackNetworkAdminService.class);
Optional<InstancePort> srcInstance = instancePortService.instancePorts().stream().filter(port -> port.ipAddress().toString().equals(srcIp)).findAny();
if (!srcInstance.isPresent()) {
print(NO_ELEMENT);
return;
}
OpenstackNode srcNode = osNodeService.node(srcInstance.get().deviceId());
if (srcNode == null || srcNode.sshAuthInfo() == null) {
log.error("Openstack node {} is null or has no SSH authentication information.\n" + " Please refers to the sample network-cfg.json in " + "OpenstackNode app to push SSH authentication information", srcNode == null ? "" : srcNode.hostname());
return;
}
if (dstIp.equals(osNetService.gatewayIp(srcInstance.get().portId()))) {
dstIp = srcIp;
}
// print uplink flow trace result
String requestStringUplink = traceRequestString(srcIp, dstIp, srcInstance.get(), osNetService, true);
print(FLOW_TRACE_REQUEST_STRING_UPLINK + requestStringUplink);
String requestStringDownlink = traceRequestString(srcIp, dstIp, srcInstance.get(), osNetService, false);
print(FLOW_TRACE_REQUEST_STRING_DOWNLINK + requestStringDownlink);
String traceResult = sendTraceRequestToNode(requestStringUplink + '\n' + requestStringDownlink, srcNode);
print(traceResult);
}
Aggregations