Exploring gRPC SouthBound Integration with ONOS: Seeking Guidance and Examples

140 views
Skip to first unread message

Sofiane MESSAOUDI

unread,
May 27, 2024, 11:53:43 AM5/27/24
to ONOS Developers

Hi everyone,

I noticed that there's already a gRPC southbound available for interacting with devices that expose a gRPC interface. However, I couldn't find any examples demonstrating its usage. I have a few questions:

  1. How can we enable the gRPC protocol?
  2. What's the process for connecting a device to ONOS using the gRPC protocol?
  3. How can we retrieve the network topology, links, and other relevant information using gRPC?
  4. Lastly, how do we push a rule to a device using gRPC?

Any guidance or examples you can provide would be greatly appreciated.

Best regards, Sofiane

Davide Scano

unread,
May 28, 2024, 3:51:36 PM5/28/24
to ONOS Developers, Sofiane MESSAOUDI
Hi Sofiane,

You can find some examples here https://github.com/opennetworkinglab/ngsdn-tutorial, this tutorial should give you the answers to your questions. 
Best,
Davide

Sofiane MESSAOUDI

unread,
May 28, 2024, 4:05:13 PM5/28/24
to Davide Scano, ONOS Developers
Hi David;

Thanks for the answer but what im trying to do is not related to p4runtime but grpc protocol ?

Sofiane

Ice

unread,
May 28, 2024, 4:19:00 PM5/28/24
to Sofiane MESSAOUDI, ONOS Developers

Hi Sofiane.

P4Runtime, like gNMI and gNOI, is based on grpc so you can take advantage of this in order to understand how implements your solution.

best

Davide

Sofiane MESSAOUDI

unread,
Aug 16, 2024, 1:30:38 PM8/16/24
to ONOS Developers, Ice, ONOS Developers, Sofiane MESSAOUDI

Hello everyone,

I'm trying to deploy a gRPC application on top of ONOS, but I'm encountering some errors:


########################So here is my pom.xml :##########################
<?xml version="1.0" encoding="UTF-8"?>
<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>
<groupId>org.onosproject</groupId>
<artifactId>onos-dependencies</artifactId>
<version>2.2.2</version>
<relativePath/> <!-- parent is remote -->
</parent>

<artifactId>grpc-rest</artifactId>
<version>1.9.0-SNAPSHOT</version>
<packaging>bundle</packaging>

<name> RPC messages</name>
<description>RPC messages</description>

<properties>
<onos.app.name>org.onosproject.grpcrest</onos.app.name>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<onos.app.url>http://onosproject.org</onos.app.url>
<onos.app.title> RPC messages</onos.app.title>
<web.context>/onos/grpc</web.context>
<onos.version>2.2.2</onos.version>
<grpc.version>1.41.0</grpc.version>
<protobuf.version>3.11.4</protobuf.version>
<java.version>1.8</java.version>
<os.detected.classifier>linux-x86_64</os.detected.classifier> <!-- Adjust this based on your OS -->
<onos.app.requires>
org.onosproject.protocols.grpc
</onos.app.requires>
</properties>

