Skip to content
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

[feature] Add support for SNMP credentials #471 #496

Merged
merged 16 commits into from May 17, 2022

Conversation

purhan
Copy link
Contributor

@purhan purhan commented Jun 18, 2021

Closes #471, closes #461

@purhan purhan marked this pull request as draft June 18, 2021 11:16
@purhan purhan self-assigned this Jun 18, 2021
@purhan purhan added this to In progress in [GSoC 2021] Netengine & add SNMP to OpenWISP via automation Jun 18, 2021
@purhan purhan force-pushed the issues/471-snmp-connections branch 3 times, most recently from 8cb6118 to 77ba59f Compare June 28, 2021 14:56
@coveralls
Copy link

coveralls commented Jun 28, 2021

Coverage Status

Coverage increased (+0.007%) to 98.545% when pulling 4dfd03b on issues/471-snmp-connections into 6d07b05 on master.

@pandafy pandafy moved this from In progress to To do in [GSoC 2021] Netengine & add SNMP to OpenWISP Jul 8, 2021
@purhan purhan moved this from To do to In progress in [GSoC 2021] Netengine & add SNMP to OpenWISP Jul 28, 2021
@purhan purhan moved this from In progress to Needs Review in [GSoC 2021] Netengine & add SNMP to OpenWISP Aug 1, 2021
@purhan purhan force-pushed the issues/471-snmp-connections branch from c89c2f7 to 6c1c844 Compare August 1, 2021 16:05
@purhan purhan marked this pull request as ready for review August 1, 2021 17:04
@purhan purhan force-pushed the issues/471-snmp-connections branch 3 times, most recently from cd3c013 to 9594d20 Compare August 2, 2021 17:11
'if enabled, user shall be able to change the '
'management ip of the device manually'
),
)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should not add a new DB column for this.
I think in OpenWISP Monitoring we should remove the field from being readonly, make it readonly with JS unless there's an SNMP check added, in that case we allow to change it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@nemesisdesign but we need some way to track that the user wants to change it, otherwise it will automatically update from the API requests (https://github.com/openwisp/openwisp-controller/pull/496/files#diff-47782e8d264d4907d7893cff2e77b42523d4fb90af8aaef26e78c7a34e996713R75). What do you think?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should not be an issue.. openwrt devices will send the right management IP so we can keep it, non openwrt devices will not send management IP and will be empty.

Please verify the following:

  • modify your openwrt device to not have "management_interface" in /etc/config/openwisp
  • restart openwisp config
  • try setting a custom management IP
  • restart openwisp config again
  • check whether the management IP is modified or not

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@nemesisdesign in that case, the management IP resets to an empty string.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I confirm that the management IP changes after config restarts. I believe this is right. We should add a hint in the admin UI.

"IP address of the management interface configured on the device. The information received from the device will overwrite any changes done here"

Copy link
Member

@nemesifier nemesifier Aug 3, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok thank you @purhan and @pandafy for double checking.

Here's my reasoning.

1. OpenWrt devices running openwisp-config and snmpd

In this case, we can assume the management IP will be set if management_ip is specified correctly in /etc/config/openwisp.

Hence we do not to add code that excludes the management IP update for this case.

2. AirOS devices running only snmp deamon, or OpenWrt running only SNMPd

Management IP will not be set at all, nor reset automatically because openwisp-config is not running.

Hence we do not to add code that excludes the management IP update for this case as well.

This code is not useful

For the reasons explained above I believe this code is not useful.

What should we look for? What would be useful?

I think we should strive for a solution which is general enough so that it can be flexibly used in different cases.

I believe a solution which can work reliably in many cases is the following:

  • allow the field to be writable
  • use JS to make it readonly by default, but provide two buttons: one to clear the management IP and one to edit it
    • clear action just resets it to empty string
    • edit action will allow the user to changethe value
  • make the help text more detailed, something like @pandafy indicated, eg:

