Refactoring file structure for protobufs.
Change-Id: I50daf100d54750f97158304d87813e67861b1422
diff --git a/incubator/protobuf/models/BUCK b/incubator/protobuf/models/BUCK
new file mode 100644
index 0000000..6bfac3d
--- /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 0000000..81521dd
--- /dev/null
+++ b/incubator/protobuf/models/pom.xml
@@ -0,0 +1,102 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ 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.
+ -->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <artifactId>onos-incubator-protobuf</artifactId>
+ <groupId>org.onosproject</groupId>
+ <version>1.11.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>onos-incubator-protobuf-models</artifactId>
+ <packaging>bundle</packaging>
+
+ <description>ONOS Protobuf object models and translators</description>
+ <url>http://onosproject.org</url>
+
+ <properties>
+ <onos.app.name>org.onosproject.incubator.protobuf.models</onos.app.name>
+ <onos.app.title>ONOS Protocol Buffers models and translators</onos.app.title>
+ </properties>
+
+ <build>
+
+ <pluginManagement>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.karaf.tooling</groupId>
+ <artifactId>karaf-maven-plugin</artifactId>
+ <version>3.0.8</version>
+ <extensions>true</extensions>
+ </plugin>
+ </plugins>
+ </pluginManagement>
+
+ <plugins>
+ <!-- TODO This is included to suppress the generation of javadocs for
+ this package. There is a problem when we try to package the
+ auto-generated code's javadoc into a jar. -->
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-javadoc-plugin</artifactId>
+ <configuration>
+ <sourcepath>${basedir}/src/main/java/</sourcepath>
+ <excludePackageNames>org.onosproject.incubator.rpc.grpc</excludePackageNames>
+ </configuration>
+ </plugin>
+
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-bundle-plugin</artifactId>
+ <extensions>true</extensions>
+ <configuration>
+ <instructions>
+ <Export-Package>org.onosproject.grpc.net,org.onosproject.incubator.protobuf.models.utils</Export-Package>
+ </instructions>
+ </configuration>
+ </plugin>
+
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ </plugin>
+
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-scr-plugin</artifactId>
+ </plugin>
+
+ <plugin>
+ <groupId>org.xolstice.maven.plugins</groupId>
+ <artifactId>protobuf-maven-plugin</artifactId>
+ </plugin>
+
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>build-helper-maven-plugin</artifactId>
+ </plugin>
+
+ <plugin>
+ <groupId>org.onosproject</groupId>
+ <artifactId>onos-maven-plugin</artifactId>
+ </plugin>
+
+ </plugins>
+ </build>
+
+</project>
diff --git a/incubator/protobuf/models/src/main/java/org/onosproject/incubator/protobuf/models/ProtobufUtils.java b/incubator/protobuf/models/src/main/java/org/onosproject/incubator/protobuf/models/ProtobufUtils.java
new file mode 100644
index 0000000..ff29b27
--- /dev/null
+++ b/incubator/protobuf/models/src/main/java/org/onosproject/incubator/protobuf/models/ProtobufUtils.java
@@ -0,0 +1,389 @@
+/*
+ * 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.models;
+
+import java.net.URI;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.onlab.packet.ChassisId;
+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;
+import org.onosproject.net.MastershipRole;
+import org.onosproject.net.Port;
+import org.onosproject.net.Port.Type;
+import org.onosproject.net.PortNumber;
+import org.onosproject.net.SparseAnnotations;
+import org.onosproject.net.device.DefaultDeviceDescription;
+import org.onosproject.net.device.DefaultPortDescription;
+import org.onosproject.net.device.DefaultPortStatistics;
+import org.onosproject.net.device.DeviceDescription;
+import org.onosproject.net.device.PortDescription;
+import org.onosproject.net.device.PortStatistics;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.google.common.annotations.Beta;
+
+/**
+ * gRPC message conversion related utilities.
+ */
+@Beta
+public final class ProtobufUtils {
+
+ private static final Logger log = LoggerFactory.getLogger(ProtobufUtils.class);
+
+ /**
+ * Translates gRPC enum MastershipRole to ONOS enum.
+ *
+ * @param role mastership role in gRPC enum
+ * @return equivalent in ONOS enum
+ */
+ 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;
+ }
+ }
+
+ /**
+ * Translates ONOS enum MastershipRole to gRPC enum.
+ *
+ * @param newRole ONOS' mastership role
+ * @return equivalent in gRPC message enum
+ */
+ public static DeviceEnums.MastershipRole translate(MastershipRole newRole) {
+ switch (newRole) {
+ case MASTER:
+ return DeviceEnums.MastershipRole.MASTER;
+ case STANDBY:
+ return DeviceEnums.MastershipRole.STANDBY;
+ case NONE:
+ default:
+ return DeviceEnums.MastershipRole.NONE;
+ }
+ }
+
+
+ /**
+ * Translates gRPC DeviceDescription to {@link DeviceDescription}.
+ *
+ * @param deviceDescription gRPC message
+ * @return {@link DeviceDescription}
+ */
+ public static DeviceDescription translate(
+ DeviceDescriptionProto.DeviceDescription deviceDescription) {
+ URI uri = URI.create(deviceDescription.getDeviceUri());
+ Device.Type type = translate(deviceDescription.getType());
+ String manufacturer = deviceDescription.getManufacturer();
+ String hwVersion = deviceDescription.getHwVersion();
+ String swVersion = deviceDescription.getSwVersion();
+ String serialNumber = deviceDescription.getSerialNumber();
+ ChassisId chassis = new ChassisId(deviceDescription.getChassisId());
+ boolean defaultAvailable = deviceDescription.getIsDefaultAvailable();
+ return new DefaultDeviceDescription(uri, type, manufacturer,
+ hwVersion, swVersion, serialNumber,
+ chassis,
+ defaultAvailable,
+ asAnnotations(deviceDescription.getAnnotationsMap()));
+ }
+
+ /**
+ * Translates {@link DeviceDescription} to gRPC DeviceDescription message.
+ *
+ * @param deviceDescription {@link DeviceDescription}
+ * @return gRPC DeviceDescription message
+ */
+ public static DeviceDescriptionProto.DeviceDescription translate(
+ DeviceDescription deviceDescription) {
+
+ 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();
+ }
+
+
+ /**
+ * Translates gRPC DeviceType to {@link Device.Type}.
+ *
+ * @param type gRPC message
+ * @return {@link Device.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 UNRECOGNIZED:
+ default:
+ log.warn("Unexpected DeviceType: {}", type);
+ return Device.Type.OTHER;
+ }
+ }
+
+ /**
+ * Translates {@link Type} to gRPC DeviceType.
+ *
+ * @param type {@link Type}
+ * @return gRPC message
+ */
+ 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;
+
+ default:
+ log.warn("Unexpected Device.Type: {}", type);
+ return DeviceType.OTHER;
+ }
+ }
+
+ /**
+ * Translates gRPC PortDescription message to {@link PortDescription}.
+ *
+ * @param portDescription gRPC message
+ * @return {@link 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());
+ return new DefaultPortDescription(number, isEnabled, type, portSpeed, annotations);
+ }
+
+ /**
+ * Translates {@link PortDescription} to gRPC PortDescription message.
+ *
+ * @param portDescription {@link PortDescription}
+ * @return gRPC PortDescription message
+ */
+ public static PortDescriptionProto.PortDescription translate(PortDescription portDescription) {
+ return PortDescriptionProto.PortDescription.newBuilder()
+ .setPortNumber(portDescription.portNumber().toString())
+ .setIsEnabled(portDescription.isEnabled())
+ .setType(translate(portDescription.type()))
+ .setPortSpeed(portDescription.portSpeed())
+ .putAllAnnotations(asMap(portDescription.annotations()))
+ .build();
+ }
+
+ /**
+ * Translates gRPC PortType to {@link Port.Type}.
+ *
+ * @param type gRPC message
+ * @return {@link Port.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 UNRECOGNIZED:
+ default:
+ log.warn("Unexpected PortType: {}", type);
+ return Type.COPPER;
+ }
+ }
+
+ /**
+ * Translates {@link Port.Type} to gRPC PortType.
+ *
+ * @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;
+
+ default:
+ log.warn("Unexpected Port.Type: {}", type);
+ return PortType.COPPER;
+ }
+ }
+
+ /**
+ * Translates gRPC PortStatistics message to {@link PortStatistics}.
+ *
+ * @param portStatistics gRPC PortStatistics message
+ * @return {@link PortStatistics}
+ */
+ public static PortStatistics translate(PortStatisticsProto.PortStatistics portStatistics) {
+ // TODO implement adding missing fields
+ return DefaultPortStatistics.builder()
+ .setPort(portStatistics.getPort())
+ .setPacketsReceived(portStatistics.getPacketsReceived())
+ .setPacketsSent(portStatistics.getPacketsSent())
+ .build();
+ }
+
+ /**
+ * Translates {@link PortStatistics} to gRPC PortStatistics message.
+ *
+ * @param portStatistics {@link PortStatistics}
+ * @return gRPC PortStatistics message
+ */
+ public static PortStatisticsProto.PortStatistics translate(PortStatistics portStatistics) {
+ // TODO implement adding missing fields
+ return PortStatisticsProto.PortStatistics.newBuilder()
+ .setPort(portStatistics.port())
+ .setPacketsReceived(portStatistics.packetsReceived())
+ .setPacketsSent(portStatistics.packetsSent())
+ .build();
+ }
+
+ // may be this can be moved to Annotation itself or AnnotationsUtils
+ /**
+ * Converts Annotations to Map of Strings.
+ *
+ * @param annotations {@link Annotations}
+ * @return Map of annotation key and values
+ */
+ public static Map<String, String> asMap(Annotations annotations) {
+ if (annotations instanceof DefaultAnnotations) {
+ return ((DefaultAnnotations) annotations).asMap();
+ }
+ Map<String, String> map = new HashMap<>();
+ annotations.keys()
+ .forEach(k -> map.put(k, annotations.value(k)));
+
+ return map;
+ }
+
+ // may be this can be moved to Annotation itself or AnnotationsUtils
+ /**
+ * Converts Map of Strings to {@link SparseAnnotations}.
+ *
+ * @param annotations Map of annotation key and values
+ * @return {@link SparseAnnotations}
+ */
+ public static SparseAnnotations asAnnotations(Map<String, String> 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());
+ }
+ });
+ return builder.build();
+ }
+
+ // Utility class not intended for instantiation.
+ private ProtobufUtils() {}
+}
diff --git a/incubator/protobuf/models/src/main/java/org/onosproject/incubator/protobuf/models/package-info.java b/incubator/protobuf/models/src/main/java/org/onosproject/incubator/protobuf/models/package-info.java
new file mode 100644
index 0000000..ee6eb33
--- /dev/null
+++ b/incubator/protobuf/models/src/main/java/org/onosproject/incubator/protobuf/models/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.
+ */
+/**
+ * Utilities to handle ProtoBuf version of ONOS network models.
+ */
+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 0000000..ecc1362
--- /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 0000000..b620bfa
--- /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<string, string> 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 0000000..7fb1f08
--- /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 0000000..9cbbf60
--- /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 0000000..f4a81d1
--- /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<string, string> 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 0000000..16fe534
--- /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<string, string> 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 0000000..fa5f5ac
--- /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 0000000..be1ee41
--- /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 0000000..2355618
--- /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<string, string> 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 0000000..065ef67
--- /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<string, string> 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 0000000..b05efc4
--- /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 0000000..309e50b
--- /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<string, string> 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 0000000..964d47c
--- /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
+}