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());
}
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());
}
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();
}
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;
}
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));
}
}
Aggregations