<dependencies>
<!-- ONOS Dependencies -->
<dependency>
<groupId>org.onosproject</groupId>
<artifactId>onos-api</artifactId>
<version>${onos.version}</version>
</dependency>
<dependency>
<groupId>org.onosproject</groupId>
<artifactId>onos-core-serializers</artifactId>
<version>${onos.version}</version>
</dependency>
<dependency>
<groupId>org.onosproject</groupId>
<artifactId>onos-core-common</artifactId>
<version>${onos.version}</version>
</dependency>
<dependency>
<groupId>org.onosproject</groupId>
<artifactId>onos-rest</artifactId>
<version>${onos.version}</version>
</dependency>
<dependency>
<groupId>org.onosproject</groupId>
<artifactId>onlab-osgi</artifactId>
<version>${onos.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.onosproject</groupId>
<artifactId>onlab-misc</artifactId>
<version>${onos.version}</version>
</dependency>

<!-- gRPC dependencies -->
<dependency>
<groupId>io.grpc</groupId>
<artifactId>grpc-netty-shaded</artifactId>
<version>${grpc.version}</version>
</dependency>
<dependency>
<groupId>io.grpc</groupId>
<artifactId>grpc-protobuf</artifactId>
<version>${grpc.version}</version>
</dependency>
<dependency>
<groupId>io.grpc</groupId>
<artifactId>grpc-stub</artifactId>
<version>${grpc.version}</version>
</dependency>

<!-- Protocol Buffers -->
<dependency>
<groupId>com.google.protobuf</groupId>
<artifactId>protobuf-java</artifactId>
<version>${protobuf.version}</version>
</dependency>

<!-- Javax Annotation API -->
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
<version>2.8.8</version>
</dependency>

<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
<version>2.8.8</version>
</dependency>

<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.8.8</version>
</dependency>
<dependency>
<groupId>io.swagger</groupId>
<artifactId>swagger-jersey2-jaxrs</artifactId>
<version>1.5.24</version>
</dependency>

<dependency>
<groupId>javax.ws.rs</groupId>
<artifactId>javax.ws.rs-api</artifactId>
<version>2.0.1</version>
</dependency>

<dependency>
<groupId>org.mortbay.jetty</groupId>
<artifactId>jetty-util</artifactId>
<version>6.1.25</version>
</dependency>

<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.7</version>
</dependency>
<dependency>
<groupId>org.json</groupId>
<artifactId>json</artifactId>
<version>20210307</version>
</dependency>

<!-- Required for OSGi bundle creation -->
<dependency>
<groupId>org.osgi</groupId>
<artifactId>org.osgi.core</artifactId>
<version>6.0.0</version>
</dependency>

<!-- REST API dependencies -->
<dependency>
<groupId>org.glassfish.jersey.media</groupId>
<artifactId>jersey-media-json-jackson</artifactId>
<version>2.7</version>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.media</groupId>
<artifactId>jersey-media-moxy</artifactId>
<version>2.7</version>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.containers</groupId>
<artifactId>jersey-container-servlet</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.onosproject</groupId>
<artifactId>onos-protocols-grpc-api</artifactId>
<version>${onos.version}</version>
</dependency>
</dependencies>

<build>
<extensions>
<extension>
<groupId>org.xolstice.maven.plugins</groupId>
<artifactId>protobuf-maven-plugin</artifactId>
<version>0.6.1</version>
</extension>
</extensions>
<plugins>
<!-- Compiler plugin -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<source>${java.version}</source>
<target>${java.version}</target>
</configuration>
</plugin>

<!-- Protobuf plugin for gRPC code generation -->
<plugin>
<groupId>org.xolstice.maven.plugins</groupId>
<artifactId>protobuf-maven-plugin</artifactId>
<version>0.6.1</version>
<configuration>
<protocArtifact>com.google.protobuf:protoc:${protobuf.version}:exe:${os.detected.classifier}</protocArtifact>
<pluginId>grpc-java</pluginId>
<pluginArtifact>io.grpc:protoc-gen-grpc-java:${grpc.version}:exe:${os.detected.classifier}</pluginArtifact>
</configuration>
<executions>
<execution>
<goals>
<goal>compile</goal>
<goal>compile-custom</goal>
</goals>
</execution>
</executions>
</plugin>

<!-- ONOS Bundle plugin for creating OSGi bundle -->
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<configuration>
<instructions>
<Bundle-RequiredExecutionEnvironment>JavaSE-1.8</Bundle-RequiredExecutionEnvironment>
<Import-Package>
org.glassfish.jersey.servlet,
org.onosproject.*,
*,io.grpc.*;version="[1.41,0)"
com.google.protobuf.*,
javax.annotation.*,
org.osgi.framework;version="[1.8,2)",
*
</Import-Package>
<!-- Web Application Integration -->
<_wab>src/main/webapp/</_wab>
<Include-Resource>
WEB-INF/classes/apidoc/swagger.json=target/swagger.json,
{maven-resources}
</Include-Resource>
<Web-ContextPath>${web.context}</Web-ContextPath>
</instructions>
</configuration>
</plugin>

<!-- ONOS-specific plugin -->
<plugin>
<groupId>org.onosproject</groupId>
<artifactId>onos-maven-plugin</artifactId>
<version>2.2</version>
</plugin>
</plugins>
</build>

</project> 



########################I deployed my application and encountered this error:########################

19:17:44.136 WARN [ApplicationManager] Unable to perform operation on application org.onosproject.grpcrest
org.apache.felix.resolver.reason.ReasonException: Unable to resolve root: missing requirement [root] osgi.identity; osgi.identity=grpc-rest; type=karaf.feature; version="[1.9.0.SNAPSHOT,1.9.0.SNAPSHOT]"; filter:="(&(osgi.identity=grpc-rest)(type=karaf.feature)(version>=1.9.0.SNAPSHOT)(version<=1.9.0.SNAPSHOT))" [caused by: Unable to resolve grpc-rest/1.9.0.SNAPSHOT: missing requirement [grpc-rest/1.9.0.SNAPSHOT] osgi.identity; osgi.identity=org.onosproject.grpc-rest; type=osgi.bundle; version="[1.9.0.SNAPSHOT,1.9.0.SNAPSHOT]"; resolution:=mandatory [caused by: Unable to resolve org.onosproject.grpc-rest/1.9.0.SNAPSHOT: missing requirement [org.onosproject.grpc-rest/1.9.0.SNAPSHOT] osgi.wiring.package; filter:="(&(osgi.wiring.package=com.google.protobuf)(version>=3.11.0)(!(version>=4.0.0)))"]]
at org.apache.felix.resolver.Candidates$MissingRequirementError.toException(Candidates.java:1343) ~[?:?]
at org.apache.felix.resolver.ResolverImpl.doResolve(ResolverImpl.java:392) ~[?:?]
at org.apache.felix.resolver.ResolverImpl.resolve(ResolverImpl.java:378) ~[?:?]
at org.apache.felix.resolver.ResolverImpl.resolve(ResolverImpl.java:332) ~[?:?]
at org.apache.karaf.features.internal.region.SubsystemResolver.resolve(SubsystemResolver.java:257) ~[?:?]
at org.apache.karaf.features.internal.service.Deployer.deploy(Deployer.java:393) ~[?:?]
at org.apache.karaf.features.internal.service.FeaturesServiceImpl.doProvision(FeaturesServiceImpl.java:1062) ~[?:?]
at org.apache.karaf.features.internal.service.FeaturesServiceImpl.lambda$doProvisionInThread$13(FeaturesServiceImpl.java:998) ~[?:?]
at java.util.concurrent.FutureTask.run(FutureTask.java:264) ~[?:?]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) [?:?]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) [?:?]
at java.lang.Thread.run(Thread.java:834) [?:?]
Caused by: org.apache.felix.resolver.reason.ReasonException: Unable to resolve grpc-rest/1.9.0.SNAPSHOT: missing requirement [grpc-rest/1.9.0.SNAPSHOT] osgi.identity; osgi.identity=org.onosproject.grpc-rest; type=osgi.bundle; version="[1.9.0.SNAPSHOT,1.9.0.SNAPSHOT]"; resolution:=mandatory [caused by: Unable to resolve org.onosproject.grpc-rest/1.9.0.SNAPSHOT: missing requirement [org.onosproject.grpc-rest/1.9.0.SNAPSHOT] osgi.wiring.package; filter:="(&(osgi.wiring.package=com.google.protobuf)(version>=3.11.0)(!(version>=4.0.0)))"]
at org.apache.felix.resolver.Candidates$MissingRequirementError.toException(Candidates.java:1343) ~[?:?]
... 12 more
Caused by: org.apache.felix.resolver.reason.ReasonException: Unable to resolve org.onosproject.grpc-rest/1.9.0.SNAPSHOT: missing requirement [org.onosproject.grpc-rest/1.9.0.SNAPSHOT] osgi.wiring.package; filter:="(&(osgi.wiring.package=com.google.protobuf)(version>=3.11.0)(!(version>=4.0.0)))"
at org.apache.felix.resolver.Candidates$MissingRequirementError.toException(Candidates.java:1343) ~[?:?]
at org.apache.felix.resolver.Candidates$MissingRequirementError.toException(Candidates.java:1343) ~[?:?]
... 12 more


