[openwisp] Introduction

2017-10-24 Thread Aarnav Bos
Hello all,

My name is Aarnav, and I'm a junior developer at 
Bluelight(Auroville,India). 
Been exploring openwisp at Bluelight for a while now, and have decided to 
come forward and contribute.

Recommendations on how I could proceed?

-- 
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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[openwisp] Re: Introduction

2017-10-24 Thread Aarnav Bos
I usually code in python, javascript and/or Go. A little bit of Django but 
mostly Flask(I build web applications).

On Tuesday, October 24, 2017 at 4:00:31 AM UTC-4, Federico Capoano wrote:
>
> Hi Aarnav and welcome!
>
> Marco's suggestions are good.
>
> What's your experience in IT? In OpenWISP, we mainly work with the 
> following technologies and programming languages:
>
>- linux
>- OpenWRT/LEDE
>- ansible
>- NetJSON
>- python
>- django
>- javascript
>- jQuery
>- d3.js
>- react
>
> The most valuable skills are python, django, javascript and OpenWRT/LEDE, 
> master these and you will become a leader in the OpenWISP community!
>
> What's your experience with Python/Django and OpenWRT?
>
> Federico
>
>
> On Tuesday, October 24, 2017 at 8:27:10 AM UTC+2, Aarnav Bos wrote:
>>
>> Hello all,
>>
>> My name is Aarnav, and I'm a junior developer at 
>> Bluelight(Auroville,India). 
>> Been exploring openwisp at Bluelight for a while now, and have decided to 
>> come forward and contribute.
>>
>> Recommendations on how I could proceed?
>>
>

-- 
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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[openwisp] Re: Device registration failed.

2017-11-15 Thread Aarnav Bos
Excuse the spelling mistakes, it was typed out in haste.

On Thursday, November 16, 2017 at 1:31:30 AM UTC-5, Aarnav Bos wrote:
>
> I was using openwisp_config to register my device to the controller. And 
> the device registration fails.
>
> Some detail: 
> Running openwisp2_config openssl version0.4.6a on LEDE 17.01
> this is my /etc/config/openwisp
>
> config controller 'http'
> option url 'https://192.168.10.201'
> #option interval '120'
> option verify_ssl '0'
> option shared_secret 'wMQQmI4xyzc9ubo87WN9cme5TW4e89CG'
> #option consistent_key '0'
> option mac_interface 'eth0'
> #option merge_config '1'
> #option test_config '1'
> #option test_script '/usr/sbin/mytest'
> option uuid ''
> option key 'H4MJysbthCLrZ7OPlspvdnCURiB8D7su'
> list unmanaged 'system.@led'
> list unmanaged 'network.loopback'
> list unmanaged 'network.@switch'
> list unmanaged 'network.@switch_vlan'
> # curl options
> option connect_timeout '15'
> option max_time '30'
> #option capath '/etc/ssl/certs'
> option cacert '/etc/ssl/certs/server.crt'
> # hooks
> #option pre_reload_hook '/usr/sbin/my_pre_reload_hook'
>
>
> after restarting the agent, my log provides this:
>
> Mon Nov 13 00:41:21 2017 daemon.info openwisp: OpenWISP config agent 
> stopping
> Mon Nov 13 00:41:21 2017 daemon.info openwisp: OpenWISP config agent 
> started
> Mon Nov 13 00:41:21 2017 daemon.info openwisp: Registering device...
> Mon Nov 13 00:41:22 2017 daemon.err openwisp: Registration failed! }
>
>
> And from the UWSGI log, the controlloer's response  to the POST request on 
> /controler/register/ is an ERROR 400(Bad Request).
>
> Could someone point out a potential mistake in the config? 
>

-- 
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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[openwisp] Device registration failed.

2017-11-15 Thread Aarnav Bos
I was using openwisp_config to register my device to the controller. And 
the device registration fails.

Some detail: 
Running openwisp2_config openssl version0.4.6a on LEDE 17.01
this is my /etc/config/openwisp

