diff options
32 files changed, 63 insertions, 65 deletions
diff --git a/cli/job_unittest.py b/cli/job_unittest.py index daec6ab7..3b2677bd 100755 --- a/cli/job_unittest.py +++ b/cli/job_unittest.py @@ -238,7 +238,7 @@ class job_stat_unittest(job_unittest): u'synch_id': None}, u'priority': 1, u'meta_host': None, - u'job': {u'control_file': u"def run(machine):\n\thost = hosts.SSHHost(machine)\n\tat = autotest.Autotest(host)\n\tat.run_test('sleeptest')\n\nparallel_simple(run, machines)", + u'job': {u'control_file': u"def run(machine):\n\thost = hosts.create_host(machine)\n\tat = autotest.Autotest(host)\n\tat.run_test('sleeptest')\n\nparallel_simple(run, machines)", u'name': u'test_sleep', u'control_type': u'Server', u'synchronizing': 0, @@ -398,7 +398,7 @@ class job_stat_unittest(job_unittest): u'host': None, u'priority': 1, u'meta_host': None, - u'job': {u'control_file': u"def run(machine):\n\thost = hosts.SSHHost(machine)\n\tat = autotest.Autotest(host)\n\tat.run_test('sleeptest')\n\nparallel_simple(run, machines)", + u'job': {u'control_file': u"def run(machine):\n\thost = hosts.create_host(machine)\n\tat = autotest.Autotest(host)\n\tat.run_test('sleeptest')\n\nparallel_simple(run, machines)", u'name': u'test_sleep', u'control_type': u'Server', u'synchronizing': 0, @@ -431,7 +431,7 @@ class job_stat_unittest(job_unittest): u'synch_id': None}, u'priority': 1, u'meta_host': None, - u'job': {u'control_file': u"def run(machine):\n\thost = hosts.SSHHost(machine)\n\tat = autotest.Autotest(host)\n\tat.run_test('sleeptest')\n\nparallel_simple(run, machines)", + u'job': {u'control_file': u"def run(machine):\n\thost = hosts.create_host(machine)\n\tat = autotest.Autotest(host)\n\tat.run_test('sleeptest')\n\nparallel_simple(run, machines)", u'name': u'test_sleep', u'control_type': u'Server', u'synchronizing': 0, @@ -453,7 +453,7 @@ class job_stat_unittest(job_unittest): u'synch_id': None}, u'priority': 1, u'meta_host': None, - u'job': {u'control_file': u"def run(machine):\n\thost = hosts.SSHHost(machine)\n\tat = autotest.Autotest(host)\n\tat.run_test('sleeptest')\n\nparallel_simple(run, machines)", + u'job': {u'control_file': u"def run(machine):\n\thost = hosts.create_host(machine)\n\tat = autotest.Autotest(host)\n\tat.run_test('sleeptest')\n\nparallel_simple(run, machines)", u'name': u'test_sleep', u'control_type': u'Server', u'synchronizing': 0, @@ -516,7 +516,7 @@ class job_stat_unittest(job_unittest): u'synch_id': None}, u'priority': 1, u'meta_host': None, - u'job': {u'control_file': u"def run(machine):\n\thost = hosts.SSHHost(machine)\n\tat = autotest.Autotest(host)\n\tat.run_test('sleeptest')\n\nparallel_simple(run, machines)", + u'job': {u'control_file': u"def run(machine):\n\thost = hosts.create_host(machine)\n\tat = autotest.Autotest(host)\n\tat.run_test('sleeptest')\n\nparallel_simple(run, machines)", u'name': u'test_sleep', u'control_type': u'Server', u'synchronizing': 0, @@ -541,7 +541,7 @@ class job_stat_unittest(job_unittest): u'synch_id': None}, u'priority': 1, u'meta_host': None, - u'job': {u'control_file': u"def run(machine):\n\thost = hosts.SSHHost(machine)\n\tat = autotest.Autotest(host)\n\tat.run_test('sleeptest')\n\nparallel_simple(run, machines)", + u'job': {u'control_file': u"def run(machine):\n\thost = hosts.create_host(machine)\n\tat = autotest.Autotest(host)\n\tat.run_test('sleeptest')\n\nparallel_simple(run, machines)", u'name': u'test_sleep', u'control_type': u'Server', u'synchronizing': 0, diff --git a/frontend/afe/control_file.py b/frontend/afe/control_file.py index 49572d70..45602fbb 100644 --- a/frontend/afe/control_file.py +++ b/frontend/afe/control_file.py @@ -31,7 +31,7 @@ kernel_install_control = \""" at = autotest.Autotest() def install_kernel(machine): - host = hosts.SSHHost(machine) + host = hosts.create_host(machine) at.run(kernel_install_control, host=host) job.parallel_simple(install_kernel, machines) diff --git a/server/autotest_unittest.py b/server/autotest_unittest.py index 573e19f1..dde7e2cf 100644 --- a/server/autotest_unittest.py +++ b/server/autotest_unittest.py @@ -4,11 +4,10 @@ __author__ = "raphtee@google.com (Travis Miller)" import unittest, os, tempfile import common -from autotest_lib.server import autotest, utils -from autotest_lib.server.hosts import ssh_host +from autotest_lib.server import autotest, utils, hosts from autotest_lib.client.common_lib import utils as client_utils, packages from autotest_lib.client.common_lib.test_utils import mock -import pdb + class TestBaseAutotest(unittest.TestCase): def setUp(self): @@ -16,7 +15,7 @@ class TestBaseAutotest(unittest.TestCase): self.god = mock.mock_god() # create mock host object - self.host = self.god.create_mock_class(ssh_host.SSHHost, "host") + self.host = self.god.create_mock_class(hosts.RemoteHost, "host") self.host.hostname = "hostname" # stubs diff --git a/server/control_segments/repair b/server/control_segments/repair index 259b6520..21e0c7c5 100644 --- a/server/control_segments/repair +++ b/server/control_segments/repair @@ -39,11 +39,11 @@ def repair(machine): print "Host is specified as 'Do not repair', skipping repair stage" elif level == protection.REPAIR_FILESYSTEM_ONLY: print "Attempting filesystem-only repair" - host = hosts.SSHHost(machine, initialize=False) + host = hosts.create_host(machine, initialize=False) repair_filesystem_only(host) elif level == protection.NO_PROTECTION: print "Attempting full repair" - host = hosts.SSHHost(machine, initialize=False) + host = hosts.create_host(machine, initialize=False) repair_full(host) diff --git a/server/control_segments/verify b/server/control_segments/verify index c2b9336e..42593b0f 100644 --- a/server/control_segments/verify +++ b/server/control_segments/verify @@ -10,7 +10,7 @@ def check_diskspace(host, path, gb): # This needs more stuff in it. Check for diskspace, etc. But it's a start. def verify(machine): print 'Initializing host ' + machine - host = hosts.SSHHost(machine, initialize=False) + host = hosts.create_host(machine, initialize=False) print 'Pinging host ' + machine sys.stdout.flush() host.ssh_ping() diff --git a/server/hosts/bootloader_unittest.py b/server/hosts/bootloader_unittest.py index a6f67561..8dc18a9c 100644 --- a/server/hosts/bootloader_unittest.py +++ b/server/hosts/bootloader_unittest.py @@ -5,8 +5,8 @@ import common from autotest_lib.client.common_lib.test_utils import mock from autotest_lib.client.common_lib import error, utils as common_utils -from autotest_lib.server import utils -from autotest_lib.server.hosts import bootloader, ssh_host +from autotest_lib.server import utils, hosts +from autotest_lib.server.hosts import bootloader class test_bootloader_install(unittest.TestCase): @@ -21,9 +21,9 @@ class test_bootloader_install(unittest.TestCase): self.god.unstub_all() - def create_mock_sshhost(self): - # useful for building disposable SSHHost mocks - return self.god.create_mock_class(ssh_host.SSHHost, "SSHHost") + def create_mock_host(self): + # useful for building disposable RemoteHost mocks + return self.god.create_mock_class(hosts.RemoteHost, "host") def create_install_boottool_mock(self, loader, dst_dir): @@ -37,7 +37,7 @@ class test_bootloader_install(unittest.TestCase): def test_install_fails_without_host(self): - host = self.create_mock_sshhost() + host = self.create_mock_host() loader = bootloader.Bootloader(host) del host self.assertRaises(error.AutoservError, loader.install_boottool) @@ -50,7 +50,7 @@ class test_bootloader_install(unittest.TestCase): BOOTTOOL_SRC = os.path.abspath(BOOTTOOL_SRC) BOOTTOOL_DST = os.path.join(TMPDIR, "boottool") # set up the recording - host = self.create_mock_sshhost() + host = self.create_mock_host() host.get_tmp_dir.expect_call().and_return(TMPDIR) utils.get_server_dir.expect_call().and_return(SERVERDIR) host.send_file.expect_call(BOOTTOOL_SRC, TMPDIR) @@ -65,7 +65,7 @@ class test_bootloader_install(unittest.TestCase): def test_get_path_automatically_installs(self): BOOTTOOL_DST = "/unittest/tmp/boottool" - host = self.create_mock_sshhost() + host = self.create_mock_host() loader = bootloader.Bootloader(host) # mock out loader.install_boottool mock_install = \ @@ -79,7 +79,7 @@ class test_bootloader_install(unittest.TestCase): def test_install_is_only_called_once(self): BOOTTOOL_DST = "/unittest/tmp/boottool" - host = self.create_mock_sshhost() + host = self.create_mock_host() loader = bootloader.Bootloader(host) # mock out loader.install_boottool mock_install = \ @@ -96,8 +96,7 @@ class test_bootloader_install(unittest.TestCase): class test_bootloader_methods(unittest.TestCase): def setUp(self): self.god = mock.mock_god() - self.host = self.god.create_mock_class(ssh_host.SSHHost, - "SSHHost") + self.host = self.god.create_mock_class(hosts.RemoteHost, "host") # creates a bootloader with _run_boottool mocked out self.loader = bootloader.Bootloader(self.host) self.god.stub_function(self.loader, "_run_boottool") diff --git a/server/hosts/guest.py b/server/hosts/guest.py index 8fe6bc2b..812f6736 100644 --- a/server/hosts/guest.py +++ b/server/hosts/guest.py @@ -18,7 +18,7 @@ stutsman@google.com (Ryan Stutsman) """ -import ssh_host +from autotest_lib.server.hosts import ssh_host class Guest(ssh_host.SSHHost): @@ -39,7 +39,7 @@ class Guest(ssh_host.SSHHost): controlling_hypervisor = None - def __init__(self, controlling_hypervisor): + def __init__(self, controlling_hypervisor, *args, **dargs): """ Construct a Guest object @@ -48,15 +48,16 @@ class Guest(ssh_host.SSHHost): responsible for the creation and management of this guest """ - hostname= controlling_hypervisor.new_guest() - super(Guest, self).__init__(hostname) - self.controlling_hypervisor= controlling_hypervisor + hostname = controlling_hypervisor.new_guest() + super(Guest, self).__init__(hostname, *args, **dargs) + self.controlling_hypervisor = controlling_hypervisor def __del__(self): """ Destroy a Guest object """ + super(Guest, self).__del__() self.controlling_hypervisor.delete_guest(self.hostname) diff --git a/server/samples/autoserv_console.srv b/server/samples/autoserv_console.srv index b0c69e61..04bf4534 100755 --- a/server/samples/autoserv_console.srv +++ b/server/samples/autoserv_console.srv @@ -1,5 +1,5 @@ # autoserv_console.srv - gives you an interactive interpreter within an autoserv -# control file. If you pass "-m hostname", an SSHHost will be available under +# control file. If you pass "-m hostname", a RemoteHost will be available under # the variable "host". # If you install IPython (http://ipython.scipy.org/, Ubuntu package "ipython"), @@ -9,7 +9,7 @@ # -Steve Howard (showard@google.com) if machines: - host = hosts.SSHHost(machines[0]) + host = hosts.create_host(machines[0]) try: import IPython diff --git a/server/samples/boottool.srv b/server/samples/boottool.srv index bb96f2d9..b07806af 100644 --- a/server/samples/boottool.srv +++ b/server/samples/boottool.srv @@ -1,4 +1,4 @@ -rh= hosts.SSHHost("192.168.1.1") +rh= hosts.create_host("192.168.1.1") print rh.bootloader.get_titles() default= rh.bootloader.get_default() diff --git a/server/samples/continuous_reboot.srv b/server/samples/continuous_reboot.srv index adbfc435..080e9e2b 100644 --- a/server/samples/continuous_reboot.srv +++ b/server/samples/continuous_reboot.srv @@ -1,5 +1,5 @@ def run(machine): - host = hosts.SSHHost(machine) + host = hosts.create_host(machine) while True: host.reboot() diff --git a/server/samples/deb_kernel.srv b/server/samples/deb_kernel.srv index 993e0def..05c9f348 100644 --- a/server/samples/deb_kernel.srv +++ b/server/samples/deb_kernel.srv @@ -1,4 +1,4 @@ -rh= hosts.SSHHost("192.168.1.1") +rh= hosts.create_host("192.168.1.1") print rh.run("uname -a").stdout diff --git a/server/samples/failtest.srv b/server/samples/failtest.srv index a793e592..373635f6 100644 --- a/server/samples/failtest.srv +++ b/server/samples/failtest.srv @@ -1,5 +1,5 @@ def run(machine): - host = hosts.SSHHost(machine) + host = hosts.create_host(machine) at = autotest.Autotest(host) at.run_test('failtest') diff --git a/server/samples/git_kernel.srv b/server/samples/git_kernel.srv index 7c88bd38..f78f705c 100644 --- a/server/samples/git_kernel.srv +++ b/server/samples/git_kernel.srv @@ -17,7 +17,7 @@ myhostname = 'myhost' kernel = git_kernel.GitKernel(repodir, giturl, weburl) # ssh to remote host -h = hosts.SSHHost(myhostname) +h = hosts.create_host(myhostname) # acquire git repo, make sure it is up-to-date, clone repo into tmp dir kernel.get(h) diff --git a/server/samples/info.srv b/server/samples/info.srv index a5d23502..5bdd2bfc 100644 --- a/server/samples/info.srv +++ b/server/samples/info.srv @@ -1,5 +1,5 @@ def run(machine): - host = hosts.SSHHost(machine, initialize = False) + host = hosts.create_host(machine, initialize = False) print 'Uptime: ' + host.check_uptime() print 'Arch: ' + host.get_arch() print 'Kernel ver: ' + host.get_kernel_ver() diff --git a/server/samples/kernbench.srv b/server/samples/kernbench.srv index a8d84e3c..50e44398 100644 --- a/server/samples/kernbench.srv +++ b/server/samples/kernbench.srv @@ -1,5 +1,5 @@ def run(machine): - host = hosts.SSHHost(machine) + host = hosts.create_host(machine) at = autotest.Autotest(host) at.run_test('kernbench', iterations=2, threads=5) diff --git a/server/samples/kvm.srv b/server/samples/kvm.srv index 4fdbef80..608edee6 100644 --- a/server/samples/kvm.srv +++ b/server/samples/kvm.srv @@ -1,8 +1,8 @@ print "XXXX start of control file" -print "XXXX creating SSHHost object" -remote_host= hosts.SSHHost("192.168.1.1") +print "XXXX creating RemoteHost object" +remote_host= hosts.create_host("192.168.1.1") print "XXXX installing KVM" diff --git a/server/samples/kvm_from_git.srv b/server/samples/kvm_from_git.srv index 7742e52c..27c4f26d 100644 --- a/server/samples/kvm_from_git.srv +++ b/server/samples/kvm_from_git.srv @@ -1,6 +1,6 @@ print "XXXX start of control file" -print "XXXX creating SSHHost object" -remote_host= hosts.SSHHost("myhost") +print "XXXX creating RemoteHost object" +remote_host= hosts.create_host("myhost") print "XXXX installing KVM" kvm_on_remote_host= kvm.KVM(remote_host) diff --git a/server/samples/netperf-guest-to-host-far.srv b/server/samples/netperf-guest-to-host-far.srv index 10ac8c73..2d89dff4 100644 --- a/server/samples/netperf-guest-to-host-far.srv +++ b/server/samples/netperf-guest-to-host-far.srv @@ -17,9 +17,9 @@ def install_kvm(kvm_on_host_var_name, host, source, addresses): "%(var_name)s.install(addresses)\n" % {"var_name": kvm_on_host_var_name}) -print "XXXX creating SSHHost objects" -remote_host1= hosts.SSHHost("192.168.1.1") -remote_host2= hosts.SSHHost("192.168.1.2") +print "XXXX creating RemoteHost objects" +remote_host1= hosts.create_host("192.168.1.1") +remote_host2= hosts.create_host("192.168.1.2") kernel= deb_kernel.DEBKernel() kernel.get("/home/foo/linux-2.6.21.3-3_2.6.21.3-3_amd64.deb") diff --git a/server/samples/parallel.srv b/server/samples/parallel.srv index 24dc1f07..b4be1d3d 100644 --- a/server/samples/parallel.srv +++ b/server/samples/parallel.srv @@ -1,7 +1,7 @@ at = autotest.Autotest() def run(machine): - host = hosts.SSHHost(machine) + host = hosts.create_host(machine) at.run_test('sleeptest', host = host) job.parallel_simple(run, machines) diff --git a/server/samples/parallel_kvm.srv b/server/samples/parallel_kvm.srv index 101b51da..fadf8852 100644 --- a/server/samples/parallel_kvm.srv +++ b/server/samples/parallel_kvm.srv @@ -2,8 +2,8 @@ import os.path print "XXXX start of control file" -print "XXXX creating SSHHost object" -remote_host= hosts.SSHHost("192.168.1.1") +print "XXXX creating RemoteHost object" +remote_host= hosts.create_host("192.168.1.1") print "XXXX installing KVM" diff --git a/server/samples/parallel_sleeptest.srv b/server/samples/parallel_sleeptest.srv index c46353ee..bbc483e2 100644 --- a/server/samples/parallel_sleeptest.srv +++ b/server/samples/parallel_sleeptest.srv @@ -44,7 +44,7 @@ def run_client(at, machine_name, machine_num, instance): at.run(control_new, tag='%s' % tests[instance][1], parallel_flag=True) def main(machine_name, machine_num): - host = hosts.SSHHost(machine_name) + host = hosts.create_host(machine_name) at = autotest.Autotest(host) at.install() diff --git a/server/samples/profilertest.srv b/server/samples/profilertest.srv index 8854e3e2..7f9721e9 100644 --- a/server/samples/profilertest.srv +++ b/server/samples/profilertest.srv @@ -1,6 +1,6 @@ import time -ssh_hosts = [hosts.SSHHost(m, initialize=False) for m in machines] +ssh_hosts = [hosts.create_host(m, initialize=False) for m in machines] at_hosts = [autotest.Autotest(h) for h in ssh_hosts] diff --git a/server/samples/reboot.srv b/server/samples/reboot.srv index 58375703..3f6445b0 100644 --- a/server/samples/reboot.srv +++ b/server/samples/reboot.srv @@ -1,5 +1,5 @@ def run(machine): - host = hosts.SSHHost(machine) + host = hosts.create_host(machine) print host.is_up() host.reboot() diff --git a/server/samples/run_test.srv b/server/samples/run_test.srv index e8b1f36b..f0129de1 100644 --- a/server/samples/run_test.srv +++ b/server/samples/run_test.srv @@ -8,7 +8,7 @@ def usage(): print "usage: -t <test name> -m <machines> -l <log dir>" def run(client): - m = hosts.SSHHost(client) + m = hosts.create_host(client) at = autotest.Autotest() results_dir = os.path.join(logdir, client) diff --git a/server/samples/sleeptest.srv b/server/samples/sleeptest.srv index 85cbf083..a0cbf30d 100644 --- a/server/samples/sleeptest.srv +++ b/server/samples/sleeptest.srv @@ -1,5 +1,5 @@ def run(machine): - host = hosts.SSHHost(machine) + host = hosts.create_host(machine) at = autotest.Autotest(host) at.run_test('sleeptest') diff --git a/server/samples/uname.srv b/server/samples/uname.srv index f67d6260..008cba04 100644 --- a/server/samples/uname.srv +++ b/server/samples/uname.srv @@ -1,4 +1,4 @@ -hosts = [hosts.SSHHost(h, initialize=False) for h in machines] +hosts = [hosts.create_host(h, initialize=False) for h in machines] for host in hosts: print host.hostname diff --git a/server/self-test/machine b/server/self-test/machine index e648bd32..e59d0810 100644 --- a/server/self-test/machine +++ b/server/self-test/machine @@ -1,7 +1,7 @@ import time print "Instantiating a machine object" -m = hosts.SSHHost(machines[0]) +m = hosts.create_host(machines[0]) print "Passed" print diff --git a/server/self-test/remote_cmd b/server/self-test/remote_cmd index a7c1eafd..76e6044a 100644 --- a/server/self-test/remote_cmd +++ b/server/self-test/remote_cmd @@ -1,7 +1,7 @@ import utils print "Instantiating a machine object" -m = hosts.SSHHost(machines[0]) +m = hosts.create_host(machines[0]) print "Passed" print diff --git a/server/self-test/timed_test.srv b/server/self-test/timed_test.srv index d3c4bfa7..235bae3d 100644 --- a/server/self-test/timed_test.srv +++ b/server/self-test/timed_test.srv @@ -1,5 +1,5 @@ def run(machine): - host = hosts.SSHHost(machine) + host = hosts.create_host(machine) at = autotest.Autotest(host) at.run_timed_test('sleeptest', seconds=1, timeout=15) # no exception try: diff --git a/server/source_kernel_unittest.py b/server/source_kernel_unittest.py index 6d05faef..6771b291 100644 --- a/server/source_kernel_unittest.py +++ b/server/source_kernel_unittest.py @@ -3,14 +3,13 @@ import unittest import common from autotest_lib.client.common_lib.test_utils import mock -from autotest_lib.server.hosts import SSHHost -from autotest_lib.server import source_kernel, autotest +from autotest_lib.server import source_kernel, autotest, hosts class TestSourceKernel(unittest.TestCase): def setUp(self): self.god = mock.mock_god() - self.host = self.god.create_mock_class(SSHHost, "host") + self.host = self.god.create_mock_class(hosts.RemoteHost, "host") self.god.stub_class(source_kernel.autotest, "Autotest") self.kernel_autotest = source_kernel.autotest.Autotest.expect_new() self.k = "kernel" diff --git a/server/tests/iperf/control.srv b/server/tests/iperf/control.srv index 0d9c823e..0d43d847 100644 --- a/server/tests/iperf/control.srv +++ b/server/tests/iperf/control.srv @@ -25,8 +25,8 @@ from autotest_lib.server import utils def run(pair): print "running on %s and %s\n" % (pair[0], pair[1]) tagname = "%s_%s" % (pair[0], pair[1]) - server = hosts.SSHHost(pair[0]) - client = hosts.SSHHost(pair[1]) + server = hosts.create_host(pair[0]) + client = hosts.create_host(pair[1]) server_at = autotest.Autotest(server) client_at = autotest.Autotest(client) diff --git a/server/tests/netperf2/control.srv b/server/tests/netperf2/control.srv index 558009ae..80187ace 100644 --- a/server/tests/netperf2/control.srv +++ b/server/tests/netperf2/control.srv @@ -26,8 +26,8 @@ def run(pair, time_limit=600, bandwidth_min=1000, bandwidth_max=1000, print "running on %s and %s\n" % (pair[0], pair[1]) tagname = "%s_%s" % (pair[0], pair[1]) - server = hosts.SSHHost(pair[0]) - client = hosts.SSHHost(pair[1]) + server = hosts.create_host(pair[0]) + client = hosts.create_host(pair[1]) server_at = autotest.Autotest(server) client_at = autotest.Autotest(client) |