########################I resolved it with : ########################

bundle:install mvn:com.google.protobuf/protobuf-java/3.11.4                                                                          bundle:start 216

########################Then i got this error and i'm stuck here:  ########################

19:19:14.674 WARN [ApplicationManager] Unable to perform operation on application org.onosproject.grpcrest
org.apache.felix.resolver.reason.ReasonException: Uses constraint violation. Unable to resolve resource org.onosproject.grpc-rest [org.onosproject.grpc-rest/1.9.0.SNAPSHOT] because it is exposed to package 'com.google.protobuf' from resources com.google.protobuf [com.google.protobuf [247](R 247.0)] and org.onosproject.com_google_protobuf_protobuf_java [org.onosproject.com_google_protobuf_protobuf_java/2.7.0.SNAPSHOT] via two dependency chains.

Chain 1:
  org.onosproject.grpc-rest [org.onosproject.grpc-rest/1.9.0.SNAPSHOT]
    import: (&(osgi.wiring.package=com.google.protobuf)(version>=3.11.0)(!(version>=4.0.0)))
     |
    export: osgi.wiring.package: com.google.protobuf
  com.google.protobuf [com.google.protobuf [247](R 247.0)]

Chain 2:
  org.onosproject.grpc-rest [org.onosproject.grpc-rest/1.9.0.SNAPSHOT]
    import: (osgi.wiring.package=io.grpc.protobuf)
     |
    export: osgi.wiring.package=io.grpc.protobuf; uses:=com.google.protobuf
  org.onosproject.io_grpc_grpc_protobuf [org.onosproject.io_grpc_grpc_protobuf/2.7.0.SNAPSHOT]
    import: (osgi.wiring.package=com.google.protobuf)
     |
    export: osgi.wiring.package: com.google.protobuf
  org.onosproject.com_google_protobuf_protobuf_java [org.onosproject.com_google_protobuf_protobuf_java/2.7.0.SNAPSHOT]