config controller 'http'
option url 'https://192.168.10.201'
#option interval '120'
option verify_ssl '0'
option shared_secret 'wMQQmI4xyzc9ubo87WN9cme5TW4e89CG'
#option consistent_key '0'
option mac_interface 'eth0'
#option merge_config '1'
#option test_config '1'
#option test_script '/usr/sbin/mytest'
option uuid ''
option key 'H4MJysbthCLrZ7OPlspvdnCURiB8D7su'
list unmanaged 'system.@led'
list unmanaged 'network.loopback'
list unmanaged 'network.@switch'
list unmanaged 'network.@switch_vlan'
# curl options
option connect_timeout '15'
option max_time '30'
#option capath '/etc/ssl/certs'
option cacert '/etc/ssl/certs/server.crt'
# hooks
#option pre_reload_hook '/usr/sbin/my_pre_reload_hook'


after restarting the agent, my log provides this:

Mon Nov 13 00:41:21 2017 daemon.info openwisp: OpenWISP config agent 
stopping
Mon Nov 13 00:41:21 2017 daemon.info openwisp: OpenWISP config agent started
Mon Nov 13 00:41:21 2017 daemon.info openwisp: Registering device...
Mon Nov 13 00:41:22 2017 daemon.err openwisp: Registration failed! }


And from the UWSGI log, the controlloer's response  to the POST request on 
/controler/register/ is an ERROR 400(Bad Request).

Could someone point out a potential mistake in the config? 

-- 
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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [openwisp] Re: Device registration failed.

2017-11-16 Thread Aarnav Bos
There was no bug. Apparently a clone(with the same MAC addr) was already 
registered and I was trying to register a duplicate. I figured this out 
through the contents of /tmp/openwisp/registration_parameters. The  error 
response was displayed quite clearly in the file. 

content of /tmp/openwisp/registration_parameters:

HTTP/1.1 400 Bad Request
Server: nginx/1.10.3
Date: Thu, 16 Nov 2017 09:18:59 GMT
Content-Type: text/plain
Content-Length: 85
Connection: keep-alive
X-Openwisp-Controller: true
X-Frame-Options: SAMEORIGIN

{
"mac_address": [
"Device with this Mac address already exists."
]
}


On Thursday, November 16, 2017 at 3:53:18 AM UTC-5, Federico Capoano wrote:
>
> Hey Aarnav,
>
> It's unfortunate this is happening.
> Same thing happened to me recently for an unexpected bug created during 
> development and it was not easy to debug.
>
> The log line "openwisp: Registration failed! }" is a bug in logging 
> failures which I described here: 
> https://github.com/openwisp/openwisp-config/issues/42
>
> I have some questions for you that will help me to debug the problem:
>
> - I suppose you installed using ansible-openwisp2, could you show us your 
> playbook.yml?
> - run the playbook again to ensure the latest versions of the modules are 
> installed
> - in LEDE, after the registration fails, stop the openwisp_config deamon 
> and run this command: cat /tmp/openwisp/registration_parameters, copy the 
> output and paste it here please
> - after the registration fails, is the configuration downloaded and 
> applied anyway? You can find out if this happens by trying to change the 
> name of the device in the openwisp2 web app, if the hostname is updated, 
> this bug is happening: 
> https://github.com/openwisp/openwisp-config/issues/43
>
> Thank you for your feedback.
> Federico
>
>
>
>
> On Thu, Nov 16, 2017 at 7:32 AM Aarnav Bos <aarn...@gmail.com 
> > wrote:
>
>> Excuse the spelling mistakes, it was typed out in haste.
>>
>>
>> On Thursday, November 16, 2017 at 1:31:30 AM UTC-5, Aarnav Bos wrote:
>>>
>>> I was using openwisp_config to register my device to the controller. And 
>>> the device registration fails.
>>>
>>> Some detail: 
>>> Running openwisp2_config openssl version0.4.6a on LEDE 17.01
>>> this is my /etc/config/openwisp
>>>
>>> config controller 'http'
>>> option url 'https://192.168.10.201'
>>> #option interval '120'
>>> option verify_ssl '0'
>>> option shared_secret 'wMQQmI4xyzc9ubo87WN9cme5TW4e89CG'
>>> #option consistent_key '0'
>>> option mac_interface 'eth0'
>>> #option merge_config '1'
>>> #option test_config '1'
>>> #option test_script '/usr/sbin/mytest'
>>> option uuid ''
>>> option key 'H4MJysbthCLrZ7OPlspvdnCURiB8D7su'
>>> list unmanaged 'system.@led'
>>> list unmanaged 'network.loopback'
>>> list unmanaged 'network.@switch'
>>> list unmanaged 'network.@switch_vlan'
>>> # curl options
>>> option connect_timeout '15'
>>> option max_time '30'
>>> #option capath '/etc/ssl/certs'
>>> option cacert '/etc/ssl/certs/server.crt'
>>> # hooks
>>> #option pre_reload_hook '/usr/sbin/my_pre_reload_hook'
>>>
>>>
>>> after restarting the agent, my log provides this:
>>>
>>> Mon Nov 13 00:41:21 2017 daemon.info openwisp: OpenWISP config agent 
>>> stopping
>>> Mon Nov 13 00:41:21 2017 daemon.info openwisp: OpenWISP config agent 
>>> started
>>> Mon Nov 13 00:41:21 2017 daemon.info openwisp: Registering device...
>>> Mon Nov 13 00:41:22 2017 daemon.err openwisp: Registration failed! }
>>>
>>>
>>> And from the UWSGI log, the controlloer's response  to the POST request 
>>> on /controler/register/ is an ERROR 400(Bad Request).
>>>
>>> Could someone point out a potential mistake in the config? 
>>>
>> -- 
>> 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.
>>
>