This is the IP address used by OpenWISP to reach the device when performing any type of push operation or active check. The value of this field is generally sent by the device and hence does not need to be changed, but can be changed or cleared manually if needed.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@nemesisdesign @pandafy Do you think perhaps a clear ip button is redundant? If the user wants to reset it, they can just edit it to be empty? This is how I have made it for now but I can change if you say so.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will check and let you know.

This comment was marked as resolved.

openwisp_controller/connection/connectors/snmp.py Outdated Show resolved Hide resolved
openwisp_controller/connection/connectors/snmp.py Outdated Show resolved Hide resolved
openwisp_controller/connection/connectors/snmp.py Outdated Show resolved Hide resolved
openwisp_controller/connection/base/models.py Outdated Show resolved Hide resolved
openwisp_controller/connection/base/models.py Outdated Show resolved Hide resolved
@purhan purhan force-pushed the issues/471-snmp-connections branch from 61a3938 to e90597d Compare August 3, 2021 10:52
Copy link
Member

@pandafy pandafy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In a review earlier Federico suggested to update the help text for management IP. That is missing from this PR.

This is the IP address used by OpenWISP to reach the device when performing any type of push operation or active check. The value of this field is generally sent by the device and hence does not need to be changed, but can be changed or cleared manually if needed

Instead of adding a big button like below,
Screenshot from 2021-08-11 16-27-00

I would prefer a small icon that goes well with rest of Django's admin

image

@purhan if you are not already working with the new these, please pull those changes from the master branch.

openwisp_controller/config/utils.py Outdated Show resolved Hide resolved
openwisp_controller/config/static/config/js/tabs.js Outdated Show resolved Hide resolved
@pandafy
Copy link
Member

pandafy commented Aug 11, 2021

Thinking out loud here

Instead of toggilng between a div and an input field. We can render the management ip field as a disabled field, just like UUID.
When a user clicks on edit icon, it will enable the field.

When the field is editable, two options should be shown to the user, one to cancel the operation and other to save the value.

Cancel function is self explanatory: revert changes and make the field disabled again.

Save function will create a PATCH request which will only update the management IP of the device on the server. If the operation is successful, the updated value is reflected in the field and the field get disabled again,

Use of disabled input field is just for making development and maintenance easier. We can also stick with the currently implement with div if that looks nicer to your eyes.

The other part regarding PATCH request occurred to me, since it was not very intuitive that I will need to click the "Save" button on the top/bottom of the page to save the value I entered in the new field that just appeared.

Second thoughts, instead of making a PATCH request the save function could trigger "Save and continue editing" operation which already exists in Django admin.

What do you think @purhan and @nemesisdesign ?

Copy link
Member

@nemesifier nemesifier left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In a review earlier Federico suggested to update the help text for management IP. That is missing from this PR.

This is the IP address used by OpenWISP to reach the device when performing any type of push operation or active check. The value of this field is generally sent by the device and hence does not need to be changed, but can be changed or cleared manually if needed

Instead of adding a big button like below,
Screenshot from 2021-08-11 16-27-00

I would prefer a small icon that goes well with rest of Django's admin

image

@purhan if you are not already working with the new these, please pull those changes from the master branch.

New theme you meant @pandafy?
@purhan I agree with Gagan, an edit icon is going to be consistent with the rest of the admin.

Thinking out loud here

Instead of toggilng between a div and an input field. We can render the management ip field as a disabled field, just like UUID.
When a user clicks on edit icon, it will enable the field.

When the field is editable, two options should be shown to the user, one to cancel the operation and other to save the value.

Cancel function is self explanatory: revert changes and make the field disabled again.

Save function will create a PATCH request which will only update the management IP of the device on the server. If the operation is successful, the updated value is reflected in the field and the field get disabled again,

Use of disabled input field is just for making development and maintenance easier. We can also stick with the currently implement with div if that looks nicer to your eyes.

