Adding a Custom Backend in netjsonconfig module

۱۶۶ بازدید
رفتن به اولین پیام خوانده‌نشده

jdroid

خوانده‌نشده،
۱۱ فروردین ۱۳۹۶، ۷:۲۴:۱۴۱۳۹۶/۱/۱۱
به OpenWISP
HI Federico and Team:
First of all, Very impressed with your work. Great work..

I have installed openwisp2 package on a ubuntu 16.04 VM, and able to register openwrt devices to it. Many thanks for all info available in openwisp google group :-)

I used ansible-openwisp2 method to install a copy of openwisp2 packages into my VM.

as part of my next step, I am trying to add a new backend under netjsonconfig. Idea is to classify and identify different models of routers (all based on openwrt, but some with one radio, others with 2 radios, plus few outdoorAPs) based on the registered backend information.

To Create a new backend, I have already cloned the netjsonconfig/backend/openwrt module and created a new backend and changed name from "OpenWrt" to "NewBackend".

I made simialr changed in django_netjsonconfig module also (including settings.py - to add this new backend info). I am able to see the new backend info in all the openwisp controller templates. openwrt's openwisp-config agent is also updated with this new backend name (backend="netjsonconfig.NewBackend").

with these changes I restarted the openwisp2 controller and I am able to register openwrt devices with the new backend.

After registration, I am running into an issue with configuration checksum. Device sends a request for configuration checksum to controller but controller returns "HTTP/1.1 500 Internal Server Error". if I put back the openwrt device backend info to "netjsonconfig.OpenWrt" and re-register, the configuration checksum goes through fine and the device is able to get new config update.

Not sure what I am missing. Is it an issue with making changes in a package which is created with ansible-openwisp2? or I need to add the new backend info to other places.

Any help is appreciated.

thanks
Kumar


Federico Capoano

خوانده‌نشده،
۱۱ فروردین ۱۳۹۶، ۷:۵۵:۴۴۱۳۹۶/۱/۱۱
به OpenWISP
Hi Kumar and welcome,

configuration backends are designed to allow to develop new ways to configure other type of firmwares (eg: AirOS, PfSense, Raspbian) and define different validation and UI fields with their schema.

To create a new backend, you should first of all work and test in a development environment, then once everything works you should depoy it.

But I think that what you are doing may be overkill.

Could you explain your need in detail so maybe I could suggest you an easier way or we could add a feature request in the system?

Federico

jdroid

خوانده‌نشده،
۱۱ فروردین ۱۳۹۶، ۸:۰۶:۱۲۱۳۹۶/۱/۱۱
به OpenWISP
HI, Thanks for a quick response.

I have different router boards, one set with single Radio, other with dual radio,  and few outdoor WDS based PTP links.
Ideally, I would like to create predefined default templates for each one of this openwrt router models. At the time of device registration, depending upon the models, I would like to assign respective configuration templates to the registering device.

is there a easier way for this?

thanks in advance
Kumar

Federico Capoano

خوانده‌نشده،
۱۱ فروردین ۱۳۹۶، ۸:۵۶:۴۰۱۳۹۶/۱/۱۱
به open...@googlegroups.com،jish...@gmail.com
I see.

I thought about this feature as well:

I thought about adding a way to specify tags to templates.
We could tag some templates as "dual-radio", some other templates as "WDS" and so on.
Then we could add these templates in the configuration of the OpenWRT/LEDE deamon which would then register the device with these templates preselected.

But this is not possible at the moment. You could use a hackish workaround though: you could use organizations (which are designed to separate roles but can be hacked in a slightly different way).

You could create organizations like:
  • dual-radio
  • WDS
  • PTP
