openwisp / netjsonconfig Goto Github PK
View Code? Open in Web Editor NEWNetwork configuration management library based on NetJSON DeviceConfiguration
Home Page: https://netjsonconfig.openwisp.org/
License: Other
Network configuration management library based on NetJSON DeviceConfiguration
Home Page: https://netjsonconfig.openwisp.org/
License: Other
Add support for ip rules in NetworkRenderer
A special renderer can convert any custom section of a netjson DeviceConfiguration
object to UCI config files. We could call this something like CustomOptionsRenderer
, OptionsRenderer
or something similar.
When the OpenWISP Firmware backend will be added (#18) the project will need a dedicated documentation website in order to properly explain the usage of the two backends.
Special cases that really need to be documented:
bridge_members
have been definedmode
attribute of file inclusion featureFilling in more "description" properties will help to explain what each properties does
and can help out in autogenerating UI help texts.
The NetJSON spec defines both.
It's necessary to improve the schema for radio settings.
The simplest approach is to enable different channels depending on the 802.11 version.
eg:
Add support for bridges in NetworkRenderer
"address" and "mask" must be required when "proto" is "static".
Add support for switch configuration in NetworkRenderer, using custom NetJSON attributes.
At the moment it is not possible to set the ula_prefix config option in the network global settings.
This commit contains a possible implementaton:
gonrin@1b754c4#diff-8202435b9cd4328371855d928459ef29R15
Add support for encryption in wireless
The wireless section should be an object, not an array (the NetJSON spec needs to be fixed).
Multiple SSIDs should be defined by defining more wireless interfaces.
Wireless interfaces in /etc/config/wireless
should contain the ifname
attribute.
The backend should be able to replicate the configuration generated by OpenWISP Manager.
Options of type "list" should be supported in each renderer.
When configuring an 802.11s interface, the validation will complain that SSID is missing, but the SSID setting is not used by 802.11s.
Including files in the render
method output would be useful to preview the results of the conversion.
The problem is this would make the UCI output invalid, but this can be dealt with by clearly separating the two sections so that the files can be easily removed programmatically if ever needed.
The routing schema of the OpenWrt
backend is pretty basic, it would be better to add the remaining OpenWRT route options to be consistent with all the other features.
This is a consequence of #32, since generate() won't be writing to disk anymore we should provide a method to write to disk that requires a name
and a path
.
File modes needs a default value and a regexp.
The OpenWrt backend should have a method that generates a tar.gz which should be importable in OpenWrt:
sysupgrade -r <archive>
Trying different combinations with bridges yelds very strange (and wrong) results.
Generation of bridged interfaces must be improved.
__find_bridges
idea is quite a bad one. It would be better to remove that code altoghether and find a simpler solution./etc/config/network
./etc/config/wireless
the attached networks can be defined with a custom attribute, like networks
.bridge_members
Interfaces with no addresses should not be entirely ignored.
Eg:
{
"interfaces": [
{
"name": "eth0",
"type": "ethernet"
}
]
}
should generate:
package network
config interface 'eth0'
option ifname 'eth0'
option proto 'none'
utils.merge_dict
should not modify existing data structures but always return a copy instead.
The only way to add strings containing new lines in JSON is to use the escaped form \n
.
Therefore to add a file with multiple lines in netjsonconfig now one has to do:
{
"files": [
{
"path": "/root/.ssh/authorized_keys",
"contents": "sshkey1\nsshkey2\nsshkey3"
}
]
}
It would be nice to add support to an array representation, each element of the array representing a line of a file:
{
"files": [
{
"path": "/root/.ssh/authorized_keys",
"contents": [
"sshkey1",
"sshkey2",
"sshkey3"
]
}
]
}
This would also improve readability a great deal.
The following would do:
Possible usage:
netjsonconfig --backend openwrt --method render <file>
Pass JSON string directly:
netjsonconfig -b openwrt -m render "<JSON>"
Consider the following:
{
"disabled": true,
"name": "wlan0",
"type": "wireless",
"wireless": {
"radio": "radio0",
"mode": "station",
"ssid": "mywifi"
}
}
One would expect that since the interface is disabled, the wifi interface won't be brought up.
Unfortunately that is not the case, because WirelessRenderer
does not inherit this attribute.
rename project to netjsonconfig
Use tab instead of spaces in generated UCI files
Validate the config attribute against the JSON Schema, this library should do:
This causes problems in consumer apps.
It would be better to return the tar.gz in memory.
ciphers
should be handled automatically when selecting the encryption setting, but it should be possible to override it.
It should also appear in the OpenWRT schema, because other firmwares do not give such a granular control.
Currently there's no "none" choice for encryption, which makes it a bit harder to choose "no encryption" when using autogenerated UIs.
A "none" option is needed, but this will require combining more schemas.
Add support for led config in SystemRenderer
tx_power
is required, but every hardware has a default value, therefore it's more convenient to make this property not required.
Since this library will only deal with NetJSON DeviceConfiguration
objects, we should not require config params to pass { "type": "DeviceConfiguration" }
because it's a waste of time.
Therefore we should allow this:
o = OpenWrt({
"interfaces": [
{
"name": "eth0",
"type": "ethernet",
"addresses": [
{
"proto": "dhcp",
"family": "ipv4"
}
]
}
]
})
the actual required config will still be valid:
o = OpenWrt({
"type": "DeviceConfiguration",
"interfaces": [
{
"name": "eth0",
"type": "ethernet",
"addresses": [
{
"proto": "dhcp",
"family": "ipv4"
}
]
}
]
})
Add support for ntp in general (/etc/config/system)
Add support for multiple SSIDs in WirelessRenderer (NetJSON spec needs to be updated).
We need a way to include arbitrary only (text) files in configuration packages.
The files should be contained in the generated archive but not in the render output (which would make the configuration output invalid).
Some generated configuration items do not have a logical name which can cause issues when some specific configurations need to be referenced.
This causes problems especially when the generated configurations are merged on the devices, because merging unnamed configurations causes duplicates (see also openwisp/openwisp-config#17).
Dates in the configuration archive are not set (default to beginning of the unix epoch).
It would be better to set the date to the time at which they were generated.
Some attributes are missing from the OpenWrt backend doc page.
This library should be licensed as GPLv3 as it could be a desirable feature to include in proprietary software, but we do not want proprietary software to take advantage of this kind of feature without contributing back in some way.
See python-jsonschema: Validating Format.
With this we can enforce valid hostnames, ipv4, ipv6, and probably ipv4 and ipv6 networks too.
See netjson/netjson#36 and netjson/netjson#37.
The following code triggers this exception, but only when the library is installed via pypi, the exception is not raised if installed with setup.py develop
.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.