cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tall...@apache.org
Subject [4/5] git commit: updated refs/heads/4.5 to 5f99917
Date Mon, 17 Nov 2014 09:46:36 GMT
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/5f999179/test/integration/component/test_netscaler_lb.py
----------------------------------------------------------------------
diff --git a/test/integration/component/test_netscaler_lb.py b/test/integration/component/test_netscaler_lb.py
index 4c99aa3..e3d65bb 100644
--- a/test/integration/component/test_netscaler_lb.py
+++ b/test/integration/component/test_netscaler_lb.py
@@ -17,7 +17,7 @@
 
 """ P1 tests for netscaler load balancing
 """
-#Import Local Modules
+# Import Local Modules
 from nose.plugins.attrib import attr
 from marvin.cloudstackTestCase import cloudstackTestCase
 from marvin.cloudstackAPI import migrateVirtualMachine
@@ -36,126 +36,117 @@ from marvin.lib.base import (Account,
 from marvin.lib.common import (get_domain,
                                get_zone,
                                get_template,
+                               GetNetscalerInfoFromConfig,
                                add_netscaler)
 from marvin.sshClient import SshClient
 import time
 
 
 class Services:
+
     """Test netscaler services
     """
 
     def __init__(self):
         self.services = {
-                         "account": {
-                                    "email": "test@test.com",
-                                    "firstname": "Test",
-                                    "lastname": "User",
-                                    "username": "test",
-                                    # Random characters are appended for unique
-                                    # username
-                                    "password": "password",
-                         },
-                         "service_offering": {
-                                    "name": "Tiny Instance",
-                                    "displaytext": "Tiny Instance",
-                                    "cpunumber": 1,
-                                    "cpuspeed": 100,    # in MHz
+            "account": {
+                "email": "test@test.com",
+                "firstname": "Test",
+                "lastname": "User",
+                "username": "test",
+                # Random characters are appended for unique
+                # username
+                "password": "password",
+            },
+            "service_offering": {
+                "name": "Tiny Instance",
+                "displaytext": "Tiny Instance",
+                "cpunumber": 1,
+                "cpuspeed": 100,    # in MHz
                                     "memory": 128,       # In MBs
-                         },
-                         "virtual_machine": {
-                                    "displayname": "TestVM",
-                                    "username": "root",
-                                    "password": "password",
-                                    "ssh_port": 22,
-                                    "hypervisor": 'XenServer',
-                                    "privateport": 22,
-                                    "publicport": 22,
-                                    "protocol": 'TCP',
-                                },
-                         "netscaler": {
-                                "ipaddress": '10.147.40.100',
-                                "username": 'nsroot',
-                                "password": 'nsroot',
-                                "networkdevicetype": 'NetscalerVPXLoadBalancer',
-                                "publicinterface": '1/1',
-                                "privateinterface": '1/1',
-                                "numretries": 2,
-                                "lbdevicededicated": False,
-                                "lbdevicecapacity": 50,
-                                "port": 22,
-                         },
-                         "network_offering_dedicated": {
-                                    "name": 'Netscaler',
-                                    "displaytext": 'Netscaler',
-                                    "guestiptype": 'Isolated',
-                                    "supportedservices": 'Dhcp,Dns,SourceNat,PortForwarding,Vpn,Firewall,Lb,UserData,StaticNat',
-                                    "traffictype": 'GUEST',
-                                    "availability": 'Optional',
-                                    "specifyVlan": False,
-                                    "specifyIpRanges": False,
-                                    "serviceProviderList": {
-                                            "Dhcp": 'VirtualRouter',
-                                            "Dns": 'VirtualRouter',
-                                            "SourceNat": 'VirtualRouter',
-                                            "PortForwarding": 'VirtualRouter',
-                                            "Vpn": 'VirtualRouter',
-                                            "Firewall": 'VirtualRouter',
-                                            "Lb": 'Netscaler',
-                                            "UserData": 'VirtualRouter',
-                                            "StaticNat": 'VirtualRouter',
-                                    },
-                                    "serviceCapabilityList": {
-                                        "SourceNat": {
-                                            "SupportedSourceNatTypes": "peraccount"
-                                        },
-                                        "lb": {
-                                               "SupportedLbIsolation": "dedicated"
-                                        },
-                                    },
-                         },
-                         "network_offering": {
-                                    "name": 'Netscaler',
-                                    "displaytext": 'Netscaler',
-                                    "guestiptype": 'Isolated',
-                                    "supportedservices": 'Dhcp,Dns,SourceNat,PortForwarding,Vpn,Firewall,Lb,UserData,StaticNat',
-                                    "traffictype": 'GUEST',
-                                    "availability": 'Optional',
-                                    "serviceProviderList": {
-                                            "Dhcp": 'VirtualRouter',
-                                            "Dns": 'VirtualRouter',
-                                            "SourceNat": 'VirtualRouter',
-                                            "PortForwarding": 'VirtualRouter',
-                                            "Vpn": 'VirtualRouter',
-                                            "Firewall": 'VirtualRouter',
-                                            "Lb": 'Netscaler',
-                                            "UserData": 'VirtualRouter',
-                                            "StaticNat": 'VirtualRouter',
-                                    },
-                         },
-                         "network": {
-                                  "name": "Netscaler",
-                                  "displaytext": "Netscaler",
-                         },
-                         "lbrule": {
-                                    "name": "SSH",
-                                    "alg": "roundrobin",
-                                    # Algorithm used for load balancing
-                                    "privateport": 22,
-                                    "publicport": 22,
-                                    "openfirewall": False,
-                         },
-                         "natrule": {
-                                    "privateport": 22,
-                                    "publicport": 22,
-                                    "protocol": "TCP"
-                         },
-                         "ostype": 'CentOS 5.3 (64-bit)',
-                         # Cent OS 5.3 (64 bit)
-                         "sleep": 60,
-                         "timeout": 10,
-                         "mode": 'advanced'
-                    }
+            },
+            "virtual_machine": {
+                "displayname": "TestVM",
+                "username": "root",
+                "password": "password",
+                "ssh_port": 22,
+                "hypervisor": 'XenServer',
+                "privateport": 22,
+                "publicport": 22,
+                "protocol": 'TCP',
+            },
+            "network_offering_dedicated": {
+                "name": 'Netscaler',
+                "displaytext": 'Netscaler',
+                "guestiptype": 'Isolated',
+                "supportedservices": 'Dhcp,Dns,SourceNat,PortForwarding,Vpn,Firewall,Lb,UserData,StaticNat',
+                "traffictype": 'GUEST',
+                "availability": 'Optional',
+                "specifyVlan": False,
+                "specifyIpRanges": False,
+                "serviceProviderList": {
+                    "Dhcp": 'VirtualRouter',
+                    "Dns": 'VirtualRouter',
+                    "SourceNat": 'VirtualRouter',
+                    "PortForwarding": 'VirtualRouter',
+                    "Vpn": 'VirtualRouter',
+                    "Firewall": 'VirtualRouter',
+                    "Lb": 'Netscaler',
+                    "UserData": 'VirtualRouter',
+                    "StaticNat": 'VirtualRouter',
+                },
+                "serviceCapabilityList": {
+                    "SourceNat": {
+                        "SupportedSourceNatTypes": "peraccount"
+                    },
+                    "lb": {
+                        "SupportedLbIsolation": "dedicated"
+                    },
+                },
+            },
+            "network_offering": {
+                "name": 'Netscaler',
+                "displaytext": 'Netscaler',
+                "guestiptype": 'Isolated',
+                "supportedservices": 'Dhcp,Dns,SourceNat,PortForwarding,Vpn,Firewall,Lb,UserData,StaticNat',
+                "traffictype": 'GUEST',
+                "availability": 'Optional',
+                "serviceProviderList": {
+                    "Dhcp": 'VirtualRouter',
+                    "Dns": 'VirtualRouter',
+                    "SourceNat": 'VirtualRouter',
+                    "PortForwarding": 'VirtualRouter',
+                    "Vpn": 'VirtualRouter',
+                    "Firewall": 'VirtualRouter',
+                    "Lb": 'Netscaler',
+                    "UserData": 'VirtualRouter',
+                    "StaticNat": 'VirtualRouter',
+                },
+            },
+            "network": {
+                "name": "Netscaler",
+                "displaytext": "Netscaler",
+            },
+            "lbrule": {
+                "name": "SSH",
+                "alg": "roundrobin",
+                # Algorithm used for load balancing
+                "privateport": 22,
+                "publicport": 22,
+                "openfirewall": False,
+            },
+            "natrule": {
+                "privateport": 22,
+                "publicport": 22,
+                "protocol": "TCP"
+            },
+            "ostype": 'CentOS 5.3 (64-bit)',
+            # Cent OS 5.3 (64 bit)
+            "sleep": 60,
+            "timeout": 10,
+            "mode": 'advanced'
+        }
+
 
 class TestLbSourceNat(cloudstackTestCase):
 
