cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tall...@apache.org
Subject [3/5] git commit: updated refs/heads/4.5 to 5f99917
Date Mon, 17 Nov 2014 09:46:35 GMT
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/5f999179/test/integration/component/test_netscaler_lb_algo.py
----------------------------------------------------------------------
diff --git a/test/integration/component/test_netscaler_lb_algo.py b/test/integration/component/test_netscaler_lb_algo.py
index 6eda9a3..0d571b4 100644
--- a/test/integration/component/test_netscaler_lb_algo.py
+++ b/test/integration/component/test_netscaler_lb_algo.py
@@ -17,98 +17,97 @@
 
 """ P1 tests for netscaler load balancing
 """
-#Import Local Modules
-import marvin
+# Import Local Modules
 from nose.plugins.attrib import attr
-from marvin.cloudstackTestCase import *
-from marvin.cloudstackAPI import *
-from marvin.lib.utils import *
-from marvin.lib.base import *
-from marvin.lib.common import *
+from marvin.cloudstackTestCase import cloudstackTestCase
+from marvin.lib.utils import (cleanup_resources)
+from marvin.lib.base import (Account,
+                             Network,
+                             VirtualMachine,
+                             ServiceOffering,
+                             NetworkOffering,
+                             PublicIPAddress,
+                             LoadBalancerRule)
+from marvin.lib.common import (get_zone,
+                               get_domain,
+                               get_template,
+                               list_configurations,
+                               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
-                                    "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.60.27',
-                                "username": 'nsroot',
-                                "password": 'nsroot',
-                                "networkdevicetype": 'NetscalerVPXLoadBalancer',
-                                "publicinterface": '1/1',
-                                "privateinterface": '1/1',
-                                "numretries": 2,
-                                "lbdevicededicated": False,
-                                "lbdevicecapacity": 50,
-                                "port": 22,
-                         },
-                         "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": "leastconn",
-                                    # Algorithm used for load balancing
-                                    "privateport": 22,
-                                    "publicport": 22,
-                                    "openfirewall": False,
-                         },
-                         "ostype": 'CentOS 5.3 (64-bit)',
-                         # Cent OS 5.3 (64 bit)
-                         "sleep": 60,
-                         "timeout": 10,
-                         "mode": 'advanced'
-                    }
+            "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',
+            },
+            "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": "leastconn",
+                # Algorithm used for load balancing
+                "privateport": 22,
+                "publicport": 22,
+                "openfirewall": False,
+            },
+            "ostype": 'CentOS 5.3 (64-bit)',
+            # Cent OS 5.3 (64 bit)
+            "sleep": 60,
+            "timeout": 10,
+            "mode": 'advanced'
+        }
 
 
 class TestLbWithRoundRobin(cloudstackTestCase):
@@ -124,36 +123,45 @@ class TestLbWithRoundRobin(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
+
+        cls._cleanup = []
         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)
@@ -163,27 +171,27 @@ class TestLbWithRoundRobin(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 = list_configurations(
-                                    self.apiclient,
-                                    name='network.gc.interval'
-                                    )
+                self.apiclient,
+                name='network.gc.interval'
+            )
             wait = list_configurations(
-                                    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!")
@@ -191,7 +199,7 @@ class TestLbWithRoundRobin(cloudstackTestCase):
             raise Exception("Warning: Exception during cleanup : %s" % e)
         return
 
-    @attr(tags = ["advancedns"])
+    @attr(tags=["advancedns"])
     def test_lb_with_round_robin(self):
         """Test Create LB rule with round robin algorithm
         """
@@ -206,119 +214,120 @@ class TestLbWithRoundRobin(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
         self.virtual_machine = 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=self.virtual_machine.id
-                                        )
+            self.apiclient,
+            id=self.virtual_machine.id
+        )
 
         self.debug(
-                "Verify listVirtualMachines response for virtual machine: %s" \
-                % self.virtual_machine.id
-            )
+            "Verify listVirtualMachines response for virtual machine: %s"
+            % self.virtual_machine.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 with round robin algo" %
-                                        ip_with_lb_rule.ipaddress.ipaddress)
+            ip_with_lb_rule.ipaddress.ipaddress)
 
         self.services["lbrule"]["alg"] = 'roundrobin'
         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
+        )
 
         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("Adding %s to the LB rule %s" % (
-                                                self.virtual_machine.name,
-                                                lb_rule.name
-                                                ))
+            self.virtual_machine.name,
+            lb_rule.name
+        ))
         lb_rule.assign(self.apiclient, [self.virtual_machine])
