Multiple/Merged Templates

176 views
Skip to first unread message

mord reneth

unread,
Feb 21, 2017, 3:40:48 AM2/21/17
to OpenWISP
I'm setting the routers with a config to use 802.11r.....

So, there some common settings (ieee80211r, mobility_domain, pmk_r1_push) which go in one common template.....and router specific settings (nasid, r1_key_holder) which go in a seperate template for that router.

Now, my question is: when setting these templates, which are object properties under wireless access point, I have to enter radio and ssid settings under both templates (and considering there is a third generic template for wireless settings).....that's 3 templates with radio/ssid settings. Thats 3 templates that HAVE to match....and any mistake will cause a problem.

Am I doing something wrong? Or is there a better way of doing it?

(FYI.....my 3 templates do match.....and the resulting configuration does meet expectations)



Template Roaming Setup:

{
    "interfaces": [
        {
            "wireless": {
                "mode": "access_point",
                "radio": "radio0",
                "ssid": "testap",
                "ieee80211r": 1,
                "mobility_domain": "e614",
                "pmk_r1_push": 1
            },
            "type": "wireless",
            "addresses": [],
            "name": "wlan0"
        }
    ]
}

Template Router Specific Setup:

{
    "interfaces": [
        {
            "wireless": {
                "mode": "access_point",
                "radio": "radio0",
                "ssid": "testap",
                "nasid": "123456789012",
                "r1_key_holder": "123456789012"
            },
            "type": "wireless",
            "network": "",
            "name": "wlan0",
            "mtu": 1500
        }
}

Federico Capoano

unread,
Feb 21, 2017, 5:26:16 AM2/21/17
to OpenWISP
See below.

On Tuesday, February 21, 2017 at 9:40:48 AM UTC+1, mord reneth wrote:
I'm setting the routers with a config to use 802.11r.....
 
Cool! I have never used 802.11r, I would be very interested to know about your progress on this task and I'm sure I'm not the only one.

So, there some common settings (ieee80211r, mobility_domain, pmk_r1_push) which go in one common template.....and router specific settings (nasid, r1_key_holder) which go in a seperate template for that router.

Now, my question is: when setting these templates, which are object properties under wireless access point, I have to enter radio and ssid settings under both templates (and considering there is a third generic template for wireless settings).....that's 3 templates with radio/ssid settings. Thats 3 templates that HAVE to match....and any mistake will cause a problem.

Am I doing something wrong? Or is there a better way of doing it?

When using multiple templates, their order is important. Templates coming after override templates that come first (I just noticed I did not explain this properly in the netjsonconfig documentation).

So you should put your general template first and the specific ones after.

The important thing is that all the interfaces have the same name ("wlan0") and the required attributes pass the schema validation.
Because some attributes are required (name, type, wireless mode, wireless radio, wireles ssid) you may need to duplicate some information in the different templates.
This duplication is not optimal and undesiderable, but easier to implement sanely at the moment, I'm sure that we'll find a better way of doing it in the near future.
 
(FYI.....my 3 templates do match.....and the resulting configuration does meet expectations)
 
Great.

You are doing things properly.

If I were you I would remove a few attributes that you don't use (I would also use the JSON boolean types instead of 1 or 0 because more readable), eg:

Template Roaming Setup:

{
    "interfaces": [
        {
            "name": "wlan0",
            "type": "wireless",
            "wireless": {
                "mode": "access_point",
                "radio": "radio0",
                "ssid": "testap",
                "ieee80211r": true,
                "mobility_domain": "e614",
                "pmk_r1_push": true
            }
        }
    ]
}


Template Router Specific Setup (MTU defaults to 1500 anyway so you can remove it):

{
    "interfaces": [
        {
            "name": "wlan0",
            "type": "wireless",
            "wireless": {
                "mode": "access_point",
                "radio": "radio0",
                "ssid": "testap",
                "nasid": "123456789012",
                "r1_key_holder": "123456789012"
            }
        }
    ]
}

But these are just small optimizations, you were doing it correctly already.

Federico

mord reneth

unread,
Feb 21, 2017, 6:14:37 AM2/21/17
to OpenWISP

OK, Glad to know i was doing something right....

I was just about to ask how to order the templates, when I saw on the configuration page, in small letters at the bottom.....drag and drop the order....Perhaps this could be made a bit bolder....

I kept the ints instead of boolean because the documentation i read elsewhere was using int's......i'll change to boolean and try it...

As for optimization......how possible is it to have 'inherited' templates.....so, in my example, Template Router Specific would inherit from Template Roaming..... and therefor not (theoretically) need the duplicate radio and ssid settings.....

Also, I havent found anywhere where I can duplicate/copy a template.....is this possible?

mord reneth

unread,
Feb 21, 2017, 7:53:07 AM2/21/17
to OpenWISP
ok, roaming is setup, and initial testing looks extremely promising.....

However, in setting up the access points, some keys need to be added to the wifi-iface section, and i'm not sure how/if it can be done in openwisp....

the keys are in the form of:

list r0kh '.......'
list r1kh '.......

As i can tell, using openwisp we can only insert 'option' keys??

Federico Capoano

unread,
Feb 21, 2017, 8:33:41 AM2/21/17
to OpenWISP
I'm going to reply to both previous emails below (inline).

On Tuesday, February 21, 2017 at 12:14:37 PM UTC+1, mord reneth wrote:

OK, Glad to know i was doing something right....

I was just about to ask how to order the templates, when I saw on the configuration page, in small letters at the bottom.....drag and drop the order....Perhaps this could be made a bit bolder....
 

I kept the ints instead of boolean because the documentation i read elsewhere was using int's......i'll change to boolean and try it...
 
boolean in NetJSON will be converted to the appropriate UCI value.

As for optimization......how possible is it to have 'inherited' templates.....so, in my example, Template Router Specific would inherit from Template Roaming..... and therefor not (theoretically) need the duplicate radio and ssid settings.....
 
Interesting idea. Don't know right now how much work would be needed to implement this, but let's keep it in mind.
Probably more people will need this feature.

Also, I havent found anywhere where I can duplicate/copy a template.....is this possible?

There's no copy/duplicate button in the admin, but you can easily copy the NetJSON content from the advanced mode and paste it into a new template.

On Tuesday, February 21, 2017 at 1:53:07 PM UTC+1, mord reneth wrote:
ok, roaming is setup, and initial testing looks extremely promising.....

However, in setting up the access points, some keys need to be added to the wifi-iface section, and i'm not sure how/if it can be done in openwisp....
 
It's easy, once you understand how to do it :-)

In this case you can just add new attributes to the wireless section of the NetJSON.

the keys are in the form of:

list r0kh '.......'
list r1kh '.......

As i can tell, using openwisp we can only insert 'option' keys??

See Including custom lists, there's also a subsection that looks similar to what you need: Wireless list setting example.

If you still can't do it, post the UCI configuration output you need to set and I'll try to help you out.

Federico

mord reneth

unread,
Feb 21, 2017, 10:01:18 AM2/21/17
to OpenWISP
I cant quite see it :D

The link appears to be for openwisp, not openwisp2....Unless its the same??

I think i should be editing schema.py in /env/lib/python3.5/site-packages/netjsonconfig/backends/openwrt

Am I along the right lines?

The UCI i need is:

        list r0kh '12:34:56:78:90:12,123456789012,8a7fcc966ed0691ff2809e1f38c16996'
        list r0kh 'AB:CD:EF:FE:DC:BA,ABCDEFFEDCBA,8a7fcc966ed0691ff2809e1f38c16996'
        list r1kh '12:34:56:78:90:12,12:34:56:78:90:12,8a7fcc966ed0691ff2809e1f38c16996'
        list r1kh 'AB:CD:EF:FE:DC:BA,AB:CD:EF:FE:DC:BA,8a7fcc966ed0691ff2809e1f38c16996'

Federico Capoano

unread,
Feb 21, 2017, 10:41:07 AM2/21/17
to OpenWISP
On Tuesday, February 21, 2017 at 4:01:18 PM UTC+1, mord reneth wrote:
I cant quite see it :D

The link appears to be for openwisp, not openwisp2....Unless its the same??
 
The links (Including custom lists and Wireless list setting example) point to the netjsonconfig documentation, which is the library used behind the scenes by openwisp2 to generate OpenWRT/LEDE UCI configurations.

netjsonconfig read NetJSON in input and returns a router configuration as output.

NetJSON is the thing you are using in the advanced mode.

So by reading those links you can understand what you have to insert in the advanced mode.

I think i should be editing schema.py in /env/lib/python3.5/site-packages/netjsonconfig/backends/openwrt

Am I along the right lines?

No, do not edit files that have been deployed because they will be lost when you upgrade.
 

The UCI i need is:

        list r0kh '12:34:56:78:90:12,123456789012,8a7fcc966ed0691ff2809e1f38c16996'
        list r0kh 'AB:CD:EF:FE:DC:BA,ABCDEFFEDCBA,8a7fcc966ed0691ff2809e1f38c16996'
        list r1kh '12:34:56:78:90:12,12:34:56:78:90:12,8a7fcc966ed0691ff2809e1f38c16996'
        list r1kh 'AB:CD:EF:FE:DC:BA,AB:CD:EF:FE:DC:BA,8a7fcc966ed0691ff2809e1f38c16996'

I need the entire config directive, what is this, a wifi-iface? Could you paste the entire block (anonymizing sensitive data)? 

mord reneth

unread,
Feb 21, 2017, 11:37:58 AM2/21/17
to OpenWISP
Ahhh....so i should simply be putting it straight into json advanced mode?

ok, here's an example of a entire block

config wifi-iface 'wifi_wlan0'
        list r0kh '12:34:56:78:90:12,123456789012,8a7fcc966ed0691ff2809e1f38c16996'
        list r0kh 'AB:CD:EF:FE:DC:BA,ABCDEFFEDCBA,8a7fcc966ed0691ff2809e1f38c16996'
        list r1kh '12:34:56:78:90:12,12:34:56:78:90:12,8a7fcc966ed0691ff2809e1f38c16996'
        list r1kh 'AB:CD:EF:FE:DC:BA,AB:CD:EF:FE:DC:BA,8a7fcc966ed0691ff2809e1f38c16996'
        option ifname 'wlan0'
        option disabled '0'
        option encryption 'psk2'
        option isolate '0'
        option key 'doesitmatter'
        option wmm '1'
        option macfilter 'disable'
        option network 'lan'
        option nasid '123456789012'
        option wds '0'
        option hidden '0'
        option ieee80211r '1'
        option ssid 'somewhere'
        option r1_key_holder '123456789012'
        option pmk_r1_push '1'
        option mobility_domain 'dead'
        option device 'radio0'
        option mode 'ap'


Just to add another question into the same thread...... nasid, r1_key_holder, and the parts of r0kh/r1kh are the router's BSSID......any way to automate/generate those entries automatically?

Federico Capoano

unread,
Feb 21, 2017, 12:46:14 PM2/21/17
to OpenWISP
See below
Try with the following NetJSON:

{
    "interfaces": [
        {
            "type": "wireless",
            "name": "wlan0",
            "wireless": {
                "network": [
                    "lan"
                ],
                "mode": "access_point",
                "radio": "radio0",
                "ssid": "somewhere",
                "hidden": false,
                "wds": false,
                "macfilter": "disable",
                "isolate": false,
                "wmm": true,
                "nasid": "123456789012",
                "ieee80211r": true,
                "r1_key_holder": "123456789012",
                "pmk_r1_push": true,
                "mobility_domain": "dead",
                "r0kh": [
                    "12:34:56:78:90:12,123456789012,8a7fcc966ed0691ff2809e1f38c16996",
                    "AB:CD:EF:FE:DC:BA,ABCDEFFEDCBA,8a7fcc966ed0691ff2809e1f38c16996"
                ],
                "r1kh": [
                    "12:34:56:78:90:12,12:34:56:78:90:12,8a7fcc966ed0691ff2809e1f38c16996",
                    "AB:CD:EF:FE:DC:BA,AB:CD:EF:FE:DC:BA,8a7fcc966ed0691ff2809e1f38c16996"
                ],
                "encryption": {
                    "disabled": false,
                    "protocol": "wpa2_personal",
                    "key": "doesitmatter",
                    "cipher": "auto"
                }
            }
        }
    ]
}

Which should generate the following UCI output:

config wifi-iface 'wifi_wlan0'
option device 'radio0'
option encryption 'psk2'
option hidden '0'
option ieee80211r '1'
option ifname 'wlan0'
option isolate '0'
option key 'doesitmatter'
option macfilter 'disable'
option mobility_domain 'dead'
option mode 'ap'
option nasid '123456789012'
option network 'lan'
option pmk_r1_push '1'
list r0kh '12:34:56:78:90:12,123456789012,8a7fcc966ed0691ff2809e1f38c16996'
list r0kh 'AB:CD:EF:FE:DC:BA,ABCDEFFEDCBA,8a7fcc966ed0691ff2809e1f38c16996'
option r1_key_holder '123456789012'
list r1kh '12:34:56:78:90:12,12:34:56:78:90:12,8a7fcc966ed0691ff2809e1f38c16996'
list r1kh 'AB:CD:EF:FE:DC:BA,AB:CD:EF:FE:DC:BA,8a7fcc966ed0691ff2809e1f38c16996'
option ssid 'somewhere'
option wds '0'
option wmm '1'

Just to add another question into the same thread...... nasid, r1_key_holder, and the parts of r0kh/r1kh are the router's BSSID......any way to automate/generate those entries automatically?

MM.. I don't think so unfortunately, but it would be a great feature, we already discussed a similar feature in another thread which I called "Generator template".

Federico Capoano

unread,
Feb 21, 2017, 12:51:32 PM2/21/17
to OpenWISP
this google groups thing really sucks for pasting code snippets, if you get the code examples not formatted properly via email take a look at the web interface:

--
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.

mord reneth

unread,
Feb 21, 2017, 1:08:49 PM2/21/17
to OpenWISP
Ok, That works fine.

I've just noticed how to do that via the gui...... You add an object properties as an array..... ;)

2 points i'd like to make from this:

1. If you add the array/items via NetJSON, after you've saved it, and reopen the template....The array/items appear in the template, but not in object properties.....by design or bug?

2. If you add an object in one template, would it be possible/useful for that object to be available in all templates?

Federico Capoano

unread,
Feb 21, 2017, 2:07:28 PM2/21/17
to mord reneth, OpenWISP
Il mar 21 feb 2017, 19:08 mord reneth <mordr...@gmail.com> ha scritto:
Ok, That works fine.

I've just noticed how to do that via the gui...... You add an object properties as an array..... ;)

Glad you made it!

2 points i'd like to make from this:

1. If you add the array/items via NetJSON, after you've saved it, and reopen the template....The array/items appear in the template, but not in object properties.....by design or bug?

I haven't understood exactly how to replicate this behaviour, could you explain? So I can verify.

2. If you add an object in one template, would it be possible/useful for that object to be available in all templates?

Not easy to implement this.

The best alternative is to implement a custom backend inheriting from the OpenWrt backend and add the properties you need in its schema, but there's no comprehensive documentation right now, apart from some fragments scattered around.

mord reneth

unread,
Feb 21, 2017, 2:59:21 PM2/21/17
to OpenWISP

1. If you add the array/items via NetJSON, after you've saved it, and reopen the template....The array/items appear in the template, but not in object properties.....by design or bug?

I haven't understood exactly how to replicate this behaviour, could you explain? So I can verify.

I mean:



 

Federico Capoano

unread,
Feb 21, 2017, 5:05:25 PM2/21/17
to mord reneth, OpenWISP

Oh.. I know what's happening, that's the object properties button for the encryption settings, look for the button for the wireless settings.

Annoying.. A better JSON-schema autogenerated UI would be very helpful.


--

mord reneth

unread,
Feb 22, 2017, 12:38:46 AM2/22/17
to OpenWISP
Ah, I see now....

Instead of user-created objects being after Mac Filter, they are completely last on the object properties 'table', therefore rendered bottom after wireless settings.

Makes sense programatically, but not to us mere mortals :)

Federico Capoano

unread,
Mar 7, 2017, 6:37:32 AM3/7/17
to OpenWISP
Regarding the following statement:


On Tuesday, February 21, 2017 at 11:26:16 AM UTC+1, Federico Capoano wrote:
When using multiple templates, their order is important. Templates coming after override templates that come first (I just noticed I did not explain this properly in the netjsonconfig documentation).

I've updated the documentation to mention template overriding:

Federico
Reply all
Reply to author
Forward
0 new messages