CLOUDSTACK-9524: Check router hypervisor before ssh to VR

SSH to VR for vmware, goes via the mgmt server and uses ssh keys at
/var/cloudstack path. Add suitable checks to tests failing on vmware.

Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>
This commit is contained in:
Rohit Yadav 2016-10-03 16:00:05 +05:30
parent 1f27874eaf
commit dc93268788
4 changed files with 127 additions and 61 deletions

View File

@ -169,6 +169,7 @@ class TestIsolatedNetworksPasswdServer(cloudstackTestCase):
def setUp(self):
self.apiclient = self.testClient.getApiClient()
self.hypervisor = self.testClient.getHypervisorInfo()
return
def test_ssh_command(self, vm, nat_rule, rule_label):
@ -204,20 +205,31 @@ class TestIsolatedNetworksPasswdServer(cloudstackTestCase):
host.user = self.hostConfig['username']
host.passwd = self.hostConfig['password']
host.port = self.services["configurableData"]["host"]["port"]
try:
if self.hypervisor.lower() in ('vmware', 'hyperv'):
result = get_process_status(
host.ipaddress,
host.port,
host.user,
host.passwd,
self.apiclient.connection.mgtSvr,
22,
self.apiclient.connection.user,
self.apiclient.connection.passwd,
router.linklocalip,
"cat /var/cache/cloud/passwords-%s | grep %s | sed 's/=/ /g' | awk '{print $1}'" % (vm.nic[0].gateway, vm.nic[0].ipaddress))
except KeyError:
self.skipTest(
"Provide a marvin config file with host\
credentials to run %s" %
self._testMethodName)
"cat /var/cache/cloud/passwords-%s | grep %s | sed 's/=/ /g' | awk '{print $1}'" % (vm.nic[0].gateway, vm.nic[0].ipaddress),
hypervisor=self.hypervisor
)
else:
try:
result = get_process_status(
host.ipaddress,
host.port,
host.user,
host.passwd,
router.linklocalip,
"cat /var/cache/cloud/passwords-%s | grep %s | sed 's/=/ /g' | awk '{print $1}'" % (vm.nic[0].gateway, vm.nic[0].ipaddress))
except KeyError:
self.skipTest(
"Provide a marvin config file with host\
credentials to run %s" %
self._testMethodName)
self.logger.debug("cat /var/cache/cloud/passwords-%s | grep %s | sed 's/=/ /g' | awk '{print $1}' RESULT IS ==> %s" % (vm.nic[0].gateway, vm.nic[0].ipaddress, result))
res = str(result)

View File

@ -750,24 +750,43 @@ class TestPrivateGwACL(cloudstackTestCase):
host.passwd = self.hostConfig['password']
host.port = self.services["configurableData"]["host"]["port"]
try:
if self.hypervisor.lower() in ('vmware', 'hyperv'):
state = get_process_status(
host.ipaddress,
host.port,
host.user,
host.passwd,
router.linklocalip,
"ip addr | grep eth6 | grep state | awk '{print $9;}'")
self.apiclient.connection.mgtSvr,
22,
self.apiclient.connection.user,
self.apiclient.connection.passwd,
router.linklocalip,
"ip addr | grep eth6 | grep state | awk '{print $9;}'",
hypervisor=self.hypervisor)
mac = get_process_status(
host.ipaddress,
host.port,
host.user,
host.passwd,
router.linklocalip,
"ip addr | grep link/ether | awk '{print $2;}' | sed -n 7p")
except KeyError:
self.skipTest("Provide a marvin config file with host credentials to run %s" % self._testMethodName)
self.apiclient.connection.mgtSvr,
22,
self.apiclient.connection.user,
self.apiclient.connection.passwd,
router.linklocalip,
"ip addr | grep link/ether | awk '{print $2;}' | sed -n 7p",
hypervisor=self.hypervisor)
else:
try:
state = get_process_status(
host.ipaddress,
host.port,
host.user,
host.passwd,
router.linklocalip,
"ip addr | grep eth6 | grep state | awk '{print $9;}'")
mac = get_process_status(
host.ipaddress,
host.port,
host.user,
host.passwd,
router.linklocalip,
"ip addr | grep link/ether | awk '{print $2;}' | sed -n 7p")
except KeyError:
self.skipTest("Provide a marvin config file with host credentials to run %s" % self._testMethodName)
state = str(state[0])
mac = str(mac[0])

View File