@@ -170,35 +161,43 @@ class TestLbSourceNat(cloudstackTestCase):
         cls.domain = get_domain(cls.api_client)
         cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
         cls.template = get_template(
-                            cls.api_client,
-                            cls.zone.id,
-                            cls.services["ostype"]
-                           )
+            cls.api_client,
+            cls.zone.id,
+            cls.services["ostype"]
+        )
+
+        response = GetNetscalerInfoFromConfig(
+            cls.config
+        )
+        assert response[0] is not None, response[1]
+        cls.services["netscaler"] = response[0]
+        cls.services["netscaler"]["lbdevicededicated"] = False
+
         try:
-           cls.netscaler = add_netscaler(cls.api_client, cls.zone.id, cls.services["netscaler"])
-           cls._cleanup.append(cls.netscaler)
-           cls.network_offering = NetworkOffering.create(
-                                            cls.api_client,
-                                            cls.services["network_offering"],
-                                            conservemode=True
-                                            )
-           # Enable Network offering
-           cls.network_offering.update(cls.api_client, state='Enabled')
-           cls.services["virtual_machine"]["zoneid"] = cls.zone.id
-           cls.services["virtual_machine"]["template"] = cls.template.id
-           cls.service_offering = ServiceOffering.create(
-                                            cls.api_client,
-                                            cls.services["service_offering"]
-                                            )
+            cls.netscaler = add_netscaler(cls.api_client, cls.zone.id, cls.services["netscaler"])
+            cls._cleanup.append(cls.netscaler)
+            cls.network_offering = NetworkOffering.create(
+                cls.api_client,
+                cls.services["network_offering"],
+                conservemode=True
+            )
+            # Enable Network offering
+            cls.network_offering.update(cls.api_client, state='Enabled')
+            cls.services["virtual_machine"]["zoneid"] = cls.zone.id
+            cls.services["virtual_machine"]["template"] = cls.template.id
+            cls.service_offering = ServiceOffering.create(
+                cls.api_client,
+                cls.services["service_offering"]
+            )
         except Exception as e:
-           cls.tearDownClass()
-           raise Exception ("Warning: Exception in setUpClass: %s" % e)
+            cls.tearDownClass()
+            raise Exception("Warning: Exception in setUpClass: %s" % e)
         return
 
     @classmethod
     def tearDownClass(cls):
         try:
-            #Cleanup resources used
+            # Cleanup resources used
             cleanup_resources(cls.api_client, cls._cleanup)
         except Exception as e:
             raise Exception("Warning: Exception during cleanup : %s" % e)
@@ -208,27 +207,27 @@ class TestLbSourceNat(cloudstackTestCase):
         self.apiclient = self.testClient.getApiClient()
         self.dbclient = self.testClient.getDbConnection()
         self.account = Account.create(
-                                     self.apiclient,
-                                     self.services["account"],
-                                     admin=True,
-                                     domainid=self.domain.id
-                                     )
+            self.apiclient,
+            self.services["account"],
+            admin=True,
+            domainid=self.domain.id
+        )
         self.cleanup = [self.account]
         return
 
     def tearDown(self):
         try:
             self.debug("Cleaning up the resources")
-            #Clean up, terminate the created network offerings
+            # Clean up, terminate the created network offerings
             cleanup_resources(self.apiclient, self.cleanup)
             interval = Configurations.list(
-                                    self.apiclient,
-                                    name='network.gc.interval'
-                                    )
+                self.apiclient,
+                name='network.gc.interval'
+            )
             wait = Configurations.list(
-                                    self.apiclient,
-                                    name='network.gc.wait'
-                                    )
+                self.apiclient,
+                name='network.gc.wait'
+            )
             # Sleep to ensure that all resources are deleted
             time.sleep(int(interval[0].value) + int(wait[0].value))
             self.debug("Cleanup complete!")
@@ -236,12 +235,11 @@ class TestLbSourceNat(cloudstackTestCase):
             raise Exception("Warning: Exception during cleanup : %s" % e)
         return
 
-    @attr(tags = ["advancedns"])
+    @attr(tags=["advancedns"])
     def test_add_lb_on_source_nat(self):
         """Test Create LB rule for sourceNat IP address
         """
 
-
         # Validate the following
         # 1. Deploy the first VM using a network from the above created
         #    Network offering.
@@ -251,120 +249,121 @@ class TestLbSourceNat(cloudstackTestCase):
 
         # Creating network using the network offering created
         self.debug("Creating network with network offering: %s" %
-                                                    self.network_offering.id)
+                   self.network_offering.id)
         self.network = Network.create(
-                                    self.apiclient,
-                                    self.services["network"],
-                                    accountid=self.account.name,
-                                    domainid=self.account.domainid,
-                                    networkofferingid=self.network_offering.id,
-                                    zoneid=self.zone.id
-                                    )
+            self.apiclient,
+            self.services["network"],
+            accountid=self.account.name,
+            domainid=self.account.domainid,
+            networkofferingid=self.network_offering.id,
+            zoneid=self.zone.id
+        )
         self.debug("Created network with ID: %s" % self.network.id)
 
         self.debug("Deploying VM in account: %s" % self.account.name)
 
         # Spawn an instance in that network
         virtual_machine_1 = VirtualMachine.create(
-                                  self.apiclient,
-                                  self.services["virtual_machine"],
-                                  accountid=self.account.name,
-                                  domainid=self.account.domainid,
-                                  serviceofferingid=self.service_offering.id,
-                                  networkids=[str(self.network.id)]
-                                  )
+            self.apiclient,
+            self.services["virtual_machine"],
+            accountid=self.account.name,
+            domainid=self.account.domainid,
+            serviceofferingid=self.service_offering.id,
+            networkids=[str(self.network.id)]
+        )
         self.debug("Deployed VM in network: %s" % self.network.id)
         list_vm_response = VirtualMachine.list(
-                                        self.apiclient,
-                                        id=virtual_machine_1.id
-                                        )
+            self.apiclient,
+            id=virtual_machine_1.id
+        )
 
         self.debug(
-                "Verify listVirtualMachines response for virtual machine: %s" \
-                % virtual_machine_1.id
-            )
+            "Verify listVirtualMachines response for virtual machine: %s"
+            % virtual_machine_1.id
+        )
 
         self.assertEqual(
-                            isinstance(list_vm_response, list),
-                            True,
-                            "Check list response returns a valid list"
-                        )
+            isinstance(list_vm_response, list),
+            True,
+            "Check list response returns a valid list"
+        )
         vm_response = list_vm_response[0]
 
         self.assertEqual(
-                            vm_response.state,
-                            "Running",
-                            "VM state should be running after deployment"
-                        )
+            vm_response.state,
+            "Running",
+            "VM state should be running after deployment"
+        )
 
         self.debug("Deploying another VM in account: %s" %
-                                            self.account.name)
+                   self.account.name)
 
         # Spawn an instance in that network
         virtual_machine_2 = VirtualMachine.create(
-                                  self.apiclient,
-                                  self.services["virtual_machine"],
-                                  accountid=self.account.name,
-                                  domainid=self.account.domainid,
-                                  serviceofferingid=self.service_offering.id,
-                                  networkids=[str(self.network.id)]
-                                  )
+            self.apiclient,
+            self.services["virtual_machine"],
+            accountid=self.account.name,
+            domainid=self.account.domainid,
+            serviceofferingid=self.service_offering.id,
+            networkids=[str(self.network.id)]
+        )
         self.debug("Deployed VM in network: %s" % self.network.id)
         list_vm_response = VirtualMachine.list(
-                                        self.apiclient,
-                                        id=virtual_machine_2.id
-                                        )
+            self.apiclient,
+            id=virtual_machine_2.id
+        )
 
         self.debug(
-                "Verify listVirtualMachines response for virtual machine: %s" \
-                % virtual_machine_2.id
-            )
+            "Verify listVirtualMachines response for virtual machine: %s"
+            % virtual_machine_2.id
+        )
 
         self.assertEqual(
-                            isinstance(list_vm_response, list),
-                            True,
-                            "Check list response returns a valid list"
-                        )
+            isinstance(list_vm_response, list),
+            True,
+            "Check list response returns a valid list"
+        )
         vm_response = list_vm_response[0]
 
         self.assertEqual(
-                            vm_response.state,
-                            "Running",
-                            "VM state should be running after deployment"
-                        )
+            vm_response.state,
+            "Running",
+            "VM state should be running after deployment"
+        )
         src_nat_list = PublicIPAddress.list(
-                                        self.apiclient,
-                                        associatednetworkid=self.network.id,
-                                        account=self.account.name,
-                                        domainid=self.account.domainid,
-                                        listall=True,
-                                        issourcenat=True,
-                                        )
+            self.apiclient,
+            associatednetworkid=self.network.id,
+            account=self.account.name,
+            domainid=self.account.domainid,
+            listall=True,
+            issourcenat=True,
+        )
         self.assertEqual(
-                         isinstance(src_nat_list, list),
-                         True,
-                         "List Public IP should return a valid source NAT"
-                         )
+            isinstance(src_nat_list, list),
+            True,
+            "List Public IP should return a valid source NAT"
+        )
         self.assertNotEqual(
-                    len(src_nat_list),
-                    0,
-                    "Length of response from listPublicIp should not be 0"
-                    )
+            len(src_nat_list),
+            0,
+            "Length of response from listPublicIp should not be 0"
+        )
 
         src_nat = src_nat_list[0]
 
         self.debug("Trying to create LB rule on source NAT IP: %s" %
-                                                        src_nat.ipaddress)
+                   src_nat.ipaddress)
         # Create Load Balancer rule with source NAT
         with self.assertRaises(Exception):
             LoadBalancerRule.create(
-                                    self.apiclient,
-                                    self.services["lbrule"],
-                                    ipaddressid=src_nat.id,
-                                    accountid=self.account.name
-                                )
+                self.apiclient,
+                self.services["lbrule"],
+                ipaddressid=src_nat.id,
+                accountid=self.account.name
+            )
         return
 
