Skip to content

Commit 102b81e

Browse files
committed
Use juju ssh to reboot machines in acceptance tests
Prior to this change, some of the acceptance tests would use `juju run` to reboot machines. However, the develop branch has removed support for '--machine' from juju run causing these tests to fail. This commit updates the affected tests to use `juju ssh` instead. In addition, this commit also updates assess_container_networking to work with python 3 by changing x.iteritems() to iter(x.items()).
1 parent bb1a75f commit 102b81e

File tree

2 files changed

+17
-7
lines changed

2 files changed

+17
-7
lines changed

acceptancetests/assess_container_networking.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -121,8 +121,8 @@ def make_machines(client, container_types, space):
121121
sargs = []
122122
if space:
123123
sargs = ['--constraints', 'spaces=' + space]
124-
125-
for host, containers in required.iteritems():
124+
125+
for host, containers in iter(required.items()):
126126
for container in containers:
127127
client.juju('add-machine', tuple(['{}:{}'.format(container, host)] + sargs))
128128

@@ -342,9 +342,14 @@ def assess_container_networking(client, types, space):
342342
try:
343343
for host in hosts:
344344
log.info("Restarting hosted machine: {}".format(host))
345-
client.juju(
346-
'run', ('--machine', host, 'sudo shutdown -r +1'))
347-
client.juju('operations', ('--machine', host, '--action', 'juju-run'))
345+
try:
346+
client.juju('ssh', (host, 'sudo shutdown -r now'))
347+
except subprocess.CalledProcessError as e:
348+
if e.returncode != 255:
349+
raise e
350+
log.info("Ignoring `juju ssh` exit status after triggering reboot")
351+
hostname = client.get_status().get_machine_dns_name(host)
352+
wait_for_port(hostname, 22, timeout=240)
348353

349354
log.info("Restarting controller machine 0")
350355
controller_client = client.get_controller_client()

acceptancetests/assess_network_health.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -464,8 +464,13 @@ def reboot_machines(self, client):
464464
self.ssh(client, machine,
465465
'sudo lxc restart {}'.format(' '.join(cont_ids)))
466466
log.info("Restarting machine: {}".format(machine))
467-
client.juju('run', ('--machine', machine,
468-
'sudo shutdown -r now'))
467+
try:
468+
client.juju('ssh', (machine, 'sudo shutdown -r now'))
469+
except subprocess.CalledProcessError as e:
470+
if e.returncode != 255:
471+
raise e
472+
log.info("Ignoring `juju ssh` exit status after triggering reboot")
473+
469474
hostname = client.get_status().get_machine_dns_name(machine)
470475
wait_for_port(hostname, 22, timeout=240)
471476

0 commit comments

Comments
 (0)