bootstrap-vz/remote/ssh_wrapper.py
Anders Ingemann e271f3e49a Initial work on integration testing started.
The work consists of three parts:
* Allow for bootstrapping remotely,
  this makes it possible to run the tests
  on e.g. OSX with VirtualBox installed
* Make bootstrapping a fully automated process
  where the manifests can be generated by the tests
  and the tests can call the bootstrapper directly in python
* Create a framework wherein instances can be booted up
  using the bootstrapped images and subsequently tested
2015-04-16 22:15:17 +02:00

28 lines
985 B
Python

class RemoteServer(object):
def __init__(self):
import random
self.server_port = random.randrange(1024, 65535)
self.client_port = random.randrange(1024, 65535)
def start(self):
import subprocess
command = ['ssh', '-i', '/Users/anders/.vagrant.d/insecure_private_key',
'-t', # Force pseudo-tty allocation so that server.py quits when we close the connection
'-p', '2222',
'-L' + str(self.server_port) + ':localhost:' + str(self.server_port),
'-R' + str(self.client_port) + ':localhost:' + str(self.client_port),
'vagrant@localhost',
'--',
'sudo', '/root/bootstrap/remote/server.py',
'--listen-port', str(self.server_port),
'--callback-port', str(self.client_port)]
self.process = subprocess.Popen(args=command)
import time
time.sleep(2)
def stop(self):
self.process.terminate()