-- 
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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [openwisp] Re: Introduction

2017-11-16 Thread Aarnav Bos
Do I submit a pull request?

On Thursday, November 9, 2017 at 4:41:45 AM UTC-5, Aarnav Bos wrote:
>
> https://github.com/openwisp/ansible-openwisp2/compare/master...R9295:master
>
>
> On Wednesday, November 8, 2017 at 6:27:14 AM UTC-5, Federico Capoano wrote:
>>
>> Hi Aarnav,
>>
>> I would schedule it for 4:30 am.
>>
>> Take a look at this file to understand how to implement it:
>> https://github.com/openwisp/ansible-openwisp2/blob/master/tasks/cron.yml
>>
>> Thanks for your contribution!
>> Federico
>>
>> On Wed, Nov 8, 2017 at 11:48 AM Aarnav Bos <aarn...@gmail.com> wrote:
>>
>>> Hey, so I took a look at this issue: 
>>> https://github.com/openwisp/ansible-openwisp2/issues/24 .
>>> And I implemented the solution on my VPS. Is there a specific time the 
>>> cronjob needs to run?  Do I submit a PR?
>>>
>>>
>>> On Wednesday, October 25, 2017 at 4:59:13 AM UTC-4, Aarnav Bos wrote:
>>>>
>>>> I'll take a look at it. Will also setup a VM to install Openwisp.
>>>>
>>>> On Tuesday, October 24, 2017 at 7:35:52 AM UTC-4, Federico Capoano 
>>>> wrote:
>>>>>
>>>>> A good way for you to start would be to create a VM with virtualbox or 
>>>>> setup an lxc container on which you can install OpenWISP 2 using 
>>>>> ansible-openwisp2 <https://github.com/openwisp/ansible-openwisp2>.
>>>>>
>>>>> You can read about the internals of OpenWISP 2 here:
>>>>>
>>>>> https://www.slideshare.net/FedericoCapoano/applying-the-unix-philosophy-to-django-projects-a-report-from-the-real-world
>>>>>
>>>>> Federico
>>>>>
>>>>>
>>>>> On Tuesday, October 24, 2017 at 12:32:55 PM UTC+2, Aarnav Bos wrote:
>>>>>>
>>>>>> I usually code in python, javascript and/or Go. A little bit of 
>>>>>> Django but mostly Flask(I build web applications).
>>>>>>
>>>>>> On Tuesday, October 24, 2017 at 4:00:31 AM UTC-4, Federico Capoano 
>>>>>> wrote:
>>>>>>>
>>>>>>> Hi Aarnav and welcome!
>>>>>>>
>>>>>>> Marco's suggestions are good.
>>>>>>>
>>>>>>> What's your experience in IT? In OpenWISP, we mainly work with the 
>>>>>>> following technologies and programming languages:
>>>>>>>
>>>>>>>- linux
>>>>>>>- OpenWRT/LEDE
>>>>>>>- ansible
>>>>>>>- NetJSON
>>>>>>>- python
>>>>>>>- django
>>>>>>>- javascript
>>>>>>>- jQuery
>>>>>>>- d3.js
>>>>>>>- react
>>>>>>>
>>>>>>> The most valuable skills are python, django, javascript and 
>>>>>>> OpenWRT/LEDE, master these and you will become a leader in the OpenWISP 
>>>>>>> community!
>>>>>>>
>>>>>>> What's your experience with Python/Django and OpenWRT?
>>>>>>>
>>>>>>> Federico
>>>>>>>
>>>>>>>
>>>>>>> On Tuesday, October 24, 2017 at 8:27:10 AM UTC+2, Aarnav Bos wrote:
>>>>>>>>
>>>>>>>> Hello all,
>>>>>>>>
>>>>>>>> My name is Aarnav, and I'm a junior developer at 
>>>>>>>> Bluelight(Auroville,India). 
>>>>>>>> Been exploring openwisp at Bluelight for a while now, and have 
>>>>>>>> decided to come forward and contribute.
>>>>>>>>
>>>>>>>> Recommendations on how I could proceed?
>>>>>>>>
>>>>>>> -- 
>>> 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.
>>>
>>