at org.apache.felix.resolver.ResolverImpl$UseConstraintError.toException(ResolverImpl.java:2471) ~[?:?]
at org.apache.felix.resolver.ResolverImpl.doResolve(ResolverImpl.java:420) ~[?:?]
at org.apache.felix.resolver.ResolverImpl.resolve(ResolverImpl.java:378) ~[?:?]
at org.apache.felix.resolver.ResolverImpl.resolve(ResolverImpl.java:332) ~[?:?]
at org.apache.karaf.features.internal.region.SubsystemResolver.resolve(SubsystemResolver.java:257) ~[?:?]
at org.apache.karaf.features.internal.service.Deployer.deploy(Deployer.java:393) ~[?:?]
at org.apache.karaf.features.internal.service.FeaturesServiceImpl.doProvision(FeaturesServiceImpl.java:1062) ~[?:?]
at org.apache.karaf.features.internal.service.FeaturesServiceImpl.lambda$doProvisionInThread$13(FeaturesServiceImpl.java:998) ~[?:?]
at java.util.concurrent.FutureTask.run(FutureTask.java:264) ~[?:?]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) [?:?]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) [?:?]
at java.lang.Thread.run(Thread.java:834) [?:?]
19:19:16.565 INFO [EventAdminConfigurationNotifier] Sending Event Admin notification (configuration successful) to org/ops4j/pax/logging/Configuration










Does anyone have and idea please ???
regards

Sofiane MESSAOUDI

unread,
Aug 26, 2024, 11:16:16 AM8/26/24
to ONOS Developers, Sofiane MESSAOUDI, Ice, ONOS Developers

Hello,

I'm following up on this bug because I'm still struggling with it. Does anyone have any ideas or suggestions, please?

Regards,
Sofiane

Osama Abu Hamdan

unread,
Dec 5, 2024, 9:31:25 AM12/5/24
to ONOS Developers, Sofiane MESSAOUDI, ONOS Developers
Are you wrapping your dependencies to be OSGi compatible?
Reply all
Reply to author
Forward
0 new messages