diff options
Diffstat (limited to 'nova/virt/powervm/operator.py')
-rw-r--r-- | nova/virt/powervm/operator.py | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/nova/virt/powervm/operator.py b/nova/virt/powervm/operator.py index 18cba0ba2..9d59e7ce4 100644 --- a/nova/virt/powervm/operator.py +++ b/nova/virt/powervm/operator.py @@ -169,6 +169,10 @@ class PowerVMOperator(object): self._host_stats = data + def get_host_uptime(self, host): + """Returns the result of calling "uptime" on the target host.""" + return self._operator.get_host_uptime(host) + def spawn(self, context, instance, image_id, network_info): def _create_image(context, instance, image_id): """Fetch image from glance and copy it to the remote system.""" @@ -626,6 +630,19 @@ class BaseOperator(object): return {'total_mem': int(total_mem), 'avail_mem': int(avail_mem)} + def get_host_uptime(self, host): + """ + Get host uptime. + :returns: string - amount of time since last system startup + """ + # The output of the command is like this: + # "02:54PM up 24 days, 5:41, 1 user, load average: 0.06, 0.03, 0.02" + cmd = self.command.sysstat('-short %s' % self.connection_data.username) + output = self.run_vios_command(cmd) + # parse the sysstat output so we just return the uptime + system_time, uptime = output[0].split(',')[0:2] + return system_time + uptime + def get_cpu_info(self): """Get CPU info. @@ -766,11 +783,11 @@ class BaseOperator(object): def _decompress_image_file(self, file_path, outfile_path): command = "/usr/bin/gunzip -c %s > %s" % (file_path, outfile_path) - output = self.run_vios_command_as_root(command) + self.run_vios_command_as_root(command) # Remove compressed image file command = "/usr/bin/rm %s" % file_path - output = self.run_vios_command_as_root(command) + self.run_vios_command_as_root(command) return outfile_path |