diff --git a/apps/kafka-integration/core/pom.xml b/apps/kafka-integration/core/pom.xml index 2974fa6053..683e9c7a53 100644 --- a/apps/kafka-integration/core/pom.xml +++ b/apps/kafka-integration/core/pom.xml @@ -66,7 +66,7 @@ org.onosproject - onos-incubator-protobuf + onos-incubator-protobuf-models ${project.version} diff --git a/apps/kafka-integration/core/src/main/java/org/onosproject/kafkaintegration/converter/DeviceEventConverter.java b/apps/kafka-integration/core/src/main/java/org/onosproject/kafkaintegration/converter/DeviceEventConverter.java index 40c6561727..696467b894 100644 --- a/apps/kafka-integration/core/src/main/java/org/onosproject/kafkaintegration/converter/DeviceEventConverter.java +++ b/apps/kafka-integration/core/src/main/java/org/onosproject/kafkaintegration/converter/DeviceEventConverter.java @@ -18,12 +18,12 @@ package org.onosproject.kafkaintegration.converter; import com.google.protobuf.GeneratedMessageV3; import org.onosproject.event.Event; -import org.onosproject.grpc.net.Device.DeviceCore; -import org.onosproject.grpc.net.Device.DeviceType; -import org.onosproject.grpc.net.DeviceEvent.DeviceEventType; -import org.onosproject.grpc.net.DeviceEvent.DeviceNotification; -import org.onosproject.grpc.net.Port.PortCore; -import org.onosproject.grpc.net.Port.PortType; +import org.onosproject.grpc.net.models.DeviceProtoOuterClass.DeviceProto; +import org.onosproject.grpc.net.models.DeviceEnums.DeviceType; +import org.onosproject.grpc.net.models.DeviceEnums.DeviceEventType; +import org.onosproject.grpc.net.models.DeviceEventProto.DeviceNotification; +import org.onosproject.grpc.net.models.PortEnums.PortType; +import org.onosproject.grpc.net.models.PortProtoOuterClass; import org.onosproject.net.device.DeviceEvent; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -42,7 +42,7 @@ public class DeviceEventConverter implements EventConverter { if (!deviceEventTypeSupported(deviceEvent)) { log.error("Unsupported Onos Device Event {}. There is no matching" - + "proto Device Event type", deviceEvent.type().toString()); + + "proto Device Event type", deviceEvent.type().toString()); return null; } @@ -70,8 +70,8 @@ public class DeviceEventConverter implements EventConverter { DeviceNotification.Builder notificationBuilder = DeviceNotification.newBuilder(); - DeviceCore deviceCore = - DeviceCore.newBuilder() + DeviceProto deviceCore = + DeviceProto.newBuilder() .setChassisId(deviceEvent.subject().chassisId().id() .toString()) .setDeviceId(deviceEvent.subject().id().toString()) @@ -83,10 +83,10 @@ public class DeviceEventConverter implements EventConverter { .valueOf(deviceEvent.subject().type().name())) .build(); - PortCore portCore = null; + PortProtoOuterClass.PortProto portProto = null; if (deviceEvent.port() != null) { - portCore = - PortCore.newBuilder() + portProto = + PortProtoOuterClass.PortProto.newBuilder() .setIsEnabled(deviceEvent.port().isEnabled()) .setPortNumber(deviceEvent.port().number() .toString()) @@ -95,7 +95,7 @@ public class DeviceEventConverter implements EventConverter { .valueOf(deviceEvent.port().type().name())) .build(); - notificationBuilder.setPort(portCore); + notificationBuilder.setPort(portProto); } notificationBuilder.setDeviceEventType(getProtoType(deviceEvent)) diff --git a/apps/kafka-integration/core/src/main/java/org/onosproject/kafkaintegration/converter/LinkEventConverter.java b/apps/kafka-integration/core/src/main/java/org/onosproject/kafkaintegration/converter/LinkEventConverter.java index fe18f42649..c8d4bca868 100644 --- a/apps/kafka-integration/core/src/main/java/org/onosproject/kafkaintegration/converter/LinkEventConverter.java +++ b/apps/kafka-integration/core/src/main/java/org/onosproject/kafkaintegration/converter/LinkEventConverter.java @@ -16,12 +16,12 @@ package org.onosproject.kafkaintegration.converter; import org.onosproject.event.Event; -import org.onosproject.grpc.net.Link.ConnectPoint; -import org.onosproject.grpc.net.Link.LinkCore; -import org.onosproject.grpc.net.Link.LinkState; -import org.onosproject.grpc.net.Link.LinkType; -import org.onosproject.grpc.net.LinkEvent.LinkEventType; -import org.onosproject.grpc.net.LinkEvent.LinkNotification; +import org.onosproject.grpc.net.models.ConnectPointProto.ConnectPoint; +import org.onosproject.grpc.net.models.LinkProtoOuterClass.LinkProto; +import org.onosproject.grpc.net.models.LinkEnums.LinkState; +import org.onosproject.grpc.net.models.LinkEnums.LinkType; +import org.onosproject.grpc.net.models.LinkEnums.LinkEventType; +import org.onosproject.grpc.net.models.LinkEventProto.LinkNotification; import org.onosproject.net.link.LinkEvent; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -42,7 +42,7 @@ public class LinkEventConverter implements EventConverter { if (!linkEventTypeSupported(linkEvent)) { log.error("Unsupported Onos Event {}. There is no matching " - + "proto Event type", linkEvent.type().toString()); + + "proto Event type", linkEvent.type().toString()); return null; } @@ -62,20 +62,20 @@ public class LinkEventConverter implements EventConverter { private LinkNotification buildDeviceProtoMessage(LinkEvent linkEvent) { LinkNotification notification = LinkNotification.newBuilder() .setLinkEventType(getProtoType(linkEvent)) - .setLink(LinkCore.newBuilder() - .setState(LinkState - .valueOf(linkEvent.subject().state().name())) - .setType(LinkType.valueOf(linkEvent.subject().type().name())) - .setDst(ConnectPoint.newBuilder() - .setDeviceId(linkEvent.subject().dst() - .deviceId().toString()) - .setPortNumber(linkEvent.subject().dst().port() - .toString())) - .setSrc(ConnectPoint.newBuilder() - .setDeviceId(linkEvent.subject().src() - .deviceId().toString()) - .setPortNumber(linkEvent.subject().src().port() - .toString()))) + .setLink(LinkProto.newBuilder() + .setState(LinkState + .valueOf(linkEvent.subject().state().name())) + .setType(LinkType.valueOf(linkEvent.subject().type().name())) + .setDst(ConnectPoint.newBuilder() + .setDeviceId(linkEvent.subject().dst() + .deviceId().toString()) + .setPortNumber(linkEvent.subject().dst().port() + .toString())) + .setSrc(ConnectPoint.newBuilder() + .setDeviceId(linkEvent.subject().src() + .deviceId().toString()) + .setPortNumber(linkEvent.subject().src().port() + .toString()))) .build(); return notification; diff --git a/bucklets/grpc.bucklet b/bucklets/grpc.bucklet index 276586e13e..6afcea7b86 100644 --- a/bucklets/grpc.bucklet +++ b/bucklets/grpc.bucklet @@ -52,7 +52,7 @@ def fetch_protoc_binary( def fetch_grpc_plugin_binary( grpc_plugin_version = GRPC_PLUGIN_VERSION -): + ): file_name = "protoc-gen-grpc-java-%s-%s.exe" % (grpc_plugin_version, get_system_arch()) if file_name not in GRPC_JAVA_SHA1S: raise Exception('Cannot download %s, architecture not supported' % file_name) @@ -79,10 +79,10 @@ def grpc_jar( name = None, deps = [], #NOTE: if targeting a directory also built with maven this path MUST end in - # /proto because maven plugin interprets imports relative to the proto - # directory and BUCK interprets imports relative to the last directory - # listed in the first listed proto_path which contains the specified - # file + # /proto because maven plugin interprets imports relative to the proto + # directory and BUCK interprets imports relative to the last directory + # listed in the first listed proto_path which contains the specified + # file proto_paths = [], proto_match_patterns = [ "**/proto/**/*.proto" ], protoc_version = PROTOC_VERSION, @@ -112,7 +112,7 @@ def grpc_jar( + '$SRCS', ) - osgi_jar_with_tests( + osgi_jar( name = name, srcs = [ ':' + protoc ], deps = deps + [ ':' + protoc ], diff --git a/features/features.xml b/features/features.xml index 9d89834abd..c9937d2251 100644 --- a/features/features.xml +++ b/features/features.xml @@ -32,6 +32,8 @@ mvn:io.netty/netty-codec/4.1.8.Final mvn:io.netty/netty-transport-native-epoll/4.1.8.Final mvn:io.netty/netty-resolver/4.1.8.Final + mvn:io.netty/netty-codec-http2/4.1.8.Final + mvn:io.netty/netty-codec-http/4.1.8.Final mvn:commons-pool/commons-pool/1.6 mvn:org.apache.commons/commons-math3/3.6.1 diff --git a/incubator/protobuf/BUCK b/incubator/protobuf/BUCK deleted file mode 100644 index 3422455b5a..0000000000 --- a/incubator/protobuf/BUCK +++ /dev/null @@ -1,25 +0,0 @@ - -COMPILE_DEPS = [ - '//lib:CORE_DEPS', - ':onos-incubator-grpc', - '//lib:protobuf-java-3.2.0', -] - -GRPC_DEPS = [ - '//lib:GRPC_1.3', - '//lib:protobuf-java-3.2.0', - '//lib:guava' -] - -grpc_jar( - name = 'onos-incubator-grpc', - deps = GRPC_DEPS, - proto_paths = ["$ONOS_ROOT/incubator/protobuf/src/main/proto"] -) - -osgi_jar_with_tests( - deps = COMPILE_DEPS, - visibility = ['PUBLIC'], -) - - diff --git a/incubator/protobuf/models/BUCK b/incubator/protobuf/models/BUCK new file mode 100644 index 0000000000..6bfac3d92c --- /dev/null +++ b/incubator/protobuf/models/BUCK @@ -0,0 +1,30 @@ + +COMPILE_DEPS = [ + '//lib:CORE_DEPS', + ':onos-incubator-protobuf-models-proto', + '//lib:protobuf-java-3.2.0', + '//lib:GRPC_1.3' +] + +GRPC_DEPS = [ + '//lib:GRPC_1.3', + '//lib:protobuf-java-3.2.0', + '//lib:guava' +] + +BUNDLES = [ + ':onos-incubator-protobuf-models', + ':onos-incubator-protobuf-models-proto', + '//lib:protobuf-java-3.2.0', +] + +grpc_jar( + name = 'onos-incubator-protobuf-models-proto', + deps = GRPC_DEPS, + proto_paths = ["$ONOS_ROOT/incubator/protobuf/models/src/main/proto"] +) + +osgi_jar_with_tests( + deps = COMPILE_DEPS, + visibility = ['PUBLIC'], +) diff --git a/incubator/protobuf/models/pom.xml b/incubator/protobuf/models/pom.xml new file mode 100644 index 0000000000..81521ddd9f --- /dev/null +++ b/incubator/protobuf/models/pom.xml @@ -0,0 +1,102 @@ + + + + 4.0.0 + + onos-incubator-protobuf + org.onosproject + 1.11.0-SNAPSHOT + ../pom.xml + + + onos-incubator-protobuf-models + bundle + + ONOS Protobuf object models and translators + http://onosproject.org + + + org.onosproject.incubator.protobuf.models + ONOS Protocol Buffers models and translators + + + + + + + + org.apache.karaf.tooling + karaf-maven-plugin + 3.0.8 + true + + + + + + + + org.apache.maven.plugins + maven-javadoc-plugin + + ${basedir}/src/main/java/ + org.onosproject.incubator.rpc.grpc + + + + + org.apache.felix + maven-bundle-plugin + true + + + org.onosproject.grpc.net,org.onosproject.incubator.protobuf.models.utils + + + + + + org.apache.maven.plugins + maven-compiler-plugin + + + + org.apache.felix + maven-scr-plugin + + + + org.xolstice.maven.plugins + protobuf-maven-plugin + + + + org.codehaus.mojo + build-helper-maven-plugin + + + + org.onosproject + onos-maven-plugin + + + + + + diff --git a/incubator/protobuf/src/main/java/org/onosproject/incubator/protobuf/net/ProtobufUtils.java b/incubator/protobuf/models/src/main/java/org/onosproject/incubator/protobuf/models/ProtobufUtils.java similarity index 53% rename from incubator/protobuf/src/main/java/org/onosproject/incubator/protobuf/net/ProtobufUtils.java rename to incubator/protobuf/models/src/main/java/org/onosproject/incubator/protobuf/models/ProtobufUtils.java index 30410d6a04..ff29b2788c 100644 --- a/incubator/protobuf/src/main/java/org/onosproject/incubator/protobuf/net/ProtobufUtils.java +++ b/incubator/protobuf/models/src/main/java/org/onosproject/incubator/protobuf/models/ProtobufUtils.java @@ -1,5 +1,5 @@ /* - * Copyright 2016-present Open Networking Laboratory + * Copyright 2017-present Open Networking Laboratory * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -13,15 +13,19 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.onosproject.incubator.protobuf.net; +package org.onosproject.incubator.protobuf.models; import java.net.URI; import java.util.HashMap; import java.util.Map; import org.onlab.packet.ChassisId; -import org.onosproject.grpc.net.Device.DeviceType; -import org.onosproject.grpc.net.Port.PortType; +import org.onosproject.grpc.net.models.DeviceDescriptionProto; +import org.onosproject.grpc.net.models.DeviceEnums; +import org.onosproject.grpc.net.models.PortDescriptionProto; +import org.onosproject.grpc.net.models.PortEnums.PortType; +import org.onosproject.grpc.net.models.DeviceEnums.DeviceType; +import org.onosproject.grpc.net.models.PortStatisticsProto; import org.onosproject.net.Annotations; import org.onosproject.net.DefaultAnnotations; import org.onosproject.net.Device; @@ -41,7 +45,6 @@ import org.slf4j.LoggerFactory; import com.google.common.annotations.Beta; - /** * gRPC message conversion related utilities. */ @@ -56,19 +59,19 @@ public final class ProtobufUtils { * @param role mastership role in gRPC enum * @return equivalent in ONOS enum */ - public static MastershipRole translate(org.onosproject.grpc.net.Device.MastershipRole role) { + public static MastershipRole translate(DeviceEnums.MastershipRole role) { switch (role) { - case NONE: - return MastershipRole.NONE; - case MASTER: - return MastershipRole.MASTER; - case STANDBY: - return MastershipRole.STANDBY; - case UNRECOGNIZED: - log.warn("Unrecognized MastershipRole gRPC message: {}", role); - return MastershipRole.NONE; - default: - return MastershipRole.NONE; + case NONE: + return MastershipRole.NONE; + case MASTER: + return MastershipRole.MASTER; + case STANDBY: + return MastershipRole.STANDBY; + case UNRECOGNIZED: + log.warn("Unrecognized MastershipRole gRPC message: {}", role); + return MastershipRole.NONE; + default: + return MastershipRole.NONE; } } @@ -78,15 +81,15 @@ public final class ProtobufUtils { * @param newRole ONOS' mastership role * @return equivalent in gRPC message enum */ - public static org.onosproject.grpc.net.Device.MastershipRole translate(MastershipRole newRole) { + public static DeviceEnums.MastershipRole translate(MastershipRole newRole) { switch (newRole) { - case MASTER: - return org.onosproject.grpc.net.Device.MastershipRole.MASTER; - case STANDBY: - return org.onosproject.grpc.net.Device.MastershipRole.STANDBY; - case NONE: - default: - return org.onosproject.grpc.net.Device.MastershipRole.NONE; + case MASTER: + return DeviceEnums.MastershipRole.MASTER; + case STANDBY: + return DeviceEnums.MastershipRole.STANDBY; + case NONE: + default: + return DeviceEnums.MastershipRole.NONE; } } @@ -97,7 +100,8 @@ public final class ProtobufUtils { * @param deviceDescription gRPC message * @return {@link DeviceDescription} */ - public static DeviceDescription translate(org.onosproject.grpc.net.Device.DeviceDescription deviceDescription) { + public static DeviceDescription translate( + DeviceDescriptionProto.DeviceDescription deviceDescription) { URI uri = URI.create(deviceDescription.getDeviceUri()); Device.Type type = translate(deviceDescription.getType()); String manufacturer = deviceDescription.getManufacturer(); @@ -119,19 +123,20 @@ public final class ProtobufUtils { * @param deviceDescription {@link DeviceDescription} * @return gRPC DeviceDescription message */ - public static org.onosproject.grpc.net.Device.DeviceDescription translate(DeviceDescription deviceDescription) { + public static DeviceDescriptionProto.DeviceDescription translate( + DeviceDescription deviceDescription) { - return org.onosproject.grpc.net.Device.DeviceDescription.newBuilder() - .setDeviceUri(deviceDescription.deviceUri().toString()) - .setType(translate(deviceDescription.type())) - .setManufacturer(deviceDescription.manufacturer()) - .setHwVersion(deviceDescription.hwVersion()) - .setSwVersion(deviceDescription.swVersion()) - .setSerialNumber(deviceDescription.serialNumber()) - .setChassisId(deviceDescription.chassisId().toString()) - .setIsDefaultAvailable(deviceDescription.isDefaultAvailable()) - .putAllAnnotations(asMap(deviceDescription.annotations())) - .build(); + return DeviceDescriptionProto.DeviceDescription.newBuilder() + .setDeviceUri(deviceDescription.deviceUri().toString()) + .setType(translate(deviceDescription.type())) + .setManufacturer(deviceDescription.manufacturer()) + .setHwVersion(deviceDescription.hwVersion()) + .setSwVersion(deviceDescription.swVersion()) + .setSerialNumber(deviceDescription.serialNumber()) + .setChassisId(deviceDescription.chassisId().toString()) + .setIsDefaultAvailable(deviceDescription.isDefaultAvailable()) + .putAllAnnotations(asMap(deviceDescription.annotations())) + .build(); } @@ -141,41 +146,41 @@ public final class ProtobufUtils { * @param type gRPC message * @return {@link Device.Type} */ - public static Device.Type translate(org.onosproject.grpc.net.Device.DeviceType type) { + public static Device.Type translate(DeviceType type) { switch (type) { - case BALANCER: - return Device.Type.BALANCER; - case CONTROLLER: - return Device.Type.CONTROLLER; - case FIBER_SWITCH: - return Device.Type.FIBER_SWITCH; - case FIREWALL: - return Device.Type.FIREWALL; - case IDS: - return Device.Type.IDS; - case IPS: - return Device.Type.IPS; - case MICROWAVE: - return Device.Type.MICROWAVE; - case OTHER: - return Device.Type.OTHER; - case OTN: - return Device.Type.OTN; - case ROADM: - return Device.Type.ROADM; - case ROADM_OTN: - return Device.Type.ROADM_OTN; - case ROUTER: - return Device.Type.ROUTER; - case SWITCH: - return Device.Type.SWITCH; - case VIRTUAL: - return Device.Type.VIRTUAL; + case BALANCER: + return Device.Type.BALANCER; + case CONTROLLER: + return Device.Type.CONTROLLER; + case FIBER_SWITCH: + return Device.Type.FIBER_SWITCH; + case FIREWALL: + return Device.Type.FIREWALL; + case IDS: + return Device.Type.IDS; + case IPS: + return Device.Type.IPS; + case MICROWAVE: + return Device.Type.MICROWAVE; + case OTHER: + return Device.Type.OTHER; + case OTN: + return Device.Type.OTN; + case ROADM: + return Device.Type.ROADM; + case ROADM_OTN: + return Device.Type.ROADM_OTN; + case ROUTER: + return Device.Type.ROUTER; + case SWITCH: + return Device.Type.SWITCH; + case VIRTUAL: + return Device.Type.VIRTUAL; - case UNRECOGNIZED: - default: - log.warn("Unexpected DeviceType: {}", type); - return Device.Type.OTHER; + case UNRECOGNIZED: + default: + log.warn("Unexpected DeviceType: {}", type); + return Device.Type.OTHER; } } @@ -187,38 +192,38 @@ public final class ProtobufUtils { */ public static DeviceType translate(Device.Type type) { switch (type) { - case BALANCER: - return DeviceType.BALANCER; - case CONTROLLER: - return DeviceType.CONTROLLER; - case FIBER_SWITCH: - return DeviceType.FIBER_SWITCH; - case FIREWALL: - return DeviceType.FIREWALL; - case IDS: - return DeviceType.IDS; - case IPS: - return DeviceType.IPS; - case MICROWAVE: - return DeviceType.MICROWAVE; - case OTHER: - return DeviceType.OTHER; - case OTN: - return DeviceType.OTN; - case ROADM: - return DeviceType.ROADM; - case ROADM_OTN: - return DeviceType.ROADM_OTN; - case ROUTER: - return DeviceType.ROUTER; - case SWITCH: - return DeviceType.SWITCH; - case VIRTUAL: - return DeviceType.VIRTUAL; + case BALANCER: + return DeviceType.BALANCER; + case CONTROLLER: + return DeviceType.CONTROLLER; + case FIBER_SWITCH: + return DeviceType.FIBER_SWITCH; + case FIREWALL: + return DeviceType.FIREWALL; + case IDS: + return DeviceType.IDS; + case IPS: + return DeviceType.IPS; + case MICROWAVE: + return DeviceType.MICROWAVE; + case OTHER: + return DeviceType.OTHER; + case OTN: + return DeviceType.OTN; + case ROADM: + return DeviceType.ROADM; + case ROADM_OTN: + return DeviceType.ROADM_OTN; + case ROUTER: + return DeviceType.ROUTER; + case SWITCH: + return DeviceType.SWITCH; + case VIRTUAL: + return DeviceType.VIRTUAL; - default: - log.warn("Unexpected Device.Type: {}", type); - return DeviceType.OTHER; + default: + log.warn("Unexpected Device.Type: {}", type); + return DeviceType.OTHER; } } @@ -228,13 +233,12 @@ public final class ProtobufUtils { * @param portDescription gRPC message * @return {@link PortDescription} */ - public static PortDescription translate(org.onosproject.grpc.net.Port.PortDescription portDescription) { + public static PortDescription translate(PortDescriptionProto.PortDescription portDescription) { PortNumber number = PortNumber.fromString(portDescription.getPortNumber()); boolean isEnabled = portDescription.getIsEnabled(); Port.Type type = translate(portDescription.getType()); long portSpeed = portDescription.getPortSpeed(); SparseAnnotations annotations = asAnnotations(portDescription.getAnnotationsMap()); - // TODO How to deal with more specific Port... return new DefaultPortDescription(number, isEnabled, type, portSpeed, annotations); } @@ -244,8 +248,8 @@ public final class ProtobufUtils { * @param portDescription {@link PortDescription} * @return gRPC PortDescription message */ - public static org.onosproject.grpc.net.Port.PortDescription translate(PortDescription portDescription) { - return org.onosproject.grpc.net.Port.PortDescription.newBuilder() + public static PortDescriptionProto.PortDescription translate(PortDescription portDescription) { + return PortDescriptionProto.PortDescription.newBuilder() .setPortNumber(portDescription.portNumber().toString()) .setIsEnabled(portDescription.isEnabled()) .setType(translate(portDescription.type())) @@ -260,56 +264,56 @@ public final class ProtobufUtils { * @param type gRPC message * @return {@link Port.Type} */ - public static Port.Type translate(PortType type) { + public static Port.Type translate(org.onosproject.grpc.net.models.PortEnums.PortType type) { switch (type) { - case COPPER: - return Type.COPPER; - case FIBER: - return Type.FIBER; - case OCH: - return Type.OCH; - case ODUCLT: - return Type.ODUCLT; - case OMS: - return Type.OMS; - case PACKET: - return Type.PACKET; - case VIRTUAL: - return Type.VIRTUAL; + case COPPER: + return Type.COPPER; + case FIBER: + return Type.FIBER; + case OCH: + return Type.OCH; + case ODUCLT: + return Type.ODUCLT; + case OMS: + return Type.OMS; + case PACKET: + return Type.PACKET; + case VIRTUAL: + return Type.VIRTUAL; - case UNRECOGNIZED: - default: - log.warn("Unexpected PortType: {}", type); - return Type.COPPER; + case UNRECOGNIZED: + default: + log.warn("Unexpected PortType: {}", type); + return Type.COPPER; } } /** * Translates {@link Port.Type} to gRPC PortType. * - * @param type {@link Port.Type} + * @param type {@link org.onosproject.net.Port.Type} * @return gRPC message */ public static PortType translate(Port.Type type) { switch (type) { - case COPPER: - return PortType.COPPER; - case FIBER: - return PortType.FIBER; - case OCH: - return PortType.OCH; - case ODUCLT: - return PortType.ODUCLT; - case OMS: - return PortType.OMS; - case PACKET: - return PortType.PACKET; - case VIRTUAL: - return PortType.VIRTUAL; + case COPPER: + return PortType.COPPER; + case FIBER: + return PortType.FIBER; + case OCH: + return PortType.OCH; + case ODUCLT: + return PortType.ODUCLT; + case OMS: + return PortType.OMS; + case PACKET: + return PortType.PACKET; + case VIRTUAL: + return PortType.VIRTUAL; - default: - log.warn("Unexpected Port.Type: {}", type); - return PortType.COPPER; + default: + log.warn("Unexpected Port.Type: {}", type); + return PortType.COPPER; } } @@ -319,7 +323,7 @@ public final class ProtobufUtils { * @param portStatistics gRPC PortStatistics message * @return {@link PortStatistics} */ - public static PortStatistics translate(org.onosproject.grpc.net.Port.PortStatistics portStatistics) { + public static PortStatistics translate(PortStatisticsProto.PortStatistics portStatistics) { // TODO implement adding missing fields return DefaultPortStatistics.builder() .setPort(portStatistics.getPort()) @@ -334,9 +338,9 @@ public final class ProtobufUtils { * @param portStatistics {@link PortStatistics} * @return gRPC PortStatistics message */ - public static org.onosproject.grpc.net.Port.PortStatistics translate(PortStatistics portStatistics) { + public static PortStatisticsProto.PortStatistics translate(PortStatistics portStatistics) { // TODO implement adding missing fields - return org.onosproject.grpc.net.Port.PortStatistics.newBuilder() + return PortStatisticsProto.PortStatistics.newBuilder() .setPort(portStatistics.port()) .setPacketsReceived(portStatistics.packetsReceived()) .setPacketsSent(portStatistics.packetsSent()) @@ -356,7 +360,7 @@ public final class ProtobufUtils { } Map map = new HashMap<>(); annotations.keys() - .forEach(k -> map.put(k, annotations.value(k))); + .forEach(k -> map.put(k, annotations.value(k))); return map; } @@ -371,12 +375,12 @@ public final class ProtobufUtils { public static SparseAnnotations asAnnotations(Map annotations) { DefaultAnnotations.Builder builder = DefaultAnnotations.builder(); annotations.entrySet().forEach(e -> { - if (e.getValue() != null) { - builder.set(e.getKey(), e.getValue()); - } else { - builder.remove(e.getKey()); - } - }); + if (e.getValue() != null) { + builder.set(e.getKey(), e.getValue()); + } else { + builder.remove(e.getKey()); + } + }); return builder.build(); } diff --git a/incubator/protobuf/src/main/java/org/onosproject/incubator/protobuf/net/package-info.java b/incubator/protobuf/models/src/main/java/org/onosproject/incubator/protobuf/models/package-info.java similarity index 85% rename from incubator/protobuf/src/main/java/org/onosproject/incubator/protobuf/net/package-info.java rename to incubator/protobuf/models/src/main/java/org/onosproject/incubator/protobuf/models/package-info.java index aa17131817..ee6eb33414 100644 --- a/incubator/protobuf/src/main/java/org/onosproject/incubator/protobuf/net/package-info.java +++ b/incubator/protobuf/models/src/main/java/org/onosproject/incubator/protobuf/models/package-info.java @@ -1,5 +1,5 @@ /* - * Copyright 2016-present Open Networking Laboratory + * Copyright 2017-present Open Networking Laboratory * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,4 +16,4 @@ /** * Utilities to handle ProtoBuf version of ONOS network models. */ -package org.onosproject.incubator.protobuf.net; +package org.onosproject.incubator.protobuf.models; diff --git a/incubator/protobuf/models/src/main/proto/ConnectPointProto.proto b/incubator/protobuf/models/src/main/proto/ConnectPointProto.proto new file mode 100644 index 0000000000..ecc1362b59 --- /dev/null +++ b/incubator/protobuf/models/src/main/proto/ConnectPointProto.proto @@ -0,0 +1,15 @@ +syntax = "proto3"; +option java_package = "org.onosproject.grpc.net.models"; + +package ConnectPoint; + +message ConnectPoint { + oneof element_id { + // DeviceID as String DeviceId#toString + string device_id = 1; + + // TODO add support to other element_id if required + } + // PortNumber as String PortNumber#toString + string port_number = 2; +} \ No newline at end of file diff --git a/incubator/protobuf/models/src/main/proto/DeviceDescriptionProto.proto b/incubator/protobuf/models/src/main/proto/DeviceDescriptionProto.proto new file mode 100644 index 0000000000..b620bfaec8 --- /dev/null +++ b/incubator/protobuf/models/src/main/proto/DeviceDescriptionProto.proto @@ -0,0 +1,18 @@ +syntax = "proto3"; +option java_package = "org.onosproject.grpc.net.models"; + +package Device; + +import "DeviceEnums.proto"; + +message DeviceDescription { + string device_Uri = 1; + Device.DeviceType type = 2; + string manufacturer = 3; + string hw_version = 4; + string sw_version = 5; + string serial_number = 6; + string chassis_id = 7; + map annotations = 8; + bool is_default_available = 9; +} \ No newline at end of file diff --git a/incubator/protobuf/models/src/main/proto/DeviceEnums.proto b/incubator/protobuf/models/src/main/proto/DeviceEnums.proto new file mode 100644 index 0000000000..7fb1f089c4 --- /dev/null +++ b/incubator/protobuf/models/src/main/proto/DeviceEnums.proto @@ -0,0 +1,39 @@ +syntax = "proto3"; +option java_package = "org.onosproject.grpc.net.models"; + +package Device; + +enum MastershipRole { + NONE = 0; + MASTER = 1; + STANDBY = 2; +} + +enum DeviceType { + OTHER = 0; + SWITCH = 1; + ROUTER = 2; + ROADM = 3; + OTN = 4; + ROADM_OTN = 5; + FIREWALL = 6; + BALANCER = 7; + IPS = 8; + IDS = 9; + CONTROLLER = 10; + VIRTUAL = 11; + FIBER_SWITCH = 12; + MICROWAVE = 13; +} + +enum DeviceEventType { + DEVICE_ADDED = 0; + DEVICE_UPDATED = 1; + DEVICE_REMOVED = 2; + DEVICE_SUSPENDED = 3; + DEVICE_AVAILABILITY_CHANGED = 4; + PORT_ADDED = 5; + PORT_UPDATED = 6; + PORT_REMOVED = 7; + PORT_STATS_UPDATED = 8; +} \ No newline at end of file diff --git a/incubator/protobuf/models/src/main/proto/DeviceEventProto.proto b/incubator/protobuf/models/src/main/proto/DeviceEventProto.proto new file mode 100644 index 0000000000..9cbbf605e1 --- /dev/null +++ b/incubator/protobuf/models/src/main/proto/DeviceEventProto.proto @@ -0,0 +1,16 @@ +syntax = "proto3"; +option java_package = "org.onosproject.grpc.net.models"; + + +import "DeviceProto.proto"; +import "DeviceEnums.proto"; +import "PortProto.proto"; + +package Device; + +// Corresponds to org.onosproject.net.device.DeviceEvent. +message DeviceNotification { + Device.DeviceProto device = 1; + Device.DeviceEventType deviceEventType = 2; + Port.PortProto port = 3; +} \ No newline at end of file diff --git a/incubator/protobuf/models/src/main/proto/DeviceProto.proto b/incubator/protobuf/models/src/main/proto/DeviceProto.proto new file mode 100644 index 0000000000..f4a81d19dc --- /dev/null +++ b/incubator/protobuf/models/src/main/proto/DeviceProto.proto @@ -0,0 +1,18 @@ +syntax = "proto3"; +option java_package = "org.onosproject.grpc.net.models"; + +package Device; + +import "DeviceEnums.proto"; + +// Corresponds to org.onosproject.net.Device. +message DeviceProto { + string deviceId = 1; + Device.DeviceType type = 2; + string manufacturer = 3; + string hw_version = 4; + string sw_version = 5; + string serial_number = 6; + string chassis_id = 7; + map annotations = 8; +} diff --git a/incubator/protobuf/models/src/main/proto/LinkDescriptionProto.proto b/incubator/protobuf/models/src/main/proto/LinkDescriptionProto.proto new file mode 100644 index 0000000000..16fe53498a --- /dev/null +++ b/incubator/protobuf/models/src/main/proto/LinkDescriptionProto.proto @@ -0,0 +1,14 @@ +syntax = "proto3"; +option java_package = "org.onosproject.grpc.net.models"; + +package Link; + +import "ConnectPointProto.proto"; +import "LinkEnums.proto"; + +message LinkDescription { + ConnectPoint.ConnectPoint src = 1; + ConnectPoint.ConnectPoint dst = 2; + Link.LinkType type = 3; + map annotations = 4; +} \ No newline at end of file diff --git a/incubator/protobuf/models/src/main/proto/LinkEnums.proto b/incubator/protobuf/models/src/main/proto/LinkEnums.proto new file mode 100644 index 0000000000..fa5f5ac45c --- /dev/null +++ b/incubator/protobuf/models/src/main/proto/LinkEnums.proto @@ -0,0 +1,40 @@ +syntax = "proto3"; +option java_package = "org.onosproject.grpc.net.models"; + +package Link; + +enum LinkType { + // Signifies that this is a direct single-segment link. + DIRECT = 0; + + // Signifies that this link is potentially comprised from multiple + // underlying segments or hops, and as such should be used to tag + // links traversing optical paths, tunnels or intervening 'dark' + // switches. + INDIRECT = 1; + + // Signifies that this link is an edge, i.e. host link. + EDGE = 2; + + // Signifies that this link represents a logical link backed by + // some form of a tunnel, e.g., GRE, MPLS, ODUk, OCH. + TUNNEL = 3; + + // Signifies that this link is realized by fiber (either single channel or WDM). + OPTICAL = 4; + + // Signifies that this link is a virtual link or a pseudo-wire. + VIRTUAL = 5; +} + +enum LinkState { + ACTIVE = 0; + INACTIVE = 1; +} + +// Link Event Types +enum LinkEventType { + LINK_ADDED = 0; + LINK_UPDATED = 1; + LINK_REMOVED = 2; +} diff --git a/incubator/protobuf/models/src/main/proto/LinkEventProto.proto b/incubator/protobuf/models/src/main/proto/LinkEventProto.proto new file mode 100644 index 0000000000..be1ee413d8 --- /dev/null +++ b/incubator/protobuf/models/src/main/proto/LinkEventProto.proto @@ -0,0 +1,13 @@ +syntax = "proto3"; +option java_package = "org.onosproject.grpc.net.models"; + +package Link; + +import "LinkProto.proto"; +import "LinkEnums.proto"; + +// Corresponds to org.onosproject.net.link.LinkEvent. +message LinkNotification { + Link.LinkEventType linkEventType = 2; + Link.LinkProto link = 3; +} \ No newline at end of file diff --git a/incubator/protobuf/models/src/main/proto/LinkProto.proto b/incubator/protobuf/models/src/main/proto/LinkProto.proto new file mode 100644 index 0000000000..23556181b9 --- /dev/null +++ b/incubator/protobuf/models/src/main/proto/LinkProto.proto @@ -0,0 +1,18 @@ +syntax = "proto3"; +option java_package = "org.onosproject.grpc.net.models"; + +package Link; + +import "LinkEnums.proto"; +import "ConnectPointProto.proto"; + +// Corresponds to org.onosproject.net.Link. +message LinkProto { + Link.LinkState state = 1; + ConnectPoint.ConnectPoint src = 2; + ConnectPoint.ConnectPoint dst = 3; + Link.LinkType type = 4; + map annotations = 5; +} + + diff --git a/incubator/protobuf/models/src/main/proto/PortDescriptionProto.proto b/incubator/protobuf/models/src/main/proto/PortDescriptionProto.proto new file mode 100644 index 0000000000..065ef67378 --- /dev/null +++ b/incubator/protobuf/models/src/main/proto/PortDescriptionProto.proto @@ -0,0 +1,15 @@ +syntax = "proto3"; +option java_package = "org.onosproject.grpc.net.models"; + +package Port; + +import "PortEnums.proto"; + +message PortDescription { + // PortNumber as String PortNumber#toString + string port_number = 1; + bool is_enabled = 2; + Port.PortType type = 3; + int64 port_speed = 4; + map annotations = 8; +} \ No newline at end of file diff --git a/incubator/protobuf/models/src/main/proto/PortEnums.proto b/incubator/protobuf/models/src/main/proto/PortEnums.proto new file mode 100644 index 0000000000..b05efc4d13 --- /dev/null +++ b/incubator/protobuf/models/src/main/proto/PortEnums.proto @@ -0,0 +1,23 @@ +syntax = "proto3"; +option java_package = "org.onosproject.grpc.net.models"; + +package Port; + +enum PortType { + // Signifies copper-based connectivity. + COPPER = 0; + // Signifies optical fiber-based connectivity. + FIBER = 1; + // Signifies optical fiber-based packet port. + PACKET = 2; + // Signifies optical fiber-based optical tributary port (called T-port). + //The signal from the client side will be formed into a ITU G.709 (OTN) frame. + ODUCLT = 3; + // Signifies optical fiber-based Line-side port (called L-port). + OCH = 4; + // Signifies optical fiber-based WDM port (called W-port). + //Optical Multiplexing Section (See ITU G.709). + OMS = 5; + // Signifies virtual port. + VIRTUAL = 6; +} \ No newline at end of file diff --git a/incubator/protobuf/models/src/main/proto/PortProto.proto b/incubator/protobuf/models/src/main/proto/PortProto.proto new file mode 100644 index 0000000000..309e50b8fd --- /dev/null +++ b/incubator/protobuf/models/src/main/proto/PortProto.proto @@ -0,0 +1,16 @@ +syntax = "proto3"; +option java_package = "org.onosproject.grpc.net.models"; + +package Port; + +import "PortEnums.proto"; + +// Corresponds to org.onosproject.net.Port. +message PortProto { + string port_number = 1; + bool is_enabled = 2; + Port.PortType type = 3; + int64 port_speed = 4; + map annotations = 5; +} + diff --git a/incubator/protobuf/models/src/main/proto/PortStatisticsProto.proto b/incubator/protobuf/models/src/main/proto/PortStatisticsProto.proto new file mode 100644 index 0000000000..964d47c8a7 --- /dev/null +++ b/incubator/protobuf/models/src/main/proto/PortStatisticsProto.proto @@ -0,0 +1,20 @@ +syntax = "proto3"; +option java_package = "org.onosproject.grpc.net.models"; + +package Port; + +message PortStatistics { + int32 port = 1; + int64 packets_received = 2; + int64 packets_sent = 3; + int64 bytes_received = 4; + int64 bytes_sent = 5; + int64 packets_rx_dropped = 6; + int64 packets_tx_dropped = 7; + int64 packets_rx_errors = 8; + int64 packets_tx_errors = 9; + int64 duration_sec = 10; + int64 duration_nano = 11; + bool is_zero = 12; + // TODO add all other fields +} diff --git a/incubator/protobuf/pom.xml b/incubator/protobuf/pom.xml index 25f36bde13..48c99844a4 100644 --- a/incubator/protobuf/pom.xml +++ b/incubator/protobuf/pom.xml @@ -1,6 +1,6 @@ - - org.apache.maven.plugins - maven-javadoc-plugin - - ${basedir}/src/main/java/ - org.onosproject.incubator.rpc.grpc - - - - - org.apache.felix - maven-bundle-plugin - true - - - org.onosproject.grpc.net,org.onosproject.incubator.protobuf.net - - - - - - org.apache.maven.plugins - maven-compiler-plugin - - - - org.apache.felix - maven-scr-plugin - - - - org.xolstice.maven.plugins - protobuf-maven-plugin - - - - org.codehaus.mojo - build-helper-maven-plugin - - - - org.onosproject - onos-maven-plugin - - - - + + models + services + diff --git a/incubator/protobuf/services/nb/BUCK b/incubator/protobuf/services/nb/BUCK new file mode 100644 index 0000000000..4d9c7898ce --- /dev/null +++ b/incubator/protobuf/services/nb/BUCK @@ -0,0 +1,54 @@ + +COMPILE_DEPS = [ + '//lib:CORE_DEPS', + ':onos-incubator-protobuf-services-nb-proto', + '//incubator/protobuf/models:onos-incubator-protobuf-models-proto', + '//incubator/protobuf/models:onos-incubator-protobuf-models', + '//lib:protobuf-java-3.2.0', + '//lib:GRPC_1.3' +] + +GRPC_DEPS = [ + '//lib:GRPC_1.3', + '//incubator/protobuf/models:onos-incubator-protobuf-models-proto', + '//lib:protobuf-java-3.2.0', + '//lib:guava' +] + +BUNDLES = [ + '//incubator/protobuf/models:onos-incubator-protobuf-models', + '//incubator/protobuf/models:onos-incubator-protobuf-models-proto', + ':onos-incubator-protobuf-services-nb', + ':onos-incubator-protobuf-services-nb-proto', + '//lib:protobuf-java-3.2.0', + '//lib:guava', + '//lib:grpc-core-1.3.0', + '//lib:grpc-protobuf-1.3.0', + '//lib:grpc-stub-1.3.0', + '//lib:grpc-netty-1.3.0', + '//lib:grpc-auth-1.3.0', + '//lib:grpc-context-1.3.0', + '//lib:google-truth-0.28', + '//core/api:onos-api', + '//lib:netty-transport', + '//lib:netty-buffer', + '//lib:netty-resolver', + '//lib:netty-common', + '//lib:netty-codec', + '//lib:netty-handler', + '//lib:netty-codec-http2', + '//lib:netty-codec-http', + "//lib:google-instrumentation-0.3.0", +] + +grpc_jar( + name = 'onos-incubator-protobuf-services-nb-proto', + deps = GRPC_DEPS, + proto_paths = ["$ONOS_ROOT/incubator/protobuf/services/nb/src/main/proto", + "$ONOS_ROOT/incubator/protobuf/models/src/main/proto"] +) + +osgi_jar_with_tests( + deps = COMPILE_DEPS, + visibility = ['PUBLIC'], +) \ No newline at end of file diff --git a/incubator/protobuf/services/nb/pom.xml b/incubator/protobuf/services/nb/pom.xml new file mode 100644 index 0000000000..5e658e8b9c --- /dev/null +++ b/incubator/protobuf/services/nb/pom.xml @@ -0,0 +1,112 @@ + + + + 4.0.0 + + onos-incubator-protobuf-services + org.onosproject + 1.11.0-SNAPSHOT + ../pom.xml + + + onos-incubator-protobuf-services-nb + bundle + + ONOS northbound gRPC services + http://onosproject.org + + + org.onosproject.incubator.protobuf.services.nb + ONOS gRPC Northbound Services + + + + + + org.onosproject + onos-incubator-protobuf-models + ${project.version} + + + + + + + + + + org.apache.karaf.tooling + karaf-maven-plugin + 3.0.8 + true + + + + + + + + org.apache.maven.plugins + maven-javadoc-plugin + + ${basedir}/src/main/java/ + org.onosproject.incubator.rpc.grpc + + + + + org.apache.felix + maven-bundle-plugin + true + + + org.onosproject.grpc.net,org.onosproject.incubator.protobuf.services.nb + + + + + + org.apache.maven.plugins + maven-compiler-plugin + + + + org.apache.felix + maven-scr-plugin + + + + org.xolstice.maven.plugins + protobuf-maven-plugin + + + + org.codehaus.mojo + build-helper-maven-plugin + + + + org.onosproject + onos-maven-plugin + + + + + + diff --git a/incubator/protobuf/services/nb/src/main/java/org/onosproject/incubator/protobuf/services/nb/DeleteMe.java b/incubator/protobuf/services/nb/src/main/java/org/onosproject/incubator/protobuf/services/nb/DeleteMe.java new file mode 100644 index 0000000000..69f61c4c54 --- /dev/null +++ b/incubator/protobuf/services/nb/src/main/java/org/onosproject/incubator/protobuf/services/nb/DeleteMe.java @@ -0,0 +1,26 @@ +/* + * Copyright 2017-present Open Networking Laboratory + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.onosproject.incubator.protobuf.services.nb; + +/** + * Delete this file. It is just a placeholder for structure. + */ +public class DeleteMe { + public DeleteMe() { + throw new RuntimeException("This is not a class that should be instantiated."); + } +} diff --git a/incubator/protobuf/services/nb/src/main/java/org/onosproject/incubator/protobuf/services/nb/package-info.java b/incubator/protobuf/services/nb/src/main/java/org/onosproject/incubator/protobuf/services/nb/package-info.java new file mode 100644 index 0000000000..f3b12c81f1 --- /dev/null +++ b/incubator/protobuf/services/nb/src/main/java/org/onosproject/incubator/protobuf/services/nb/package-info.java @@ -0,0 +1,19 @@ +/* + * Copyright 2017-present Open Networking Laboratory + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/** + * gRPC server implementations for northbound services. + */ +package org.onosproject.incubator.protobuf.services.nb; diff --git a/incubator/protobuf/services/nb/src/main/proto/PlaceHolderToDelete.proto b/incubator/protobuf/services/nb/src/main/proto/PlaceHolderToDelete.proto new file mode 100644 index 0000000000..d1207ddfd9 --- /dev/null +++ b/incubator/protobuf/services/nb/src/main/proto/PlaceHolderToDelete.proto @@ -0,0 +1,6 @@ +syntax="proto3"; +option java_package = "org.onosproject.grpc.net.services.nb"; + +message ToDelete{ + +} \ No newline at end of file diff --git a/incubator/protobuf/services/pom.xml b/incubator/protobuf/services/pom.xml new file mode 100644 index 0000000000..cd83218ca7 --- /dev/null +++ b/incubator/protobuf/services/pom.xml @@ -0,0 +1,80 @@ + + + + 4.0.0 + + onos-incubator-protobuf + org.onosproject + 1.11.0-SNAPSHOT + ../pom.xml + + + onos-incubator-protobuf-services + pom + + + nb + + + + + org.onosproject + onos-incubator-protobuf-models + 1.11.0-SNAPSHOT + + + + org.onosproject + onos-incubator-api + 1.11.0-SNAPSHOT + + + + org.onosproject + onlab-osgi + ${project.version} + + + + org.osgi + org.osgi.core + + + + org.osgi + org.osgi.compendium + + + + junit + junit + test + + + + org.onosproject + onlab-junit + ${project.version} + test + + + + + ONOS ProtoBuf service models and implementations + http://onosproject.org + + diff --git a/incubator/protobuf/src/main/proto/models/Device.proto b/incubator/protobuf/src/main/proto/models/Device.proto deleted file mode 100644 index 75cf0f5616..0000000000 --- a/incubator/protobuf/src/main/proto/models/Device.proto +++ /dev/null @@ -1,51 +0,0 @@ -syntax = "proto3"; -option java_package = "org.onosproject.grpc.net"; - -package Device; - -message DeviceDescription { - string device_Uri = 1; - DeviceType type = 2; - string manufacturer = 3; - string hw_version = 4; - string sw_version = 5; - string serial_number = 6; - string chassis_id = 7; - map annotations = 8; - bool is_default_available = 9; -} - -enum MastershipRole { - NONE = 0; - MASTER = 1; - STANDBY = 2; -} - -enum DeviceType { - OTHER = 0; - SWITCH = 1; - ROUTER = 2; - ROADM = 3; - OTN = 4; - ROADM_OTN = 5; - FIREWALL = 6; - BALANCER = 7; - IPS = 8; - IDS = 9; - CONTROLLER = 10; - VIRTUAL = 11; - FIBER_SWITCH = 12; - MICROWAVE = 13; -} - -// Corresponds to org.onosproject.net.Device. -message DeviceCore { - string deviceId = 1; - DeviceType type = 2; - string manufacturer = 3; - string hw_version = 4; - string sw_version = 5; - string serial_number = 6; - string chassis_id = 7; - map annotations = 8; -} diff --git a/incubator/protobuf/src/main/proto/models/DeviceEvent.proto b/incubator/protobuf/src/main/proto/models/DeviceEvent.proto deleted file mode 100644 index f834aa10c7..0000000000 --- a/incubator/protobuf/src/main/proto/models/DeviceEvent.proto +++ /dev/null @@ -1,28 +0,0 @@ -syntax = "proto3"; -option java_package = "org.onosproject.grpc.net"; - - -import "models/Device.proto"; -import "models/Port.proto"; - -package DeviceEvent; - -// Corresponds to org.onosproject.net.device.DeviceEvent. -message DeviceNotification { - Device.DeviceCore device = 1; - DeviceEventType deviceEventType = 2; - Port.PortCore port = 3; -} - -enum DeviceEventType { - DEVICE_ADDED = 0; - DEVICE_UPDATED = 1; - DEVICE_REMOVED = 2; - DEVICE_SUSPENDED = 3; - DEVICE_AVAILABILITY_CHANGED = 4; - PORT_ADDED = 5; - PORT_UPDATED = 6; - PORT_REMOVED = 7; - PORT_STATS_UPDATED = 8; -} - diff --git a/incubator/protobuf/src/main/proto/models/Link.proto b/incubator/protobuf/src/main/proto/models/Link.proto deleted file mode 100644 index a1ae8ffdbe..0000000000 --- a/incubator/protobuf/src/main/proto/models/Link.proto +++ /dev/null @@ -1,60 +0,0 @@ -syntax = "proto3"; -option java_package = "org.onosproject.grpc.net"; - -package Link; - -enum LinkType { - // Signifies that this is a direct single-segment link. - DIRECT = 0; - - // Signifies that this link is potentially comprised from multiple - // underlying segments or hops, and as such should be used to tag - // links traversing optical paths, tunnels or intervening 'dark' - // switches. - INDIRECT = 1; - - // Signifies that this link is an edge, i.e. host link. - EDGE = 2; - - // Signifies that this link represents a logical link backed by - // some form of a tunnel, e.g., GRE, MPLS, ODUk, OCH. - TUNNEL = 3; - - // Signifies that this link is realized by fiber (either single channel or WDM). - OPTICAL = 4; - - // Signifies that this link is a virtual link or a pseudo-wire. - VIRTUAL = 5; -} - -message ConnectPoint { - oneof element_id { - // DeviceID as String DeviceId#toString - string device_id = 1; - - // TODO add support to other element_id if required - } - // PortNumber as String PortNumber#toString - string port_number = 2; -} - -enum LinkState { - ACTIVE = 0; - INACTIVE = 1; -} - -// Corresponds to org.onosproject.net.Link. -message LinkCore { - LinkState state = 1; - ConnectPoint src = 2; - ConnectPoint dst = 3; - LinkType type = 4; - map annotations = 5; -} - -message LinkDescription { - ConnectPoint src = 1; - ConnectPoint dst = 2; - LinkType type = 3; - map annotations = 4; -} diff --git a/incubator/protobuf/src/main/proto/models/LinkEvent.proto b/incubator/protobuf/src/main/proto/models/LinkEvent.proto deleted file mode 100644 index fcd13fb11f..0000000000 --- a/incubator/protobuf/src/main/proto/models/LinkEvent.proto +++ /dev/null @@ -1,19 +0,0 @@ -syntax = "proto3"; -option java_package = "org.onosproject.grpc.net"; - -package LinkEvent; - -import "models/Link.proto"; - -// Corresponds to org.onosproject.net.link.LinkEvent. -message LinkNotification { - LinkEventType linkEventType = 2; - Link.LinkCore link = 3; -} - -// Link Event Types -enum LinkEventType { - LINK_ADDED = 0; - LINK_UPDATED = 1; - LINK_REMOVED = 2; -} diff --git a/incubator/protobuf/src/main/proto/models/Port.proto b/incubator/protobuf/src/main/proto/models/Port.proto deleted file mode 100644 index a3fd34d8f0..0000000000 --- a/incubator/protobuf/src/main/proto/models/Port.proto +++ /dev/null @@ -1,48 +0,0 @@ -syntax = "proto3"; -option java_package = "org.onosproject.grpc.net"; - -package Port; - -enum PortType { - // Signifies copper-based connectivity. - COPPER = 0; - // Signifies optical fiber-based connectivity. - FIBER = 1; - // Signifies optical fiber-based packet port. - PACKET = 2; - // Signifies optical fiber-based optical tributary port (called T-port). - //The signal from the client side will be formed into a ITU G.709 (OTN) frame. - ODUCLT = 3; - // Signifies optical fiber-based Line-side port (called L-port). - OCH = 4; - // Signifies optical fiber-based WDM port (called W-port). - //Optical Multiplexing Section (See ITU G.709). - OMS = 5; - // Signifies virtual port. - VIRTUAL = 6; -} - -message PortDescription { - // PortNumber as String PortNumber#toString - string port_number = 1; - bool is_enabled = 2; - PortType type = 3; - int64 port_speed = 4; - map annotations = 8; -} - -// Corresponds to org.onosproject.net.Port. -message PortCore { - string port_number = 1; - bool is_enabled = 2; - PortType type = 3; - int64 port_speed = 4; - map annotations = 5; -} - -message PortStatistics { - int32 port = 1; - int64 packets_received = 2; - int64 packets_sent = 3; - // TODO add all other fields -} diff --git a/incubator/rpc-grpc/src/main/java/org/onosproject/incubator/rpc/grpc/DeviceProviderServiceClientProxy.java b/incubator/rpc-grpc/src/main/java/org/onosproject/incubator/rpc/grpc/DeviceProviderServiceClientProxy.java index bd133ad150..4f41835b51 100644 --- a/incubator/rpc-grpc/src/main/java/org/onosproject/incubator/rpc/grpc/DeviceProviderServiceClientProxy.java +++ b/incubator/rpc-grpc/src/main/java/org/onosproject/incubator/rpc/grpc/DeviceProviderServiceClientProxy.java @@ -17,7 +17,7 @@ package org.onosproject.incubator.rpc.grpc; import static com.google.common.base.Preconditions.checkNotNull; import static java.util.stream.Collectors.toList; -import static org.onosproject.incubator.protobuf.net.ProtobufUtils.translate; +import static org.onosproject.incubator.protobuf.models.ProtobufUtils.translate; import static org.onosproject.net.DeviceId.deviceId; import java.util.Collection; @@ -31,7 +31,7 @@ import org.onosproject.grpc.net.device.DeviceService.DeviceProviderServiceMsg; import org.onosproject.grpc.net.device.DeviceService.IsReachableRequest; import org.onosproject.grpc.net.device.DeviceService.RoleChanged; import org.onosproject.grpc.net.device.DeviceService.TriggerProbe; -import org.onosproject.incubator.protobuf.net.ProtobufUtils; +import org.onosproject.incubator.protobuf.models.ProtobufUtils; import org.onosproject.net.DeviceId; import org.onosproject.net.MastershipRole; import org.onosproject.net.device.DeviceDescription; diff --git a/incubator/rpc-grpc/src/main/java/org/onosproject/incubator/rpc/grpc/GrpcRemoteServiceServer.java b/incubator/rpc-grpc/src/main/java/org/onosproject/incubator/rpc/grpc/GrpcRemoteServiceServer.java index 2604d09213..2f5be39f24 100644 --- a/incubator/rpc-grpc/src/main/java/org/onosproject/incubator/rpc/grpc/GrpcRemoteServiceServer.java +++ b/incubator/rpc-grpc/src/main/java/org/onosproject/incubator/rpc/grpc/GrpcRemoteServiceServer.java @@ -18,7 +18,7 @@ package org.onosproject.incubator.rpc.grpc; import static com.google.common.base.Preconditions.checkNotNull; import static java.util.concurrent.Executors.newScheduledThreadPool; import static java.util.stream.Collectors.toList; -import static org.onosproject.incubator.protobuf.net.ProtobufUtils.translate; +import static org.onosproject.incubator.protobuf.models.ProtobufUtils.translate; import static org.onosproject.net.DeviceId.deviceId; import java.io.IOException; @@ -50,7 +50,7 @@ import org.onosproject.grpc.net.device.DeviceService.ReceivedRoleReply; import org.onosproject.grpc.net.device.DeviceService.RegisterProvider; import org.onosproject.grpc.net.device.DeviceService.UpdatePortStatistics; import org.onosproject.grpc.net.device.DeviceService.UpdatePorts; -import org.onosproject.incubator.protobuf.net.ProtobufUtils; +import org.onosproject.incubator.protobuf.models.ProtobufUtils; import org.onosproject.net.DeviceId; import org.onosproject.net.MastershipRole; import org.onosproject.net.PortNumber; diff --git a/incubator/rpc-grpc/src/main/java/org/onosproject/incubator/rpc/grpc/LinkProviderServiceClientProxy.java b/incubator/rpc-grpc/src/main/java/org/onosproject/incubator/rpc/grpc/LinkProviderServiceClientProxy.java index 0a8918ee90..78f9f37d5d 100644 --- a/incubator/rpc-grpc/src/main/java/org/onosproject/incubator/rpc/grpc/LinkProviderServiceClientProxy.java +++ b/incubator/rpc-grpc/src/main/java/org/onosproject/incubator/rpc/grpc/LinkProviderServiceClientProxy.java @@ -15,7 +15,7 @@ */ package org.onosproject.incubator.rpc.grpc; -import static org.onosproject.incubator.protobuf.net.ProtobufUtils.asMap; +import static org.onosproject.incubator.protobuf.models.ProtobufUtils.asMap; import java.util.concurrent.ExecutionException; import java.util.concurrent.TimeUnit; diff --git a/incubator/rpc-grpc/src/main/java/org/onosproject/incubator/rpc/grpc/LinkProviderServiceServerProxy.java b/incubator/rpc-grpc/src/main/java/org/onosproject/incubator/rpc/grpc/LinkProviderServiceServerProxy.java index 26210f637b..69f9cfd23a 100644 --- a/incubator/rpc-grpc/src/main/java/org/onosproject/incubator/rpc/grpc/LinkProviderServiceServerProxy.java +++ b/incubator/rpc-grpc/src/main/java/org/onosproject/incubator/rpc/grpc/LinkProviderServiceServerProxy.java @@ -31,7 +31,7 @@ import org.onosproject.grpc.net.link.LinkProviderServiceRpcGrpc.LinkProviderServ import org.onosproject.grpc.net.link.LinkService.LinkDetectedMsg; import org.onosproject.grpc.net.link.LinkService.LinkVanishedMsg; import org.onosproject.grpc.net.link.LinkService.Void; -import org.onosproject.incubator.protobuf.net.ProtobufUtils; +import org.onosproject.incubator.protobuf.models.ProtobufUtils; import org.onosproject.net.ConnectPoint; import org.onosproject.net.DeviceId; import org.onosproject.net.Link; diff --git a/lib/BUCK b/lib/BUCK index 41d76be5f1..69f5dffdc5 100644 --- a/lib/BUCK +++ b/lib/BUCK @@ -1,4 +1,4 @@ -# ***** This file was auto-generated at Wed, 14 Jun 2017 22:44:38 GMT. Do not edit this file manually. ***** +# ***** This file was auto-generated at Fri, 23 Jun 2017 05:52:13 GMT. Do not edit this file manually. ***** # ***** Use onos-lib-gen ***** pass_thru_pom( @@ -130,6 +130,22 @@ osgi_feature_group( ':grpc-stub-1.3.0', ':grpc-netty-1.3.0', ':grpc-auth-1.3.0', + ':grpc-context-1.3.0', + ':google-truth-0.28', + ], +) + +osgi_feature_group( + name = 'GRPC_TEST_1.3', + visibility = ['PUBLIC'], + exported_deps = [ + ':grpc-testing-1.3.0', + ':grpc-testing-proto-1.3.0', + ':google-code-findbugs-3.0.0', + ':google-errorprone-2.0.19', + ':google-instrumentation-0.3.0', + ':junit-dep', + ':objenesis', ], ) @@ -315,10 +331,10 @@ remote_jar ( remote_jar ( name = 'gson', - out = 'gson-2.6.2.jar', - url = 'mvn:com.google.code.gson:gson:jar:2.6.2', - sha1 = 'f1bc476cc167b18e66c297df599b2377131a8947', - maven_coords = 'com.google.code.gson:gson:2.6.2', + out = 'gson-2.7.jar', + url = 'mvn:com.google.code.gson:gson:jar:2.7', + sha1 = '751f548c85fa49f330cecbb1875893f971b33c4e', + maven_coords = 'com.google.code.gson:gson:2.7', visibility = [ 'PUBLIC' ], ) @@ -682,6 +698,15 @@ remote_jar ( visibility = [ 'PUBLIC' ], ) +remote_jar ( + name = 'junit-dep', + out = 'junit-4.10.jar', + url = 'mvn:junit:junit:jar:4.10', + sha1 = 'e4f1766ce7404a08f45d859fb9c226fc9e41a861', + maven_coords = 'junit:junit:jar:NON-OSGI:4.10', + visibility = [ 'PUBLIC' ], +) + remote_jar ( name = 'kryo', out = 'kryo-4.0.0.jar', @@ -835,6 +860,24 @@ remote_jar ( visibility = [ 'PUBLIC' ], ) +remote_jar ( + name = 'netty-codec-http2', + out = 'netty-codec-http2-4.1.8.Final.jar', + url = 'mvn:io.netty:netty-codec-http2:jar:4.1.8.Final', + sha1 = '105a99ee5767463370ccc3d2e16800bd99f5648e', + maven_coords = 'io.netty:netty-codec-http2:4.1.8.Final', + visibility = [ 'PUBLIC' ], +) + +remote_jar ( + name = 'netty-codec-http', + out = 'netty-codec-http-4.1.8.Final.jar', + url = 'mvn:io.netty:netty-codec-http:jar:4.1.8.Final', + sha1 = '1e88617c4a6c88da7e86fdbbd9494d22a250c879', + maven_coords = 'io.netty:netty-codec-http:4.1.8.Final', + visibility = [ 'PUBLIC' ], +) + remote_jar ( name = 'catalyst-concurrent', out = 'catalyst-concurrent-1.2.1.jar', @@ -1337,3 +1380,66 @@ remote_jar ( visibility = [ 'PUBLIC' ], ) +remote_jar ( + name = 'grpc-testing-1.3.0', + out = 'grpc-testing-1.3.0.jar', + url = 'mvn:io.grpc:grpc-testing:jar:1.3.0', + sha1 = '2828c4bbab639470b9a017f521426490ba919803', + maven_coords = 'io.grpc:grpc-testing:jar:NON-OSGI:1.3.0', + visibility = [ 'PUBLIC' ], +) + +remote_jar ( + name = 'grpc-testing-proto-1.3.0', + out = 'grpc-testing-proto-1.3.0.jar', + url = 'mvn:io.grpc:grpc-testing-proto:jar:1.3.0', + sha1 = '6e707eb79bb892abd22dae80d5799156e614393d', + maven_coords = 'io.grpc:grpc-testing-proto:jar:NON-OSGI:1.3.0', + visibility = [ 'PUBLIC' ], +) + +remote_jar ( + name = 'grpc-context-1.3.0', + out = 'grpc-context-1.3.0.jar', + url = 'mvn:io.grpc:grpc-context:jar:1.3.0', + sha1 = '2a924ad1897dd1b768e1859943e2d0408789150a', + maven_coords = 'io.grpc:grpc-context:jar:NON-OSGI:1.3.0', + visibility = [ 'PUBLIC' ], +) + +remote_jar ( + name = 'google-truth-0.28', + out = 'truth-0.28.jar', + url = 'mvn:com.google.truth:truth:jar:0.28', + sha1 = '0a388c7877c845ff4b8e19689dda5ac9d34622c4', + maven_coords = 'com.google.truth:truth:jar:NON-OSGI:0.28', + visibility = [ 'PUBLIC' ], +) + +remote_jar ( + name = 'google-code-findbugs-3.0.0', + out = 'jsr305-3.0.0.jar', + url = 'mvn:com.google.code.findbugs:jsr305:jar:3.0.0', + sha1 = '5871fb60dc68d67da54a663c3fd636a10a532948', + maven_coords = 'com.google.code.findbugs:jsr305:jar:NON-OSGI:3.0.0', + visibility = [ 'PUBLIC' ], +) + +remote_jar ( + name = 'google-errorprone-2.0.19', + out = 'error_prone_annotations-2.0.19.jar', + url = 'mvn:com.google.errorprone:error_prone_annotations:jar:2.0.19', + sha1 = 'c3754a0bdd545b00ddc26884f9e7624f8b6a14de', + maven_coords = 'com.google.errorprone:error_prone_annotations:jar:NON-OSGI:2.0.19', + visibility = [ 'PUBLIC' ], +) + +remote_jar ( + name = 'google-instrumentation-0.3.0', + out = 'instrumentation-api-0.3.0.jar', + url = 'mvn:com.google.instrumentation:instrumentation-api:jar:0.3.0', + sha1 = 'a2e145e7a7567c6372738f5c5a6f3ba6407ac354', + maven_coords = 'com.google.instrumentation:instrumentation-api:jar:NON-OSGI:0.3.0', + visibility = [ 'PUBLIC' ], +) + diff --git a/lib/deps.json b/lib/deps.json index fdc04e7ee1..f3f3e629c0 100644 --- a/lib/deps.json +++ b/lib/deps.json @@ -93,7 +93,18 @@ "grpc-protobuf-1.3.0", "grpc-stub-1.3.0", "grpc-netty-1.3.0", - "grpc-auth-1.3.0" + "grpc-auth-1.3.0", + "grpc-context-1.3.0", + "google-truth-0.28" + ], + "GRPC_TEST_1.3": [ + "grpc-testing-1.3.0", + "grpc-testing-proto-1.3.0", + "google-code-findbugs-3.0.0", + "google-errorprone-2.0.19", + "google-instrumentation-0.3.0", + "junit-dep", + "objenesis" ] }, @@ -159,6 +170,7 @@ "jsch": "mvn:com.jcraft:jsch:0.1.53", "jsr305": "mvn:com.google.code.findbugs:jsr305:3.0.1", "junit": "mvn:junit:junit:4.12", + "junit-dep": "mvn:junit:junit:4.10", "kryo": "mvn:com.esotericsoftware:kryo:4.0.0", "mapdb": "mvn:org.mapdb:mapdb:1.0.9", "metrics-core": "mvn:io.dropwizard.metrics:metrics-core:3.2.2", @@ -176,6 +188,8 @@ "netty-transport": "mvn:io.netty:netty-transport:4.1.8.Final", "netty-transport-native-epoll": "mvn:io.netty:netty-transport-native-epoll:4.1.8.Final", "netty-resolver": "mvn:io.netty:netty-resolver:4.1.8.Final", + "netty-codec-http2": "mvn:io.netty:netty-codec-http2:4.1.8.Final", + "netty-codec-http": "mvn:io.netty:netty-codec-http:4.1.8.Final", "catalyst-concurrent": "mvn:io.atomix.catalyst:catalyst-concurrent:1.2.1", "catalyst-netty": "mvn:io.atomix.catalyst:catalyst-netty:1.2.1", "catalyst-transport": "mvn:io.atomix.catalyst:catalyst-transport:1.2.1", @@ -235,6 +249,14 @@ "grpc-netty-1.3.0": "mvn:io.grpc:grpc-netty:1.3.0", "grpc-auth-1.3.0": "mvn:io.grpc:grpc-auth:1.3.0", "protobuf-java-3.3.0": "mvn:com.google.protobuf:protobuf-java:3.3.0", - "protobuf-java-3.2.0": "mvn:com.google.protobuf:protobuf-java:3.2.0" + "protobuf-java-3.2.0": "mvn:com.google.protobuf:protobuf-java:3.2.0", + "grpc-testing-1.3.0": "mvn:io.grpc:grpc-testing:1.3.0", + "grpc-testing-proto-1.3.0": "mvn:io.grpc:grpc-testing-proto:1.3.0", + "grpc-context-1.3.0": "mvn:io.grpc:grpc-context:1.3.0", + "google-truth-0.28": "mvn:com.google.truth:truth:0.28", + "google-code-findbugs-3.0.0": "mvn:com.google.code.findbugs:jsr305:3.0.0", + "google-errorprone-2.0.19": "mvn:com.google.errorprone:error_prone_annotations:2.0.19", + "google-instrumentation-0.3.0": "mvn:com.google.instrumentation:instrumentation-api:0.3.0", + "gson": "mvn:com.google.code.gson:gson:2.7" } } diff --git a/modules.defs b/modules.defs index d52b2e412f..ec14130e8c 100644 --- a/modules.defs +++ b/modules.defs @@ -9,7 +9,6 @@ UTILS = [ API = [ '//core/api:onos-api', '//incubator/api:onos-incubator-api', - '//incubator/protobuf:onos-incubator-grpc', ] CORE = UTILS + API + [ @@ -81,6 +80,9 @@ CORE = UTILS + API + [ '//web/api:onos-rest', '//web/gui:onos-gui', + + '//incubator/protobuf/models:onos-incubator-protobuf-models', + '//incubator/protobuf/services/nb:onos-incubator-protobuf-services-nb', ] ONOS_DRIVERS = [