Search in sources :

Example 11 with Version

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

the class VersionTest method snapshot.

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

Example 12 with Version

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

the class VersionTest method shortNumber.

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

Example 13 with Version

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

the class ApplicationArchive method loadAppDescription.

private ApplicationDescription loadAppDescription(XMLConfiguration cfg) {
    String name = cfg.getString(NAME);
    Version version = Version.version(cfg.getString(VERSION));
    String origin = cfg.getString(ORIGIN);
    String title = cfg.getString(TITLE);
    // FIXME: title should be set as attribute to APP, but fallback for now...
    title = title == null ? name : title;
    String category = cfg.getString(CATEGORY, UTILITY);
    String url = cfg.getString(URL);
    byte[] icon = getApplicationIcon(name);
    ApplicationRole role = getRole(cfg.getString(ROLE));
    Set<Permission> perms = getPermissions(cfg);
    String featRepo = cfg.getString(FEATURES_REPO);
    URI featuresRepo = featRepo != null ? URI.create(featRepo) : null;
    List<String> features = ImmutableList.copyOf(cfg.getString(FEATURES).split(","));
    String apps = cfg.getString(APPS, "");
    List<String> requiredApps = apps.isEmpty() ? ImmutableList.of() : ImmutableList.copyOf(apps.split(","));
    // put full description to readme field
    String readme = cfg.getString(DESCRIPTION);
    // put short description to description field
    String desc = compactDescription(readme);
    return DefaultApplicationDescription.builder().withName(name).withVersion(version).withTitle(title).withDescription(desc).withOrigin(origin).withCategory(category).withUrl(url).withReadme(readme).withIcon(icon).withRole(role).withPermissions(perms).withFeaturesRepo(featuresRepo).withFeatures(features).withRequiredApps(requiredApps).build();
}
Also used : Version(org.onosproject.core.Version) Permission(org.onosproject.security.Permission) AppPermission(org.onosproject.security.AppPermission) ApplicationRole(org.onosproject.core.ApplicationRole) URI(java.net.URI)

Example 14 with Version

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

the class NodesListCommand method json.

// Produces JSON structure.
private JsonNode json(ClusterAdminService service, List<ControllerNode> nodes) {
    ObjectMapper mapper = new ObjectMapper();
    ArrayNode result = mapper.createArrayNode();
    ControllerNode self = service.getLocalNode();
    for (ControllerNode node : nodes) {
        ControllerNode.State nodeState = service.getState(node.id());
        Version nodeVersion = service.getVersion(node.id());
        IpAddress nodeIp = node.ip();
        ObjectNode newNode = mapper.createObjectNode().put("id", node.id().toString()).put("ip", nodeIp != null ? nodeIp.toString() : node.host()).put("tcpPort", node.tcpPort()).put("self", node.equals(self));
        if (nodeState != null) {
            newNode.put("state", nodeState.toString());
        }
        if (nodeVersion != null) {
            newNode.put("version", nodeVersion.toString());
        }
        result.add(newNode);
    }
    return result;
}
Also used : ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) Version(org.onosproject.core.Version) ControllerNode(org.onosproject.cluster.ControllerNode) IpAddress(org.onlab.packet.IpAddress) ArrayNode(com.fasterxml.jackson.databind.node.ArrayNode) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper)

Example 15 with Version

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

the class ConsistentMapTestCommand method doExecute.

@Override
protected void doExecute() {
    StorageService storageService = get(StorageService.class);
    map = storageService.<String, String>consistentMapBuilder().withName(name).withSerializer(Serializer.using(KryoNamespaces.BASIC)).withVersion(Version.version("1.0.0")).withCompatibilityFunction((value, version) -> version + ":" + value).build();
    if ("get".equals(operation)) {
        print(map.get(arg1));
    } else if ("put".equals(operation)) {
        print(map.put(arg1, arg2));
    } else if ("size".equals(operation)) {
        print("%d", map.size());
    } else if ("isEmpty".equals(operation)) {
        print("%b", map.isEmpty());
    } else if ("putIfAbsent".equals(operation)) {
        print(map.putIfAbsent(arg1, arg2));
    } else if ("putAndGet".equals(operation)) {
        print(map.putAndGet(arg1, arg2));
    } else if ("clear".equals(operation)) {
        map.clear();
    } else if ("remove".equals(operation)) {
        if (arg2 == null) {
            print(map.remove(arg1));
        } else {
            print("%b", map.remove(arg1, arg2));
        }
    } else if ("containsKey".equals(operation)) {
        print("%b", map.containsKey(arg1));
    } else if ("containsValue".equals(operation)) {
        print("%b", map.containsValue(arg1));
    } else if ("replace".equals(operation)) {
        if (arg3 == null) {
            print(map.replace(arg1, arg2));
        } else {
            print("%b", map.replace(arg1, arg2, arg3));
        }
    } else if ("compatiblePut".equals(operation)) {
        ConsistentMap<String, String> map = storageService.<String, String>consistentMapBuilder().withName(name).withSerializer(Serializer.using(KryoNamespaces.BASIC)).withCompatibilityFunction((value, version) -> version + ":" + value).withVersion(Version.version("2.0.0")).build();
        print(map.put(arg1, arg2));
    } else if ("compatibleGet".equals(operation)) {
        ConsistentMap<String, String> map = storageService.<String, String>consistentMapBuilder().withName(name).withSerializer(Serializer.using(KryoNamespaces.BASIC)).withCompatibilityFunction((value, version) -> version + ":" + value).withVersion(Version.version("2.0.0")).build();
        print(map.get(arg1));
    }
}
Also used : ConsistentMap(org.onosproject.store.service.ConsistentMap) AbstractShellCommand(org.onosproject.cli.AbstractShellCommand) Serializer(org.onosproject.store.service.Serializer) Versioned(org.onosproject.store.service.Versioned) StorageService(org.onosproject.store.service.StorageService) Service(org.apache.karaf.shell.api.action.lifecycle.Service) Version(org.onosproject.core.Version) Argument(org.apache.karaf.shell.api.action.Argument) KryoNamespaces(org.onosproject.store.serializers.KryoNamespaces) Command(org.apache.karaf.shell.api.action.Command) ConsistentMap(org.onosproject.store.service.ConsistentMap) StorageService(org.onosproject.store.service.StorageService)

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