+
 class TestLbOnIpWithPf(cloudstackTestCase):
 
     @classmethod
@@ -378,36 +377,44 @@ class TestLbOnIpWithPf(cloudstackTestCase):
         cls.domain = get_domain(cls.api_client)
         cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
         cls.template = get_template(
-                            cls.api_client,
-                            cls.zone.id,
-                            cls.services["ostype"]
-                            )
+            cls.api_client,
+            cls.zone.id,
+            cls.services["ostype"]
+        )
+
+        response = GetNetscalerInfoFromConfig(
+            cls.config
+        )
+        assert response[0] is not None, response[1]
+        cls.services["netscaler"] = response[0]
+        cls.services["netscaler"]["lbdevicededicated"] = False
+
         try:
-           cls.netscaler = add_netscaler(cls.api_client, cls.zone.id, cls.services["netscaler"])
-           cls._cleanup.append(cls.netscaler)
-           cls.network_offering = NetworkOffering.create(
-                                            cls.api_client,
-                                            cls.services["network_offering"],
-                                            conservemode=True
-                                            )
-           # Enable Network offering
-           cls.network_offering.update(cls.api_client, state='Enabled')
-           cls.services["virtual_machine"]["zoneid"] = cls.zone.id
-           cls.services["virtual_machine"]["template"] = cls.template.id
-
-           cls.service_offering = ServiceOffering.create(
-                                            cls.api_client,
-                                            cls.services["service_offering"]
-                                            )
+            cls.netscaler = add_netscaler(cls.api_client, cls.zone.id, cls.services["netscaler"])
+            cls._cleanup.append(cls.netscaler)
+            cls.network_offering = NetworkOffering.create(
+                cls.api_client,
+                cls.services["network_offering"],
+                conservemode=True
+            )
+            # Enable Network offering
+            cls.network_offering.update(cls.api_client, state='Enabled')
+            cls.services["virtual_machine"]["zoneid"] = cls.zone.id
+            cls.services["virtual_machine"]["template"] = cls.template.id
+
+            cls.service_offering = ServiceOffering.create(
+                cls.api_client,
+                cls.services["service_offering"]
+            )
         except Exception as e:
-           cls.tearDownClass()
-           raise Exception ("Warning: Exception in setUpClass: %s" % e)
+            cls.tearDownClass()
+            raise Exception("Warning: Exception in setUpClass: %s" % e)
         return
 
     @classmethod
     def tearDownClass(cls):
         try:
-            #Cleanup resources used
+            # Cleanup resources used
             cleanup_resources(cls.api_client, cls._cleanup)
         except Exception as e:
             raise Exception("Warning: Exception during cleanup : %s" % e)
@@ -417,27 +424,27 @@ class TestLbOnIpWithPf(cloudstackTestCase):
         self.apiclient = self.testClient.getApiClient()
         self.dbclient = self.testClient.getDbConnection()
         self.account = Account.create(
-                                     self.apiclient,
-                                     self.services["account"],
-                                     admin=True,
-                                     domainid=self.domain.id
-                                     )
+            self.apiclient,
+            self.services["account"],
+            admin=True,
+            domainid=self.domain.id
+        )
         self.cleanup = [self.account]
         return
 
     def tearDown(self):
         try:
             self.debug("Cleaning up the resources")
-            #Clean up, terminate the created network offerings
+            # Clean up, terminate the created network offerings
             cleanup_resources(self.apiclient, self.cleanup)
             interval = Configurations.list(
-                                    self.apiclient,
-                                    name='network.gc.interval'
-                                    )
+                self.apiclient,
+                name='network.gc.interval'
+            )
             wait = Configurations.list(
-                                    self.apiclient,
-                                    name='network.gc.wait'
-                                    )
+                self.apiclient,
+                name='network.gc.wait'
+            )
             # Sleep to ensure that all resources are deleted
             time.sleep(int(interval[0].value) + int(wait[0].value))
             self.debug("Cleanup complete!")
@@ -445,12 +452,11 @@ class TestLbOnIpWithPf(cloudstackTestCase):
             raise Exception("Warning: Exception during cleanup : %s" % e)
         return
 
-    @attr(tags = ["advancedns"])
+    @attr(tags=["advancedns"])
     def test_lb_on_ip_with_pf(self):
         """Test Create LB rule for sourceNat IP address
         """
 
-
         # Validate the following
         # 1. Deploy the first VM using a network from the above created
         #    Network offering.
