5 import yardstick.ssh as ssh
6 from yardstick.benchmark.scenarios import base
8 LOG = logging.getLogger(__name__)
11 class Sfc(base.Scenario):
12 ''' SFC scenario class '''
14 __scenario_type__ = "sfc"
16 PRE_SETUP_SCRIPT = 'sfc_pre_setup.bash'
17 TACKER_SCRIPT = 'sfc_tacker.bash'
18 SERVER_SCRIPT = 'sfc_server.bash'
19 TEARDOWN_SCRIPT = "sfc_teardown.bash"
21 def __init__(self, scenario_cfg, context_cfg):
22 self.scenario_cfg = scenario_cfg
23 self.context_cfg = context_cfg
24 self.setup_done = False
25 self.teardown_done = False
29 self.tacker_script = pkg_resources.resource_filename(
30 'yardstick.benchmark.scenarios.networking',
33 self.server_script = pkg_resources.resource_filename(
34 'yardstick.benchmark.scenarios.networking',
37 ''' calling Tacker to instantiate VNFs and Service Chains '''
38 cmd_tacker = "%s" % (self.tacker_script)
39 subprocess.call(cmd_tacker, shell=True)
41 target = self.context_cfg['target']
42 target_user = target.get('user', 'root')
43 target_pwd = target.get('password', 'octopus')
44 target_ip = target.get('ip', None)
46 ''' webserver start automatically during the vm boot '''
47 LOG.info("user:%s, target:%s", target_user, target_ip)
48 self.server = ssh.SSH(target_user, target_ip, password=target_pwd)
49 self.server.wait(timeout=600)
50 self.server.run("cat > ~/server.sh",
51 stdin=open(self.server_script, "rb"))
52 cmd_server = "sudo bash server.sh"
53 LOG.debug("Executing command: %s", cmd_server)
54 status, stdout, stderr = self.server.execute(cmd_server)
55 LOG.debug("Output server command: %s", status)
57 self.setup_done = True
59 def run(self, result):
60 ''' Creating client and server VMs to perform the test'''
61 host = self.context_cfg['host']
62 host_user = host.get('user', 'cirros')
63 host_pwd = host.get('password', 'cubswin:)')
64 host_ip = host.get('ip', None)
66 LOG.info("user:%s, host:%s", host_user, host_ip)
67 self.client = ssh.SSH(host_user, host_ip, password=host_pwd)
68 self.client.wait(timeout=600)
70 if not self.setup_done:
73 target = self.context_cfg['target']
74 target_ip = target.get('ip', None)
76 cmd_client = "curl %s", target_ip
77 LOG.debug("Executing command: %s", cmd_client)
78 result = self.client.execute(cmd_client)
79 LOG.debug("Output client command: %s", result)
82 ''' for scenario teardown remove tacker VNFs, chains and classifiers'''
83 self.teardown_script = pkg_resources.resource_filename(
84 "yardstick.benchmark.scenarios.sfc",
86 subprocess.call(self.teardown_script, shell=True)
87 self.teardown_done = True
92 internal test function
93 logger = logging.getLogger("Sfc Yardstick")
94 logger.setLevel(logging.DEBUG)
104 if __name__ == '__main__':