use of org.onosproject.cluster.ClusterService 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.cluster.ClusterService in project onos by opennetworkinglab.
the class ResetMastershipCommand method doExecute.
@Override
protected void doExecute() {
MastershipAdminService mastershipService = get(MastershipAdminService.class);
ClusterService clusterService = get(ClusterService.class);
DeviceService deviceService = get(DeviceService.class);
if ((isConcentrate && isBalance) || (!isConcentrate && !isBalance)) {
print("Please specify either -b or -c option only");
return;
}
NodeId localId = clusterService.getLocalNode().id();
if (isConcentrate) {
deviceService.getAvailableDevices(Device.Type.SWITCH).forEach(d -> mastershipService.setRole(localId, d.id(), MastershipRole.MASTER));
}
if (isBalance) {
mastershipService.balanceRoles();
}
}
use of org.onosproject.cluster.ClusterService in project onos by opennetworkinglab.
the class FpmConnectionsList method print.
private void print(FpmPeerInfo info) {
ClusterService clusterService = get(ClusterService.class);
info.connections().forEach(cinfo -> print(FORMAT, cinfo.peer().address(), cinfo.peer().port(), cinfo.connectedTo(), Tools.timeAgo(cinfo.connectTime()), cinfo.connectedTo().equals(clusterService.getLocalNode().id()) ? "*" : "", info.routes(), cinfo.isAcceptRoutes()));
}
use of org.onosproject.cluster.ClusterService in project onos by opennetworkinglab.
the class LeaderElectorTestCommand method doExecute.
@Override
protected void doExecute() {
ClusterService clusterService = get(ClusterService.class);
DistributedPrimitivesTest test = get(DistributedPrimitivesTest.class);
leaderElector = test.getLeaderElector(name);
NodeId localNodeId = clusterService.getLocalNode().id();
if ("run".equals(operation)) {
print(leaderElector.run(topic, localNodeId));
} else if ("withdraw".equals(operation)) {
leaderElector.withdraw(topic);
} else if ("show".equals(operation)) {
print(leaderElector.getLeadership(topic));
}
}
use of org.onosproject.cluster.ClusterService in project onos by opennetworkinglab.
the class SimpleVirtualMastershipStore method createFakeClusterService.
/**
* Returns a fake cluster service for a test purpose only.
*
* @return a fake cluster service
*/
private ClusterService createFakeClusterService() {
// just for ease of unit test
final ControllerNode instance = new DefaultControllerNode(new NodeId("local"), IpAddress.valueOf("127.0.0.1"));
ClusterService faceClusterService = new ClusterService() {
private final Instant creationTime = Instant.now();
@Override
public ControllerNode getLocalNode() {
return instance;
}
@Override
public Set<ControllerNode> getNodes() {
return ImmutableSet.of(instance);
}
@Override
public Set<Node> getConsensusNodes() {
return ImmutableSet.of();
}
@Override
public ControllerNode getNode(NodeId nodeId) {
if (instance.id().equals(nodeId)) {
return instance;
}
return null;
}
@Override
public ControllerNode.State getState(NodeId nodeId) {
if (instance.id().equals(nodeId)) {
return ControllerNode.State.ACTIVE;
} else {
return ControllerNode.State.INACTIVE;
}
}
@Override
public Version getVersion(NodeId nodeId) {
if (instance.id().equals(nodeId)) {
return versionService.version();
}
return null;
}
@Override
public Instant getLastUpdatedInstant(NodeId nodeId) {
return creationTime;
}
@Override
public void addListener(ClusterEventListener listener) {
}
@Override
public void removeListener(ClusterEventListener listener) {
}
};
return faceClusterService;
}
Aggregations