-        self.debug("SSH into Netscaler to check whether algorithm is configured properly or not?")
+        self.debug(
+            "SSH into Netscaler to check whether algorithm is configured properly or not?")
         self.debug("SSH into netscaler: %s" %
-                                    self.services["netscaler"]["ipaddress"])
+                   self.services["netscaler"]["ipaddress"])
         try:
             ssh_client = SshClient(
-                                    self.services["netscaler"]["ipaddress"],
-                                    self.services["netscaler"]["port"],
-                                    self.services["netscaler"]["username"],
-                                    self.services["netscaler"]["password"],
-                                    )
+                self.services["netscaler"]["ipaddress"],
+                self.services["netscaler"]["port"],
+                self.services["netscaler"]["username"],
+                self.services["netscaler"]["password"],
+            )
             cmd = "show lb vserver Cloud-VirtualServer-%s-%s" % (
-                                        ip_with_lb_rule.ipaddress.ipaddress,
-                                        lb_rule.publicport)
+                ip_with_lb_rule.ipaddress.ipaddress,
+                lb_rule.publicport)
             self.debug("command: %s" % cmd)
             res = ssh_client.execute(cmd)
             result = str(res)
             self.debug("Output: %s" % result)
 
             self.assertEqual(
-                    result.count("Configured Method: ROUNDROBIN"),
-                    1,
-                    "'ROUNDROBIN' algorithm should be configured on NS"
-                    )
+                result.count("Configured Method: ROUNDROBIN"),
+                1,
+                "'ROUNDROBIN' algorithm should be configured on NS"
+            )
 
         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
 
@@ -336,38 +345,48 @@ class TestLbWithLeastConn(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
+            )
+            cls._cleanup.append(cls.network_offering)
+            # 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._cleanup.append(cls.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)
@@ -377,27 +396,27 @@ class TestLbWithLeastConn(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 = list_configurations(
-                                    self.apiclient,
-                                    name='network.gc.interval'
-                                    )
+                self.apiclient,
+                name='network.gc.interval'
+            )
             wait = list_configurations(
-                                    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!")
@@ -405,7 +424,7 @@ class TestLbWithLeastConn(cloudstackTestCase):
             raise Exception("Warning: Exception during cleanup : %s" % e)
         return
 
-    @attr(tags = ["advancedns"])
+    @attr(tags=["advancedns"])
     def test_lb_with_least_conn(self):
         """Test Create LB rule with least connection algorithm
         """
@@ -420,127 +439,128 @@ class TestLbWithLeastConn(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
         self.virtual_machine = 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=self.virtual_machine.id
-                                        )
+            self.apiclient,
+            id=self.virtual_machine.id
+        )
 
         self.debug(
-                "Verify listVirtualMachines response for virtual machine: %s" \
-                % self.virtual_machine.id
-            )
+            "Verify listVirtualMachines response for virtual machine: %s"
+            % self.virtual_machine.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)
 
         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
+        )
         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 with round robin algo" %
-                                        ip_with_lb_rule.ipaddress.ipaddress)
+            ip_with_lb_rule.ipaddress.ipaddress)
 
         self.services["lbrule"]["alg"] = 'leastconn'
         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
+        )
 
         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("Adding %s to the LB rule %s" % (
-                                                self.virtual_machine.name,
-                                                lb_rule.name
-                                                ))
+            self.virtual_machine.name,
+            lb_rule.name
+        ))
         lb_rule.assign(self.apiclient, [self.virtual_machine])
 
-        self.debug("SSH into Netscaler to check whether algorithm is configured properly or not?")
+        self.debug(
+            "SSH into Netscaler to check whether algorithm is configured properly or not?")
         self.debug("SSH into netscaler: %s" %
-                                    self.services["netscaler"]["ipaddress"])
+                   self.services["netscaler"]["ipaddress"])
         try:
             ssh_client = SshClient(
-                                    self.services["netscaler"]["ipaddress"],
-                                    self.services["netscaler"]["port"],
-                                    self.services["netscaler"]["username"],
-                                    self.services["netscaler"]["password"],
-                                    )
+                self.services["netscaler"]["ipaddress"],
+                self.services["netscaler"]["port"],
+                self.services["netscaler"]["username"],
+                self.services["netscaler"]["password"],
+            )
             cmd = "show lb vserver Cloud-VirtualServer-%s-%s" % (
-                                        ip_with_lb_rule.ipaddress.ipaddress,
-                                        lb_rule.publicport)
+                ip_with_lb_rule.ipaddress.ipaddress,
+                lb_rule.publicport)
             self.debug("command: %s" % cmd)
             res = ssh_client.execute(cmd)
             result = str(res)
             self.debug("Output: %s" % result)
 
             self.assertEqual(
-                    result.count("Configured Method: LEASTCONNECTION"),
-                    1,
-                    "'LEASTCONNECTION' algorithm should be configured on NS"
-                    )
+                result.count("Configured Method: LEASTCONNECTION"),
+                1,
+                "'LEASTCONNECTION' algorithm should be configured on NS"
+            )
 
         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
 
