How to create an ONOS app with bazel?

553 views
Skip to first unread message

IRENE VILLA

unread,
Sep 15, 2021, 3:09:07 PM9/15/21
to ONOS Developers
Hi, I am trying to create an onos application with bazel, the onos files compile perfectly but as soon as I introduce the .java files (in the onos folder) that my teachers have provided me to finish creating the application, it does not compile properly, I do not know how to form the BUILD correctly, also I do not know if I have to modify the WORKSPACE. The error I get is the following: ERROR: Skipping '//apps/tutoria:onos-apps-tutoria-native': no such target '//apps/tutoria:onos-apps-tutoria-native': target 'onos-apps-tutoria-native' not declared in package 'apps/tutoria' defined by /home/irene/Escritorio/onos/apps/tutoria/BUILD
WARNING: Target pattern parsing failed.


apps -> is the folder where I have stored all the files
tutoria -> is the folder where I have the .java files that my teachers have provided me with (and the files are correct)


Eder Ollora

unread,
Sep 15, 2021, 3:31:32 PM9/15/21
to ONOS Developers, 206.ire...@gmail.com

Hi!

If you clone ONOS source code and want to build it, you should use Bazel to build it. However, ONOS still supports apps using Maven and you can generate .oar archives to later install and enable in the controller. You can find the steps here.

Else, if you want to add the apps to ONOS source code (which you do not necessarily need to) and build them with Bazel I cannot give you any particular steps. Last time I did it I remember learning from apps already deployed. For instance, you can check the apps folder (as you mentioned) and learn from an already deployed app like fwd. To be a little more specific, you see that fwd has an src folder and BUILD file. Your app should follow the same structure. You have to define which dependencies your app is having, see fwd:

cap.PNG

CORE_DEPS or KRYO include a list of dependencies commonly used (I think). Many of your dependencies might be covered by the link in the previous sentence. You might need to add new ones, depends on your app.

Hope that helps :)

Cheers,

IRENE VILLA

unread,
Sep 17, 2021, 3:51:57 AM9/17/21
to ONOS Developers, Eder Ollora
Thank you very much!

Another question, my project already compiles but it doesn't create any .oar file, do you know why this could be? Because I don't get any error and it compiles and synchronizes without problems.

This is what I get when I compile it in the Bazel console:

Syncing project: Sync (incremental)...
Updating VCS...
Command: bazel info --tool_tag=ijwb:IDEA:ultimate --curses=no --color=yes --progress_in_terminal_title=no --

Running Bazel info...
Command: git diff --name-status --no-renames 78b4d6f3c3060bba748e7b51af615abf796e1e94

Computing VCS working set...
  apps/tutoria/BUILD (added)
  apps/tutoria/src/main/java/org/onosproject/tutoria/AppComponent.java (added)
  apps/tutoria/src/main/java/org/onosproject/tutoria/DHTpacket.java (added)
  apps/tutoria/src/main/java/org/onosproject/tutoria/DHTproviderdevices.java (added)
  apps/tutoria/src/main/java/org/onosproject/tutoria/DHTproviderlink.java (added)
  core/api/src/main/java/org/onosproject/net/device/DefaultPortDescription.java (modified)

Sync targets from project view targets:
  //apps/acl:onos-apps-acl-native
  //apps/acl:onos-apps-acl-tests
  //apps/artemis:onos-apps-artemis-native
  //apps/bgprouter:onos-apps-bgprouter-native
  //apps/castor:onos-apps-castor-native
  //apps/cfm/api:onos-apps-cfm-api-native
  //apps/cfm/api:onos-apps-cfm-api-tests
  //apps/cfm/app:onos-apps-cfm-app-native
  //apps/cfm/app:onos-apps-cfm-app-tests
  //apps/cfm/nbi:onos-apps-cfm-nbi-native
  //apps/cfm/nbi:onos-apps-cfm-nbi-tests
  //apps/config:onos-apps-config-native
  //apps/config:onos-apps-config-tests
  //apps/cord-support:onos-apps-cord-support-native
  //apps/cpman/api:onos-apps-cpman-api-native
  //apps/cpman/api:onos-apps-cpman-api-tests
  //apps/cpman/app:onos-apps-cpman-app-native
  //apps/cpman/app:onos-apps-cpman-app-tests
  //apps/dhcp/api:onos-apps-dhcp-api-native
  //apps/dhcp/api:onos-apps-dhcp-api-tests
  //apps/dhcp/app:onos-apps-dhcp-app-native
  //apps/dhcp/app:onos-apps-dhcp-app-tests
  //apps/dhcprelay/app:onos-apps-dhcprelay-app-native
  //apps/dhcprelay/app:onos-apps-dhcprelay-app-tests
  //apps/dhcprelay/web:onos-apps-dhcprelay-web-native
  //apps/dpistats/api:onos-apps-dpistats-api-native
  //apps/dpistats/app:onos-apps-dpistats-app-native
  //apps/drivermatrix:onos-apps-drivermatrix-native
  //apps/events:onos-apps-events-native
  //apps/faultmanagement/fmcli:onos-apps-faultmanagement-fmcli-native
  //apps/faultmanagement/fmgui:onos-apps-faultmanagement-fmgui-native
  //apps/faultmanagement/fmmgr:onos-apps-faultmanagement-fmmgr-native
  //apps/faultmanagement/fmmgr:onos-apps-faultmanagement-fmmgr-tests
  //apps/faultmanagement/fmweb:onos-apps-faultmanagement-fmweb-native
  //apps/faultmanagement/fmweb:onos-apps-faultmanagement-fmweb-tests
  //apps/flowanalyzer:onos-apps-flowanalyzer-native
  //apps/flowanalyzer:onos-apps-flowanalyzer-tests
  //apps/flowspec-api/flowapi:onos-apps-flowspec-api-flowapi-native
  //apps/fwd:onos-apps-fwd-native
  //apps/gangliametrics:onos-apps-gangliametrics-native
  //apps/gangliametrics:onos-apps-gangliametrics-tests
  //apps/graphitemetrics:onos-apps-graphitemetrics-native
  //apps/graphitemetrics:onos-apps-graphitemetrics-tests
  //apps/imr/api:onos-apps-imr-api-native
  //apps/imr/app:onos-apps-imr-app-native
  //apps/inbandtelemetry/api:onos-apps-inbandtelemetry-api-native
  //apps/inbandtelemetry/app:onos-apps-inbandtelemetry-app-native
  //apps/inbandtelemetry/impl:onos-apps-inbandtelemetry-impl-native
  //apps/inbandtelemetry/impl:onos-apps-inbandtelemetry-impl-tests
  //apps/influxdbmetrics:onos-apps-influxdbmetrics-native

