"""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__)
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: ",
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()
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:
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)