-- 
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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [openwisp] Re: Introduction

2017-11-09 Thread Aarnav Bos
https://github.com/openwisp/ansible-openwisp2/compare/master...R9295:master


On Wednesday, November 8, 2017 at 6:27:14 AM UTC-5, Federico Capoano wrote:
>
> Hi Aarnav,
>
> I would schedule it for 4:30 am.
>
> Take a look at this file to understand how to implement it:
> https://github.com/openwisp/ansible-openwisp2/blob/master/tasks/cron.yml
>
> Thanks for your contribution!
> Federico
>
> On Wed, Nov 8, 2017 at 11:48 AM Aarnav Bos <aarn...@gmail.com 
> > wrote:
>
>> Hey, so I took a look at this issue: 
>> https://github.com/openwisp/ansible-openwisp2/issues/24 .
>> And I implemented the solution on my VPS. Is there a specific time the 
>> cronjob needs to run?  Do I submit a PR?
>>
>>
>> On Wednesday, October 25, 2017 at 4:59:13 AM UTC-4, Aarnav Bos wrote:
>>>
>>> I'll take a look at it. Will also setup a VM to install Openwisp.
>>>
>>> On Tuesday, October 24, 2017 at 7:35:52 AM UTC-4, Federico Capoano wrote:
>>>>
>>>> A good way for you to start would be to create a VM with virtualbox or 
>>>> setup an lxc container on which you can install OpenWISP 2 using 
>>>> ansible-openwisp2 <https://github.com/openwisp/ansible-openwisp2>.
>>>>
>>>> You can read about the internals of OpenWISP 2 here:
>>>>
>>>> https://www.slideshare.net/FedericoCapoano/applying-the-unix-philosophy-to-django-projects-a-report-from-the-real-world
>>>>
>>>> Federico
>>>>
>>>>
>>>> On Tuesday, October 24, 2017 at 12:32:55 PM UTC+2, Aarnav Bos wrote:
>>>>>
>>>>> I usually code in python, javascript and/or Go. A little bit of Django 
>>>>> but mostly Flask(I build web applications).
>>>>>
>>>>> On Tuesday, October 24, 2017 at 4:00:31 AM UTC-4, Federico Capoano 
>>>>> wrote:
>>>>>>
>>>>>> Hi Aarnav and welcome!
>>>>>>
>>>>>> Marco's suggestions are good.
>>>>>>
>>>>>> What's your experience in IT? In OpenWISP, we mainly work with the 
>>>>>> following technologies and programming languages:
>>>>>>
>>>>>>- linux
>>>>>>- OpenWRT/LEDE
>>>>>>- ansible
>>>>>>- NetJSON
>>>>>>- python
>>>>>>- django
>>>>>>- javascript
>>>>>>- jQuery
>>>>>>- d3.js
>>>>>>- react
>>>>>>
>>>>>> The most valuable skills are python, django, javascript and 
>>>>>> OpenWRT/LEDE, master these and you will become a leader in the OpenWISP 
>>>>>> community!
>>>>>>
>>>>>> What's your experience with Python/Django and OpenWRT?
>>>>>>
>>>>>> Federico
>>>>>>
>>>>>>
>>>>>> On Tuesday, October 24, 2017 at 8:27:10 AM UTC+2, Aarnav Bos wrote:
>>>>>>>
>>>>>>> Hello all,
>>>>>>>
>>>>>>> My name is Aarnav, and I'm a junior developer at 
>>>>>>> Bluelight(Auroville,India). 
>>>>>>> Been exploring openwisp at Bluelight for a while now, and have 
>>>>>>> decided to come forward and contribute.
>>>>>>>
>>>>>>> Recommendations on how I could proceed?
>>>>>>>
>>>>>> -- 
>> 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.
>>
>