@@ -557,38 +577,47 @@ class TestLbWithSourceIp(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
+
+        cls._cleanup = []
         try:
-           cls.netscaler = add_netscaler(cls.api_client, cls.zone.id, cls.services["netscaler"])
-           cls._cleanup = [
-                    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
+            )
+            cls._cleanup.append(cls.network_offering)
+            # 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._cleanup.append(cls.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)
@@ -598,27 +627,27 @@ class TestLbWithSourceIp(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 = list_configurations(
-                                    self.apiclient,
-                                    name='network.gc.interval'
-                                    )
+                self.apiclient,
+                name='network.gc.interval'
+            )
             wait = list_configurations(
-                                    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!")
@@ -626,7 +655,7 @@ class TestLbWithSourceIp(cloudstackTestCase):
             raise Exception("Warning: Exception during cleanup : %s" % e)
         return
 
-    @attr(tags = ["advancedns"])
+    @attr(tags=["advancedns"])
     def test_lb_with_source_ip(self):
         """Test Create LB rule with source Ip algorithm
         """
@@ -641,120 +670,121 @@ class TestLbWithSourceIp(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
         self.virtual_machine = 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=self.virtual_machine.id
-                                        )
+            self.apiclient,
+            id=self.virtual_machine.id
+        )
 
         self.debug(
-                "Verify listVirtualMachines response for virtual machine: %s" \
-                % self.virtual_machine.id
-            )
+            "Verify listVirtualMachines response for virtual machine: %s"
+            % self.virtual_machine.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 with round robin algo" %
-                                        ip_with_lb_rule.ipaddress.ipaddress)
+            ip_with_lb_rule.ipaddress.ipaddress)
 
         self.services["lbrule"]["alg"] = 'source'
         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
+        )
 
         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("Adding %s to the LB rule %s" % (
-                                                self.virtual_machine.name,
-                                                lb_rule.name
-                                                ))
+            self.virtual_machine.name,
+            lb_rule.name
+        ))
         lb_rule.assign(self.apiclient, [self.virtual_machine])
-        self.debug("SSH into Netscaler to check whether algorithm is configured properly or not?")
+        self.debug(
+            "SSH into Netscaler to check whether algorithm is configured properly or not?")
         self.debug("SSH into netscaler: %s" %
-                                    self.services["netscaler"]["ipaddress"])
+                   self.services["netscaler"]["ipaddress"])
         try:
             ssh_client = SshClient(
-                                    self.services["netscaler"]["ipaddress"],
-                                    self.services["netscaler"]["port"],
-                                    self.services["netscaler"]["username"],
-                                    self.services["netscaler"]["password"],
-                                    )
+                self.services["netscaler"]["ipaddress"],
+                self.services["netscaler"]["port"],
+                self.services["netscaler"]["username"],
+                self.services["netscaler"]["password"],
+            )
             cmd = "show lb vserver Cloud-VirtualServer-%s-%s" % (
-                                        ip_with_lb_rule.ipaddress.ipaddress,
-                                        lb_rule.publicport)
+                ip_with_lb_rule.ipaddress.ipaddress,
+                lb_rule.publicport)
             self.debug("command: %s" % cmd)
             res = ssh_client.execute(cmd)
             result = str(res)
             self.debug("Output: %s" % result)
 
             self.assertEqual(
-                    result.count("Configured Method: SOURCEIPHASH"),
-                    1,
-                    "'SOURCEIPHASH' algorithm should be configured on NS"
-                    )
+                result.count("Configured Method: SOURCEIPHASH"),
+                1,
+                "'SOURCEIPHASH' algorithm should be configured on NS"
+            )
 
         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
 
