Created LinkService and added unit tests.

Change-Id: I1f2104c873e5a9e2df34074d36cddc823e3b3ec5
diff --git a/incubator/protobuf/models/BUCK b/incubator/protobuf/models/BUCK
index 6bfac3d..99619ed 100644
--- a/incubator/protobuf/models/BUCK
+++ b/incubator/protobuf/models/BUCK
@@ -3,13 +3,15 @@
     '//lib:CORE_DEPS',
     ':onos-incubator-protobuf-models-proto',
     '//lib:protobuf-java-3.2.0',
-    '//lib:GRPC_1.3'
+    '//lib:GRPC_1.3',
+    '//incubator/grpc-dependencies:grpc-core-repkg-1.3.0'
 ]
 
 GRPC_DEPS = [
     '//lib:GRPC_1.3',
     '//lib:protobuf-java-3.2.0',
-    '//lib:guava'
+    '//lib:guava',
+    '//incubator/grpc-dependencies:grpc-core-repkg-1.3.0'
 ]
 
 BUNDLES = [
diff --git a/incubator/protobuf/models/src/main/java/org/onosproject/incubator/protobuf/models/GrpcNbDeviceServiceUtil.java b/incubator/protobuf/models/src/main/java/org/onosproject/incubator/protobuf/models/GrpcNbDeviceServiceUtil.java
new file mode 100644
index 0000000..4b84a1a
--- /dev/null
+++ b/incubator/protobuf/models/src/main/java/org/onosproject/incubator/protobuf/models/GrpcNbDeviceServiceUtil.java
@@ -0,0 +1,389 @@
+/*
+ * Copyright 2017-present Open Networking Foundation
+ *
+ * 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 org.onlab.packet.ChassisId;
+import org.onosproject.grpc.net.device.models.DeviceDescriptionProtoOuterClass;
+import org.onosproject.grpc.net.device.models.DeviceDescriptionProtoOuterClass.DeviceDescriptionProto;
+import org.onosproject.grpc.net.device.models.DeviceEnumsProto.DeviceTypeProto;
+import org.onosproject.grpc.net.device.models.DeviceEnumsProto.MastershipRoleProto;
+import org.onosproject.grpc.net.device.models.PortDescriptionProtoOuterClass.PortDescriptionProto;
+import org.onosproject.grpc.net.device.models.PortEnumsProto;
+
+import org.onosproject.grpc.net.device.models.PortStatisticsProtoOuterClass;
+import org.onosproject.grpc.net.device.models.PortStatisticsProtoOuterClass.PortStatisticsProto;
+import org.onosproject.net.Annotations;
+import org.onosproject.net.DefaultAnnotations;
+import org.onosproject.net.Device.Type;
+import org.onosproject.net.MastershipRole;
+import org.onosproject.net.Port;
+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 java.net.URI;
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * gRPC message conversion related utilities for device service.
+ */
+public final class GrpcNbDeviceServiceUtil {
+
+    private static final Logger log = LoggerFactory.getLogger(GrpcNbDeviceServiceUtil.class);
+
+    /**
+     * Translates gRPC enum MastershipRole to ONOS enum.
+     *
+     * @param role mastership role in gRPC enum
+     * @return equivalent in ONOS enum
+     */
+    public static MastershipRole translate(MastershipRoleProto 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 MastershipRoleProto translate(MastershipRole newRole) {
+        switch (newRole) {
+            case MASTER:
+                return MastershipRoleProto.MASTER;
+            case STANDBY:
+                return MastershipRoleProto.STANDBY;
+            case NONE:
+            default:
+                return MastershipRoleProto.NONE;
+        }
+    }
+
+
+    /**
+     * Translates gRPC DeviceDescription to {@link DeviceDescriptionProtoOuterClass}.
+     *
+     * @param deviceDescription gRPC message
+     * @return {@link DeviceDescriptionProtoOuterClass}
+     */
+    public static DeviceDescription translate(
+            DeviceDescriptionProto deviceDescription) {
+        URI uri = URI.create(deviceDescription.getDeviceUri());
+        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 translate(
+            DeviceDescription deviceDescription) {
+
+        return DeviceDescriptionProto.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 Type}.
+     *
+     * @param type      gRPC message
+     * @return  {@link Type}
+     */
+    public static Type translate(DeviceTypeProto type) {
+        switch (type) {
+            case BALANCER:
+                return Type.BALANCER;
+            case CONTROLLER:
+                return Type.CONTROLLER;
+            case FIBER_SWITCH:
+                return Type.FIBER_SWITCH;
+            case FIREWALL:
+                return Type.FIREWALL;
+            case IDS:
+                return Type.IDS;
+            case IPS:
+                return Type.IPS;
+            case MICROWAVE:
+                return Type.MICROWAVE;
+            case OTHER:
+                return Type.OTHER;
+            case OTN:
+                return Type.OTN;
+            case ROADM:
+                return Type.ROADM;
+            case ROADM_OTN:
+                return Type.ROADM_OTN;
+            case ROUTER:
+                return Type.ROUTER;
+            case SWITCH:
+                return Type.SWITCH;
+            case VIRTUAL_DEVICE:
+                return Type.VIRTUAL;
+
+            case UNRECOGNIZED:
+            default:
+                log.warn("Unexpected DeviceType: {}", type);
+                return Type.OTHER;
+        }
+    }
+
+    /**
+     * Translates {@link Type} to gRPC DeviceType.
+     *
+     * @param type {@link Type}
+     * @return  gRPC message
+     */
+    public static DeviceTypeProto translate(Type type) {
+        switch (type) {
+            case BALANCER:
+                return DeviceTypeProto.BALANCER;
+            case CONTROLLER:
+                return DeviceTypeProto.CONTROLLER;
+            case FIBER_SWITCH:
+                return DeviceTypeProto.FIBER_SWITCH;
+            case FIREWALL:
+                return DeviceTypeProto.FIREWALL;
+            case IDS:
+                return DeviceTypeProto.IDS;
+            case IPS:
+                return DeviceTypeProto.IPS;
+            case MICROWAVE:
+                return DeviceTypeProto.MICROWAVE;
+            case OTHER:
+                return DeviceTypeProto.OTHER;
+            case OTN:
+                return DeviceTypeProto.OTN;
+            case ROADM:
+                return DeviceTypeProto.ROADM;
+            case ROADM_OTN:
+                return DeviceTypeProto.ROADM_OTN;
+            case ROUTER:
+                return DeviceTypeProto.ROUTER;
+            case SWITCH:
+                return DeviceTypeProto.SWITCH;
+            case VIRTUAL:
+                return DeviceTypeProto.VIRTUAL_DEVICE;
+
+            default:
+                log.warn("Unexpected Device.Type: {}", type);
+                return DeviceTypeProto.OTHER;
+        }
+    }
+
+    /**
+     * Translates gRPC PortDescription message to {@link PortDescription}.
+     *
+     * @param portDescription gRPC message
+     * @return {@link PortDescription}
+     */
+    public static PortDescription translate(PortDescriptionProto 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);
+    }
+
+    /**
+     * Translates {@link PortDescription} to gRPC PortDescription message.
+     *
+     * @param portDescription {@link PortDescription}
+     * @return gRPC PortDescription message
+     */
+    public static PortDescriptionProto translate(PortDescription portDescription) {
+        return PortDescriptionProto.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(PortEnumsProto.PortTypeProto type) {
+        switch (type) {
+            case COPPER:
+                return Port.Type.COPPER;
+            case FIBER:
+                return Port.Type.FIBER;
+            case OCH:
+                return Port.Type.OCH;
+            case ODUCLT:
+                return Port.Type.ODUCLT;
+            case OMS:
+                return Port.Type.OMS;
+            case PACKET:
+                return Port.Type.PACKET;
+            case VIRTUAL_PORT:
+                return Port.Type.VIRTUAL;
+
+            case UNRECOGNIZED:
+            default:
+                log.warn("Unexpected PortType: {}", type);
+                return Port.Type.COPPER;
+        }
+    }
+
+    /**
+     * Translates {@link Port.Type} to gRPC PortType.
+     *
+     * @param type      {@link Port.Type}
+     * @return  gRPC message
+     */
+    public static PortEnumsProto.PortTypeProto translate(Port.Type type) {
+        switch (type) {
+            case COPPER:
+                return PortEnumsProto.PortTypeProto.COPPER;
+            case FIBER:
+                return PortEnumsProto.PortTypeProto.FIBER;
+            case OCH:
+                return PortEnumsProto.PortTypeProto.OCH;
+            case ODUCLT:
+                return PortEnumsProto.PortTypeProto.ODUCLT;
+            case OMS:
+                return PortEnumsProto.PortTypeProto.OMS;
+            case PACKET:
+                return PortEnumsProto.PortTypeProto.PACKET;
+            case VIRTUAL:
+                return PortEnumsProto.PortTypeProto.VIRTUAL_PORT;
+
+            default:
+                log.warn("Unexpected Port.Type: {}", type);
+                return PortEnumsProto.PortTypeProto.COPPER;
+        }
+    }
+
+    /**
+     * Translates gRPC PortStatistics message to {@link PortStatisticsProtoOuterClass}.
+     *
+     * @param portStatistics gRPC PortStatistics message
+     * @return {@link PortStatisticsProtoOuterClass}
+     */
+    public static PortStatistics translate(PortStatisticsProto 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 translate(PortStatistics portStatistics) {
+        // TODO implement adding missing fields
+        return PortStatisticsProto.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 GrpcNbDeviceServiceUtil() {}
+}
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
index adfa496..14df91c 100644
--- 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
@@ -57,7 +57,7 @@
      * Translates gRPC enum MastershipRoleProto to ONOS enum.
      *
      * @param role mastership role in gRPC enum
-     * @return equivalent in ONOS enum
+     * @return equivalent ONOS enum
      */
     public static MastershipRole translate(MastershipRoleProto role) {
         switch (role) {
@@ -79,7 +79,7 @@
      * Translates ONOS enum MastershipRole to gRPC enum.
      *
      * @param newRole ONOS' mastership role
-     * @return equivalent in gRPC message enum
+     * @return equivalent gRPC message enum
      */
     public static MastershipRoleProto translate(MastershipRole newRole) {
         switch (newRole) {
@@ -93,7 +93,6 @@
         }
     }
 
-
     /**
      * Translates gRPC DeviceDescriptionProto to {@link DeviceDescription}.
      *
@@ -139,7 +138,6 @@
                 .build();
     }
 
-
     /**
      * Translates gRPC DeviceTypeProto to {@link Device.Type}.
      *
diff --git a/incubator/protobuf/models/src/main/java/org/onosproject/incubator/protobuf/models/net/ConnectPointProtoTranslator.java b/incubator/protobuf/models/src/main/java/org/onosproject/incubator/protobuf/models/net/ConnectPointProtoTranslator.java
new file mode 100644
index 0000000..c0177fe
--- /dev/null
+++ b/incubator/protobuf/models/src/main/java/org/onosproject/incubator/protobuf/models/net/ConnectPointProtoTranslator.java
@@ -0,0 +1,94 @@
+/*
+ * Copyright 2017-present Open Networking Foundation
+ *
+ * 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.net;
+
+import org.onlab.packet.IpAddress;
+import org.onosproject.grpc.net.models.ConnectPointProtoOuterClass;
+import org.onosproject.net.ConnectPoint;
+import org.onosproject.net.DeviceId;
+import org.onosproject.net.HostId;
+import org.onosproject.net.IpElementId;
+import org.onosproject.net.PortNumber;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.Optional;
+
+/**
+ * gRPC ConnectPoint message to org.onosproject.net.ConnectPoint conversion related utilities.
+ */
+public final class ConnectPointProtoTranslator {
+
+    private static final Logger log = LoggerFactory.getLogger(ConnectPointProtoTranslator.class);
+
+    /**
+     * Translates gRPC ConnectPoint message to Optional of {@link org.onosproject.net.ConnectPoint}.
+     *
+     * @param connectPoint gRPC message
+     * @return Optional of equivalent {@link org.onosproject.net.ConnectPoint} or empty if ElementId is not recognized
+     */
+    public static Optional<ConnectPoint> translate(ConnectPointProtoOuterClass.ConnectPointProto connectPoint) {
+        switch (connectPoint.getElementIdCase()) {
+            case DEVICE_ID:
+                return Optional.of(new ConnectPoint(DeviceId.deviceId(connectPoint.getDeviceId()),
+                                                    PortNumber.portNumber(connectPoint.getPortNumber())));
+            case HOST_ID:
+                return Optional.of(new ConnectPoint(HostId.hostId(connectPoint.getHostId()),
+                                                    PortNumber.portNumber(connectPoint.getPortNumber())));
+            case IP_ELEMENT_ID:
+                return Optional.of(new ConnectPoint(IpElementId.ipElement(IpAddress
+                                                                                  .valueOf(connectPoint
+                                                                                                   .getIpElementId()
+                                                                                  )),
+                                                    PortNumber.portNumber(connectPoint.getPortNumber())));
+            default:
+                return Optional.empty();
+        }
+    }
+
+    /**
+     * Translates {@link org.onosproject.net.ConnectPoint} to gRPC ConnectPoint message.
+     *
+     * @param connectPoint {@link org.onosproject.net.ConnectPoint}
+     * @return gRPC ConnectPoint message
+     */
+    public static ConnectPointProtoOuterClass.ConnectPointProto translate(ConnectPoint connectPoint) {
+        if (connectPoint.elementId() instanceof DeviceId) {
+            return ConnectPointProtoOuterClass.ConnectPointProto.newBuilder()
+                    .setDeviceId(connectPoint.deviceId().toString())
+                    .setPortNumber(connectPoint.port().toString())
+                    .build();
+        } else if (connectPoint.elementId() instanceof HostId) {
+            return ConnectPointProtoOuterClass.ConnectPointProto.newBuilder()
+                    .setHostId(connectPoint.hostId().toString())
+                    .setPortNumber(connectPoint.port().toString())
+                    .build();
+        } else if (connectPoint.ipElementId() instanceof IpElementId) {
+            return ConnectPointProtoOuterClass.ConnectPointProto.newBuilder()
+                    .setIpElementId(connectPoint.ipElementId().toString())
+                    .setPortNumber(connectPoint.port().toString())
+                    .build();
+        } else {
+            log.warn("Unrecognized ElementId", connectPoint);
+            throw new IllegalArgumentException("Unrecognized ElementId");
+        }
+    }
+
+
+    // Utility class not intended for instantiation.
+    private ConnectPointProtoTranslator() {}
+}
+
diff --git a/incubator/protobuf/models/src/main/java/org/onosproject/incubator/protobuf/models/net/LinkProtoTranslator.java b/incubator/protobuf/models/src/main/java/org/onosproject/incubator/protobuf/models/net/LinkProtoTranslator.java
new file mode 100644
index 0000000..56804c7
--- /dev/null
+++ b/incubator/protobuf/models/src/main/java/org/onosproject/incubator/protobuf/models/net/LinkProtoTranslator.java
@@ -0,0 +1,84 @@
+/*
+ * Copyright 2017-present Open Networking Foundation
+ *
+ * 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.net;
+
+import org.onosproject.grpc.net.models.LinkProtoOuterClass;
+import org.onosproject.incubator.protobuf.models.ProtobufUtils;
+import org.onosproject.incubator.protobuf.models.net.link.LinkEnumsProtoTranslator;
+import org.onosproject.net.Annotations;
+import org.onosproject.net.ConnectPoint;
+import org.onosproject.net.DefaultLink;
+import org.onosproject.net.Link;
+import org.onosproject.net.provider.ProviderId;
+
+/**
+ * gRPC LinkProto message to equivalent ONOS Link conversion related utilities.
+ */
+public final class LinkProtoTranslator {
+
+    /**
+     * Translates gRPC LinkCore message to {@link org.onosproject.net.Link}.
+     *
+     * @param link gRPC message
+     * @return {@link org.onosproject.net.Link} null if link is a default instance
+     */
+    public static Link translate(LinkProtoOuterClass.LinkProto link) {
+        if (link.equals(LinkProtoOuterClass.LinkProto.getDefaultInstance())) {
+            return null;
+        }
+        ProviderId providerId = ProviderIdProtoTranslator.translate(link.getProviderId());
+        Link.State state = LinkEnumsProtoTranslator.translate(link.getState()).get();
+        ConnectPoint src = ConnectPointProtoTranslator.translate(link.getSrc()).get();
+        ConnectPoint dst = ConnectPointProtoTranslator.translate(link.getDst()).get();
+        Link.Type type = LinkEnumsProtoTranslator.translate(link.getType()).get();
+        Annotations annots = ProtobufUtils.asAnnotations(link.getAnnotations());
+        Boolean isExpected = link.getIsExpected();
+        return DefaultLink.builder().state(state)
+                .annotations(annots)
+                .providerId(providerId)
+                .src(src)
+                .dst(dst)
+                .type(type)
+                .isExpected(isExpected)
+                .build();
+    }
+
+
+    /**
+     * Translates {@link org.onosproject.net.Link} to gRPC LinkCore message.
+     *
+     * @param link {@link org.onosproject.net.Link}
+     * @return gRPC LinkCore message
+     */
+    public static LinkProtoOuterClass.LinkProto translate(Link link) {
+        if (link == null) {
+            return LinkProtoOuterClass.LinkProto.getDefaultInstance();
+        }
+        return LinkProtoOuterClass.LinkProto.newBuilder()
+                .setProviderId(ProviderIdProtoTranslator.translate(link.providerId()))
+                .setState(LinkEnumsProtoTranslator.translate(link.state()))
+                .setSrc(ConnectPointProtoTranslator.translate(link.src()))
+                .setDst(ConnectPointProtoTranslator.translate(link.dst()))
+                .setType(LinkEnumsProtoTranslator.translate(link.type()))
+                .setIsExpected(link.isExpected())
+                .build();
+    }
+
+    // Utility class not intended for instantiation.
+    private LinkProtoTranslator() {}
+
+}
+
diff --git a/incubator/protobuf/models/src/main/java/org/onosproject/incubator/protobuf/models/net/ProviderIdProtoTranslator.java b/incubator/protobuf/models/src/main/java/org/onosproject/incubator/protobuf/models/net/ProviderIdProtoTranslator.java
new file mode 100644
index 0000000..8ee4fe5
--- /dev/null
+++ b/incubator/protobuf/models/src/main/java/org/onosproject/incubator/protobuf/models/net/ProviderIdProtoTranslator.java
@@ -0,0 +1,61 @@
+/*
+ * Copyright 2017-present Open Networking Foundation
+ *
+ * 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.net;
+
+import org.onosproject.grpc.net.models.ProviderIdProtoOuterClass;
+import org.onosproject.net.provider.ProviderId;
+
+/**
+ * gRPC ProviderId message to org.onosproject.net.provider.ProviderId conversion related utilities.
+ */
+public final class ProviderIdProtoTranslator {
+
+    /**
+     * Translates gRPC ProviderId message to {@link org.onosproject.net.provider.ProviderId}.
+     *
+     * @param providerId gRPC ProviderId message
+     * @return {@link org.onosproject.net.provider.ProviderId} or null if providerId is a default instance
+     */
+    public static ProviderId translate(ProviderIdProtoOuterClass.ProviderIdProto providerId) {
+        if (providerId.equals(ProviderIdProtoOuterClass.ProviderIdProto.getDefaultInstance())) {
+            return null;
+        }
+        return new ProviderId(providerId.getScheme(), providerId.getId(), providerId.getAncillary());
+    }
+
+    /**
+     * Translates {@link org.onosproject.net.provider.ProviderId} to gRPC ProviderId message.
+     *
+     * @param providerId {@link org.onosproject.net.provider.ProviderId}
+     * @return gRPC ProviderId message
+     */
+    public static ProviderIdProtoOuterClass.ProviderIdProto translate(ProviderId providerId) {
+        if (providerId == null) {
+            return ProviderIdProtoOuterClass.ProviderIdProto.getDefaultInstance();
+        }
+        return ProviderIdProtoOuterClass.ProviderIdProto.newBuilder()
+                .setScheme(providerId.scheme())
+                .setId(providerId.id())
+                .setAncillary(providerId.isAncillary())
+                .build();
+    }
+
+
+    // Utility class not intended for instantiation.
+    private ProviderIdProtoTranslator() {}
+
+}
+
diff --git a/incubator/protobuf/models/src/main/java/org/onosproject/incubator/protobuf/models/net/link/LinkEnumsProtoTranslator.java b/incubator/protobuf/models/src/main/java/org/onosproject/incubator/protobuf/models/net/link/LinkEnumsProtoTranslator.java
new file mode 100644
index 0000000..bc87984
--- /dev/null
+++ b/incubator/protobuf/models/src/main/java/org/onosproject/incubator/protobuf/models/net/link/LinkEnumsProtoTranslator.java
@@ -0,0 +1,125 @@
+/*
+ * Copyright 2017-present Open Networking Foundation
+ *
+ * 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.net.link;
+
+import org.onosproject.grpc.net.link.models.LinkEnumsProto;
+import org.onosproject.net.Link;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.Optional;
+
+/**
+ * gRPC LinkType and LinkState message to equivalent ONOS enum conversion related utilities.
+ */
+public final class LinkEnumsProtoTranslator {
+
+    private static final Logger log = LoggerFactory.getLogger(LinkEnumsProtoTranslator.class);
+
+    /**
+     * Translates gRPC enum LinkType to Optional of ONOS enum.
+     *
+     * @param type linktype type in gRPC enum
+     * @return Optional of equivalent ONOS enum or empty if not recognized
+     */
+    public static Optional<Link.Type> translate(LinkEnumsProto.LinkTypeProto type) {
+        switch (type) {
+            case DIRECT:
+                return Optional.of(Link.Type.DIRECT);
+            case INDIRECT:
+                return Optional.of(Link.Type.INDIRECT);
+            case EDGE:
+                return Optional.of(Link.Type.EDGE);
+            case TUNNEL:
+                return Optional.of(Link.Type.TUNNEL);
+            case OPTICAL:
+                return Optional.of(Link.Type.OPTICAL);
+            case VIRTUAL:
+                return Optional.of(Link.Type.VIRTUAL);
+            default:
+                log.warn("Unrecognized Type gRPC message: {}", type);
+                return Optional.empty();
+        }
+    }
+
+    /**
+     * Translates ONOS enum Type to gRPC enum.
+     *
+     * @param type ONOS' Type type
+     * @return equivalent gRPC message enum
+     */
+    public static LinkEnumsProto.LinkTypeProto translate(Link.Type type) {
+        switch (type) {
+            case DIRECT:
+                return LinkEnumsProto.LinkTypeProto.DIRECT;
+            case INDIRECT:
+                return LinkEnumsProto.LinkTypeProto.INDIRECT;
+            case EDGE:
+                return LinkEnumsProto.LinkTypeProto.EDGE;
+            case TUNNEL:
+                return LinkEnumsProto.LinkTypeProto.TUNNEL;
+            case OPTICAL:
+                return LinkEnumsProto.LinkTypeProto.OPTICAL;
+            case VIRTUAL:
+                return LinkEnumsProto.LinkTypeProto.VIRTUAL;
+            default:
+                log.warn("Unrecognized type", type);
+                throw new IllegalArgumentException("Unrecognized Type");
+        }
+    }
+
+    /**
+     * Translates gRPC enum LinkState to Optional of ONOS enum.
+     *
+     * @param state linkstate state in gRPC enum
+     * @return Optional of equivalent ONOS enum or empty if not recognized
+     */
+    public static Optional<Link.State> translate(LinkEnumsProto.LinkStateProto state) {
+        switch (state) {
+            case ACTIVE:
+                return Optional.of(Link.State.ACTIVE);
+            case INACTIVE:
+                return Optional.of(Link.State.INACTIVE);
+            default:
+                log.warn("Unrecognized State gRPC message: {}", state);
+                return Optional.empty();
+        }
+    }
+
+    /**
+     * Translates ONOS enum State to gRPC enum.
+     *
+     * @param state ONOS' state state
+     * @return equivalent gRPC message enum
+     */
+    public static LinkEnumsProto.LinkStateProto translate(Link.State state) {
+        switch (state) {
+            case ACTIVE:
+                return LinkEnumsProto.LinkStateProto.ACTIVE;
+            case INACTIVE:
+                return LinkEnumsProto.LinkStateProto.INACTIVE;
+            default:
+                log.warn("Unrecognized State", state);
+                throw new IllegalArgumentException("Unrecognized State");
+        }
+    }
+
+
+    // Utility class not intended for instantiation.
+    private LinkEnumsProtoTranslator() {}
+
+}
+
diff --git a/incubator/protobuf/models/src/main/java/org/onosproject/incubator/protobuf/models/net/link/package-info.java b/incubator/protobuf/models/src/main/java/org/onosproject/incubator/protobuf/models/net/link/package-info.java
new file mode 100644
index 0000000..1392669
--- /dev/null
+++ b/incubator/protobuf/models/src/main/java/org/onosproject/incubator/protobuf/models/net/link/package-info.java
@@ -0,0 +1,19 @@
+/*
+ * Copyright 2017-present Open Networking Foundation
+ *
+ * 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 link models.
+ */
+package org.onosproject.incubator.protobuf.models.net.link;
diff --git a/incubator/protobuf/models/src/main/java/org/onosproject/incubator/protobuf/models/net/package-info.java b/incubator/protobuf/models/src/main/java/org/onosproject/incubator/protobuf/models/net/package-info.java
new file mode 100644
index 0000000..e393681
--- /dev/null
+++ b/incubator/protobuf/models/src/main/java/org/onosproject/incubator/protobuf/models/net/package-info.java
@@ -0,0 +1,19 @@
+/*
+ * Copyright 2017-present Open Networking Foundation
+ *
+ * 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.net;
diff --git a/incubator/protobuf/models/src/main/proto/net/ConnectPointProto.proto b/incubator/protobuf/models/src/main/proto/net/ConnectPointProto.proto
index 3749b6f..e0444b4 100644
--- a/incubator/protobuf/models/src/main/proto/net/ConnectPointProto.proto
+++ b/incubator/protobuf/models/src/main/proto/net/ConnectPointProto.proto
@@ -7,8 +7,8 @@
     oneof element_id {
         // DeviceID as String DeviceId#toString
         string device_id = 1;
-
-        // TODO add support to other element_id if required
+        string host_id = 3;
+        string ip_element_id = 4;
     }
     // PortNumber as String PortNumber#toString
     string port_number = 2;
diff --git a/incubator/protobuf/models/src/main/proto/net/LinkProto.proto b/incubator/protobuf/models/src/main/proto/net/LinkProto.proto
index 77bb32b..9b41dc4 100644
--- a/incubator/protobuf/models/src/main/proto/net/LinkProto.proto
+++ b/incubator/protobuf/models/src/main/proto/net/LinkProto.proto
@@ -5,6 +5,7 @@
 
 import "net/link/LinkEnumsProto.proto";
 import "net/ConnectPointProto.proto";
+import "net/ProviderIdProto.proto";
 
 // Corresponds to org.onosproject.net.Link.
 message LinkProto {
@@ -13,6 +14,6 @@
     net.ConnectPointProto dst = 3;
     net.link.LinkTypeProto type = 4;
     map<string, string> annotations = 5;
-}
-
-
+    net.ProviderIdProto provider_id = 6;
+    bool isExpected = 7;
+}
\ No newline at end of file
diff --git a/incubator/protobuf/models/src/main/proto/net/ProviderIdProto.proto b/incubator/protobuf/models/src/main/proto/net/ProviderIdProto.proto
new file mode 100644
index 0000000..3e470c7
--- /dev/null
+++ b/incubator/protobuf/models/src/main/proto/net/ProviderIdProto.proto
@@ -0,0 +1,11 @@
+syntax = "proto3";
+option java_package = "org.onosproject.grpc.net.models";
+
+package net;
+
+// Corresponds to org.onosproject.net.provider.ProviderId
+message ProviderIdProto {
+    string scheme = 1;
+    string id = 2;
+    bool ancillary = 3;
+}
\ No newline at end of file