use of org.onosproject.openstacknetworking.api.InstancePort 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))));
}
}
Aggregations