@@ -772,62 +802,72 @@ class TestLbAlgoRrLc(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.account = Account.create(
-                                     cls.api_client,
-                                     cls.services["account"],
-                                     admin=True,
-                                     domainid=cls.domain.id
-                                     )
-           cls._cleanup.insert(0,cls.account)
-           cls.network = Network.create(
-                                    cls.api_client,
-                                    cls.services["network"],
-                                    accountid=cls.account.name,
-                                    domainid=cls.account.domainid,
-                                    networkofferingid=cls.network_offering.id,
-                                    zoneid=cls.zone.id
-                                    )
-           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"]
-                                            )
-
-           # Spawn an instance in that network
-           cls.virtual_machine = VirtualMachine.create(
-                                  cls.api_client,
-                                  cls.services["virtual_machine"],
-                                  accountid=cls.account.name,
-                                  domainid=cls.account.domainid,
-                                  serviceofferingid=cls.service_offering.id,
-                                  networkids=[str(cls.network.id)]
-                                  )
-           cls.public_ip = PublicIPAddress.create(
-                                cls.api_client,
-                                accountid=cls.account.name,
-                                zoneid=cls.zone.id,
-                                domainid=cls.account.domainid,
-                                networkid=cls.network.id
-                                )
+            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
+            )
+            cls._cleanup.append(cls.network_offering)
+            # Enable Network offering
+            cls.network_offering.update(cls.api_client, state='Enabled')
+            cls.account = Account.create(
+                cls.api_client,
+                cls.services["account"],
+                admin=True,
+                domainid=cls.domain.id
+            )
+            cls._cleanup.insert(0, cls.account)
+            cls.network = Network.create(
+                cls.api_client,
+                cls.services["network"],
+                accountid=cls.account.name,
+                domainid=cls.account.domainid,
+                networkofferingid=cls.network_offering.id,
+                zoneid=cls.zone.id
+            )
+            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._cleanup.append(cls.service_offering)
+
+            # Spawn an instance in that network
+            cls.virtual_machine = VirtualMachine.create(
+                cls.api_client,
+                cls.services["virtual_machine"],
+                accountid=cls.account.name,
+                domainid=cls.account.domainid,
+                serviceofferingid=cls.service_offering.id,
+                networkids=[str(cls.network.id)]
+            )
+            cls.public_ip = PublicIPAddress.create(
+                cls.api_client,
+                accountid=cls.account.name,
+                zoneid=cls.zone.id,
+                domainid=cls.account.domainid,
+                networkid=cls.network.id
+            )
         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
@@ -855,7 +895,7 @@ class TestLbAlgoRrLc(cloudstackTestCase):
             raise Exception("Warning: Exception during cleanup : %s" % e)
         return
 
-    @attr(tags = ["advancedns"])
+    @attr(tags=["advancedns"])
     def test_lb_round_robin_to_least_conn(self):
         """Test edit LB rule from round robin to least connection algo
         """
@@ -872,93 +912,95 @@ class TestLbAlgoRrLc(cloudstackTestCase):
 
         self.debug(
             "Creating LB rule for IP address: %s with round robin algo" %
-                                        self.public_ip.ipaddress.ipaddress)
+            self.public_ip.ipaddress.ipaddress)
 
         self.services["lbrule"]["alg"] = 'roundrobin'
         lb_rule = LoadBalancerRule.create(
-                                    self.apiclient,
-                                    self.services["lbrule"],
-                                    ipaddressid=self.public_ip.ipaddress.id,
-                                    accountid=self.account.name,
-                                    networkid=self.network.id
-                                )
+            self.apiclient,
+            self.services["lbrule"],
+            ipaddressid=self.public_ip.ipaddress.id,
+            accountid=self.account.name,
+            networkid=self.network.id
+        )
         self.cleanup.append(lb_rule)
 
         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("Adding %s to the LB rule %s" % (
-                                                self.virtual_machine.name,
-                                                lb_rule.name
-                                                ))
+            self.virtual_machine.name,
+            lb_rule.name
+        ))
         lb_rule.assign(self.apiclient, [self.virtual_machine])
 