Then you could create default templates for these organizations, but all the other templates will have to be set as global (don't set any organization to them).

Federico

--
You received this message because you are subscribed to the Google Groups "OpenWISP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to openwisp+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Federico Capoano

خوانده‌نشده،
۱۱ فروردین ۱۳۹۶، ۹:۲۲:۰۷۱۳۹۶/۱/۱۱
به OpenWISP

jdroid

خوانده‌نشده،
۱۱ فروردین ۱۳۹۶، ۹:۲۴:۴۰۱۳۹۶/۱/۱۱
به OpenWISP
HI Federico:
I will give a try with organization method. I am assuming openwisp-config agent  in openwrt device will have a organization element based on which it can pick templates from respective organization. Will go in details and get back.

In the mean time, I would like to understand how I would add a new backend in a package which is installed with ansible-openwisp. you had mentioned earlier that I need to work and test in a development environment. I want to understand this more clear. So if I download individual packages (both django-netjsonconfig and netjsonconfig module using git ), include the new backend and how do I re-integrate them with ansible-openwisp downloaded package? do you have any instruction in place for this. I am new to django framework, hence this question.

thanks in advance,
Kumar

Federico Capoano

خوانده‌نشده،
۱۱ فروردین ۱۳۹۶، ۹:۳۴:۴۳۱۳۹۶/۱/۱۱
به OpenWISP


On Friday, March 31, 2017 at 3:24:40 PM UTC+2, jdroid wrote:
HI Federico:
I will give a try with organization method. I am assuming openwisp-config agent  in openwrt device will have a organization element based on which it can pick templates from respective organization. Will go in details and get back.


Each organization has a shared_secret, so each firmware type (WDS, PTP, etc) will have the shared_secret of the org you are using for that scope.
 
In the mean time, I would like to understand how I would add a new backend in a package which is installed with ansible-openwisp. you had mentioned earlier that I need to work and test in a development environment. I want to understand this more clear. So if I download individual packages (both django-netjsonconfig and netjsonconfig module using git ), include the new backend and how do I re-integrate them with ansible-openwisp downloaded package? do you have any instruction in place for this. I am new to django framework, hence this question.

There's no documentation yet on how to do this.

It's a bit long to explain and I don't have time right now because I'm preparing a presentation about OpenWISP to present at Pycon Italy next week.

If you remind me next week I'll try to write an outline of how to do this. But it's not easy, I warn you.

Federico

jdroid

خوانده‌نشده،
۱۱ فروردین ۱۳۹۶، ۹:۴۷:۰۷۱۳۹۶/۱/۱۱
به OpenWISP
Federico:
Thanks for info.
I will try out the organization. It should help me out with my current need.

I will also ping you next week on the second item.

btw.. do you have plans to support openwrt image upgrade (firmware upgrade) to these registered openwrt devices.

thanks
jish

Federico Capoano

خوانده‌نشده،
۱۱ فروردین ۱۳۹۶، ۱۰:۱۶:۲۳۱۳۹۶/۱/۱۱
به open...@googlegroups.com
On Fri, Mar 31, 2017 at 3:47 PM jdroid <jish...@gmail.com> wrote:
btw.. do you have plans to support openwrt image upgrade (firmware upgrade) to these registered openwrt devices.

Yes but I don't know when I will be able to pull that off.

Hopefully before the end of 2017 but it depends on how many contributors we can onboard.
The more contributors we get and the more they will help me with less complicated tasks, the more I can focus on big features like that.

Federico

jdroid

خوانده‌نشده،
۱۳ فروردین ۱۳۹۶، ۲:۴۶:۲۱۱۳۹۶/۱/۱۳
به OpenWISP
HI:
With the latest checked out ansible openwisp2  package, I am able to hack the organisation to assign different configuration templates to different models of AP/Routers.

Moving on to adding radio and interface details on a configuration template, I run into another issue. In a new template for configuration, I add new radio section and in the radio section the driver field pull down menu, I didn't find the "qcawifi" value which is required for new QCA based wlan driver. I could add this enum option in the netjsonconfig/backend/openwrt/schema.py , but on retsrating the openwisp package, I don't see the value getting listed in template radio section pull down menu.

So if I add or modify contents in netjsonconfig/backend/openwrt/schema.py, what is the procedure I should follow to see these modified values. I am working on ansible checkout code.

Any help is appreciated,

thanks
Kumar

Federico Capoano

خوانده‌نشده،
۱۳ فروردین ۱۳۹۶، ۵:۲۶:۵۱۱۳۹۶/۱/۱۳
به open...@googlegroups.com
Hi Kumar,

Commit the result and push it on your fork, then proceed by installing manually your fork in your instance, with:

cd /opt/openwisp2
source env/bin/activate

We could also allow the ansible role (ansible-openwisp2) to install the development versions of the base libraries and modules from different sources so you could avoid to do this step maually, but I don't have time to add this feature right now (although I will keep it in mind for the near future).

Bytheway, I didn't know this driver. I tried looking on google right now but couldn't find much, do you have any useful link of examples of use of this driver with OpenWRT or LEDE that I can take read?

Federico

--

jdroid

خوانده‌نشده،
۱۳ فروردین ۱۳۹۶، ۷:۲۴:۱۳۱۳۹۶/۱/۱۳
به OpenWISP

HI Federico:
thanks for the procedure, will give it a try.

about the driver, I too dont have much info, as the driver code comes as a bin package, except the scripts to configure them. This is somewhat similar to madwifi, with additional custom config variables. I too couldnt find much info about it in google. I was assuming you would be aware of this :-)

thanks
Kumar

Federico Capoano

خوانده‌نشده،
۱۳ فروردین ۱۳۹۶، ۱۱:۱۵:۴۰۱۳۹۶/۱/۱۳
به OpenWISP

No I wasn't aware of it but now thanks to you I am ;-)

If more people will need this we could add support for it.

Fed

Federico Capoano

خوانده‌نشده،
۲۵ فروردین ۱۳۹۶، ۱۰:۴۶:۱۴۱۳۹۶/۱/۲۵
به OpenWISP
I'm working on the template tags feature: https://github.com/openwisp/django-netjsonconfig/pull/54
پاسخ به همه
پاسخ به نویسنده
فرستادن
0 پیام جدید