You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by bh...@apache.org on 2016/10/21 04:45:54 UTC

[07/17] git commit: updated refs/heads/4.8 to a664e03

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 <ro...@shapeblue.com>


Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/dc932687
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/dc932687
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/dc932687

Branch: refs/heads/4.8
Commit: dc932687888aa068ff4d4e657a76c07cff26cd90
Parents: 1f27874
Author: Rohit Yadav <ro...@shapeblue.com>
Authored: Mon Oct 3 16:00:05 2016 +0530
Committer: Rohit Yadav <ro...@shapeblue.com>
Committed: Wed Oct 5 15:11:00 2016 +0530

----------------------------------------------------------------------
 test/integration/smoke/test_password_server.py  | 36 +++++++----
 test/integration/smoke/test_privategw_acl.py    | 49 +++++++++-----
 test/integration/smoke/test_router_dhcphosts.py | 35 ++++++----
 .../test_routers_iptables_default_policy.py     | 68 +++++++++++++-------
 4 files changed, 127 insertions(+), 61 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/dc932687/test/integration/smoke/test_password_server.py
----------------------------------------------------------------------
diff --git a/test/integration/smoke/test_password_server.py b/test/integration/smoke/test_password_server.py
index a85bd54..98c5ced 100644
--- a/test/integration/smoke/test_password_server.py
+++ b/test/integration/smoke/test_password_server.py
@@ -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)

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/dc932687/test/integration/smoke/test_privategw_acl.py
----------------------------------------------------------------------
diff --git a/test/integration/smoke/test_privategw_acl.py b/test/integration/smoke/test_privategw_acl.py
index 4946dfa..9d39bdb 100644
--- a/test/integration/smoke/test_privategw_acl.py
+++ b/test/integration/smoke/test_privategw_acl.py
@@ -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])

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/dc932687/test/integration/smoke/test_router_dhcphosts.py
----------------------------------------------------------------------
diff --git a/test/integration/smoke/test_router_dhcphosts.py b/test/integration/smoke/test_router_dhcphosts.py
index c90599b..4e61954 100644
--- a/test/integration/smoke/test_router_dhcphosts.py
+++ b/test/integration/smoke/test_router_dhcphosts.py
@@ -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)

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/dc932687/test/integration/smoke/test_routers_iptables_default_policy.py
----------------------------------------------------------------------
diff --git a/test/integration/smoke/test_routers_iptables_default_policy.py b/test/integration/smoke/test_routers_iptables_default_policy.py
index 2607207..ec35396 100644
--- a/test/integration/smoke/test_routers_iptables_default_policy.py
+++ b/test/integration/smoke/test_routers_iptables_default_policy.py
@@ -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)