Plus 360 more targets
Building Bazel targets...
Command: bazel build --tool_tag=ijwb:IDEA:ultimate --keep_going --build_event_binary_file=/tmp/intellij-bep-db0043e8-d31f-499b-ba81-ccf4e6ed5fe6 --nobuild_event_binary_file_path_conversion --curses=no --color=yes --progress_in_terminal_title=no --noexperimental_run_validations --aspects=@intellij_aspect//:intellij_info_bundled.bzl%intellij_info_aspect --override_repository=intellij_aspect=/home/irene/.local/share/JetBrains/IntelliJIdea2020.2/ijwb/aspect --output_groups=intellij-info-generic,intellij-info-java,intellij-resolve-java -- //apps/acl:onos-apps-acl-native //apps/acl:onos-apps-acl-tests //apps/artemis:onos-apps-artemis-native //apps/bgprouter:onos-apps-bgprouter-native //apps/castor:onos-apps-castor-native //apps/cfm/api:onos-apps-cfm-api-native //apps/cfm/api:onos-apps-cfm-api-tests //apps/cfm/app:onos-apps-cfm-app-native //apps/cfm/app:onos-apps-cfm-app-tests //apps/cfm/nbi:onos-apps-cfm-nbi-native //apps/cfm/nbi:onos-apps-cfm-nbi-tests //apps/config:onos-apps-config-nati...
Loading:
Loading: 0 packages loaded
Analyzing: 410 targets (14 packages loaded, 0 targets configured)
Analyzing: 410 targets (29 packages loaded, 213 targets configured)
Analyzing: 410 targets (42 packages loaded, 2060 targets configured)
INFO: Analyzed 410 targets (42 packages loaded, 2174 targets configured).

INFO: Found 410 targets...
[0 / 1] [Prepa] BazelWorkspaceStatusAction stable-status.txt
[390 / 406] checking cached actions
INFO: Elapsed time: 31.037s, Critical Path: 5.67s
INFO: 1 process: 1 internal.
INFO: Build completed successfully, 1 total action
INFO: Build completed successfully, 1 total action
INFO: Build Event Protocol files produced successfully.
INFO: Build completed successfully, 1 total action
build invocation result: success
Parsing build outputs...
Total rules: 783, new/changed: 0, removed: 0
Reading IDE info result...
Reading IDE info result...
Updating target map
Loaded 0 aspect files, total size 0kB
Target map size: 783
Prefetching output artifacts...
Reading jdeps files...
Loaded 0 jdeps files, total size 0kB
Reading package manifests...
Java content entry count: 397
Filtering empty jars...
Fetching JARs to track empty status..
[Empty JAR Filter] Calculated empty status of 7 JARs
Filtered 0 JARs, in 18ms
Updating Jar Cache...
Prefetching files...
Refreshing files
Computing directory structure...
Initializing project SDKs...
Committing project structure...
Workspace has 168 libraries
Workspace has 2 modules
Updating in-memory state...
Sync finished

Timing summary:
BlazeInvocation: 31,2s, Prefetching: 1ms, Other: 245ms



Best regards.

Eder Ollora

unread,
Sep 17, 2021, 8:03:55 AM9/17/21
to ONOS Developers, 206.ire...@gmail.com, Eder Ollora
Hi!

So if you build ONOS with your app using Bazel you will never have an .oar package. That file is only created when you create and build your app aside from ONOS, using Maven (not Bazel). Apps built with Bazel that are part of the ONOS code, do not need to be installed or uninstalled, they are already part of the controller.

If the build (bazel build onos) has no errors, you should run ONOS (bazel run onos-local -- clean debug), access ONOS CLI (tools/test/bin/onos localhost) and check if your app is listed at running "apps -s". Remember that your app needs to define its own id so you can identify it in the list of included apps. I think this is the way you define it unless there are other config files that need to include it (which I cannot remember right now). Once you identify that the app is there, you can activate it if you wish (app activate app_name).

Cheers,

IRENE VILLA

unread,
Sep 20, 2021, 2:19:05 PM9/20/21
to ONOS Developers, Eder Ollora, IRENE VILLA
Hello,

Thank you very much for your reply.

Now I have another different problem and it is that when I try to enter a topology in ONOS, the topology is not represented in ONOS, ie if I enter the data of the topology in mininet I do not get any error, the error appears when I want to represent it in ONOS. Do you know why?

I send you the error that appears in the terminal, the .py file that I am executing and the command that I am introducing.

sudo mn --custom topo-2sw-2host.py --topo mytopo --controller remote,ip=127.0.0.1,port=6633 

Cheers,
19.png
topo-2sw-2host.py
Reply all
Reply to author
Forward
0 new messages