-- 
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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[openwisp] Re: Introduction

2017-11-08 Thread Aarnav Bos
Hey, so I took a look at this 
issue: https://github.com/openwisp/ansible-openwisp2/issues/24 .
And I implemented the solution on my VPS. Is there a specific time the 
cronjob needs to run?  Do I submit a PR?

On Wednesday, October 25, 2017 at 4:59:13 AM UTC-4, Aarnav Bos wrote:
>
> I'll take a look at it. Will also setup a VM to install Openwisp.
>
> On Tuesday, October 24, 2017 at 7:35:52 AM UTC-4, Federico Capoano wrote:
>>
>> A good way for you to start would be to create a VM with virtualbox or 
>> setup an lxc container on which you can install OpenWISP 2 using 
>> ansible-openwisp2 <https://github.com/openwisp/ansible-openwisp2>.
>>
>> You can read about the internals of OpenWISP 2 here:
>>
>> https://www.slideshare.net/FedericoCapoano/applying-the-unix-philosophy-to-django-projects-a-report-from-the-real-world
>>
>> Federico
>>
>>
>> On Tuesday, October 24, 2017 at 12:32:55 PM UTC+2, Aarnav Bos wrote:
>>>
>>> I usually code in python, javascript and/or Go. A little bit of Django 
>>> but mostly Flask(I build web applications).
>>>
>>> On Tuesday, October 24, 2017 at 4:00:31 AM UTC-4, Federico Capoano wrote:
>>>>
>>>> Hi Aarnav and welcome!
>>>>
>>>> Marco's suggestions are good.
>>>>
>>>> What's your experience in IT? In OpenWISP, we mainly work with the 
>>>> following technologies and programming languages:
>>>>
>>>>- linux
>>>>- OpenWRT/LEDE
>>>>- ansible
>>>>- NetJSON
>>>>- python
>>>>- django
>>>>- javascript
>>>>- jQuery
>>>>    - d3.js
>>>>- react
>>>>
>>>> The most valuable skills are python, django, javascript and 
>>>> OpenWRT/LEDE, master these and you will become a leader in the OpenWISP 
>>>> community!
>>>>
>>>> What's your experience with Python/Django and OpenWRT?
>>>>
>>>> Federico
>>>>
>>>>
>>>> On Tuesday, October 24, 2017 at 8:27:10 AM UTC+2, Aarnav Bos wrote:
>>>>>
>>>>> Hello all,
>>>>>
>>>>> My name is Aarnav, and I'm a junior developer at 
>>>>> Bluelight(Auroville,India). 
>>>>> Been exploring openwisp at Bluelight for a while now, and have decided 
>>>>> to come forward and contribute.
>>>>>
>>>>> Recommendations on how I could proceed?
>>>>>
>>>>

-- 
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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[openwisp] Re: Introduction