@ -169,6 +169,7 @@ class TestRouterDHCPHosts(cloudstackTestCase):
def setUp(self):
self.apiclient = self.testClient.getApiClient()
self.hypervisor = self.testClient.getHypervisorInfo()
self.cleanup = []
return
@ -212,20 +213,30 @@ class TestRouterDHCPHosts(cloudstackTestCase):
host.user = self.hostConfig['username']
host.passwd = self.hostConfig['password']
host.port = self.services["configurableData"]["host"]["port"]
#mac1,10.7.32.101,infinite
try:
if self.hypervisor.lower() in ('vmware', 'hyperv'):
result = get_process_status(
host.ipaddress,
host.port,
host.user,
host.passwd,
self.apiclient.connection.mgtSvr,
22,
self.apiclient.connection.user,
self.apiclient.connection.passwd,
router.linklocalip,
"cat /etc/dhcphosts.txt | grep %s | sed 's/\,/ /g' | awk '{print $2}'" % (vm.nic[0].ipaddress))
except KeyError:
self.skipTest(
"Provide a marvin config file with host\
credentials to run %s" %
self._testMethodName)
"cat /etc/dhcphosts.txt | grep %s | sed 's/\,/ /g' | awk '{print $2}'" % (vm.nic[0].ipaddress),
hypervisor=self.hypervisor)
else:
try:
result = get_process_status(
host.ipaddress,
host.port,
host.user,
host.passwd,
router.linklocalip,
"cat /etc/dhcphosts.txt | grep %s | sed 's/\,/ /g' | awk '{print $2}'" % (vm.nic[0].ipaddress))
except KeyError:
self.skipTest(
"Provide a marvin config file with host\
credentials to run %s" %
self._testMethodName)
self.logger.debug("cat /etc/dhcphosts.txt | grep %s | sed 's/\,/ /g' | awk '{print $2}' RESULT IS ==> %s" % (vm.nic[0].ipaddress, result))
res = str(result)

View File

@ -253,6 +253,7 @@ class TestVPCIpTablesPolicies(cloudstackTestCase):
return
def setUp(self):
self.hypervisor = self.testClient.getHypervisorInfo()
self.logger.debug("Creating a VPC offering.")
self.vpc_off = VpcOffering.create(
self.apiclient,
@ -317,19 +318,30 @@ class TestVPCIpTablesPolicies(cloudstackTestCase):
tables = [self.services["configurableData"]["input"], self.services["configurableData"]["forward"]]
for table in tables:
try:
result = None
if self.hypervisor.lower() in ('vmware', 'hyperv'):
result = get_process_status(
host.ipaddress,
host.port,
host.user,
host.passwd,
self.apiclient.connection.mgtSvr,
22,
self.apiclient.connection.user,
self.apiclient.connection.passwd,
router.linklocalip,
'iptables -L %s' % table)
except KeyError:
self.skipTest(
"Provide a marvin config file with host\
credentials to run %s" %
self._testMethodName)
'iptables -L %s' % table,
hypervisor=self.hypervisor)
else:
try:
result = get_process_status(
host.ipaddress,
host.port,
host.user,
host.passwd,
router.linklocalip,
'iptables -L %s' % table)
except KeyError:
self.skipTest(
"Provide a marvin config file with host\
credentials to run %s" %
self._testMethodName)
self.logger.debug("iptables -L %s: %s" % (table, result))
res = str(result)
@ -392,6 +404,7 @@ class TestRouterIpTablesPolicies(cloudstackTestCase):
return
def setUp(self):
self.hypervisor = self.testClient.getHypervisorInfo()
self.cleanup = []
self.entity_manager.set_cleanup(self.cleanup)
return
@ -434,19 +447,30 @@ class TestRouterIpTablesPolicies(cloudstackTestCase):
tables = [self.services["configurableData"]["input"], self.services["configurableData"]["forward"]]
for table in tables:
try:
result = None
if self.hypervisor.lower() in ('vmware', 'hyperv'):
result = get_process_status(
host.ipaddress,
host.port,
host.user,
host.passwd,
self.apiclient.connection.mgtSvr,
22,
self.apiclient.connection.user,
self.apiclient.connection.passwd,
router.linklocalip,
'iptables -L %s' % table)
except KeyError:
self.skipTest(
"Provide a marvin config file with host\
credentials to run %s" %
self._testMethodName)
'iptables -L %s' % table,
hypervisor=self.hypervisor)
else:
try:
result = get_process_status(
host.ipaddress,
host.port,
host.user,
host.passwd,
router.linklocalip,
'iptables -L %s' % table)
except KeyError:
self.skipTest(
"Provide a marvin config file with host\
credentials to run %s" %
self._testMethodName)
self.logger.debug("iptables -L %s: %s" % (table, result))
res = str(result)