openwisp / openwisp/openwisp-controller
[controller] Device name changed by a template is not updated in the device model instance
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 773
- Forks
- 315
- Avg merge
- 2d 16h
- Merged PRs (30d)
- 14
Description
We have a template to change the device hostname based on the location where it's in use:
{
"system": [
{
"config_name": "system",
"config_value": "system",
"hostname": "{{ LOCATION_NAME }}"
}
]
}
There's one issue with this, though:
The device name in the device model instance is not updated because:
- it is not sent to the controller by
openwisp-config, for example byupdate_info: https://github.com/openwisp/openwisp-config/blob/master/openwisp-config/files/openwisp.agent#L353 - it's not included in
UPDATABLE_FIELDS: https://github.com/openwisp/openwisp-controller/blob/64598a775d641d706da4ac22cf5ffbd7a3889792/openwisp_controller/config/controller/views.py#L129
I think it's a valid usecase to update the device hostname with a template and thus have this change reflected in the device model instance.
@nemesisdesign What do you think?
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Read openwisp-config/files/openwisp.agent around update_info and openwisp_controller/config/controller/views.py around UPDATABLE_FIELDS. Trace how the templated hostname reaches the controller and device model instance. Done means the model instance reflects the hostname supplied by the template.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- django, python
- Domain
- backend, networking
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100