CLOUDSTACK-8255: Adding secondary IP to correct ethernet interface present on 
the VM

Signed-off-by: SrikanteswaraRao Talluri <tall...@apache.org>


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

Branch: refs/heads/hotfix/scp-exception
Commit: e66ceaa254b21b3b365ade0682470bffa48c15b4
Parents: d552eb4
Author: Gaurav Aradhye <gaurav.arad...@clogeny.com>
Authored: Fri Feb 13 03:07:16 2015 -0800
Committer: SrikanteswaraRao Talluri <tall...@apache.org>
Committed: Fri Feb 13 18:08:17 2015 +0530

----------------------------------------------------------------------
 .../component/test_lb_secondary_ip.py           | 104 +++++++++++++++++--
 1 file changed, 97 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/e66ceaa2/test/integration/component/test_lb_secondary_ip.py
----------------------------------------------------------------------
diff --git a/test/integration/component/test_lb_secondary_ip.py 
b/test/integration/component/test_lb_secondary_ip.py
index ecf0985..03551ab 100644
--- a/test/integration/component/test_lb_secondary_ip.py
+++ b/test/integration/component/test_lb_secondary_ip.py
@@ -112,6 +112,14 @@ class TestAssignLBRule(cloudstackTestCase):
         cls.testdata["virtual_machine"]["template"] = template.id
         cls._cleanup = []
         try:
+            cls.hypervisor = cloudstackTestClient.getHypervisorInfo()
+            # As Hyperv is GUI based VM, it requires more resources to be
+            # able to SSH properly to it
+            if cls.hypervisor.lower() == 'hyperv':
+                cls.testdata["service_offering"]["name"] = "Medium Instance"
+                cls.testdata["service_offering"]["memory"] = "1024"
+                cls.testdata["service_offering"]["cpuspeed"] = "1024"
+
             cls.service_offering = ServiceOffering.create(
                 cls.api_client,
                 cls.testdata["service_offering"])
@@ -431,6 +439,14 @@ class TestFailureScenarios(cloudstackTestCase):
         cls._cleanup = []
 
         try:
+            cls.hypervisor = cloudstackTestClient.getHypervisorInfo()
+            # As Hyperv is GUI based VM, it requires more resources to be
+            # able to SSH properly to it
+            if cls.hypervisor.lower() == 'hyperv':
+                cls.testdata["service_offering"]["name"] = "Medium Instance"
+                cls.testdata["service_offering"]["memory"] = "1024"
+                cls.testdata["service_offering"]["cpuspeed"] = "1024"
+
             cls.service_offering = ServiceOffering.create(
                 cls.api_client,
                 cls.testdata["service_offering"])
@@ -686,6 +702,14 @@ class TestListLBRuleInstances(cloudstackTestCase):
         cls._cleanup = []
 
         try:
+            cls.hypervisor = cloudstackTestClient.getHypervisorInfo()
+            # As Hyperv is GUI based VM, it requires more resources to be
+            # able to SSH properly to it
+            if cls.hypervisor.lower() == 'hyperv':
+                cls.testdata["service_offering"]["name"] = "Medium Instance"
+                cls.testdata["service_offering"]["memory"] = "1024"
+                cls.testdata["service_offering"]["cpuspeed"] = "1024"
+
             cls.service_offering = ServiceOffering.create(
                 cls.api_client,
                 cls.testdata["service_offering"])
@@ -869,6 +893,14 @@ class TestLbRuleFunctioning(cloudstackTestCase):
         cls._cleanup = []
 
         try:
+            cls.hypervisor = cloudstackTestClient.getHypervisorInfo()
+            # As Hyperv is GUI based VM, it requires more resources to be
+            # able to SSH properly to it
+            if cls.hypervisor.lower() == 'hyperv':
+                cls.testdata["service_offering"]["name"] = "Medium Instance"
+                cls.testdata["service_offering"]["memory"] = "1024"
+                cls.testdata["service_offering"]["cpuspeed"] = "1024"
+
             cls.service_offering = ServiceOffering.create(
                 cls.api_client,
                 cls.testdata["service_offering"])
@@ -933,14 +965,28 @@ class TestLbRuleFunctioning(cloudstackTestCase):
                                   self.virtual_machine.username,
                                   self.virtual_machine.password
                                   )
-            cmd = "ip addr add {0}/24 broadcast {0} dev eth0".format(
-                self.secondaryip.ipaddress)
+            response = sshClient.execute("netstat -i")
+            # Sample Reponse:
+            # [u'Kernel Interface table',
+            # u'Iface MTU Met RX-OK RX-ERR RX-DRP RX-OVR TX-OK TX-ERR TX-DRP 
TX-OVR Flg',
+            # u'eth2 1500  0   29     0     0       0      38    0       0     
0    BMRU',
+            # u'lo   16436 0   4      0     0       0       4    0       0
+            # 0    LRU']}
+
+            # We need to extract default interface out of the response
+            defaultEthernetDevice = str(response[2].split()[0])
+
+            cmd = "ip addr add {0}/24 broadcast {0} dev {1}".format(
+                self.secondaryip.ipaddress, defaultEthernetDevice)
             sshClient.execute(cmd)
             sshClient.execute("ip addr show")
 
             # Deleting NAT rule after configuring secondary IP
             nat_rule.delete(self.apiclient)
 