@@ -460,120 +466,120 @@ class TestLbOnIpWithPf(cloudstackTestCase):
 
         # Creating network using the network offering created
         self.debug("Creating network with network offering: %s" %
-                                                    self.network_offering.id)
+                   self.network_offering.id)
         self.network = Network.create(
-                                    self.apiclient,
-                                    self.services["network"],
-                                    accountid=self.account.name,
-                                    domainid=self.account.domainid,
-                                    networkofferingid=self.network_offering.id,
-                                    zoneid=self.zone.id
-                                    )
+            self.apiclient,
+            self.services["network"],
+            accountid=self.account.name,
+            domainid=self.account.domainid,
+            networkofferingid=self.network_offering.id,
+            zoneid=self.zone.id
+        )
         self.debug("Created network with ID: %s" % self.network.id)
 
         self.debug("Deploying VM in account: %s" % self.account.name)
 
         # Spawn an instance in that network
         virtual_machine_1 = VirtualMachine.create(
-                                  self.apiclient,
-                                  self.services["virtual_machine"],
-                                  accountid=self.account.name,
-                                  domainid=self.account.domainid,
-                                  serviceofferingid=self.service_offering.id,
-                                  networkids=[str(self.network.id)]
-                                  )
+            self.apiclient,
+            self.services["virtual_machine"],
+            accountid=self.account.name,
+            domainid=self.account.domainid,
+            serviceofferingid=self.service_offering.id,
+            networkids=[str(self.network.id)]
+        )
         self.debug("Deployed VM in network: %s" % self.network.id)
         list_vm_response = VirtualMachine.list(
-                                        self.apiclient,
-                                        id=virtual_machine_1.id
-                                        )
+            self.apiclient,
+            id=virtual_machine_1.id
+        )
 
         self.debug(
-                "Verify listVirtualMachines response for virtual machine: %s" \
-                % virtual_machine_1.id
-            )
+            "Verify listVirtualMachines response for virtual machine: %s"
+            % virtual_machine_1.id
+        )
 
         self.assertEqual(
-                            isinstance(list_vm_response, list),
-                            True,
-                            "Check list response returns a valid list"
-                        )
+            isinstance(list_vm_response, list),
+            True,
+            "Check list response returns a valid list"
+        )
         vm_response = list_vm_response[0]
 
         self.assertEqual(
-                            vm_response.state,
-                            "Running",
-                            "VM state should be running after deployment"
-                        )
+            vm_response.state,
+            "Running",
+            "VM state should be running after deployment"
+        )
 
         self.debug("Deploying another VM in account: %s" %
-                                            self.account.name)
+                   self.account.name)
 
         # Spawn an instance in that network
         virtual_machine_2 = VirtualMachine.create(
-                                  self.apiclient,
-                                  self.services["virtual_machine"],
-                                  accountid=self.account.name,
-                                  domainid=self.account.domainid,
-                                  serviceofferingid=self.service_offering.id,
-                                  networkids=[str(self.network.id)]
-                                  )
+            self.apiclient,
+            self.services["virtual_machine"],
+            accountid=self.account.name,
+            domainid=self.account.domainid,
+            serviceofferingid=self.service_offering.id,
+            networkids=[str(self.network.id)]
+        )
         self.debug("Deployed VM in network: %s" % self.network.id)
         list_vm_response = VirtualMachine.list(
-                                        self.apiclient,
-                                        id=virtual_machine_2.id
-                                        )
+            self.apiclient,
+            id=virtual_machine_2.id
+        )
 
         self.debug(
-                "Verify listVirtualMachines response for virtual machine: %s" \
-                % virtual_machine_2.id
-            )
+            "Verify listVirtualMachines response for virtual machine: %s"
+            % virtual_machine_2.id
+        )
 
         self.assertEqual(
-                            isinstance(list_vm_response, list),
-                            True,
-                            "Check list response returns a valid list"
-                        )
+            isinstance(list_vm_response, list),
+            True,
+            "Check list response returns a valid list"
+        )
         vm_response = list_vm_response[0]
 
         self.assertEqual(
-                            vm_response.state,
-                            "Running",
-                            "VM state should be running after deployment"
-                        )
+            vm_response.state,
+            "Running",
+            "VM state should be running after deployment"
+        )
         self.debug("Associating public IP for network: %s" % self.network.id)
         ip_with_nat_rule = PublicIPAddress.create(
-                                    self.apiclient,
-                                    accountid=self.account.name,
-                                    zoneid=self.zone.id,
-                                    domainid=self.account.domainid,
-                                    networkid=self.network.id
-                                    )
+            self.apiclient,
+            accountid=self.account.name,
+            zoneid=self.zone.id,
+            domainid=self.account.domainid,
+            networkid=self.network.id
+        )
 
         self.debug("Associated %s with network %s" % (
-                                        ip_with_nat_rule.ipaddress.ipaddress,
-                                        self.network.id
-                                        ))
+            ip_with_nat_rule.ipaddress.ipaddress,
+            self.network.id
+        ))
         self.debug("Creating PF rule for IP address: %s" %
-                                        ip_with_nat_rule.ipaddress.ipaddress)
+                   ip_with_nat_rule.ipaddress.ipaddress)
         NATRule.create(
-                         self.apiclient,
-                         virtual_machine_1,
-                         self.services["natrule"],
-                         ipaddressid=ip_with_nat_rule.ipaddress.id
-                      )
+            self.apiclient,
+            virtual_machine_1,
+            self.services["natrule"],
+            ipaddressid=ip_with_nat_rule.ipaddress.id
+        )
 
         self.debug("Trying to create LB rule on IP with NAT: %s" %
-                                    ip_with_nat_rule.ipaddress.ipaddress)
+                   ip_with_nat_rule.ipaddress.ipaddress)
 
         # Create Load Balancer rule on IP already having NAT rule
         with self.assertRaises(Exception):
-                LoadBalancerRule.create(
-                                    self.apiclient,
-                                    self.services["lbrule"],
-                                    ipaddressid=ip_with_nat_rule.ipaddress.id,
-                                    accountid=self.account.name
-                                    )
+            LoadBalancerRule.create(
+                self.apiclient,
+                self.services["lbrule"],
+                ipaddressid=ip_with_nat_rule.ipaddress.id,
+                accountid=self.account.name
+            )
         return
 
 
@@ -590,36 +596,44 @@ class TestPfOnIpWithLb(cloudstackTestCase):
         cls.domain = get_domain(cls.api_client)
         cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
         cls.template = get_template(
-                            cls.api_client,
-                            cls.zone.id,
-                            cls.services["ostype"]
-                            )
+            cls.api_client,
+            cls.zone.id,
+            cls.services["ostype"]
+        )
+
+        response = GetNetscalerInfoFromConfig(
+            cls.config
+        )
+        assert response[0] is not None, response[1]
+        cls.services["netscaler"] = response[0]
+        cls.services["netscaler"]["lbdevicededicated"] = False
+
         try:
-           cls.netscaler = add_netscaler(cls.api_client, cls.zone.id, cls.services["netscaler"])
-           cls._cleanup.append(cls.netscaler)
-           cls.network_offering = NetworkOffering.create(
-                                            cls.api_client,
-                                            cls.services["network_offering"],
-                                            conservemode=True
-                                            )
-           # Enable Network offering
-           cls.network_offering.update(cls.api_client, state='Enabled')
-           cls.services["virtual_machine"]["zoneid"] = cls.zone.id
-           cls.services["virtual_machine"]["template"] = cls.template.id
-
-           cls.service_offering = ServiceOffering.create(
-                                            cls.api_client,
-                                            cls.services["service_offering"]
-                                            )
+            cls.netscaler = add_netscaler(cls.api_client, cls.zone.id, cls.services["netscaler"])
+            cls._cleanup.append(cls.netscaler)
+            cls.network_offering = NetworkOffering.create(
+                cls.api_client,
+                cls.services["network_offering"],
+                conservemode=True
+            )
+            # Enable Network offering
+            cls.network_offering.update(cls.api_client, state='Enabled')
+            cls.services["virtual_machine"]["zoneid"] = cls.zone.id
+            cls.services["virtual_machine"]["template"] = cls.template.id
+
+            cls.service_offering = ServiceOffering.create(
+                cls.api_client,
+                cls.services["service_offering"]
+            )
         except Exception as e:
-           cls.tearDownClass()
-           raise Exception ("Warning: Exception in setUpClass: %s" % e)
+            cls.tearDownClass()
+            raise Exception("Warning: Exception in setUpClass: %s" % e)
         return
 
     @classmethod
     def tearDownClass(cls):
         try:
-            #Cleanup resources used
+            # Cleanup resources used
             cleanup_resources(cls.api_client, cls._cleanup)
         except Exception as e:
             raise Exception("Warning: Exception during cleanup : %s" % e)
@@ -629,27 +643,27 @@ class TestPfOnIpWithLb(cloudstackTestCase):
         self.apiclient = self.testClient.getApiClient()
         self.dbclient = self.testClient.getDbConnection()
         self.account = Account.create(
-                                     self.apiclient,
-                                     self.services["account"],
-                                     admin=True,
-                                     domainid=self.domain.id
-                                     )
+            self.apiclient,
+            self.services["account"],
+            admin=True,
+            domainid=self.domain.id
+        )
         self.cleanup = [self.account]
         return
 
     def tearDown(self):
         try:
             self.debug("Cleaning up the resources")
-            #Clean up, terminate the created network offerings
+            # Clean up, terminate the created network offerings
             cleanup_resources(self.apiclient, self.cleanup)
             interval = Configurations.list(
-                                    self.apiclient,
-                                    name='network.gc.interval'
-                                    )
+                self.apiclient,
+                name='network.gc.interval'
+            )
             wait = Configurations.list(
-                                    self.apiclient,
-                                    name='network.gc.wait'
-                                    )
+                self.apiclient,
+                name='network.gc.wait'
+            )
             # Sleep to ensure that all resources are deleted
             time.sleep(int(interval[0].value) + int(wait[0].value))
             self.debug("Cleanup complete!")
@@ -657,12 +671,12 @@ class TestPfOnIpWithLb(cloudstackTestCase):
             raise Exception("Warning: Exception during cleanup : %s" % e)
         return
 
-    @attr(tags = ["advancedns"])
+    @attr(tags=["advancedns"])
     def test_pf_on_ip_with_lb(self):
