3 # Copyright (c) 2015 All rights reserved
4 # This program and the accompanying materials
5 # are made available under the terms of the Apache License, Version 2.0
6 # which accompanies this distribution, and is available at
8 # http://www.apache.org/licenses/LICENSE-2.0
10 """vPingSSH testcase."""
14 from functest.core import singlevm
15 from functest.utils import config
18 class VPingSSH(singlevm.SingleVm2):
20 VPingSSH testcase implementation.
22 Class to execute the vPing test using a Floating IP to connect to one VM
23 to issue the ping command to the second
26 __logger = logging.getLogger(__name__)
28 def __init__(self, **kwargs):
29 """Initialize testcase."""
30 if "case_name" not in kwargs:
31 kwargs["case_name"] = "vping_ssh"
32 super(VPingSSH, self).__init__(**kwargs)
36 super(VPingSSH, self).prepare()
37 self.vm2 = self.boot_vm(
38 '{}-vm2_{}'.format(self.case_name, self.guid),
39 security_groups=[self.sec.id])
44 Returns: ping exit codes
47 (_, stdout, stderr) = self.ssh.exec_command(
48 'ping -c 1 ' + self.vm2.private_v4)
49 self.__logger.info("output:\n%s", stdout.read())
50 self.__logger.info("error:\n%s", stderr.read())
51 return stdout.channel.recv_exit_status()
56 self.cloud.delete_server(
58 timeout=getattr(config.CONF, 'vping_vm_delete_timeout'))
59 super(VPingSSH, self).clean()