Skip to content

Commit

Permalink
Merge pull request #20 from kushaldas/fetch_file_directly
Browse files Browse the repository at this point in the history
Fixes PEP257 issues
  • Loading branch information
kushaldas committed Oct 25, 2018
2 parents 0c65623 + 5824460 commit f22753f
Showing 1 changed file with 5 additions and 12 deletions.
17 changes: 5 additions & 12 deletions ansible_module/conns/qubes.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,7 @@

# this _has to be_ named Connection
class Connection(ConnectionBase):
"""
This is a connection plugin for qubes: it uses qubes-run-vm binary to interact with the containers
"""
"""This is a connection plugin for qubes: it uses qubes-run-vm binary to interact with the containers."""

# String used to identify this Connection class from other classes
transport = 'qubes'
Expand All @@ -80,8 +78,7 @@ def __init__(self, play_context, new_stdin, *args, **kwargs):
self.user = self._play_context.remote_user

def _qubes(self, cmd=None, in_data=None, shell="qubes.VMShell"):
"""
run qvm-run executable
"""run qvm-run executable
:param cmd: cmd string for remote system
:param in_data: data passed to qvm-run-vm's stdin
Expand Down Expand Up @@ -118,15 +115,13 @@ def _qubes(self, cmd=None, in_data=None, shell="qubes.VMShell"):
return p.returncode, stdout, stderr

def _connect(self):
"""
No persistent connection is being maintained.
"""
"""No persistent connection is being maintained."""
super(Connection, self)._connect()
self._connected = True

@ensure_connect
def exec_command(self, cmd, in_data=None, sudoable=False):
""" run specified command in a running QubesVM """
"""Run specified command in a running QubesVM """
super(Connection, self).exec_command(cmd, in_data=in_data, sudoable=sudoable)

display.vvvv("CMD IS: %s" % cmd)
Expand Down Expand Up @@ -154,11 +149,10 @@ def put_file(self, in_path, out_path):
raise RuntimeError('Failed to write target file {0}'.format(out_path))

def fetch_file(self, in_path, out_path):
""" obtain file specified via 'in_path' from the container and place it at 'out_path' """
"""Obtain file specified via 'in_path' from the container and place it at 'out_path' """
super(Connection, self).fetch_file(in_path, out_path)
display.vvv("FETCH %s TO %s" % (in_path, out_path), host=self._remote_vmname)


# We are running in dom0
cmd_args_list = ["qvm-run", "--pass-io", self._remote_vmname, "'cat {0}'".format(in_path)]
with open(out_path, "wb") as fobj:
Expand All @@ -167,7 +161,6 @@ def fetch_file(self, in_path, out_path):
if p.returncode != 0:
raise RuntimeError('Failed to write target file {0}'.format(out_path))


def close(self):
""" Closing the connection """
super(Connection, self).close()
Expand Down

0 comments on commit f22753f

Please sign in to comment.