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
diff --git a/tempest/common/utils/linux/remote_client.py b/tempest/common/utils/linux/remote_client.py
index fa59e14..a2315b5 100644
--- a/tempest/common/utils/linux/remote_client.py
+++ b/tempest/common/utils/linux/remote_client.py
@@ -16,7 +16,6 @@
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 @@
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)