How to create yang buck apps?

422 views
Skip to first unread message

Naoki

unread,
Jun 13, 2017, 7:58:24 AM6/13/17
to ONOS Developers
Hi all,

I'm following the Yang Compiler document here https://wiki.onosproject.org/display/ONOS/YANG+Compiler#YANGCompiler-YangBuckPlugin:

I couldn't find out how to create new buck-base applications in ONOS. Are there any documents or tutorials about it? (I succeeded to create the Maven-base applications.)

Thanks,

BHARAT SARASWAL

unread,
Jun 13, 2017, 8:32:33 AM6/13/17
to Naoki, ONOS Developers
Hi Naoki,

You can refer to l3vpn app in ONOS_ROOT/apps/l3vpn

Regards,
Bharat


--
You received this message because you are subscribed to the Google Groups "ONOS Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to onos-dev+unsubscribe@onosproject.org.
To post to this group, send email to onos...@onosproject.org.
Visit this group at https://groups.google.com/a/onosproject.org/group/onos-dev/.
To view this discussion on the web visit https://groups.google.com/a/onosproject.org/d/msgid/onos-dev/f1784814-0176-41ad-b88c-e134e896188b%40onosproject.org.

Janani Baskaran

unread,
Jun 13, 2017, 8:32:37 AM6/13/17
to Naoki, ONOS Developers
Hi,

To create YANG app with BUCK, you can refer '/home/root1/onos/models/l3vpn' where L3VPN YANG files are kept and are used by L3VPN app in '/home/root1/onos/apps/l3vpn'.

Please let me know if any more queries you have.

Thanks & Regards,

Janani B

Marc De Leenheer

unread,
Jun 13, 2017, 1:34:36 PM6/13/17
to Janani Baskaran, Naoki, ONOS Developers
You can also take a look at onos/apps/openroadm. The actual models are under onos/models/openroadm


Hope this helps,

marc

Naoki

unread,
Jun 14, 2017, 2:16:59 AM6/14/17
to ONOS Developers, jananisv...@gmail.com, naoki.m...@gmail.com
Hi Bharat, Janani and Marc

Thanks a lot for your replies. I succeeded to build l3vpn and openroadm apps by buck built-in ONOS. But I failed to build a new app I added. It seems that my new app isn't built. Do I have to register my app somewhere to compile and build?

1. I added a new app named 'yang-sample'

ubuntu@miyata:~/onos/apps/yang-sample$ pwd
/home/ubuntu/onos/apps/yang-sample

2. There are some YANG files in the src/main/yang directory

ubuntu@miyata:~/onos/apps/yang-sample$ find .
.
./src
./src/main
./src/main/yang
./src/main/yang/ietf-yang-types.yang
./src/main/yang/ietf-inet-types.yang
...(some YANG files)...
./src/main/java
./src/main/java/org
./src/main/java/org/onosproject
./src/main/java/org/onosproject/yang
./src/test
./src/test/java
./.buckd
...
./BUCK
./pom.xml

3. I copied BUCK file from the YANG Compiler document and referred to BUCK files in l3vpn and openroadm.

ubuntu@miyata:~/onos/apps/yang-sample$ cat BUCK
COMPILE_DEPS = [
'//lib:CORE_DEPS',
'//lib:onos-yang-model',
]

TEST_DEPS = [
]

yang_osgi_jar(
deps = COMPILE_DEPS,
name = 'onos-apps-yang',
srcs = glob(['src/main/**/*.yang']),
visibility = [
'PUBLIC'
],
)

osgi_jar_with_tests(
deps = COMPILE_DEPS,
test_deps = TEST_DEPS,
)

onos_app(
app_name = 'org.onosproject.yang-sample',
title = 'YANG SampleApp',
category = 'YANG',
url = 'http://onosproject.org',
description = 'YANG Sample Application',
required_apps = APPS,
)


4. use buck to build

