Rewrite RemoteClient.get_boot_time()

This is doing conversion between time formats, while we could really
just stay in seconds. This also fixes the method to work for cirros,
which doesn't know about human readable time formats.

Change-Id: Id123d71adb29d169a26f0dde6af00f292fe61d09
Closes-Bug: #1244823
This commit is contained in:
Vincent Untz 2014-01-18 10:56:00 +01:00
parent c7c332e713
commit 3c0b5b90b5

View File

@ -16,7 +16,6 @@ import re
import time
from tempest.common.ssh import Client
from tempest.common import utils
from tempest import config
from tempest.exceptions import ServerUnreachable
@ -78,11 +77,10 @@ class RemoteClient():
return output
def get_boot_time(self):
cmd = 'date -d "`cut -f1 -d. /proc/uptime` seconds ago" \
"+%Y-%m-%d %H:%M:%S"'
boot_time_string = self.ssh_client.exec_command(cmd)
boot_time_string = boot_time_string.replace('\n', '')
return time.strptime(boot_time_string, utils.LAST_REBOOT_TIME_FORMAT)
cmd = 'cut -f1 -d. /proc/uptime'
boot_secs = self.ssh_client.exec_command(cmd)
boot_time = time.time() - int(boot_secs)
return time.localtime(boot_time)
def write_to_console(self, message):
message = re.sub("([$\\`])", "\\\\\\\\\\1", message)