-        """Test Create a port forwarding rule  on an Ip address that already has a LB rule.
+        """Test Create a port forwarding rule  on an Ip address
+        that already has a LB rule.
         """
 
-
         # Validate the following
         # 1. Deploy the first VM using a network from the above created
         #    Network offering.
@@ -672,121 +686,121 @@ class TestPfOnIpWithLb(cloudstackTestCase):
 
         # Creating network using the network offering created
         self.debug("Creating network with network offering: %s" %
-                                                    self.network_offering.id)
+                   self.network_offering.id)
         self.network = Network.create(
-                                    self.apiclient,
-                                    self.services["network"],
-                                    accountid=self.account.name,
-                                    domainid=self.account.domainid,
-                                    networkofferingid=self.network_offering.id,
-                                    zoneid=self.zone.id
-                                    )
+            self.apiclient,
+            self.services["network"],
+            accountid=self.account.name,
+            domainid=self.account.domainid,
+            networkofferingid=self.network_offering.id,
+            zoneid=self.zone.id
+        )
         self.debug("Created network with ID: %s" % self.network.id)
 
         self.debug("Deploying VM in account: %s" % self.account.name)
 
         # Spawn an instance in that network
         virtual_machine_1 = VirtualMachine.create(
-                                  self.apiclient,
-                                  self.services["virtual_machine"],
-                                  accountid=self.account.name,
-                                  domainid=self.account.domainid,
-                                  serviceofferingid=self.service_offering.id,
-                                  networkids=[str(self.network.id)]
-                                  )
+            self.apiclient,
+            self.services["virtual_machine"],
+            accountid=self.account.name,
+            domainid=self.account.domainid,
+            serviceofferingid=self.service_offering.id,
+            networkids=[str(self.network.id)]
+        )
         self.debug("Deployed VM in network: %s" % self.network.id)
         list_vm_response = VirtualMachine.list(
-                                        self.apiclient,
-                                        id=virtual_machine_1.id
-                                        )
+            self.apiclient,
+            id=virtual_machine_1.id
+        )
 
         self.debug(
-                "Verify listVirtualMachines response for virtual machine: %s" \
-                % virtual_machine_1.id
-            )
+            "Verify listVirtualMachines response for virtual machine: %s"
+            % virtual_machine_1.id
+        )
 
         self.assertEqual(
-                            isinstance(list_vm_response, list),
-                            True,
-                            "Check list response returns a valid list"
-                        )
+            isinstance(list_vm_response, list),
+            True,
+            "Check list response returns a valid list"
+        )
         vm_response = list_vm_response[0]
 
         self.assertEqual(
-                            vm_response.state,
-                            "Running",
-                            "VM state should be running after deployment"
-                        )
+            vm_response.state,
+            "Running",
+            "VM state should be running after deployment"
+        )
 
         self.debug("Deploying another VM in account: %s" %
-                                            self.account.name)
+                   self.account.name)
 
         # Spawn an instance in that network
         virtual_machine_2 = VirtualMachine.create(
-                                  self.apiclient,
-                                  self.services["virtual_machine"],
-                                  accountid=self.account.name,
-                                  domainid=self.account.domainid,
-                                  serviceofferingid=self.service_offering.id,
-                                  networkids=[str(self.network.id)]
-                                  )
+            self.apiclient,
+            self.services["virtual_machine"],
+            accountid=self.account.name,
+            domainid=self.account.domainid,
+            serviceofferingid=self.service_offering.id,
+            networkids=[str(self.network.id)]
+        )
         self.debug("Deployed VM in network: %s" % self.network.id)
         list_vm_response = VirtualMachine.list(
-                                        self.apiclient,
-                                        id=virtual_machine_2.id
-                                        )
+            self.apiclient,
+            id=virtual_machine_2.id
+        )
 
         self.debug(
-                "Verify listVirtualMachines response for virtual machine: %s" \
-                % virtual_machine_2.id
-            )
+            "Verify listVirtualMachines response for virtual machine: %s"
+            % virtual_machine_2.id
+        )
 
         self.assertEqual(
-                            isinstance(list_vm_response, list),
-                            True,
-                            "Check list response returns a valid list"
-                        )
+            isinstance(list_vm_response, list),
+            True,
+            "Check list response returns a valid list"
+        )
         vm_response = list_vm_response[0]
 
         self.assertEqual(
-                            vm_response.state,
-                            "Running",
-                            "VM state should be running after deployment"
-                        )
+            vm_response.state,
+            "Running",
+            "VM state should be running after deployment"
+        )
         self.debug("Associating public IP for network: %s" % self.network.id)
 
         ip_with_lb_rule = PublicIPAddress.create(
-                                self.apiclient,
-                                accountid=self.account.name,
-                                zoneid=self.zone.id,
-                                domainid=self.account.domainid,
-                                networkid=self.network.id
-                                )
+            self.apiclient,
+            accountid=self.account.name,
+            zoneid=self.zone.id,
+            domainid=self.account.domainid,
+            networkid=self.network.id
+        )
         self.debug("Associated %s with network %s" % (
-                                        ip_with_lb_rule.ipaddress.ipaddress,
-                                        self.network.id
-                                        ))
+            ip_with_lb_rule.ipaddress.ipaddress,
+            self.network.id
+        ))
         self.debug("Creating LB rule for IP address: %s" %
-                                        ip_with_lb_rule.ipaddress.ipaddress)
+                   ip_with_lb_rule.ipaddress.ipaddress)
 
         LoadBalancerRule.create(
-                                    self.apiclient,
-                                    self.services["lbrule"],
-                                    ipaddressid=ip_with_lb_rule.ipaddress.id,
-                                    accountid=self.account.name,
-                                    networkid=self.network.id
-                                )
+            self.apiclient,
+            self.services["lbrule"],
+            ipaddressid=ip_with_lb_rule.ipaddress.id,
+            accountid=self.account.name,
+            networkid=self.network.id
+        )
 
         self.debug("Trying to create PF rule on IP with LB rule: %s" %
-                                        ip_with_lb_rule.ipaddress.ipaddress)
+                   ip_with_lb_rule.ipaddress.ipaddress)
 
         with self.assertRaises(Exception):
             NATRule.create(
-                         self.apiclient,
-                         virtual_machine_1,
-                         self.services["natrule"],
-                         ipaddressid=ip_with_lb_rule.ipaddress.id
-                      )
+                self.apiclient,
+                virtual_machine_1,
+                self.services["natrule"],
+                ipaddressid=ip_with_lb_rule.ipaddress.id
+            )
         return
 
 
@@ -803,36 +817,44 @@ class TestLbOnNonSourceNat(cloudstackTestCase):
         cls.domain = get_domain(cls.api_client)
         cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
         cls.template = get_template(
-                            cls.api_client,
-                            cls.zone.id,
-                            cls.services["ostype"]
-                            )
+            cls.api_client,
+            cls.zone.id,
+            cls.services["ostype"]
+        )
+
+        response = GetNetscalerInfoFromConfig(
+            cls.config
+        )
+        assert response[0] is not None, response[1]
+        cls.services["netscaler"] = response[0]
+        cls.services["netscaler"]["lbdevicededicated"] = False
+
         try:
-           cls.netscaler = add_netscaler(cls.api_client, cls.zone.id, cls.services["netscaler"])
-           cls._cleanup.append(cls.netscaler)
-           cls.network_offering = NetworkOffering.create(
-                                            cls.api_client,
-                                            cls.services["network_offering"],
-                                            conservemode=False
-                                            )
-           # Enable Network offering
-           cls.network_offering.update(cls.api_client, state='Enabled')
-           cls.services["virtual_machine"]["zoneid"] = cls.zone.id
-           cls.services["virtual_machine"]["template"] = cls.template.id
-
-           cls.service_offering = ServiceOffering.create(
-                                            cls.api_client,
-                                            cls.services["service_offering"]
-                                            )
+            cls.netscaler = add_netscaler(cls.api_client, cls.zone.id, cls.services["netscaler"])
+            cls._cleanup.append(cls.netscaler)
+            cls.network_offering = NetworkOffering.create(
+                cls.api_client,
+                cls.services["network_offering"],
+                conservemode=False
+            )
+            # Enable Network offering
+            cls.network_offering.update(cls.api_client, state='Enabled')
+            cls.services["virtual_machine"]["zoneid"] = cls.zone.id
+            cls.services["virtual_machine"]["template"] = cls.template.id
+
+            cls.service_offering = ServiceOffering.create(
+                cls.api_client,
+                cls.services["service_offering"]
+            )
         except Exception as e:
-           cls.tearDownClass()
-           raise Exception ("Warning: Exception in setUpClass: %s" % e)
+            cls.tearDownClass()
+            raise Exception("Warning: Exception in setUpClass: %s" % e)
         return
 
     @classmethod
     def tearDownClass(cls):
         try:
-            #Cleanup resources used
+            # Cleanup resources used
             cleanup_resources(cls.api_client, cls._cleanup)
         except Exception as e:
             raise Exception("Warning: Exception during cleanup : %s" % e)
@@ -842,27 +864,27 @@ class TestLbOnNonSourceNat(cloudstackTestCase):
         self.apiclient = self.testClient.getApiClient()
         self.dbclient = self.testClient.getDbConnection()
         self.account = Account.create(
-                                     self.apiclient,
-                                     self.services["account"],
-                                     admin=True,
-                                     domainid=self.domain.id
-                                     )
+            self.apiclient,
+            self.services["account"],
+            admin=True,
+            domainid=self.domain.id
+        )
         self.cleanup = [self.account]
         return
 
     def tearDown(self):
         try:
             self.debug("Cleaning up the resources")
-            #Clean up, terminate the created network offerings
+            # Clean up, terminate the created network offerings
             cleanup_resources(self.apiclient, self.cleanup)
             interval = Configurations.list(
-                                    self.apiclient,
-                                    name='network.gc.interval'
-                                    )
+                self.apiclient,
+                name='network.gc.interval'
+            )
             wait = Configurations.list(
-                                    self.apiclient,
-                                    name='network.gc.wait'
-                                    )
+                self.apiclient,
+                name='network.gc.wait'
+            )
             # Sleep to ensure that all resources are deleted
             time.sleep(int(interval[0].value) + int(wait[0].value))
             self.debug("Cleanup complete!")
@@ -870,12 +892,11 @@ class TestLbOnNonSourceNat(cloudstackTestCase):
             raise Exception("Warning: Exception during cleanup : %s" % e)
         return
 
-    @attr(tags = ["advancedns"])
+    @attr(tags=["advancedns"])
     def test_lb_on_non_source_nat(self):
         """Test Create LB rule for non-sourceNat IP address
         """
 
-
         # Validate the following
         # 1. Deploy the first VM using a network from the above created
         #    Network offering.
@@ -885,124 +906,124 @@ class TestLbOnNonSourceNat(cloudstackTestCase):
 
         # Creating network using the network offering created
         self.debug("Creating network with network offering: %s" %
-                                                    self.network_offering.id)
+                   self.network_offering.id)
         self.network = Network.create(
-                                    self.apiclient,
-                                    self.services["network"],
-                                    accountid=self.account.name,
-                                    domainid=self.account.domainid,
-                                    networkofferingid=self.network_offering.id,
-                                    zoneid=self.zone.id
-                                    )
+            self.apiclient,
+            self.services["network"],
+            accountid=self.account.name,
+            domainid=self.account.domainid,
+            networkofferingid=self.network_offering.id,
+            zoneid=self.zone.id
+        )
         self.debug("Created network with ID: %s" % self.network.id)
 
         self.debug("Deploying VM in account: %s" % self.account.name)
 
         # Spawn an instance in that network
         virtual_machine_1 = VirtualMachine.create(
-                                  self.apiclient,
-                                  self.services["virtual_machine"],
-                                  accountid=self.account.name,
-                                  domainid=self.account.domainid,
-                                  serviceofferingid=self.service_offering.id,
-                                  networkids=[str(self.network.id)]
-                                  )
+            self.apiclient,
+            self.services["virtual_machine"],
+            accountid=self.account.name,
+            domainid=self.account.domainid,
+            serviceofferingid=self.service_offering.id,
+            networkids=[str(self.network.id)]
+        )
         self.debug("Deployed VM in network: %s" % self.network.id)
         list_vm_response = VirtualMachine.list(
-                                        self.apiclient,
-                                        id=virtual_machine_1.id
-                                        )
+            self.apiclient,
+            id=virtual_machine_1.id
+        )
 
         self.debug(
-                "Verify listVirtualMachines response for virtual machine: %s" \
-                % virtual_machine_1.id
-            )
+            "Verify listVirtualMachines response for virtual machine: %s"
+            % virtual_machine_1.id
+        )
 
         self.assertEqual(
-                            isinstance(list_vm_response, list),
-                            True,
-                            "Check list response returns a valid list"
-                        )
+            isinstance(list_vm_response, list),
+            True,
+            "Check list response returns a valid list"
+        )
         vm_response = list_vm_response[0]
 
         self.assertEqual(
-                            vm_response.state,
-                            "Running",
-                            "VM state should be running after deployment"
-                        )
+            vm_response.state,
+            "Running",
+            "VM state should be running after deployment"
+        )
 
         self.debug("Deploying another VM in account: %s" %
-                                            self.account.name)
+                   self.account.name)
 
         # Spawn an instance in that network
         virtual_machine_2 = VirtualMachine.create(
-                                  self.apiclient,
-                                  self.services["virtual_machine"],
-                                  accountid=self.account.name,
-                                  domainid=self.account.domainid,
-                                  serviceofferingid=self.service_offering.id,
-                                  networkids=[str(self.network.id)]
-                                  )
+            self.apiclient,
+            self.services["virtual_machine"],
+            accountid=self.account.name,
+            domainid=self.account.domainid,
+            serviceofferingid=self.service_offering.id,
+            networkids=[str(self.network.id)]
+        )
         self.debug("Deployed VM in network: %s" % self.network.id)
         list_vm_response = VirtualMachine.list(
-                                        self.apiclient,
-                                        id=virtual_machine_2.id
-                                        )
+            self.apiclient,
+            id=virtual_machine_2.id
+        )
 
         self.debug(
-                "Verify listVirtualMachines response for virtual machine: %s" \
-                % virtual_machine_2.id
-            )
+            "Verify listVirtualMachines response for virtual machine: %s"
+            % virtual_machine_2.id
+        )
 
         self.assertEqual(
-                            isinstance(list_vm_response, list),
-                            True,
-                            "Check list response returns a valid list"
-                        )
+            isinstance(list_vm_response, list),
+            True,
+            "Check list response returns a valid list"
+        )
         vm_response = list_vm_response[0]
 
         self.assertEqual(
-                            vm_response.state,
-                            "Running",
-                            "VM state should be running after deployment"
-                        )
+            vm_response.state,
+            "Running",
+            "VM state should be running after deployment"
+        )
         self.debug("Associating public IP for network: %s" % self.network.id)
 
         ip_with_lb_rule = PublicIPAddress.create(
-                                self.apiclient,
-                                accountid=self.account.name,
-                                zoneid=self.zone.id,
-                                domainid=self.account.domainid,
-                                networkid=self.network.id
-                                )
+            self.apiclient,
+            accountid=self.account.name,
+            zoneid=self.zone.id,
+            domainid=self.account.domainid,
+            networkid=self.network.id
+        )
         self.debug("Associated %s with network %s" % (
-                                        ip_with_lb_rule.ipaddress.ipaddress,
-                                        self.network.id
-                                        ))
+            ip_with_lb_rule.ipaddress.ipaddress,
+            self.network.id
+        ))
         self.debug("Creating LB rule for IP address: %s" %
-                                        ip_with_lb_rule.ipaddress.ipaddress)
+                   ip_with_lb_rule.ipaddress.ipaddress)
 
         lb_rule = LoadBalancerRule.create(
-                                    self.apiclient,
-                                    self.services["lbrule"],
-                                    ipaddressid=ip_with_lb_rule.ipaddress.id,
-                                    accountid=self.account.name,
-                                    networkid=self.network.id
-                                )
+            self.apiclient,
+            self.services["lbrule"],
+            ipaddressid=ip_with_lb_rule.ipaddress.id,
+            accountid=self.account.name,
+            networkid=self.network.id
+        )
 
         self.debug("Trying to create PF rule on IP with LB rule: %s" %
-                                        ip_with_lb_rule.ipaddress.ipaddress)
+                   ip_with_lb_rule.ipaddress.ipaddress)
 
         lb_rules = LoadBalancerRule.list(
-                                         self.apiclient,
-                                         id=lb_rule.id,
-                                         listall=True
-                                         )
+            self.apiclient,
+            id=lb_rule.id,
+            listall=True
+        )
         self.assertEqual(
-                         isinstance(lb_rules, list),
-                         True,
-                         "List LB rules should return a newly created LB rule"
-                         )
+            isinstance(lb_rules, list),
+            True,
+            "List LB rules should return a newly created LB rule"
+        )
         return
 
 
@@ -1019,36 +1040,44 @@ class TestAddMultipleVmsLb(cloudstackTestCase):
         cls.domain = get_domain(cls.api_client)
         cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
         cls.template = get_template(
-                            cls.api_client,
-                            cls.zone.id,
-                            cls.services["ostype"]
-                            )
+            cls.api_client,
+            cls.zone.id,
+            cls.services["ostype"]
+        )
+
+        response = GetNetscalerInfoFromConfig(
+            cls.config
+        )
+        assert response[0] is not None, response[1]
+        cls.services["netscaler"] = response[0]
+        cls.services["netscaler"]["lbdevicededicated"] = False
+
         try:
-           cls.netscaler = add_netscaler(cls.api_client, cls.zone.id, cls.services["netscaler"])
-           cls._cleanup.append(cls.netscaler)
-           cls.network_offering = NetworkOffering.create(
-                                            cls.api_client,
-                                            cls.services["network_offering"],
-                                            conservemode=True
-                                            )
-           # Enable Network offering
-           cls.network_offering.update(cls.api_client, state='Enabled')
-           cls.services["virtual_machine"]["zoneid"] = cls.zone.id
-           cls.services["virtual_machine"]["template"] = cls.template.id
-
-           cls.service_offering = ServiceOffering.create(
-                                            cls.api_client,
-                                            cls.services["service_offering"]
-                                            )
+            cls.netscaler = add_netscaler(cls.api_client, cls.zone.id, cls.services["netscaler"])
+            cls._cleanup.append(cls.netscaler)
+            cls.network_offering = NetworkOffering.create(
+                cls.api_client,
+                cls.services["network_offering"],
+                conservemode=True
+            )
+            # Enable Network offering
+            cls.network_offering.update(cls.api_client, state='Enabled')
+            cls.services["virtual_machine"]["zoneid"] = cls.zone.id
+            cls.services["virtual_machine"]["template"] = cls.template.id
+
+            cls.service_offering = ServiceOffering.create(
+                cls.api_client,
+                cls.services["service_offering"]
+            )
         except Exception as e:
-           cls.tearDownClass()
-           raise Exception ("Warning: Exception in setUpClass: %s" % e)
+            cls.tearDownClass()
+            raise Exception("Warning: Exception in setUpClass: %s" % e)
         return
 
     @classmethod
     def tearDownClass(cls):
         try:
-            #Cleanup resources used
+            # Cleanup resources used
             cleanup_resources(cls.api_client, cls._cleanup)
         except Exception as e:
             raise Exception("Warning: Exception during cleanup : %s" % e)
@@ -1058,27 +1087,27 @@ class TestAddMultipleVmsLb(cloudstackTestCase):
         self.apiclient = self.testClient.getApiClient()
         self.dbclient = self.testClient.getDbConnection()
         self.account = Account.create(
-                                     self.apiclient,
-                                     self.services["account"],
-                                     admin=True,
-                                     domainid=self.domain.id
-                                     )
+            self.apiclient,
+            self.services["account"],
+            admin=True,
+            domainid=self.domain.id
+        )
         self.cleanup = [self.account]
         return
 
     def tearDown(self):
         try:
             self.debug("Cleaning up the resources")
-            #Clean up, terminate the created network offerings
+            # Clean up, terminate the created network offerings
             cleanup_resources(self.apiclient, self.cleanup)
             interval = Configurations.list(
-                                    self.apiclient,
-                                    name='network.gc.interval'
-                                    )
+                self.apiclient,
+                name='network.gc.interval'
+            )
             wait = Configurations.list(
-                                    self.apiclient,
-                                    name='network.gc.wait'
-                                    )
+                self.apiclient,
+                name='network.gc.wait'
+            )
             # Sleep to ensure that all resources are deleted
             time.sleep(int(interval[0].value) + int(wait[0].value))
             self.debug("Cleanup complete!")
@@ -1086,12 +1115,11 @@ class TestAddMultipleVmsLb(cloudstackTestCase):
             raise Exception("Warning: Exception during cleanup : %s" % e)
         return
 
-    @attr(tags = ["advancedns"])
+    @attr(tags=["advancedns"])
     def test_add_multiple_vms_lb(self):
         """Test Add multiple Vms to an existing LB rule.
         """
 
-
         # Validate the following
         # 1. Deploy the first VM using a network from the above created
         #    Network offering.
@@ -1106,151 +1134,151 @@ class TestAddMultipleVmsLb(cloudstackTestCase):
 
         # Creating network using the network offering created
         self.debug("Creating network with network offering: %s" %
-                                                    self.network_offering.id)
+                   self.network_offering.id)
         self.network = Network.create(
-                                    self.apiclient,
-                                    self.services["network"],
-                                    accountid=self.account.name,
-                                    domainid=self.account.domainid,
-                                    networkofferingid=self.network_offering.id,
-                                    zoneid=self.zone.id
-                                    )
+            self.apiclient,
+            self.services["network"],
+            accountid=self.account.name,
+            domainid=self.account.domainid,
+            networkofferingid=self.network_offering.id,
+            zoneid=self.zone.id
+        )
         self.debug("Created network with ID: %s" % self.network.id)
 
         self.debug("Deploying VM in account: %s" % self.account.name)
 
         # Spawn an instance in that network
         virtual_machine_1 = VirtualMachine.create(
-                                  self.apiclient,
-                                  self.services["virtual_machine"],
-                                  accountid=self.account.name,
-                                  domainid=self.account.domainid,
-                                  serviceofferingid=self.service_offering.id,
-                                  networkids=[str(self.network.id)]
-                                  )
+            self.apiclient,
+            self.services["virtual_machine"],
+            accountid=self.account.name,
+            domainid=self.account.domainid,
+            serviceofferingid=self.service_offering.id,
+            networkids=[str(self.network.id)]
+        )
         self.debug("Deployed VM in network: %s" % self.network.id)
         list_vm_response = VirtualMachine.list(
-                                        self.apiclient,
-                                        id=virtual_machine_1.id
-                                        )
+            self.apiclient,
+            id=virtual_machine_1.id
+        )
 
         self.debug(
-                "Verify listVirtualMachines response for virtual machine: %s" \
-                % virtual_machine_1.id
-            )
+            "Verify listVirtualMachines response for virtual machine: %s"
+            % virtual_machine_1.id
+        )
 
         self.assertEqual(
-                            isinstance(list_vm_response, list),
-                            True,
-                            "Check list response returns a valid list"
-                        )
+            isinstance(list_vm_response, list),
+            True,
+            "Check list response returns a valid list"
+        )
         vm_response = list_vm_response[0]
 
         self.assertEqual(
-                            vm_response.state,
-                            "Running",
-                            "VM state should be running after deployment"
-                        )
+            vm_response.state,
+            "Running",
+            "VM state should be running after deployment"
+        )
 
         self.debug("Deploying another VM in account: %s" %
-                                            self.account.name)
+                   self.account.name)
 
         # Spawn an instance in that network
         virtual_machine_2 = VirtualMachine.create(
-                                  self.apiclient,
-                                  self.services["virtual_machine"],
-                                  accountid=self.account.name,
-                                  domainid=self.account.domainid,
-                                  serviceofferingid=self.service_offering.id,
-                                  networkids=[str(self.network.id)]
-                                  )
+            self.apiclient,
+            self.services["virtual_machine"],
+            accountid=self.account.name,
+            domainid=self.account.domainid,
+            serviceofferingid=self.service_offering.id,
+            networkids=[str(self.network.id)]
+        )
         self.debug("Deployed VM in network: %s" % self.network.id)
         list_vm_response = VirtualMachine.list(
-                                        self.apiclient,
-                                        id=virtual_machine_2.id
-                                        )
+            self.apiclient,
+            id=virtual_machine_2.id
+        )
 
         self.debug(
-                "Verify listVirtualMachines response for virtual machine: %s" \
-                % virtual_machine_2.id
-            )
+            "Verify listVirtualMachines response for virtual machine: %s"
+            % virtual_machine_2.id
+        )
 
         self.assertEqual(
-                            isinstance(list_vm_response, list),
-                            True,
-                            "Check list response returns a valid list"
-                        )
+            isinstance(list_vm_response, list),
+            True,
+            "Check list response returns a valid list"
+        )
         vm_response = list_vm_response[0]
 
         self.assertEqual(
-                            vm_response.state,
-                            "Running",
-                            "VM state should be running after deployment"
-                        )
+            vm_response.state,
+            "Running",
+            "VM state should be running after deployment"
+        )
         self.debug("Associating public IP for network: %s" % self.network.id)
 
         ip_with_lb_rule = PublicIPAddress.create(
-                                self.apiclient,
-                                accountid=self.account.name,
-                                zoneid=self.zone.id,
-                                domainid=self.account.domainid,
-                                networkid=self.network.id
-                                )
+            self.apiclient,
+            accountid=self.account.name,
+            zoneid=self.zone.id,
+            domainid=self.account.domainid,
+            networkid=self.network.id
+        )
         self.debug("Associated %s with network %s" % (
-                                        ip_with_lb_rule.ipaddress.ipaddress,
-                                        self.network.id
-                                        ))
+            ip_with_lb_rule.ipaddress.ipaddress,
+            self.network.id
+        ))
         self.debug("Creating LB rule for IP address: %s" %
-                                        ip_with_lb_rule.ipaddress.ipaddress)
+                   ip_with_lb_rule.ipaddress.ipaddress)
 
         lb_rule = LoadBalancerRule.create(
-                                    self.apiclient,
-                                    self.services["lbrule"],
-                                    ipaddressid=ip_with_lb_rule.ipaddress.id,
-                                    accountid=self.account.name,
-                                    networkid=self.network.id
-                                )
+            self.apiclient,
+            self.services["lbrule"],
+            ipaddressid=ip_with_lb_rule.ipaddress.id,
+            accountid=self.account.name,
+            networkid=self.network.id
+        )
 
         self.debug("Trying to create PF rule on IP with LB rule: %s" %
-                                        ip_with_lb_rule.ipaddress.ipaddress)
+                   ip_with_lb_rule.ipaddress.ipaddress)
 
         lb_rules = LoadBalancerRule.list(
-                                         self.apiclient,
-                                         id=lb_rule.id,
-                                         listall=True
-                                         )
+            self.apiclient,
+            id=lb_rule.id,
+            listall=True
+        )
         self.assertEqual(
-                         isinstance(lb_rules, list),
-                         True,
-                         "List LB rules should return a newly created LB rule"
-                         )
+            isinstance(lb_rules, list),
+            True,
+            "List LB rules should return a newly created LB rule"
+        )
         self.debug("Assigning virtual machines to LB rule")
         lb_rule.assign(self.apiclient, [virtual_machine_1, virtual_machine_2])
 
         self.debug("SSH into netscaler: %s" %
-                                    self.services["netscaler"]["ipaddress"])
+                   self.services["netscaler"]["ipaddress"])
         try:
             ssh_client = SshClient(
-                                    self.services["netscaler"]["ipaddress"],
-                                    22,
-                                    self.services["netscaler"]["username"],
-                                    self.services["netscaler"]["password"],
-                                    )
+                self.services["netscaler"]["ipaddress"],
+                22,
+                self.services["netscaler"]["username"],
+                self.services["netscaler"]["password"],
+            )
             self.debug("command: show server")
             res = ssh_client.execute("show server")
             result = str(res)
             self.debug("Output: %s" % result)
 
             self.assertEqual(
-                    result.count(virtual_machine_1.ipaddress),
-                    2,
-                    "Server must be configured for virtual machines"
-                    )
+                result.count(virtual_machine_1.ipaddress),
+                2,
+                "Server must be configured for virtual machines"
+            )
             self.assertEqual(
-                    result.count(virtual_machine_2.ipaddress),
-                    2,
-                    "Server must be configured for virtual machines"
-                    )
+                result.count(virtual_machine_2.ipaddress),
+                2,
+                "Server must be configured for virtual machines"
+            )
 
             self.debug("Command:show service")
             res = ssh_client.execute("show service")
@@ -1259,15 +1287,15 @@ class TestAddMultipleVmsLb(cloudstackTestCase):
             self.debug("Output: %s" % result)
 
             self.assertEqual(
-                    result.count(virtual_machine_1.ipaddress),
-                    3,
-                    "Service must be configured for virtual machines"
-                    )
+                result.count(virtual_machine_1.ipaddress),
+                3,
+                "Service must be configured for virtual machines"
+            )
             self.assertEqual(
-                    result.count(virtual_machine_2.ipaddress),
-                    3,
-                    "Service must be configured for virtual machines"
-                    )
+                result.count(virtual_machine_2.ipaddress),
+                3,
+                "Service must be configured for virtual machines"
+            )
             self.debug("Command:show lb vserver")
             res = ssh_client.execute("show lb vserver")
 
@@ -1275,15 +1303,16 @@ class TestAddMultipleVmsLb(cloudstackTestCase):
             self.debug("Output: %s" % result)
 
             self.assertEqual(
-                    result.count(ip_with_lb_rule.ipaddress.ipaddress),
-                    2,
-                    "virtual server must be configured for public IP address"
-                    )
+                result.count(ip_with_lb_rule.ipaddress.ipaddress),
+                2,
+                "virtual server must be configured for public IP address"
+            )
         except Exception as e:
-            self.fail("SSH Access failed for %s: %s" % \
+            self.fail("SSH Access failed for %s: %s" %
                       (self.services["netscaler"]["ipaddress"], e))
         return
 
+
 class TestMultipleLbRules(cloudstackTestCase):
 
     @classmethod
@@ -1297,37 +1326,45 @@ class TestMultipleLbRules(cloudstackTestCase):
         cls.domain = get_domain(cls.api_client)
         cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
         cls.template = get_template(
-                            cls.api_client,
-                            cls.zone.id,
-                            cls.services["ostype"]
-                            )
+            cls.api_client,
+            cls.zone.id,
+            cls.services["ostype"]
+        )
+
+        response = GetNetscalerInfoFromConfig(
+            cls.config
+        )
+        assert response[0] is not None, response[1]
+        cls.services["netscaler"] = response[0]
+        cls.services["netscaler"]["lbdevicededicated"] = False
+
         try:
-           cls.netscaler = add_netscaler(cls.api_client, cls.zone.id, cls.services["netscaler"])
-           cls._cleanup.append(cls.netscaler)
-           cls.network_offering = NetworkOffering.create(
-                                            cls.api_client,
-                                            cls.services["network_offering"],
-                                            conservemode=True
-                                            )
-           # Enable Network offering
-           cls.network_offering.update(cls.api_client, state='Enabled')
-           cls.services["virtual_machine"]["zoneid"] = cls.zone.id
-           cls.services["virtual_machine"]["template"] = cls.template.id
-
-           cls.service_offering = ServiceOffering.create(
-                                            cls.api_client,
-                                            cls.services["service_offering"]
-                                            )
+            cls.netscaler = add_netscaler(cls.api_client, cls.zone.id, cls.services["netscaler"])
+            cls._cleanup.append(cls.netscaler)
+            cls.network_offering = NetworkOffering.create(
+                cls.api_client,
+                cls.services["network_offering"],
+                conservemode=True
+            )
+            # Enable Network offering
+            cls.network_offering.update(cls.api_client, state='Enabled')
+            cls.services["virtual_machine"]["zoneid"] = cls.zone.id
+            cls.services["virtual_machine"]["template"] = cls.template.id
+
+            cls.service_offering = ServiceOffering.create(
+                cls.api_client,
+                cls.services["service_offering"]
+            )
         except Exception as e:
-           cls.tearDownClass()
-           raise Exception ("Warning: Exception in setUpClass: %s" % e)
+            cls.tearDownClass()
+            raise Exception("Warning: Exception in setUpClass: %s" % e)
 
         return
 
     @classmethod
     def tearDownClass(cls):
         try:
-            #Cleanup resources used
+            # Cleanup resources used
             cleanup_resources(cls.api_client, cls._cleanup)
         except Exception as e:
             raise Exception("Warning: Exception during cleanup : %s" % e)
@@ -1337,27 +1374,27 @@ class TestMultipleLbRules(cloudstackTestCase):
         self.apiclient = self.testClient.getApiClient()
         self.dbclient = self.testClient.getDbConnection()
         self.account = Account.create(
-                                     self.apiclient,
-                                     self.services["account"],
-                                     admin=True,
-                                     domainid=self.domain.id
-                                     )
+            self.apiclient,
+            self.services["account"],
+            admin=True,
+            domainid=self.domain.id
+        )
         self.cleanup = [self.account]
         return
 
     def tearDown(self):
         try:
             self.debug("Cleaning up the resources")
-            #Clean up, terminate the created network offerings
+            # Clean up, terminate the created network offerings
             cleanup_resources(self.apiclient, self.cleanup)
             interval = Configurations.list(
-                                    self.apiclient,
-                                    name='network.gc.interval'
-                                    )
+                self.apiclient,
+                name='network.gc.interval'
+            )
             wait = Configurations.list(
-                                    self.apiclient,
-                                    name='network.gc.wait'
-                                    )
+                self.apiclient,
+                name='network.gc.wait'
+            )
             # Sleep to ensure that all resources are deleted
             time.sleep(int(interval[0].value) + int(wait[0].value))
             self.debug("Cleanup complete!")
@@ -1365,12 +1402,11 @@ class TestMultipleLbRules(cloudstackTestCase):
             raise Exception("Warning: Exception during cleanup : %s" % e)
         return
 
-    @attr(tags = ["advancedns"])
+    @attr(tags=["advancedns"])
     def test_multiple_lb_publicip(self):
         """Test Create multiple LB rules using different public Ips acquired
         """
 
-
         # Validate the following
         # 1. Deploy the first VM using a network from the above created
         #    Network offering.
@@ -1381,188 +1417,188 @@ class TestMultipleLbRules(cloudstackTestCase):
 
         # Creating network using the network offering created
         self.debug("Creating network with network offering: %s" %
-                                                    self.network_offering.id)
+                   self.network_offering.id)
         self.network = Network.create(
-                                    self.apiclient,
-                                    self.services["network"],
-                                    accountid=self.account.name,
-                                    domainid=self.account.domainid,
-                                    networkofferingid=self.network_offering.id,
-                                    zoneid=self.zone.id
-                                    )
+            self.apiclient,
+            self.services["network"],
+            accountid=self.account.name,
+            domainid=self.account.domainid,
+            networkofferingid=self.network_offering.id,
+            zoneid=self.zone.id
+        )
         self.debug("Created network with ID: %s" % self.network.id)


<TRUNCATED>

Mime
View raw message