-        self.debug("SSH into Netscaler to check whether algorithm is configured properly or not?")
+        self.debug(
+            "SSH into Netscaler to check whether algorithm is configured properly or not?")
         self.debug("SSH into netscaler: %s" %
-                                    self.services["netscaler"]["ipaddress"])
+                   self.services["netscaler"]["ipaddress"])
         try:
             ssh_client = SshClient(
-                                    self.services["netscaler"]["ipaddress"],
-                                    self.services["netscaler"]["port"],
-                                    self.services["netscaler"]["username"],
-                                    self.services["netscaler"]["password"],
-                                    )
+                self.services["netscaler"]["ipaddress"],
+                self.services["netscaler"]["port"],
+                self.services["netscaler"]["username"],
+                self.services["netscaler"]["password"],
+            )
             cmd = "show lb vserver Cloud-VirtualServer-%s-%s" % (
-                                        self.public_ip.ipaddress.ipaddress,
-                                        lb_rule.publicport)
+                self.public_ip.ipaddress.ipaddress,
+                lb_rule.publicport)
             self.debug("command: %s" % cmd)
             res = ssh_client.execute(cmd)
             result = str(res)
             self.debug("Output: %s" % result)
 
             self.assertEqual(
-                    result.count("Configured Method: ROUNDROBIN"),
-                    1,
-                    "'ROUNDROBIN' algorithm should be configured on NS"
-                    )
+                result.count("Configured Method: ROUNDROBIN"),
+                1,
+                "'ROUNDROBIN' algorithm should be configured on NS"
+            )
         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))
 
         self.debug(
-                "Updating LB rule: %s with new algorithm: %s" % (
-                                                                lb_rule.name,
-                                                                'leastconn'))
+            "Updating LB rule: %s with new algorithm: %s" % (
+                lb_rule.name,
+                'leastconn'))
         lb_rule.update(self.apiclient, algorithm='leastconn')
 
-        self.debug("SSH into Netscaler to check whether algorithm is configured properly or not?")
+        self.debug(
+            "SSH into Netscaler to check whether algorithm is configured properly or not?")
         self.debug("SSH into netscaler: %s" %
-                                    self.services["netscaler"]["ipaddress"])
+                   self.services["netscaler"]["ipaddress"])
         try:
             ssh_client = SshClient(
-                                    self.services["netscaler"]["ipaddress"],
-                                    self.services["netscaler"]["port"],
-                                    self.services["netscaler"]["username"],
-                                    self.services["netscaler"]["password"],
-                                    )
+                self.services["netscaler"]["ipaddress"],
+                self.services["netscaler"]["port"],
+                self.services["netscaler"]["username"],
+                self.services["netscaler"]["password"],
+            )
             cmd = "show lb vserver Cloud-VirtualServer-%s-%s" % (
-                                        self.public_ip.ipaddress.ipaddress,
-                                        lb_rule.publicport)
+                self.public_ip.ipaddress.ipaddress,
+                lb_rule.publicport)
             self.debug("command: %s" % cmd)
             res = ssh_client.execute(cmd)
             result = str(res)
             self.debug("Output: %s" % result)
 
             self.assertEqual(
-                    result.count("Configured Method: LEASTCONNECTION"),
-                    1,
-                    "'LEASTCONNECTION' algorithm should be configured on NS"
-                    )
+                result.count("Configured Method: LEASTCONNECTION"),
+                1,
+                "'LEASTCONNECTION' algorithm should be configured on NS"
+            )
         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
 
@@ -976,62 +1018,72 @@ class TestLbAlgoLcRr(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.account = Account.create(
-                                     cls.api_client,
-                                     cls.services["account"],
-                                     admin=True,
-                                     domainid=cls.domain.id
-                                     )
-           cls._cleanup.insert(0,cls.account)
-           cls.network = Network.create(
-                                    cls.api_client,
-                                    cls.services["network"],
-                                    accountid=cls.account.name,
-                                    domainid=cls.account.domainid,
-                                    networkofferingid=cls.network_offering.id,
-                                    zoneid=cls.zone.id
-                                    )
-           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"]
-                                            )
-
-           # Spawn an instance in that network
-           cls.virtual_machine = VirtualMachine.create(
-                                  cls.api_client,
-                                  cls.services["virtual_machine"],
-                                  accountid=cls.account.name,
-                                  domainid=cls.account.domainid,
-                                  serviceofferingid=cls.service_offering.id,
-                                  networkids=[str(cls.network.id)]
-                                  )
-           cls.public_ip = PublicIPAddress.create(
-                                cls.api_client,
-                                accountid=cls.account.name,
-                                zoneid=cls.zone.id,
-                                domainid=cls.account.domainid,
-                                networkid=cls.network.id
-                                )
+            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
+            )
+            cls._cleanup.append(cls.network_offering)
+            # Enable Network offering
+            cls.network_offering.update(cls.api_client, state='Enabled')
+            cls.account = Account.create(
+                cls.api_client,
+                cls.services["account"],
+                admin=True,
+                domainid=cls.domain.id
+            )
+            cls._cleanup.insert(0, cls.account)
+            cls.network = Network.create(
+                cls.api_client,
+                cls.services["network"],
+                accountid=cls.account.name,
+                domainid=cls.account.domainid,
+                networkofferingid=cls.network_offering.id,
+                zoneid=cls.zone.id
+            )
+            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._cleanup.append(cls.service_offering)
+
+            # Spawn an instance in that network
+            cls.virtual_machine = VirtualMachine.create(
+                cls.api_client,
+                cls.services["virtual_machine"],
+                accountid=cls.account.name,
+                domainid=cls.account.domainid,
+                serviceofferingid=cls.service_offering.id,
+                networkids=[str(cls.network.id)]
+            )
+            cls.public_ip = PublicIPAddress.create(
+                cls.api_client,
+                accountid=cls.account.name,
+                zoneid=cls.zone.id,
+                domainid=cls.account.domainid,
+                networkid=cls.network.id
+            )
         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