The other part regarding PATCH request occurred to me, since it was not very intuitive that I will need to click the "Save" button on the top/bottom of the page to save the value I entered in the new field that just appeared.

Second thoughts, instead of making a PATCH request the save function could trigger "Save and continue editing" operation which already exists in Django admin.

What do you think @purhan and @nemesisdesign ?

@pandafy @purhan I think we should keep this simple for now and what Purhan is doing is good enough to start using it.
I suggest focusing on refining the backend and networking features because once we get those right we can kind of forget about them for a while, the UI is something which makes sense to improve only once the feature gains more usage and we're really sure the time invested in it is worth it.

@purhan purhan force-pushed the issues/471-snmp-connections branch from df510ed to 02755ae Compare August 11, 2021 17:51
Copy link
Member

@pandafy pandafy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good work Purhan!

Few minor changes are requested regarding UI. With them, this should be complete.

Copy link
Member

@nemesifier nemesifier left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok we are on the right track! 👍

I see one problem though: it is possible to set a management IP which is already taken, which will be an issue. I am have created a dedicated issue (#523) because it's a non-blocking issue, I mean that we can continue testing and iterating this feature also without validation, but validation will be needed for real usage.

See my comments below. Once those are solved I think we can merge so I can deploy this to a staging system and we can start testing the feature.

README.rst Outdated Show resolved Hide resolved
'if enabled, user shall be able to change the '
'management ip of the device manually'
),
)

This comment was marked as resolved.

openwisp_controller/connection/base/models.py Show resolved Hide resolved
openwisp_controller/config/static/config/js/device.js Outdated Show resolved Hide resolved
openwisp_controller/config/static/config/js/device.js Outdated Show resolved Hide resolved
openwisp_controller/connection/base/models.py Show resolved Hide resolved
openwisp_controller/connection/settings.py Outdated Show resolved Hide resolved
openwisp_controller/connection/settings.py Outdated Show resolved Hide resolved
README.rst Outdated Show resolved Hide resolved
purhan and others added 6 commits May 3, 2022 11:59
@Aryamanz29 Aryamanz29 force-pushed the issues/471-snmp-connections branch from 8b0fe68 to 0b8c234 Compare May 3, 2022 06:59
@Aryamanz29 Aryamanz29 requested a review from nemesifier May 3, 2022 07:13
@nemesifier nemesifier added this to In progress in OpenWISP Priorities for next releases via automation May 3, 2022
@nemesifier nemesifier assigned Aryamanz29 and nemesifier and unassigned purhan May 4, 2022
Copy link
Member

@nemesifier nemesifier left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for updating it @Aryamanz29, I will test it after the release of OpenWISP 22.

Copy link
Member

@nemesifier nemesifier left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Aryamanz29 good progress, see my comments below, I think after those changes this PR is ready.

We should then proceed with openwisp/openwisp-monitoring#309.

Copy link
Member

@nemesifier nemesifier left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I changed the help_text of management_ip in the past migrations and removed 0041_alter_management_ip_help_text.py because I think we can live happily without it.

I found a couple of details which I think can be improved which I didn't see before, should be quick to fix.

openwisp_controller/connection/settings.py Outdated Show resolved Hide resolved
openwisp_controller/connection/settings.py Outdated Show resolved Hide resolved
@Aryamanz29 Aryamanz29 force-pushed the issues/471-snmp-connections branch from bce3a95 to 4dfd03b Compare May 17, 2022 18:11
Copy link
Member

@nemesifier nemesifier left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Almost.. see below.

README.rst Show resolved Hide resolved
@nemesifier nemesifier merged commit ea86343 into master May 17, 2022
OpenWISP Priorities for next releases automation moved this from In progress to Done May 17, 2022
@nemesifier nemesifier deleted the issues/471-snmp-connections branch May 17, 2022 19:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

[feature] Implement an SNMP connector class [feat] Allow setting the management IP from the web UI
5 participants