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

openwisp_controller.connection module (SSH connections) #31

Merged
merged 57 commits into from Apr 22, 2019

Conversation

nemesifier
Copy link
Member

@nemesifier nemesifier commented May 6, 2018

WIP, refers to #30

@nemesifier nemesifier self-assigned this May 6, 2018
@nemesifier nemesifier added this to To do (general) in OpenWISP Contributor's Board via automation May 6, 2018
@nemesifier nemesifier moved this from To do (general) to In progress in OpenWISP Contributor's Board May 6, 2018
@okraits
Copy link
Member

okraits commented May 9, 2018

On Debian Stretch, I additionally needed to install redis (from stretch-backports) and libsqlite3-mod-spatialite and add

SPATIALITE_LIBRARY_PATH = 'mod_spatialite'

to settings.py or local_settings.py.

I can create a PR with updated README.rst and settings.py if you want.

@nemesifier
Copy link
Member Author

@okraits not sure travis would work with `SPATIALITE_LIBRARY_PATH = 'mod_spatialite' but we can try

@okraits
Copy link
Member

okraits commented May 9, 2018

@nemesisdesign So should I come up with a PR for the dependencies and settings.py?

Edit: there you are: #33

@coveralls
Copy link

coveralls commented May 9, 2018

Coverage Status

Coverage decreased (-1.09%) to 98.502% when pulling 0b1fd0a on connections into 487f13f on master.

@nemesifier
Copy link
Member Author

I just rebased this branch on the current master.

@nemesifier
Copy link
Member Author

@okraits on the feature side it's basically ready, unfortunately there's no nice widget to enter the credentials (it's a raw text field which expects json syntax now) but shouldn't be hard to add it later, especially once this is ready: openwisp/django-jsonschema-widget#1) in the next weeks I count on adding the missing tests.
CC: @atb00ker this is the first instance in which I want to reuse the jsonschema widget outside of django-netjsonconfig, I'm talking about the admin for the Credentials model



class Ssh(object):
schema = {
Copy link
Member Author

Choose a reason for hiding this comment

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

@atb00ker this is the schema for SSH credentials. In the future we may have other ways to access devices. For example, OpenWrt has an HTTP-RPC API served by ubus. Ubiquiti AirOS also has some sort o HTTP access that allows to update the config via HTTP calls (not sure if they have an API but surely calls to their web interface can be simulated).
That's where we want to get at some point with openwisp/netjsonconfig#91

Copy link
Member

Choose a reason for hiding this comment

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

That seems great. I see a lot of things i need to learn about and i'll start with reading the same.
Thanks. 😄

Copy link
Member

@atb00ker atb00ker left a comment

Choose a reason for hiding this comment

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

Found a small typo here:

print('# Previus command failed, aborting upgrade...')


Available update strategies. An update strategy is a subclass of a
connector class which defines an ``update_config`` method which is
in charge of updating the configuratio of the device.
Copy link
Member

@okraits okraits Dec 28, 2018

Choose a reason for hiding this comment

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

Missing char: configuration

@NoumbissiValere NoumbissiValere force-pushed the connections branch 3 times, most recently from a72b423 to 0d2864f Compare April 15, 2019 18:07
@NoumbissiValere
Copy link
Contributor

@nemesisdesign Please can you review this when you have time? I will love to apply corrections if any exist

out = ''
while stdout.channel.recv_ready():
out += str(stdout.channel.recv(1024))
self.assertIn('openwisp-config restarted', out)
Copy link
Member Author

Choose a reason for hiding this comment

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

you're executing an echo on the mock ssh server and asserting the output, for what purpose?
We need to mock the command /etc/init.d/openwisp-config restart so when that command is executed in the mock ssh server it print that output, so we can then capture the output and run an assertion on it.

Copy link
Contributor

Choose a reason for hiding this comment

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

I myself was not convinced about this test. I was running from executing this comment on the server because from your last comment, you said this command was suppose to be executed during config.full_clean() and config.save().
will try to refine it. Thanks

visible=[data['cred1'].name + ' (SSH)'],
hidden=[data['cred2'].name + ' (SSH)', data['cred3_inactive']],
select_widget=True
)
Copy link
Member Author

Choose a reason for hiding this comment

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

why is this test being removed?

Copy link
Contributor

Choose a reason for hiding this comment

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

This was failing with Python 2.7 on travis, so i removed to deal with the most important issue before coming back to it

@NoumbissiValere NoumbissiValere force-pushed the connections branch 6 times, most recently from 593b9e3 to 54f2480 Compare April 19, 2019 04:52
@NoumbissiValere
Copy link
Contributor

@nemesisdesign please can you review this, have been trying to make the test pass for DJANGO="django>=1.11,<1.12" to no avail. Please can you checkout it and give me an idea. Thanks

@NoumbissiValere
Copy link
Contributor

from https://realpython.com/python-mock-library/ , python2.7 doesn't know unittest.mock so travis was failing with this import. in order to make the import work for both python2 and python 3, from https://stackoverflow.com/questions/11501520/importerror-no-module-named-mock i had to use the backport which is mock rather than unittest.mock. Thus, i had to add mock to setup.py in order to enable travis install it for testing.

@nemesifier nemesifier changed the title openwisp_controller.connection module (work in progress) openwisp_controller.connection module (SSH connections) Apr 22, 2019
@nemesifier nemesifier merged commit 8b18302 into master Apr 22, 2019
OpenWISP Contributor's Board automation moved this from In progress to Done Apr 22, 2019
OpenWISP Priorities for next releases automation moved this from In progress to Done Apr 22, 2019
@atb00ker atb00ker deleted the connections branch January 7, 2020 08:33
@atb00ker atb00ker restored the connections branch January 7, 2020 08:33
@nemesifier nemesifier deleted the connections branch January 9, 2020 18:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Important Higher priority or release blocker
Development

Successfully merging this pull request may close these issues.

None yet

5 participants