ubuntu@miyata:~/onos/apps/yang-sample$ ../../bin/buck build onos
Waiting for Watchman query [[query, /home/ubuntu/onos, {since=n:buckd149c3c92-bacf-4b03-95d7-2dc4c1f5b8ee, expression=[not, [anyof, [type, d], [dirname, .idea], [dirname, .buckd], [dirname, buck-out/cache], [dirname, .git], [dirname, buck-out/.trash], [dirname, buck-out], [match, **/*.pbxproj, wholename, {includedotfiles=true}], [match, **/*.xcscheme, wholename, {includedotfiles=true}], [match, **/*.xcworkspacedata, wholename, {includedotfiles=true}], [match, **/*~, wholename, {includedotfiles=true}], [match, **/#*#, wholename, {includedotfiles=true}], [match, **/.#*, wholename, {includedotfiles=true}], [match, **/*.swo, wholename, {includedotfiles=true}], [match, **/*.swp, wholename, {includedotfiles=true}], [match, **/*.swpx, wholename, {includedotfiles=true}], [match, **/*.un~, wholename, {includedotfiles=true}], [match, **/.netrhwist, wholename, {includedotfiles=true}], [match, .idea, wholename, {includedotfiles=true}], [match, .iml, wholename, {includedotfiles=true}], [match, **/*.pydevproject, wholename, {includedotfiles=true}], [match, .project, wholename, {includedotfiles=true}], [match, .metadata, wholename, {includedotfiles=true}], [match, **/*.tmp, wholename, {includedotfiles=true}], [match, **/*.bak, wholename, {includedotfiles=true}], [match, **/*~.nib, wholename, {includedotfiles=true}], [match, .classpath, wholename, {includedotfiles=true}], [match, .settings, wholename, {includedotfiles=true}], [match, .loadpath, wholename, {includedotfiles=true}], [match, .externalToolBuilders, wholename, {includedotfiles=true}], [match, .cproject, wholename, {includedotfiles=true}], [match, .buildpath, wholename, {includedotfiles=true}], [match, .DS_Store, wholename, {includedotfiles=true}], [match, .AppleDouble, wholename, {includedotfiles=true}], [match, .LSOverride, wholename, {includedotfiles=true}], [match, .Spotlight-V100, wholename, {includedotfiles=true}], [match, .Trashes, wholename, {includedotfiles=true}], [match, $RECYCLE.BIN, wholename, {includedotfiles=true}], [match, .*.sublime-workspace, wholename, {includedotfiles=true}]]], empty_on_fresh_instance=true, fields=[name, exists, new]}]]...
[-] PROCESSING BUCK FILES...FINISHED 3.4s [100%] New Buck instance
[-] DOWNLOADING... (0.00 B/S AVG, TOTAL: 0.00 B, 0 Artifacts)
[-] BUILDING...FINISHED 2.6s [100%] (1/1 JOBS, 0 UPDATED, 0 [0.0%] CACHE MISS)

4. There aren't built files in the buck-out directory.

ubuntu@miyata:~/onos/apps/yang-sample$ ls -d ~/onos/buck-out/gen/apps/yang*
/home/ubuntu/onos/buck-out/gen/apps/yang /home/ubuntu/onos/buck-out/gen/apps/yang-gui

I'm not sure where the default directory is and how I can configure the destination directory as the document says.

Thanks,
Naoki

2017年6月14日水曜日 2時34分36秒 UTC+9 Marc De Leenheer:
> You can also take a look at onos/apps/openroadm. The actual models are under onos/models/openroadm
>
>
>
>
> Hope this helps,
>
>
> marc
>
>
> On Tue, Jun 13, 2017 at 5:32 AM, Janani Baskaran <jananisv...@gmail.com> wrote:
>
>
> Hi,
>
>
> To create YANG app with BUCK, you can refer '/home/root1/onos/models/l3vpn' where L3VPN YANG files are kept and are used by L3VPN app in '/home/root1/onos/apps/l3vpn'.
>
>
> Please let me know if any more queries you have.
>
>
> Thanks & Regards,
>
>
> Janani B
>
>
>
>
>
> On 13 June 2017 at 17:28, Naoki <naoki.m...@gmail.com> wrote:
> Hi all,
>
>
>
> I'm following the Yang Compiler document here https://wiki.onosproject.org/display/ONOS/YANG+Compiler#YANGCompiler-YangBuckPlugin:
>
>
>
> I couldn't find out how to create new buck-base applications in ONOS. Are there any documents or tutorials about it? (I succeeded to create the Maven-base applications.)
>
>
>
> Thanks,
>
>
>
> --
>
> You received this message because you are subscribed to the Google Groups "ONOS Developers" group.
>
> To unsubscribe from this group and stop receiving emails from it, send an email to onos-dev+u...@onosproject.org.
>
> To post to this group, send email to onos...@onosproject.org.
>
> Visit this group at https://groups.google.com/a/onosproject.org/group/onos-dev/.
>
> To view this discussion on the web visit https://groups.google.com/a/onosproject.org/d/msgid/onos-dev/f1784814-0176-41ad-b88c-e134e896188b%40onosproject.org.
>
>
>
>
>
>
>
> --
>
> You received this message because you are subscribed to the Google Groups "ONOS Developers" group.
>
> To unsubscribe from this group and stop receiving emails from it, send an email to onos-dev+u...@onosproject.org.

BHARAT SARASWAL

unread,
Jun 14, 2017, 2:27:56 AM6/14/17
to Naoki, ONOS Developers, Janani Baskaran
Hi Naoki,

Did you added it to modules.def file?
that will build your app with other when you use 'buck build onos' command.

And for your buck file. there are 2 case.
1. if you want to put your yang files with your app then your folder structures should be like
yang-sample--|
                       |--app
                       |-- yangmodel

in this case you current buck file will be divided into 2 , yang related will go in yangmodel buck and app related will go in app buck. for this you can refer below patch


you can download this patch and see how app is written. 

2. currently in onos model based folder structure as used as janani and marc has mentioned. you keep your yang files in model folder and put dependency to model. for that you can see current master and change those app.

thanks,
Bharat
 

To unsubscribe from this group and stop receiving emails from it, send an email to onos-dev+unsubscribe@onosproject.org.

To post to this group, send email to onos...@onosproject.org.
Visit this group at https://groups.google.com/a/onosproject.org/group/onos-dev/.

Naoki

unread,
Jun 15, 2017, 4:28:08 AM6/15/17
to ONOS Developers, naoki.m...@gmail.com, jananisv...@gmail.com
Hi Bharat,

I really appreciate your help. I've finally built my new app based on Buck. I can move on to the next step.

The log is the following (in this case, I added a yang-sample app).

1. Add a new directory in $ONOS_ROOT/models and put YANG files in it.

ubuntu@miyata ~/onos> find models/yang-sample/ -type f
models/yang-sample/src/main/yang/ietf-yang-types.yang
...(some YANG files)...
models/yang-sample/BUCK
models/yang-sample/pom.xml

ubuntu@miyata ~/onos> cat models/yang-sample/BUCK
yang_model(
app_name = 'org.onosproject.models.yang-sample',
title = 'YANG Sample Model',
)

2. Add a new directory in apps directory. Src directory shouldn't be empty. I added a dummy class in src/main/java here.

ubuntu@miyata ~/onos> find apps/yang-sample/ -type f
apps/yang-sample/src/main/java/org/onosproject/sample/DeviceInfo.java
apps/yang-sample/BUCK

ubuntu@miyata ~/onos> cat apps/yang-sample/BUCK
COMPILE_DEPS = [
'//lib:CORE_DEPS',
'//models/yang-sample:onos-models-yang-sample',
'//lib:onos-yang-model',
]

TEST_DEPS = [
'//lib:TEST_ADAPTERS',
'//utils/osgi:onlab-osgi-tests',
]

APPS = [
'org.onosproject.models.yang-sample',
]

osgi_jar_with_tests(
deps = COMPILE_DEPS,
test_deps = TEST_DEPS,
)

onos_app(
app_name = 'org.onosproject.yang-sample',
title = 'YANG Sample App',
category = 'YANG',
url = 'http://onosproject.org',
description = 'YANG Sample Application',
required_apps = APPS,
)

3. Add entries in $ONOS_ROOT/modules.def. The target name will be automatically generated by scripts in $ONOS_ROOT/bucklets/. '/' in the file path is replaced with '-' and '-oar' is added as suffix. (onos/apps/yang-sample -> onos-apps-yang-sample-oar and onos/models/yang-sample -> onos-models-yang-sample-oar).

ubuntu@miyata ~/onos> git diff
diff --git a/modules.defs b/modules.defs
index df4530a..79183cc 100644
--- a/modules.defs
+++ b/modules.defs
@@ -202,12 +202,14 @@ ONOS_APPS = [
'//apps/network-troubleshoot:onos-apps-network-troubleshoot-oar',
'//apps/l3vpn:onos-apps-l3vpn-oar',
'//apps/openroadm:onos-apps-openroadm-oar',
+ '//apps/yang-sample:onos-apps-yang-sample-oar',
]

MODELS = [
'//models/huawei:onos-models-huawei-oar',
'//models/openroadm:onos-models-openroadm-oar',
'//models/l3vpn:onos-models-l3vpn-oar',
+ '//models/yang-sample:onos-models-yang-sample-oar',
]

APP_JARS = [

4. Use built-in buck to build. When we had some errors in build process in try & error, "./bin/buck clean" often solved the cache problem.

ubuntu@miyata ~/onos> ./bin/buck build onos
[-] PROCESSING BUCK FILES...FINISHED 0.1s 🐇
[-] DOWNLOADING... (0.00 B/S AVG, TOTAL: 0.00 B, 0 Artifacts)
[-] BUILDING...FINISHED 0.4s [100%] (1/1 JOBS, 0 UPDATED, 0 [0.0%] CACHE MISS)

5. Java codes were generated based on the YANG files.

ubuntu@miyata ~/onos> find buck-out/gen/models/yang-sample/onos-models-yang-sample-yang\#srcs__yang-gen/ -type f
...(some YANG files)...
buck-out/gen/models/yang-sample/onos-models-yang-sample-yang#srcs__yang-gen/org/onosproject/yang/gen/v1/ietfyangtypes/rev20130715/IetfYangTypes.java
buck-out/gen/models/yang-sample/onos-models-yang-sample-yang#srcs__yang-gen/org/onosproject/yang/gen/v1/ietfyangtypes/rev20130715/package-info.java
buck-out/gen/models/yang-sample/onos-models-yang-sample-yang#srcs__yang-gen/org/onosproject/yang/gen/v1/ietfyangtypes/rev20130715/ietfyangtypes/Timestamp.java
buck-out/gen/models/yang-sample/onos-models-yang-sample-yang#srcs__yang-gen/org/onosproject/yang/gen/v1/ietfyangtypes/rev20130715/ietfyangtypes/Gauge64.java
buck-out/gen/models/yang-sample/onos-models-yang-sample-yang#srcs__yang-gen/org/onosproject/yang/gen/v1/ietfyangtypes/rev20130715/ietfyangtypes/YangIdentifier.java

It seems to work well :)

Thanks,
Naoki


2017年6月14日水曜日 15時27分56秒 UTC+9 saraswalb:
> To view this discussion on the web visit https://groups.google.com/a/onosproject.org/d/msgid/onos-dev/4dc17ff4-1f83-48f0-9b6a-3e453da8fdfa%40onosproject.org.

Bharat Saraswal

unread,
Jun 15, 2017, 4:51:05 AM6/15/17
to Naoki, ONOS Developers, Sojan koshy

Marc De Leenheer

unread,
Jun 15, 2017, 6:22:17 PM6/15/17
to Bharat Saraswal, Naoki, ONOS Developers, Sojan koshy
Naoki,

Glad to hear you resolved your issues. I have taken the liberty to create a page on our wiki based on your log.

Feel free to update it as you see fit.


Thanks,

marc

To unsubscribe from this group and stop receiving emails from it, send an email to onos-dev+unsubscribe@onosproject.org.
--
You received this message because you are subscribed to the Google Groups "ONOS Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to onos-dev+unsubscribe@onosproject.org.

To post to this group, send email to onos...@onosproject.org.
Visit this group at https://groups.google.com/a/onosproject.org/group/onos-dev/.

Sarath Babu

unread,
Mar 6, 2019, 6:19:13 AM3/6/19
to ONOS Developers, naoki.m...@gmail.com, jananisv...@gmail.com
Hi,

I am trying this scenario to create a yang based app.
we could not find "modules.defs" anywhere.

Could anyone explain more about this?

Regards
Sarath

Thomas Vachuska

unread,
Mar 6, 2019, 12:12:36 PM3/6/19
to Sarath Babu, ONOS Developers, naoki.m...@gmail.com, jananisv...@gmail.com
If you’re building on master branch, please use Bazel (and BUILD files) to build ONOS. Use of Maven and Buck has been completely obsoleted since a few releases ago.

Thomas

Reply all
Reply to author
Forward
0 new messages