X-Git-Url: https://gerrit.opnfv.org/gerrit/gitweb?a=blobdiff_plain;f=yardstick%2Fbenchmark%2Fscenarios%2Fcompute%2Fmemload.py;h=93d10c0b5e937ec7fe74f88ba770b3e4930572f7;hb=99abbb424007da2e01762f3c040a39c0157cbe1f;hp=48088f87c8d99efd8117c90347c66efc5f9a3158;hpb=eb527820ddb21081399b27deaacc8a651ea5f06a;p=yardstick.git diff --git a/yardstick/benchmark/scenarios/compute/memload.py b/yardstick/benchmark/scenarios/compute/memload.py index 48088f87c..93d10c0b5 100644 --- a/yardstick/benchmark/scenarios/compute/memload.py +++ b/yardstick/benchmark/scenarios/compute/memload.py @@ -9,10 +9,12 @@ """Memory load and statistics.""" +from __future__ import absolute_import import logging import yardstick.ssh as ssh from yardstick.benchmark.scenarios import base +from six.moves import zip LOG = logging.getLogger(__name__) @@ -47,21 +49,15 @@ class MEMLoad(base.Scenario): def setup(self): """Scenario setup.""" host = self.context_cfg['host'] - user = host.get('user', 'ubuntu') - ssh_port = host.get("ssh_port", ssh.DEFAULT_PORT) - ip = host.get('ip', None) - key_filename = host.get('key_filename', '~/.ssh/id_rsa') - - LOG.info("user:%s, host:%s", user, ip) - self.client = ssh.SSH(user, ip, key_filename=key_filename, - port=ssh_port) + + self.client = ssh.SSH.from_node(host, defaults={"user": "ubuntu"}) self.client.wait(timeout=600) self.setup_done = True def _execute_command(self, cmd): """Execute a command on server.""" - LOG.info("Executing: %s" % cmd) + LOG.info("Executing: %s", cmd) status, stdout, stderr = self.client.execute(cmd) if status: raise RuntimeError("Failed executing command: ", @@ -72,10 +68,10 @@ class MEMLoad(base.Scenario): fields = [] free = {} ite = 0 - average = {'total': 0, 'used': 0, 'free': 0, 'cached': 0, 'shared': 0, - 'buffers': 0} - maximum = {'total': 0, 'used': 0, 'free': 0, 'cached': 0, 'shared': 0, - 'buffers': 0} + average = {'total': 0, 'used': 0, 'free': 0, 'buff/cache': 0, + 'shared': 0} + maximum = {'total': 0, 'used': 0, 'free': 0, 'buff/cache': 0, + 'shared': 0} for row in result.split('\n'): line = row.split() @@ -88,7 +84,7 @@ class MEMLoad(base.Scenario): ite += 1 values = line[1:] if values and len(values) == len(fields): - free[memory] = dict(zip(fields, values)) + free[memory] = dict(list(zip(fields, values))) for entry in free: for item in average: @@ -109,7 +105,7 @@ class MEMLoad(base.Scenario): interval = options.get("interval", 1) count = options.get("count", 1) - cmd = "free -s %s -c %s" % (interval, count) + cmd = "free -c '%s' -s '%s'" % (count, interval) result = self._execute_command(cmd) filtrated_result = self._filtrate_result(result)