2017-10-25 Thread Aarnav Bos
I'll take a look at it. Will also setup a VM to install Openwisp.

On Tuesday, October 24, 2017 at 7:35:52 AM UTC-4, Federico Capoano wrote:
>
> A good way for you to start would be to create a VM with virtualbox or 
> setup an lxc container on which you can install OpenWISP 2 using 
> ansible-openwisp2 <https://github.com/openwisp/ansible-openwisp2>.
>
> You can read about the internals of OpenWISP 2 here:
>
> https://www.slideshare.net/FedericoCapoano/applying-the-unix-philosophy-to-django-projects-a-report-from-the-real-world
>
> Federico
>
>
> On Tuesday, October 24, 2017 at 12:32:55 PM UTC+2, Aarnav Bos wrote:
>>
>> I usually code in python, javascript and/or Go. A little bit of Django 
>> but mostly Flask(I build web applications).
>>
>> On Tuesday, October 24, 2017 at 4:00:31 AM UTC-4, Federico Capoano wrote:
>>>
>>> Hi Aarnav and welcome!
>>>
>>> Marco's suggestions are good.
>>>
>>> What's your experience in IT? In OpenWISP, we mainly work with the 
>>> following technologies and programming languages:
>>>
>>>- linux
>>>- OpenWRT/LEDE
>>>- ansible
>>>- NetJSON
>>>- python
>>>- django
>>>- javascript
>>>- jQuery
>>>- d3.js
>>>- react
>>>
>>> The most valuable skills are python, django, javascript and 
>>> OpenWRT/LEDE, master these and you will become a leader in the OpenWISP 
>>> community!
>>>
>>> What's your experience with Python/Django and OpenWRT?
>>>
>>> Federico
>>>
>>>
>>> On Tuesday, October 24, 2017 at 8:27:10 AM UTC+2, Aarnav Bos wrote:
>>>>
>>>> Hello all,
>>>>
>>>> My name is Aarnav, and I'm a junior developer at 
>>>> Bluelight(Auroville,India). 
>>>> Been exploring openwisp at Bluelight for a while now, and have decided 
>>>> to come forward and contribute.
>>>>
>>>> Recommendations on how I could proceed?
>>>>
>>>

-- 
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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[openwisp] Google Code-In Grand Prize Winners: select 1 mentor to meet

2018-02-14 Thread Aarnav Bos
I nominate Federico and Xavier:)

-- 
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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[openwisp] Making netjsonconfig easier to extend

2018-11-05 Thread Aarnav Bos
As the issue https://github.com/openwisp/netjsonconfig/issues/112 goes,
It'd be ideal to be able to easily extend the backends. Since the use-case 
of adding support for an OpenWRT package is very common, this 
implementation primarily focuses on that.

Adding a method to BaseBackend to allow insertions of converters and 
schemas is an approach

class BaseBackend(object):
...
...
def add_plugin(self, key, schema, converter):
schema.pop('$schema', None)
# add to backend's schema, this could have an option to raise an 
error if the value is being overridden
self.schema['properties'][key] = schema
if getattr(self, 'converters'):
 self.converters.append(converter)
else:
 self.converters = [converter]

Tracking the 'plugins' can become simpler too, by adding a an attribute to 
the converter, if needed. 
Let's say I was to create a plugin for Coova-Chilli:

coova_schema = {
"$schema": "http://json-schema.org/draft-04/schema#;,
"type": "object",
"properties" : {
 "disabled" : {"type" : "integer"},
 },
}


class CoovaConverter(OpenWrtConverter):
def to_intermediate_loop(self, block, result, index=None):
if block:
block.update({
'.type': 'chilli',
'.name': 'chilli'
})
result['chilli'] = [self.sorted_dict(block)]
return result




o = OpenWrt({
'chilli': {
"disabled": 1,
}
})
o.add_plugin(key='chilli', schema=coova_schema, converter=CoovaConverter)
o.render()
'''
package chilli

config chilli 'chilli'
option disabled '1'
'''
This is incomplete code, obviously, but gives an idea of how the 
implementation goes.

Thoughts?

-- 
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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.