hetzner: Fix type for prefixLength in net_info.

This actually was an oversight from the pretty-printer branch during a
last-minute fix. Luckily the VM test is covering this and properly
failed:

http://hydra.nixos.org/build/5965297

Signed-off-by: aszlig <aszlig@redmoonstudios.org>
Fix show-physical --backup.
Fix show-physical --backup output in case there is no snapshot available.
Use /* */ style comments. Thanks aszlig
Added release date for 1.1
Set higher memory for coordinator in hetzner backend test.
Wrap nixops with the openssh of the system it is building for.
Fix dhcpcd in VirtualBox

Mixing "jobs" and "systemd.services" has the side-effect of setting
"Type=oneshot".  This causes dhcpcd to stay in the "activating" phase
forever.
release: Add paramiko to dependencies.

So, this marks the start of moving from subprocess based OpenSSH calls
over to a more native approach, namely the Paramiko library.

Signed-off-by: aszlig <aszlig@redmoonstudios.org>
Add basic unit tests for the new SSH class.

We're going to refactor the class so let's begin by providing some basic
test cases and work on the implementation.

Obviously this makes running the test cases using setup.py fail and thus
the Hydra build product won't succeed as well.

In this new test case we're setting up a small dummp SSH server using
Paramiko, connect to the server and try various commands. Of course at
the moment, we only have two tests, because we need to replace
SSH.run_command().

Signed-off-by: aszlig <aszlig@redmoonstudios.org>
MachineState: Refactor copy_closure_to().

This now should not need the Perl version anymore and will use calls to
nix-store directly instead of passing OpenSSH flags to an external
program.

Of course, this is only a basic version and it won't print the paths as
they're moved onto the target machine, but let's improve that later.

Signed-off-by: aszlig <aszlig@redmoonstudios.org>
ssh_util: Restructure and refactor SSH class.

The SSH class now only is one main class with a connect() method that's
returning a SSHConnection instance. Of course this looks pointless right
now, but that way we can easily implement connection pooling later,
without those dirty hacks like register_*_fun(), which add unnecessary
references to the SSH instance and thus could prevent it from being
garbage collected.

In addition, we now no longer need the SSHMaster process stuff anymore
(which is one of the primary reasons for switching to Paramiko) and the
SSHConnection stays open for further requests until it is either closed
directly or by the pooling functionality (as soon as it's implemented).

Now the downside is that we need to pass more arguments tu methods of
SSHConnection, but that's actually a good thing because we can clearly
separate it from the rest of the code.

And of course, this implementation is neither correctly working at the
moment, nor is it complete. So we have more work ahead.

Signed-off-by: aszlig <aszlig@redmoonstudios.org>
ssh_util: Correctly accumulate stdin buffer.

After reading from the stdin string or file instance, check whether the
send() call to the channel really sent all data. And if not, buffer up
data until we have sent everything.

That way we should no longer have gaps inside the input data and the
unit tests now succeed.

Signed-off-by: aszlig <aszlig@redmoonstudios.org>
ssh_util: Avoid reading if stdout is not ready.

This happens only if we have stderr data that's bigger than the buffer
size and there is no data on stdout in-between.

Of course, also add tests to ensure something like this won't happen
again.

Signed-off-by: aszlig <aszlig@redmoonstudios.org>
logger: Add a new log_raw() method.

This methods automatically detects newlines and splits logging output
accordingly, so we don't have to fuzz around with log_start() and
log_end() outside of the Logger.

Signed-off-by: aszlig <aszlig@redmoonstudios.org>
ssh_util: Use callback instead of Logger instance.

This should make SSH completely decoupled from anything that has to do
with Logger and we now have a more lightweight way of logging _and_
testing because we can even provide a function that just captures stderr
instead of actually logging it.

Signed-off-by: aszlig <aszlig@redmoonstudios.org>
ssh_util: Stop send/recv if channel is closed.

This is something which happens if you - for example - issue a reboot
command on the remote machine. There is no EOF happening and instead the
channel is just closed.

Signed-off-by: aszlig <aszlig@redmoonstudios.org>
MachineState: Adapt to use refactored ssh_util.

This now should get us into a (more or less) working state again and we
can actually deploy machines using the new implementation.

Signed-off-by: aszlig <aszlig@redmoonstudios.org>
ssh_util: Implement and integrate SFTP.

This allows for basic uploading and downloading of files, though not
recursively. It also provides an open() method, to manipulate files on
the remote side as if they were local.

Signed-off-by: aszlig <aszlig@redmoonstudios.org>
ssh_util: Turn open() into a context manager.

The previous approach closed the SFTPClient too early. And before
creating hacky solutions for that, let's use a context manager here.

This should finally fix key uploading.

Signed-off-by: aszlig <aszlig@redmoonstudios.org>