-
-
Notifications
You must be signed in to change notification settings - Fork 72
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[backward-conversion] Recognize templates #100
Comments
@nemesisdesign please can you give me directives on how to reproduce this issue on my local repo? so that i can better visualize the issue in other to easily get a fix for it. thanks |
Okay, so just to confirm if I have understood it correctly. However, if Am I correct in my understanding of the issue? 😄 |
Kind of a flag, I'd think it more as a function argument. I am not sure you understood the aim of this change. We need to make able OpenWISP to capture the configuration from the devices, so we'll send the full config from the devices to OpenWISP Controller which in turn will call netjsonconfig to understand what to do. Let's start with the more common case, normal updates. The other case is when a device registers. I'm not 100% sure about the solution proposed in this old ticket. I would discuss that further before proceeding. BTW, until this point, have you understood something? |
I think I am able to understand the problem. As of case 2, please correct me if I have misunderstood anything about what we want:
** Note: I am assuming that we convert the configs we received from device to NetJson So, bottom line, we need a function to compare two different DeviceConfigurations and return keys that have different value and store those values. Is my understanding correct? |
@atb00ker: I'll try to explain with some pseudocode. We need to be able to do the following: backend_instance = OpenWrt(
native=tar_gz_fileobj,
config=device.config,
templates=[management_vpn, snmpd]
)
The result should be a
At that point in openwisp-controller we'll just have to do: device.config.config = backend_instance.config
device.config.full_clean()
device.config.save() Is it clearer now? |
@atb00ker But I don't think that's all, is it? I need more input on what I need to do now |
When you say you have taken changes from pull request, I assume you are talking about openwisp/openwisp-config#107 And yes, that's not enough, after this we would need to complete this work in netjsonconfig #152 When that is complete, the next step is taking that release of The blocker from my end & Federico's end is bandwidth, we are not able to get to it, so if you have experience with Django, please test it and see if there are any bugs / problems, if yes, please help us solve them. That's a high level idea of what remains in this. (I think it is a lot of work considering you don't have knowledge about the server.) |
There's an issue with the backward conversion which I did not consider in the beginning.
Imagine the situation in which the configuration of a device is converted to NetJSON and sent to an openwisp2 instance.
Case 1) First registration
The system gets a NetJSON containing the full configuration, which will be inserted in the config field, BUT will override any configuration present in templates that are either set as default or are set in a second step by a user.
Case 2) Updates
Imagine an already registered OpenWRT device. A local user logs in via SSH or luci and updates some configurations. Some magic trick then detects the configuration changes and sends the updated NetJSON full configuration to the server.
Without an appropriate mechanism, the configuration present in templates will be duplicated in the main
config
fieldIn short
The library needs to understand how to handle both cases, in the first, if same configuration keys are present both in the local conf and in templates, the templates win and the local conf values are discarded.
In the second case, local conf values are discarded only if they are equal to the same values present in the values of templates.
Challenges
I'm noting down challenges regarding this task.
Recognize variables
When a configuration is received, if the content of a configuration option matches the content of a variable in a template, it should be recognized as the template, not as a custom local configuration that needs to be stored.
The text was updated successfully, but these errors were encountered: