From 0dba6321d7f91655022d82db62bd1169358d89cb Mon Sep 17 00:00:00 2001 From: Michael Drake Date: Thu, 10 Sep 2015 12:55:14 +0000 Subject: Remove VM host known_hosts updating. --- scripts/release-test-os | 60 +++++-------------------------------------------- 1 file changed, 6 insertions(+), 54 deletions(-) diff --git a/scripts/release-test-os b/scripts/release-test-os index 5dd9769e..dacbf791 100755 --- a/scripts/release-test-os +++ b/scripts/release-test-os @@ -42,27 +42,11 @@ class TimeoutError(cliapp.AppException): def __init__(self, msg): super(TimeoutError, self).__init__(msg) - -class VMHost(object): - - def __init__(self, user, address): - self.user = user - self.address = address - - @property - def ssh_host(self): - return '{user}@{address}'.format(user=self.user, address=self.address) - - def runcmd(self, *args, **kwargs): - cliapp.ssh_runcmd(self.ssh_host, *args, **kwargs) - - class DeployedSystemInstance(object): - def __init__(self, deployment, host_machine, ip_addr, hostname): + def __init__(self, deployment, ip_addr, hostname): self.deployment = deployment self.ip_address = ip_addr - self.host_machine = host_machine self.hostname = hostname @property @@ -159,35 +143,12 @@ class DeployedSystemInstance(object): class Deployment(object): - def __init__(self, host_machine, net_id, image_file, flavour): - self.host_machine = host_machine + def __init__(self, net_id, image_file, flavour): self.net_id = net_id self.image_file = image_file self.flavour = flavour - @staticmethod - def _ssh_host_key_exists(hostname): - """Check if an ssh host key exists in known_hosts""" - filename = os.path.expanduser('~/.ssh/known_hosts') - if not os.path.exists(filename): - return False - with open(filename, 'r') as known_hosts: - return any(line.startswith(hostname) for line in known_hosts) - - def _update_known_hosts(self): - if not self._ssh_host_key_exists(self.host_machine.address): - filename = os.path.expanduser('~/.ssh/known_hosts') - print("No known_hosts: ensuring path"); - if not os.path.exists(os.path.dirname(filename)): - os.makedirs(os.path.dirname(filename)) - with open(filename, 'a') as known_hosts: - print("Generating known_hosts"); - cliapp.runcmd(['ssh-keyscan', self.host_machine.address], - stdout=known_hosts) - def deploy(self): - self._update_known_hosts() - hostname = str(uuid.uuid4()) # Deploy the image to openstack @@ -250,8 +211,7 @@ class Deployment(object): # Print the IP address print "IP address for instance %s: %s" % (hostname, ip_addr) - return DeployedSystemInstance(self, self.host_machine, - ip_addr, hostname) + return DeployedSystemInstance(self, ip_addr, hostname) class ReleaseApp(cliapp.Application): @@ -260,10 +220,6 @@ class ReleaseApp(cliapp.Application): def add_settings(self): """Add the command line options needed""" group_main = 'Program Options' - self.settings.string(['os-host'], - 'HOST that VMs can be deployed to', - default=None, - group=group_main) self.settings.string(['net-id'], 'Openstack network ID', default=None, @@ -301,11 +257,7 @@ class ReleaseApp(cliapp.Application): def deploy_and_test_systems(self, tests): """Run the deployments and tests""" - # TODO: Don't assume root is the user we ssh to for tests - host_machine = VMHost('root', self.settings['os-host']) - - deployment = Deployment(host_machine, - self.settings['net-id'], + deployment = Deployment(self.settings['net-id'], self.settings['image-file'], self.settings['flavour']) @@ -317,12 +269,12 @@ class ReleaseApp(cliapp.Application): def process_args(self, args): """Process the command line args and kick off the builds/tests""" - for setting in ('os-host', 'net-id', 'image-file', 'flavour'): + for setting in ('net-id', 'image-file', 'flavour'): self.settings.require(setting) if len(args) == 0: raise cliapp.AppException( - 'Usage: release-test-os --os-host --net-id --image-file --flavour ...') + 'Usage: release-test-os --net-id --image-file --flavour ...') self.deploy_and_test_systems(args) -- cgit v1.2.1