+            self.testdata["lbrule"]["publicport"] = 22
+            self.testdata["lbrule"]["privateport"] = 22
+
             self.lb_rule = LoadBalancerRule.create(
                 self.apiclient,
                 self.testdata["lbrule"],
@@ -1361,6 +1407,14 @@ class TestNetworkOperations(cloudstackTestCase):
         cls._cleanup = []
 
         try:
+            cls.hypervisor = cloudstackTestClient.getHypervisorInfo()
+            # As Hyperv is GUI based VM, it requires more resources to be
+            # able to SSH properly to it
+            if cls.hypervisor.lower() == 'hyperv':
+                cls.testdata["service_offering"]["name"] = "Medium Instance"
+                cls.testdata["service_offering"]["memory"] = "1024"
+                cls.testdata["service_offering"]["cpuspeed"] = "1024"
+
             cls.service_offering = ServiceOffering.create(
                 cls.api_client,
                 cls.testdata["service_offering"])
@@ -1424,14 +1478,28 @@ class TestNetworkOperations(cloudstackTestCase):
                                   self.virtual_machine.username,
                                   self.virtual_machine.password
                                   )
-            cmd = "ip addr add {0}/24 broadcast {0} dev eth0".format(
-                self.secondaryip.ipaddress)
+            response = sshClient.execute("netstat -i")
+            # Sample Reponse:
+            # [u'Kernel Interface table',
+            # u'Iface MTU Met RX-OK RX-ERR RX-DRP RX-OVR TX-OK TX-ERR TX-DRP 
TX-OVR Flg',
+            # u'eth2 1500  0   29     0     0       0      38    0       0     
0    BMRU',
+            # u'lo   16436 0   4      0     0       0       4    0       0
+            # 0    LRU']}
+
+            # We need to extract default interface out of the response
+            defaultEthernetDevice = str(response[2].split()[0])
+
+            cmd = "ip addr add {0}/24 broadcast {0} dev {1}".format(
+                self.secondaryip.ipaddress, defaultEthernetDevice)
             sshClient.execute(cmd)
             sshClient.execute("ip addr show")
 
             # Deleting NAT rule after configuring secondary IP
             nat_rule.delete(self.apiclient)
 
+            self.testdata["lbrule"]["publicport"] = 22
+            self.testdata["lbrule"]["privateport"] = 22
+
             self.lb_rule = LoadBalancerRule.create(
                 self.apiclient,
                 self.testdata["lbrule"],
@@ -1775,7 +1843,7 @@ class TestExternalLoadBalancer(cloudstackTestCase):
         cls.testdata["virtual_machine"]["template"] = template.id
         cls._cleanup = []
         cls.testdata["configurableData"]\
-        ["netscaler"]["lbdevicededicated"] = False
+            ["netscaler"]["lbdevicededicated"] = False
 
         try:
             cls.netscaler = add_netscaler(
@@ -1787,6 +1855,14 @@ class TestExternalLoadBalancer(cloudstackTestCase):
             raise unittest.SkipTest("Failed to add netscaler device: %s" % e)
 
         try:
+            cls.hypervisor = cloudstackTestClient.getHypervisorInfo()
+            # As Hyperv is GUI based VM, it requires more resources to be
+            # able to SSH properly to it
+            if cls.hypervisor.lower() == 'hyperv':
+                cls.testdata["service_offering"]["name"] = "Medium Instance"
+                cls.testdata["service_offering"]["memory"] = "1024"
+                cls.testdata["service_offering"]["cpuspeed"] = "1024"
+
             cls.service_offering = ServiceOffering.create(
                 cls.api_client,
                 cls.testdata["service_offering"])
@@ -1896,14 +1972,28 @@ class TestExternalLoadBalancer(cloudstackTestCase):
                               self.virtual_machine.username,
                               self.virtual_machine.password
                               )
-        cmd = "ip addr add {0}/24 broadcast {0} dev eth0".format(
-            secondaryip.ipaddress)
+        response = sshClient.execute("netstat -i")
+        # Sample Reponse:
+        # [u'Kernel Interface table',
+        # u'Iface MTU Met RX-OK RX-ERR RX-DRP RX-OVR TX-OK TX-ERR TX-DRP 
TX-OVR Flg',
+        # u'eth2 1500  0   29     0     0       0      38    0       0     0   
 BMRU',
+        # u'lo   16436 0   4      0     0       0       4    0       0     0
+        # LRU']}
+
+        # We need to extract default interface out of the response
+        defaultEthernetDevice = str(response[2].split()[0])
+
+        cmd = "ip addr add {0}/24 broadcast {0} dev {1}".format(
+            self.secondaryip.ipaddress, defaultEthernetDevice)
         sshClient.execute(cmd)
         sshClient.execute("ip addr show")
 
         # Deleting NAT rule after configuring secondary IP
         nat_rule.delete(self.apiclient)
 
+        self.testdata["lbrule"]["publicport"] = 22
+        self.testdata["lbrule"]["privateport"] = 22
+
         lb_rule = LoadBalancerRule.create(
             self.apiclient,
             self.testdata["lbrule"],

Reply via email to