@@ -1059,7 +1111,7 @@ class TestLbAlgoLcRr(cloudstackTestCase):
             raise Exception("Warning: Exception during cleanup : %s" % e)
         return
 
-    @attr(tags = ["advancedns"])
+    @attr(tags=["advancedns"])
     def test_lb_least_conn_to_round_robin(self):
         """Test edit LB rule from least conn to round robin algo
         """
@@ -1076,90 +1128,92 @@ class TestLbAlgoLcRr(cloudstackTestCase):
 
         self.debug(
             "Creating LB rule for IP address: %s with least conn algo" %
-                                        self.public_ip.ipaddress.ipaddress)
+            self.public_ip.ipaddress.ipaddress)
 
         self.services["lbrule"]["alg"] = 'leastconn'
         lb_rule = LoadBalancerRule.create(
-                                    self.apiclient,
-                                    self.services["lbrule"],
-                                    ipaddressid=self.public_ip.ipaddress.id,
-                                    accountid=self.account.name,
-                                    networkid=self.network.id
-                                )
+            self.apiclient,
+            self.services["lbrule"],
+            ipaddressid=self.public_ip.ipaddress.id,
+            accountid=self.account.name,
+            networkid=self.network.id
+        )
         self.cleanup.append(lb_rule)
 
         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("Adding %s to the LB rule %s" % (
-                                                self.virtual_machine.name,
-                                                lb_rule.name
-                                                ))
+            self.virtual_machine.name,
+            lb_rule.name
+        ))
         lb_rule.assign(self.apiclient, [self.virtual_machine])
-        self.debug("SSH into Netscaler to check whether algorithm is configured properly or not?")
+        self.debug(
+            "SSH into Netscaler to check whether algorithm is configured properly or not?")
         self.debug("SSH into netscaler: %s" %
-                                    self.services["netscaler"]["ipaddress"])
+                   self.services["netscaler"]["ipaddress"])
         try:
             ssh_client = SshClient(
-                                    self.services["netscaler"]["ipaddress"],
-                                    self.services["netscaler"]["port"],
-                                    self.services["netscaler"]["username"],
-                                    self.services["netscaler"]["password"],
-                                    )
+                self.services["netscaler"]["ipaddress"],
+                self.services["netscaler"]["port"],
+                self.services["netscaler"]["username"],
+                self.services["netscaler"]["password"],
+            )
             cmd = "show lb vserver Cloud-VirtualServer-%s-%s" % (
-                                        self.public_ip.ipaddress.ipaddress,
-                                        lb_rule.publicport)
+                self.public_ip.ipaddress.ipaddress,
+                lb_rule.publicport)
             self.debug("command: %s" % cmd)
             res = ssh_client.execute(cmd)
             result = str(res)
             self.debug("Output: %s" % result)
 
             self.assertEqual(
-                    result.count("Configured Method: LEASTCONNECTION"),
-                    1,
-                    "'LEASTCONNECTION' algorithm should be configured on NS"
-                    )
+                result.count("Configured Method: LEASTCONNECTION"),
+                1,
+                "'LEASTCONNECTION' algorithm should be configured on NS"
+            )
         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))
 
         self.debug(
-                "Updating LB rule: %s with new algorithm: %s" % (
-                                                                lb_rule.name,
-                                                                'roundrobin'))
+            "Updating LB rule: %s with new algorithm: %s" % (
+                lb_rule.name,
+                'roundrobin'))
         lb_rule.update(self.apiclient, algorithm='roundrobin')
