Search in sources :

Example 1 with Version

use of org.onosproject.core.Version in project onos by opennetworkinglab.

the class NodesListCommand method doExecute.

@Override
protected void doExecute() {
    ClusterAdminService service = get(ClusterAdminService.class);
    List<ControllerNode> nodes = newArrayList(service.getNodes());
    Collections.sort(nodes, Comparators.NODE_COMPARATOR);
    if (outputJson()) {
        print("%s", json(service, nodes));
    } else {
        ControllerNode self = service.getLocalNode();
        for (ControllerNode node : nodes) {
            String timeAgo = service.localStatus(node.id());
            Version version = service.getVersion(node.id());
            print(FMT, node.id(), node.ip(), node.tcpPort(), service.getState(node.id()), version == null ? "unknown" : version, timeAgo, node.equals(self) ? "*" : "");
        }
    }
}
Also used : Version(org.onosproject.core.Version) ClusterAdminService(org.onosproject.cluster.ClusterAdminService) ControllerNode(org.onosproject.cluster.ControllerNode)

Example 2 with Version

use of org.onosproject.core.Version in project onos by opennetworkinglab.

the class SummaryCommand method doExecute.

@Override
protected void doExecute() {
    IpAddress nodeIp = get(ClusterService.class).getLocalNode().ip();
    Version version = get(CoreService.class).version();
    long numNodes = activeNodes(get(ClusterService.class).getNodes());
    int numDevices = get(DeviceService.class).getDeviceCount();
    int numLinks = get(LinkService.class).getLinkCount();
    int numHosts = get(HostService.class).getHostCount();
    int numScc = get(TopologyService.class).currentTopology().clusterCount();
    int numFlows = get(FlowRuleService.class).getFlowRuleCount();
    long numIntents = get(IntentService.class).getIntentCount();
    String clusterId = get(ClusterMetadataService.class).getClusterMetadata().getName();
    if (outputJson()) {
        print("%s", new ObjectMapper().createObjectNode().put("node", nodeIp.toString()).put("version", version.toString()).put("clusterId", clusterId).put("nodes", numNodes).put("devices", numDevices).put("links", numLinks).put("hosts", numHosts).put("SCC(s)", numScc).put("flows", numFlows).put("intents", numIntents));
    } else {
        print("node=%s, version=%s clusterId=%s", nodeIp, version, clusterId);
        print("nodes=%d, devices=%d, links=%d, hosts=%d, SCC(s)=%s, flows=%d, intents=%d", numNodes, numDevices, numLinks, numHosts, numScc, numFlows, numIntents);
    }
}
Also used : HostService(org.onosproject.net.host.HostService) IntentService(org.onosproject.net.intent.IntentService) Version(org.onosproject.core.Version) DeviceService(org.onosproject.net.device.DeviceService) CoreService(org.onosproject.core.CoreService) IpAddress(org.onlab.packet.IpAddress) FlowRuleService(org.onosproject.net.flow.FlowRuleService) LinkService(org.onosproject.net.link.LinkService) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper)

Example 3 with Version

use of org.onosproject.core.Version in project onos by opennetworkinglab.

the class VersionTest method testToFromInt.

@Test
public void testToFromInt() {
    Version version1;
    Version version2;
    version1 = version("1.2");
    version2 = Version.fromInt(version1.toInt());
    assertEquals(version2, version(1, 2, "0", "0"));
    version1 = version("1.2.foo.bar");
    version2 = Version.fromInt(version1.toInt());
    assertEquals(version2, version(1, 2, "0", "0"));
    version1 = version("1.2.3");
    version2 = Version.fromInt(version1.toInt());
    assertEquals(version2, version(1, 2, "3", "0"));
    version1 = version("1.2.3-SNAPSHOT");
    version2 = Version.fromInt(version1.toInt());
    assertEquals(version2, version(1, 2, "3", "0"));
    version1 = version("255.254.253.252");
    version2 = Version.fromInt(version1.toInt());
    assertEquals(version2, version(255, 254, "253", "252"));
    assertTrue(version("0.0.2").toInt() > version("0.0.1").toInt());
    assertTrue(version("0.1.0").toInt() > version("0.0.1").toInt());
    assertTrue(version("1.0.0").toInt() > version("0.1.0").toInt());
    assertTrue(version("1.1.0").toInt() > version("1.0.1").toInt());
    assertTrue(version("2.1.1").toInt() > version("1.10.10").toInt());
    assertTrue(version("0.1.0-rc2").toInt() > version("0.1.0-rc1").toInt());
}
Also used : Version(org.onosproject.core.Version) Test(org.junit.Test)

Example 4 with Version

use of org.onosproject.core.Version in project onos by opennetworkinglab.

the class VersionTest method minimal.

@Test
public void minimal() {
    Version v = version("1.4");
    assertEquals("wrong major", 1, v.major());
    assertEquals("wrong minor", 4, v.minor());
    assertEquals("wrong patch", null, v.patch());
    assertEquals("wrong build", null, v.build());
}
Also used : Version(org.onosproject.core.Version) Test(org.junit.Test)

Example 5 with Version

use of org.onosproject.core.Version in project onos by opennetworkinglab.

the class VersionTest method fromParts.

@Test
public void fromParts() {
    Version v = version(1, 2, "3", "4321");
    assertEquals("wrong major", 1, v.major());
    assertEquals("wrong minor", 2, v.minor());
    assertEquals("wrong patch", "3", v.patch());
    assertEquals("wrong build", "4321", v.build());
}
Also used : Version(org.onosproject.core.Version) Test(org.junit.Test)

Aggregations

Version (org.onosproject.core.Version)15 Test (org.junit.Test)7 ControllerNode (org.onosproject.cluster.ControllerNode)5 Set (java.util.Set)3 IpAddress (org.onlab.packet.IpAddress)3 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)2 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)2 ImmutableSet (com.google.common.collect.ImmutableSet)2 Maps (com.google.common.collect.Maps)2 Sets (com.google.common.collect.Sets)2 List (java.util.List)2 DefaultControllerNode (org.onosproject.cluster.DefaultControllerNode)2 NodeId (org.onosproject.cluster.NodeId)2 CoreService (org.onosproject.core.CoreService)2 DeviceService (org.onosproject.net.device.DeviceService)2 FlowRuleService (org.onosproject.net.flow.FlowRuleService)2 HostService (org.onosproject.net.host.HostService)2 IntentService (org.onosproject.net.intent.IntentService)2 LinkService (org.onosproject.net.link.LinkService)2 Permission (org.onosproject.security.Permission)2