-        self.debug("SSH into Netscaler to check whether algorithm is configured properly or not?")
+        self.debug(
+            "SSH into Netscaler to check whether algorithm is configured properly or not?")
         self.debug("SSH into netscaler: %s" %
-                                    self.services["netscaler"]["ipaddress"])
+                   self.services["netscaler"]["ipaddress"])
         try:
             ssh_client = SshClient(
-                                    self.services["netscaler"]["ipaddress"],
-                                    self.services["netscaler"]["port"],
-                                    self.services["netscaler"]["username"],
-                                    self.services["netscaler"]["password"],
-                                    )
+                self.services["netscaler"]["ipaddress"],
+                self.services["netscaler"]["port"],
+                self.services["netscaler"]["username"],
+                self.services["netscaler"]["password"],
+            )
             cmd = "show lb vserver Cloud-VirtualServer-%s-%s" % (
-                                        self.public_ip.ipaddress.ipaddress,
-                                        lb_rule.publicport)
+                self.public_ip.ipaddress.ipaddress,
+                lb_rule.publicport)
             self.debug("command: %s" % cmd)
             res = ssh_client.execute(cmd)
             result = str(res)
             self.debug("Output: %s" % result)
 
             self.assertEqual(
-                    result.count("Configured Method: ROUNDROBIN"),
-                    1,
-                    "'ROUNDROBIN' algorithm should be configured on NS"
-                    )
+                result.count("Configured Method: ROUNDROBIN"),
+                1,
+                "'ROUNDROBIN' algorithm should be configured on NS"
+            )
         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
 
@@ -1177,63 +1231,73 @@ class TestLbAlgoRrSb(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.account = Account.create(
-                                     cls.api_client,
-                                     cls.services["account"],
-                                     admin=True,
-                                     domainid=cls.domain.id
-                                     )
-           cls._cleanup.insert(0,cls.account)
-           cls.network = Network.create(
-                                    cls.api_client,
-                                    cls.services["network"],
-                                    accountid=cls.account.name,
-                                    domainid=cls.account.domainid,
-                                    networkofferingid=cls.network_offering.id,
-                                    zoneid=cls.zone.id
-                                    )
-           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"]
-                                            )
-
-           # Spawn an instance in that network
-           cls.virtual_machine = VirtualMachine.create(
-                                  cls.api_client,
-                                  cls.services["virtual_machine"],
-                                  accountid=cls.account.name,
-                                  domainid=cls.account.domainid,
-                                  serviceofferingid=cls.service_offering.id,
-                                  networkids=[str(cls.network.id)]
-                                  )
-
-           cls.public_ip = PublicIPAddress.create(
-                                cls.api_client,
-                                accountid=cls.account.name,
-                                zoneid=cls.zone.id,
-                                domainid=cls.account.domainid,
-                                networkid=cls.network.id
-                                )
+            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
+            )
+            cls._cleanup.append(cls.network_offering)
+            # Enable Network offering
+            cls.network_offering.update(cls.api_client, state='Enabled')
+            cls.account = Account.create(
+                cls.api_client,
+                cls.services["account"],
+                admin=True,
+                domainid=cls.domain.id
+            )
+            cls._cleanup.insert(0, cls.account)
+            cls.network = Network.create(
+                cls.api_client,
+                cls.services["network"],
+                accountid=cls.account.name,
+                domainid=cls.account.domainid,
+                networkofferingid=cls.network_offering.id,
+                zoneid=cls.zone.id
+            )
+            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._cleanup.append(cls.service_offering)
+
+            # Spawn an instance in that network
+            cls.virtual_machine = VirtualMachine.create(
+                cls.api_client,
+                cls.services["virtual_machine"],
+                accountid=cls.account.name,
+                domainid=cls.account.domainid,
+                serviceofferingid=cls.service_offering.id,
+                networkids=[str(cls.network.id)]
+            )
+
+            cls.public_ip = PublicIPAddress.create(
+                cls.api_client,
+                accountid=cls.account.name,
+                zoneid=cls.zone.id,
+                domainid=cls.account.domainid,
+                networkid=cls.network.id
+            )
         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
@@ -1261,7 +1325,7 @@ class TestLbAlgoRrSb(cloudstackTestCase):
             raise Exception("Warning: Exception during cleanup : %s" % e)
         return
 
-    @attr(tags = ["advancedns"])
+    @attr(tags=["advancedns"])
     def test_lb_round_robin_to_source(self):
         """Test edit LB rule from round robin to source algo
         """
@@ -1278,92 +1342,94 @@ class TestLbAlgoRrSb(cloudstackTestCase):
 
         self.debug(
             "Creating LB rule for IP address: %s with round robin algo" %
-                                        self.public_ip.ipaddress.ipaddress)
+            self.public_ip.ipaddress.ipaddress)
 
         self.services["lbrule"]["alg"] = 'roundrobin'
         lb_rule = LoadBalancerRule.create(
-                                    self.apiclient,
-                                    self.services["lbrule"],
-                                    ipaddressid=self.public_ip.ipaddress.id,
-                                    accountid=self.account.name,
-                                    networkid=self.network.id
-                                )
+            self.apiclient,
+            self.services["lbrule"],
+            ipaddressid=self.public_ip.ipaddress.id,
+            accountid=self.account.name,
+            networkid=self.network.id
+        )
         self.cleanup.append(lb_rule)
 
         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("Adding %s to the LB rule %s" % (
-                                                self.virtual_machine.name,
-                                                lb_rule.name
-                                                ))
+            self.virtual_machine.name,
+            lb_rule.name
+        ))
         lb_rule.assign(self.apiclient, [self.virtual_machine])
-        self.debug("SSH into Netscaler to check whether algorithm is configured properly or not?")
+        self.debug(
+            "SSH into Netscaler to check whether algorithm is configured properly or not?")
         self.debug("SSH into netscaler: %s" %
-                                    self.services["netscaler"]["ipaddress"])
+                   self.services["netscaler"]["ipaddress"])
         try:
             ssh_client = SshClient(
-                                    self.services["netscaler"]["ipaddress"],
-                                    self.services["netscaler"]["port"],
-                                    self.services["netscaler"]["username"],
-                                    self.services["netscaler"]["password"],
-                                    )
+                self.services["netscaler"]["ipaddress"],
+                self.services["netscaler"]["port"],
+                self.services["netscaler"]["username"],
+                self.services["netscaler"]["password"],
+            )
             cmd = "show lb vserver Cloud-VirtualServer-%s-%s" % (
-                                        self.public_ip.ipaddress.ipaddress,
-                                        lb_rule.publicport)
+                self.public_ip.ipaddress.ipaddress,
+                lb_rule.publicport)
             self.debug("command: %s" % cmd)
             res = ssh_client.execute(cmd)
             result = str(res)
             self.debug("Output: %s" % result)
 
             self.assertEqual(
-                    result.count("Configured Method: ROUNDROBIN"),
-                    1,
-                    "'ROUNDROBIN' algorithm should be configured on NS"
-                    )
+                result.count("Configured Method: ROUNDROBIN"),
+                1,
+                "'ROUNDROBIN' algorithm should be configured on NS"
+            )
         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))
 
         self.debug(
-                "Updating LB rule: %s with new algorithm: %s" % (
-                                                                lb_rule.name,
-                                                                'source'))
+            "Updating LB rule: %s with new algorithm: %s" % (
+                lb_rule.name,
+                'source'))
         lb_rule.update(self.apiclient, algorithm='source')
 
-        self.debug("SSH into Netscaler to check whether algorithm is configured properly or not?")
+        self.debug(
+            "SSH into Netscaler to check whether algorithm is configured properly or not?")
         self.debug("SSH into netscaler: %s" %
-                                    self.services["netscaler"]["ipaddress"])
+                   self.services["netscaler"]["ipaddress"])
         try:
             ssh_client = SshClient(
-                                    self.services["netscaler"]["ipaddress"],
-                                    self.services["netscaler"]["port"],
-                                    self.services["netscaler"]["username"],
-                                    self.services["netscaler"]["password"],
-                                    )
+                self.services["netscaler"]["ipaddress"],
+                self.services["netscaler"]["port"],
+                self.services["netscaler"]["username"],
+                self.services["netscaler"]["password"],
+            )
             cmd = "show lb vserver Cloud-VirtualServer-%s-%s" % (
-                                        self.public_ip.ipaddress.ipaddress,
-                                        lb_rule.publicport)
+                self.public_ip.ipaddress.ipaddress,
+                lb_rule.publicport)
             self.debug("command: %s" % cmd)
             res = ssh_client.execute(cmd)
             result = str(res)
             self.debug("Output: %s" % result)
 
             self.assertEqual(
-                    result.count("Configured Method: SOURCEIPHASH"),
-                    1,
-                    "'SOURCEIPHASH' algorithm should be configured on NS"
-                    )
+                result.count("Configured Method: SOURCEIPHASH"),
+                1,
+                "'SOURCEIPHASH' algorithm should be configured on NS"
+            )
 
         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
 
@@ -1381,64 +1447,74 @@ class TestLbAlgoSbRr(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.ap

<TRUNCATED>

Mime
View raw message