You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by ta...@apache.org on 2014/11/17 11:00:43 UTC
[1/5] git commit: updated refs/heads/master to 91ffaaa
Repository: cloudstack
Updated Branches:
refs/heads/master 3996b402a -> 91ffaaa5a
CLOUDSTACK-7913 : Added reconnect functionality to Host class in base.py
Signed-off-by: SrikanteswaraRao Talluri <ta...@apache.org>
Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/d8d60f01
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/d8d60f01
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/d8d60f01
Branch: refs/heads/master
Commit: d8d60f017250cc1acb98c8d5b3064c55b348ae56
Parents: 3996b40
Author: Chandan Purushothama <Ch...@citrix.com>
Authored: Thu Nov 13 22:56:01 2014 -0800
Committer: SrikanteswaraRao Talluri <ta...@apache.org>
Committed: Mon Nov 17 15:30:12 2014 +0530
----------------------------------------------------------------------
tools/marvin/marvin/lib/base.py | 7 +++++++
1 file changed, 7 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d8d60f01/tools/marvin/marvin/lib/base.py
----------------------------------------------------------------------
diff --git a/tools/marvin/marvin/lib/base.py b/tools/marvin/marvin/lib/base.py
index 580d0ab..e38c394 100755
--- a/tools/marvin/marvin/lib/base.py
+++ b/tools/marvin/marvin/lib/base.py
@@ -2462,6 +2462,13 @@ class Host:
[setattr(cmd, k, v) for k, v in kwargs.items()]
return(apiclient.updateHost(cmd))
+ @classmethod
+ def reconnect(cls, apiclient, **kwargs):
+ """Reconnect the Host"""
+
+ cmd = reconnectHost.reconnectHostCmd()
+ [setattr(cmd, k, v) for k, v in kwargs.items()]
+ return(apiclient.reconnectHost(cmd))
class StoragePool:
"""Manage Storage pools (Primary Storage)"""
[4/5] git commit: updated refs/heads/master to 91ffaaa
Posted by ta...@apache.org.
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/91ffaaa5/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>
[3/5] git commit: updated refs/heads/master to 91ffaaa
Posted by ta...@apache.org.
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/91ffaaa5/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>
[2/5] git commit: updated refs/heads/master to 91ffaaa
Posted by ta...@apache.org.
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/91ffaaa5/test/integration/component/test_netscaler_lb_sticky.py
----------------------------------------------------------------------
diff --git a/test/integration/component/test_netscaler_lb_sticky.py b/test/integration/component/test_netscaler_lb_sticky.py
index c333f60..a5f55a8 100644
--- a/test/integration/component/test_netscaler_lb_sticky.py
+++ b/test/integration/component/test_netscaler_lb_sticky.py
@@ -17,99 +17,95 @@
""" P1 tests for netscaler load balancing sticky policy
"""
-#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,
+ LoadBalancerRule,
+ PublicIPAddress,
+ Network,
+ NetworkOffering,
+ ServiceOffering,
+ VirtualMachine)
+from marvin.lib.common import (get_domain,
+ get_zone,
+ get_template,
+ add_netscaler,
+ GetNetscalerInfoFromConfig)
from marvin.sshClient import SshClient
-import datetime
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": "roundrobin",
- # 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": "roundrobin",
+ # 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 TestLbStickyPolicy(cloudstackTestCase):
@@ -125,69 +121,80 @@ class TestLbStickyPolicy(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.account = Account.create(
- cls.api_client,
- cls.services["account"],
- admin=True,
- domainid=cls.domain.id
- )
- cls._cleanup.insert(0,cls.account)
- # Creating network using the network offering created
- 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
- )
-
- # 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
+ )
+ # 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.account = Account.create(
+ cls.api_client,
+ cls.services["account"],
+ admin=True,
+ domainid=cls.domain.id
+ )
+ cls._cleanup.insert(0, cls.account)
+ # Creating network using the network offering created
+ 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
+ )
+
+ # 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
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)
@@ -202,16 +209,17 @@ class TestLbStickyPolicy(cloudstackTestCase):
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)
self.debug("Cleanup complete!")
except Exception as e:
raise Exception("Warning: Exception during cleanup : %s" % e)
return
- @attr(tags = ["advancedns"])
+ @attr(tags=["advancedns"])
def test_01_source_based_roundrobin(self):
- """Test Create a "SourceBased" stick policy for a Lb rule with "RoundRobin" algorithm
+ """Test Create a "SourceBased" stick policy for a Lb rule with
+ "RoundRobin" algorithm
"""
# Validate the following
@@ -226,80 +234,83 @@ class TestLbStickyPolicy(cloudstackTestCase):
self.debug(
"Creating LB rule for IP address: %s with round robin algo" %
- self.public_ip.ipaddress.ipaddress)
+ self.public_ip.ipaddress.ipaddress)
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)
self.debug("Created the load balancing rule for public IP: %s" %
- self.public_ip.ipaddress.ipaddress)
+ self.public_ip.ipaddress.ipaddress)
self.debug("Assigning VM instance: %s to 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("Assigned VM instance: %s to lb rule: %s" % (
- self.virtual_machine.name,
- lb_rule.name
- ))
+ self.virtual_machine.name,
+ lb_rule.name
+ ))
self.debug(
"Configuring 'SourceBased' Sticky policy on lb rule: %s" %
- lb_rule.name)
+ lb_rule.name)
try:
result = lb_rule.createSticky(
- self.apiclient,
- methodname='SourceBased',
- name='SourceBasedRR',
- param={"holdtime": 20}
- )
+ self.apiclient,
+ methodname='SourceBased',
+ name='SourceBasedRR',
+ param={"holdtime": 20}
+ )
self.debug("Response: %s" % result)
except Exception as e:
self.fail("Configure sticky policy failed with exception: %s" % e)
- self.debug("SSH into Netscaler to check whether sticky policy configured properly or not?")
+ self.debug(
+ "SSH into Netscaler to check whether sticky policy 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("Persistence: SOURCEIP"),
- 1,
- "'SourceBased' sticky policy should be configured on NS"
- )
+ result.count("Persistence: SOURCEIP"),
+ 1,
+ "'SourceBased' sticky policy should be configured on NS"
+ )
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
- @attr(tags = ["advancedns"])
+ @attr(tags=["advancedns"])
def test_02_source_based_source_algo(self):
- """Test Create a "SourceBased" stick policy for a Lb rule with "Source" algorithm
+ """Test Create a "SourceBased" stick policy for a Lb rule
+ with "Source" algorithm
"""
# Validate the following
@@ -314,79 +325,81 @@ class TestLbStickyPolicy(cloudstackTestCase):
self.debug(
"Creating LB rule for IP address: %s with source algo" %
- self.public_ip.ipaddress.ipaddress)
+ self.public_ip.ipaddress.ipaddress)
self.services["lbrule"]["alg"] = 'source'
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)
self.debug("Created the load balancing rule for public IP: %s" %
- self.public_ip.ipaddress.ipaddress)
+ self.public_ip.ipaddress.ipaddress)
self.debug("Assigning VM instance: %s to 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("Assigned VM instance: %s to lb rule: %s" % (
- self.virtual_machine.name,
- lb_rule.name
- ))
+ self.virtual_machine.name,
+ lb_rule.name
+ ))
self.debug(
"Configuring 'SourceBased' Sticky policy on lb rule: %s" %
- lb_rule.name)
+ lb_rule.name)
try:
result = lb_rule.createSticky(
- self.apiclient,
- methodname='SourceBased',
- name='SourceBasedSource',
- param={"holdtime": 20}
- )
+ self.apiclient,
+ methodname='SourceBased',
+ name='SourceBasedSource',
+ param={"holdtime": 20}
+ )
self.debug("Response: %s" % result)
except Exception as e:
self.fail("Configure sticky policy failed with exception: %s" % e)
- self.debug("SSH into Netscaler to check whether sticky policy configured properly or not?")
+ self.debug(
+ "SSH into Netscaler to check whether sticky policy\
+ 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("Persistence: SOURCEIP"),
- 1,
- "'SourceBased' sticky policy should be configured on NS"
- )
+ result.count("Persistence: SOURCEIP"),
+ 1,
+ "'SourceBased' sticky policy should be configured on NS"
+ )
self.assertEqual(
- result.count("Configured Method: SOURCEIPHASH"),
- 1,
- "'SOURCE' algorithm should be configured on NS"
- )
+ result.count("Configured Method: SOURCEIPHASH"),
+ 1,
+ "'SOURCE' 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
- @attr(tags = ["advancedns"])
+ @attr(tags=["advancedns"])
def test_03_source_based_leastconn(self):
"""Test Create a "SourceBased" stick policy for a Lb rule with leastconn algo
"""
@@ -403,79 +416,81 @@ class TestLbStickyPolicy(cloudstackTestCase):
self.debug(
"Creating LB rule for IP address: %s with leastconn 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)
self.debug("Created the load balancing rule for public IP: %s" %
- self.public_ip.ipaddress.ipaddress)
+ self.public_ip.ipaddress.ipaddress)
self.debug("Assigning VM instance: %s to 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("Assigned VM instance: %s to lb rule: %s" % (
- self.virtual_machine.name,
- lb_rule.name
- ))
+ self.virtual_machine.name,
+ lb_rule.name
+ ))
self.debug(
"Configuring 'SourceBased' Sticky policy on lb rule: %s" %
- lb_rule.name)
+ lb_rule.name)
try:
result = lb_rule.createSticky(
- self.apiclient,
- methodname='SourceBased',
- name='SourceBasedLeast',
- param={"holdtime": 20}
- )
+ self.apiclient,
+ methodname='SourceBased',
+ name='SourceBasedLeast',
+ param={"holdtime": 20}
+ )
self.debug("Response: %s" % result)
except Exception as e:
self.fail("Configure sticky policy failed with exception: %s" % e)
- self.debug("SSH into Netscaler to check whether sticky policy configured properly or not?")
+ self.debug(
+ "SSH into Netscaler to check whether sticky policy 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("Persistence: SOURCEIP"),
- 1,
- "'SourceBased' sticky policy should be configured on NS"
- )
+ result.count("Persistence: SOURCEIP"),
+ 1,
+ "'SourceBased' sticky policy should be configured on NS"
+ )
self.assertEqual(
- result.count("Configured Method: LEASTCONNECTION"),
- 1,
- "'leastconn' algorithm should be configured on NS"
- )
+ result.count("Configured Method: LEASTCONNECTION"),
+ 1,
+ "'leastconn' 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
- @attr(tags = ["advancedns"])
+ @attr(tags=["advancedns"])
def test_04_lbcookie_based_roundrobin(self):
"""Test Create a "LBCookie" stick policy for a Lb rule with roundrobin algo
"""
@@ -492,81 +507,83 @@ class TestLbStickyPolicy(cloudstackTestCase):
self.debug(
"Creating LB rule for IP address: %s with roundrobin algo" %
- self.public_ip.ipaddress.ipaddress)
+ self.public_ip.ipaddress.ipaddress)
self.services["lbrule"]["alg"] = 'roundrobin'
self.services["lbrule"]["publicport"] = 80
self.services["lbrule"]["privateport"] = 80
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)
self.debug("Created the load balancing rule for public IP: %s" %
- self.public_ip.ipaddress.ipaddress)
+ self.public_ip.ipaddress.ipaddress)
self.debug("Assigning VM instance: %s to 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("Assigned VM instance: %s to lb rule: %s" % (
- self.virtual_machine.name,
- lb_rule.name
- ))
+ self.virtual_machine.name,
+ lb_rule.name
+ ))
self.debug(
"Configuring 'SourceBased' Sticky policy on lb rule: %s" %
- lb_rule.name)
+ lb_rule.name)
try:
result = lb_rule.createSticky(
- self.apiclient,
- methodname='LbCookie',
- name='LbCookieRR',
- param={"holdtime": 20}
- )
+ self.apiclient,
+ methodname='LbCookie',
+ name='LbCookieRR',
+ param={"holdtime": 20}
+ )
self.debug("Response: %s" % result)
except Exception as e:
self.fail("Configure sticky policy failed with exception: %s" % e)
- self.debug("SSH into Netscaler to check whether sticky policy configured properly or not?")
+ self.debug(
+ "SSH into Netscaler to check whether sticky policy\
+ 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("Persistence: COOKIEINSERT"),
- 1,
- "'LBCookie' sticky policy should be configured on NS"
- )
+ result.count("Persistence: COOKIEINSERT"),
+ 1,
+ "'LBCookie' sticky policy should be configured on NS"
+ )
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
- @attr(tags = ["advancedns"])
+ @attr(tags=["advancedns"])
def test_05_lbcookie_source_algo(self):
"""Test Create a "LBCookie" stick policy for a Lb rule with "Source" algorithm
"""
@@ -583,81 +600,83 @@ class TestLbStickyPolicy(cloudstackTestCase):
self.debug(
"Creating LB rule for IP address: %s with source algo" %
- self.public_ip.ipaddress.ipaddress)
+ self.public_ip.ipaddress.ipaddress)
self.services["lbrule"]["alg"] = 'source'
self.services["lbrule"]["publicport"] = 80
self.services["lbrule"]["privateport"] = 80
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)
self.debug("Created the load balancing rule for public IP: %s" %
- self.public_ip.ipaddress.ipaddress)
+ self.public_ip.ipaddress.ipaddress)
self.debug("Assigning VM instance: %s to 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("Assigned VM instance: %s to lb rule: %s" % (
- self.virtual_machine.name,
- lb_rule.name
- ))
+ self.virtual_machine.name,
+ lb_rule.name
+ ))
self.debug(
"Configuring 'SourceBased' Sticky policy on lb rule: %s" %
- lb_rule.name)
+ lb_rule.name)
try:
result = lb_rule.createSticky(
- self.apiclient,
- methodname='LbCookie',
- name='LbCookieSource',
- param={"holdtime": 20}
- )
+ self.apiclient,
+ methodname='LbCookie',
+ name='LbCookieSource',
+ param={"holdtime": 20}
+ )
self.debug("Response: %s" % result)
except Exception as e:
self.fail("Configure sticky policy failed with exception: %s" % e)
- self.debug("SSH into Netscaler to check whether sticky policy configured properly or not?")
+ self.debug(
+ "SSH into Netscaler to check whether sticky policy\
+ 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("Persistence: COOKIEINSERT"),
- 1,
- "'LbCookie' sticky policy should be configured on NS"
- )
+ result.count("Persistence: COOKIEINSERT"),
+ 1,
+ "'LbCookie' sticky policy should be configured on NS"
+ )
self.assertEqual(
- result.count("Configured Method: SOURCEIPHASH"),
- 1,
- "'SOURCE' algorithm should be configured on NS"
- )
+ result.count("Configured Method: SOURCEIPHASH"),
+ 1,
+ "'SOURCE' 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
- @attr(tags = ["advancedns"])
+ @attr(tags=["advancedns"])
def test_06_lbcookie_leastconn(self):
"""Test Create a "LBCookie" stick policy for a Lb rule with leastconn algo
"""
@@ -674,81 +693,83 @@ class TestLbStickyPolicy(cloudstackTestCase):
self.debug(
"Creating LB rule for IP address: %s with leastconn algo" %
- self.public_ip.ipaddress.ipaddress)
+ self.public_ip.ipaddress.ipaddress)
self.services["lbrule"]["alg"] = 'leastconn'
self.services["lbrule"]["publicport"] = 80
self.services["lbrule"]["privateport"] = 80
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)
self.debug("Created the load balancing rule for public IP: %s" %
- self.public_ip.ipaddress.ipaddress)
+ self.public_ip.ipaddress.ipaddress)
self.debug("Assigning VM instance: %s to 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("Assigned VM instance: %s to lb rule: %s" % (
- self.virtual_machine.name,
- lb_rule.name
- ))
+ self.virtual_machine.name,
+ lb_rule.name
+ ))
self.debug(
"Configuring 'SourceBased' Sticky policy on lb rule: %s" %
- lb_rule.name)
+ lb_rule.name)
try:
result = lb_rule.createSticky(
- self.apiclient,
- methodname='LBCookie',
- name='LbcookieLeastConn',
- param={"holdtime": 20}
- )
+ self.apiclient,
+ methodname='LBCookie',
+ name='LbcookieLeastConn',
+ param={"holdtime": 20}
+ )
self.debug("Response: %s" % result)
except Exception as e:
self.fail("Configure sticky policy failed with exception: %s" % e)
- self.debug("SSH into Netscaler to check whether sticky policy configured properly or not?")
+ self.debug(
+ "SSH into Netscaler to check whether sticky policy\
+ 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("Persistence: COOKIEINSERT"),
- 1,
- "'LbCookie' sticky policy should be configured on NS"
- )
+ result.count("Persistence: COOKIEINSERT"),
+ 1,
+ "'LbCookie' sticky policy should be configured on NS"
+ )
self.assertEqual(
- result.count("Configured Method: LEASTCONNECTION"),
- 1,
- "'leastconn' algorithm should be configured on NS"
- )
+ result.count("Configured Method: LEASTCONNECTION"),
+ 1,
+ "'leastconn' 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
- @attr(tags = ["advancedns"])
+ @attr(tags=["advancedns"])
def test_07_appcookie_based_roundrobin(self):
"""Test Create a "AppCookie" stick policy for a Lb rule with roundrobin algo
"""
@@ -765,81 +786,83 @@ class TestLbStickyPolicy(cloudstackTestCase):
self.debug(
"Creating LB rule for IP address: %s with roundrobin algo" %
- self.public_ip.ipaddress.ipaddress)
+ self.public_ip.ipaddress.ipaddress)
self.services["lbrule"]["alg"] = 'roundrobin'
self.services["lbrule"]["publicport"] = 80
self.services["lbrule"]["privateport"] = 80
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)
self.debug("Created the load balancing rule for public IP: %s" %
- self.public_ip.ipaddress.ipaddress)
+ self.public_ip.ipaddress.ipaddress)
self.debug("Assigning VM instance: %s to 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("Assigned VM instance: %s to lb rule: %s" % (
- self.virtual_machine.name,
- lb_rule.name
- ))
+ self.virtual_machine.name,
+ lb_rule.name
+ ))
self.debug(
"Configuring 'SourceBased' Sticky policy on lb rule: %s" %
- lb_rule.name)
+ lb_rule.name)
try:
result = lb_rule.createSticky(
- self.apiclient,
- methodname='AppCookie',
- name='AppCookieRR',
- param={"name": 20}
- )
+ self.apiclient,
+ methodname='AppCookie',
+ name='AppCookieRR',
+ param={"name": 20}
+ )
self.debug("Response: %s" % result)
except Exception as e:
self.fail("Configure sticky policy failed with exception: %s" % e)
- self.debug("SSH into Netscaler to check whether sticky policy configured properly or not?")
+ self.debug(
+ "SSH into Netscaler to check whether sticky policy\
+ 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("Persistence: RULE"),
- 1,
- "'AppCookie' sticky policy should be configured on NS"
- )
+ result.count("Persistence: RULE"),
+ 1,
+ "'AppCookie' sticky policy should be configured on NS"
+ )
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
- @attr(tags = ["advancedns"])
+ @attr(tags=["advancedns"])
def test_08_appcookie_source_algo(self):
"""Test Create a "AppCookie" stick policy for a Lb rule with "Source"
"""
@@ -856,81 +879,83 @@ class TestLbStickyPolicy(cloudstackTestCase):
self.debug(
"Creating LB rule for IP address: %s with source algo" %
- self.public_ip.ipaddress.ipaddress)
+ self.public_ip.ipaddress.ipaddress)
self.services["lbrule"]["alg"] = 'source'
self.services["lbrule"]["publicport"] = 80
self.services["lbrule"]["privateport"] = 80
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)
self.debug("Created the load balancing rule for public IP: %s" %
- self.public_ip.ipaddress.ipaddress)
+ self.public_ip.ipaddress.ipaddress)
self.debug("Assigning VM instance: %s to 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("Assigned VM instance: %s to lb rule: %s" % (
- self.virtual_machine.name,
- lb_rule.name
- ))
+ self.virtual_machine.name,
+ lb_rule.name
+ ))
self.debug(
"Configuring 'SourceBased' Sticky policy on lb rule: %s" %
- lb_rule.name)
+ lb_rule.name)
try:
result = lb_rule.createSticky(
- self.apiclient,
- methodname='AppCookie',
- name='AppCookieSource',
- param={"name": 20}
- )
+ self.apiclient,
+ methodname='AppCookie',
+ name='AppCookieSource',
+ param={"name": 20}
+ )
self.debug("Response: %s" % result)
except Exception as e:
self.fail("Configure sticky policy failed with exception: %s" % e)
- self.debug("SSH into Netscaler to check whether sticky policy configured properly or not?")
+ self.debug(
+ "SSH into Netscaler to check whether sticky policy\
+ 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("Persistence: RULE"),
- 1,
- "'AppCookie' sticky policy should be configured on NS"
- )
+ result.count("Persistence: RULE"),
+ 1,
+ "'AppCookie' sticky policy should be configured on NS"
+ )
self.assertEqual(
- result.count("Configured Method: SOURCEIPHASH"),
- 1,
- "'SOURCE' algorithm should be configured on NS"
- )
+ result.count("Configured Method: SOURCEIPHASH"),
+ 1,
+ "'SOURCE' 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
- @attr(tags = ["advancedns"])
+ @attr(tags=["advancedns"])
def test_09_appcookie_leastconn(self):
"""Test Create a "AppCookie" stick policy for a Lb rule with leastconn
"""
@@ -947,76 +972,78 @@ class TestLbStickyPolicy(cloudstackTestCase):
self.debug(
"Creating LB rule for IP address: %s with leastconn algo" %
- self.public_ip.ipaddress.ipaddress)
+ self.public_ip.ipaddress.ipaddress)
self.services["lbrule"]["alg"] = 'leastconn'
self.services["lbrule"]["publicport"] = 80
self.services["lbrule"]["privateport"] = 80
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)
self.debug("Created the load balancing rule for public IP: %s" %
- self.public_ip.ipaddress.ipaddress)
+ self.public_ip.ipaddress.ipaddress)
self.debug("Assigning VM instance: %s to 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("Assigned VM instance: %s to lb rule: %s" % (
- self.virtual_machine.name,
- lb_rule.name
- ))
+ self.virtual_machine.name,
+ lb_rule.name
+ ))
self.debug(
"Configuring 'SourceBased' Sticky policy on lb rule: %s" %
- lb_rule.name)
+ lb_rule.name)
try:
result = lb_rule.createSticky(
- self.apiclient,
- methodname='AppCookie',
- name='AppCookieLeastConn',
- param={"name": 20}
- )
+ self.apiclient,
+ methodname='AppCookie',
+ name='AppCookieLeastConn',
+ param={"name": 20}
+ )
self.debug("Response: %s" % result)
except Exception as e:
self.fail("Configure sticky policy failed with exception: %s" % e)
- self.debug("SSH into Netscaler to check whether sticky policy configured properly or not?")
+ self.debug(
+ "SSH into Netscaler to check whether sticky policy\
+ 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("Persistence: RULE"),
- 1,
- "'AppCookie' sticky policy should be configured on NS"
- )
+ result.count("Persistence: RULE"),
+ 1,
+ "'AppCookie' sticky policy should be configured on NS"
+ )
self.assertEqual(
- result.count("Configured Method: LEASTCONNECTION"),
- 1,
- "'leastconn' algorithm should be configured on NS"
- )
+ result.count("Configured Method: LEASTCONNECTION"),
+ 1,
+ "'leastconn' 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
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/91ffaaa5/test/integration/component/test_persistent_networks.py
----------------------------------------------------------------------
diff --git a/test/integration/component/test_persistent_networks.py b/test/integration/component/test_persistent_networks.py
index 4cd0aa8..f782700 100644
--- a/test/integration/component/test_persistent_networks.py
+++ b/test/integration/component/test_persistent_networks.py
@@ -40,7 +40,8 @@ from marvin.lib.common import (get_domain,
get_template,
verifyNetworkState,
add_netscaler,
- wait_for_cleanup)
+ wait_for_cleanup,
+ GetNetscalerInfoFromConfig)
from nose.plugins.attrib import attr
from marvin.codes import PASS, FAIL, FAILED
from marvin.sshClient import SshClient
@@ -97,6 +98,13 @@ class TestPersistentNetworks(cloudstackTestCase):
cls.isolated_network_offering_netscaler = cls.createNetworkOffering(
"nw_off_isolated_netscaler")
+ response = GetNetscalerInfoFromConfig(
+ cls.config
+ )
+ assert response[0] is not None, response[1]
+ cls.services["netscaler"] = response[0]
+ cls.services["netscaler"]["lbdevicededicated"] = False
+
# Configure Netscaler device
# If configuration succeeds, set ns_configured to True so that
# Netscaler tests are executed
@@ -105,7 +113,7 @@ class TestPersistentNetworks(cloudstackTestCase):
cls.netscaler = add_netscaler(
cls.api_client,
cls.zone.id,
- cls.services["netscaler_VPX"])
+ cls.services["netscaler"])
cls._cleanup.append(cls.netscaler)
cls.ns_configured = True
except Exception:
@@ -1500,6 +1508,13 @@ class TestAssignVirtualMachine(cloudstackTestCase):
cls.persistent_network_offering_netscaler = cls.createNetworkOffering(
"nw_off_isolated_persistent_netscaler")
+ response = GetNetscalerInfoFromConfig(
+ cls.config
+ )
+ assert response[0] is not None, response[1]
+ cls.services["netscaler"] = response[0]
+ cls.services["netscaler"]["lbdevicededicated"] = False
+
# Configure Netscaler device
# If configuration succeeds, set ns_configured to True so that
# Netscaler tests are executed
@@ -1508,7 +1523,7 @@ class TestAssignVirtualMachine(cloudstackTestCase):
cls.netscaler = add_netscaler(
cls.api_client,
cls.zone.id,
- cls.services["netscaler_VPX"])
+ cls.services["netscaler"])
cls._cleanup.append(cls.netscaler)
cls.ns_configured = True
except Exception:
@@ -1964,6 +1979,13 @@ class TestRestartPersistentNetwork(cloudstackTestCase):
cls.api_client,
state="enabled")
+ response = GetNetscalerInfoFromConfig(
+ cls.config
+ )
+ assert response[0] is not None, response[1]
+ cls.services["netscaler"] = response[0]
+ cls.services["netscaler"]["lbdevicededicated"] = False
+
# Configure Netscaler device
# If configuration succeeds, set ns_configured to True so that
# Netscaler tests are executed
@@ -1972,7 +1994,7 @@ class TestRestartPersistentNetwork(cloudstackTestCase):
cls.netscaler = add_netscaler(
cls.api_client,
cls.zone.id,
- cls.services["netscaler_VPX"])
+ cls.services["netscaler"])
cls._cleanup.append(cls.netscaler)
cls.ns_configured = True
except Exception:
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/91ffaaa5/tools/marvin/marvin/lib/common.py
----------------------------------------------------------------------
diff --git a/tools/marvin/marvin/lib/common.py b/tools/marvin/marvin/lib/common.py
index 9e3d40c..63662b9 100644
--- a/tools/marvin/marvin/lib/common.py
+++ b/tools/marvin/marvin/lib/common.py
@@ -1376,3 +1376,21 @@ def isNetworkDeleted(apiclient, networkid, timeout=600):
time.sleep(60)
#end while
return networkDeleted
+
+def GetNetscalerInfoFromConfig(config):
+ """ Read netscaler data from config file and
+ return it
+
+ Input: Config
+ Output: [netscalerInfoDict, isExceptionOccured]
+ """
+ try:
+ netscalerInfo = config.__dict__[
+ "netscalerDevice"].__dict__
+ return [netscalerInfo, None]
+ except KeyError:
+ exceptionMessage = "Please make sure you have included netscalerDevice\
+ dict in your config file"
+ return [None, exceptionMessage]
+ except Exception as e:
+ return [None, e]
[5/5] git commit: updated refs/heads/master to 91ffaaa
Posted by ta...@apache.org.
CLOUDSTACK-7912: Remove hardcoded netscaler info and read it from config file
Signed-off-by: SrikanteswaraRao Talluri <ta...@apache.org>
Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/91ffaaa5
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/91ffaaa5
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/91ffaaa5
Branch: refs/heads/master
Commit: 91ffaaa5a2163b2b62868097dea587bd712061d8
Parents: d8d60f0
Author: Gaurav Aradhye <ga...@clogeny.com>
Authored: Fri Nov 14 19:53:25 2014 +0530
Committer: SrikanteswaraRao Talluri <ta...@apache.org>
Committed: Mon Nov 17 15:30:24 2014 +0530
----------------------------------------------------------------------
.../component/test_lb_secondary_ip.py | 12 +-
test/integration/component/test_netscaler_lb.py | 3011 +++++++++---------
.../component/test_netscaler_lb_algo.py | 2180 +++++++------
.../component/test_netscaler_lb_sticky.py | 1013 +++---
.../component/test_persistent_networks.py | 30 +-
tools/marvin/marvin/lib/common.py | 18 +
6 files changed, 3251 insertions(+), 3013 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/91ffaaa5/test/integration/component/test_lb_secondary_ip.py
----------------------------------------------------------------------
diff --git a/test/integration/component/test_lb_secondary_ip.py b/test/integration/component/test_lb_secondary_ip.py
index daffe34..841257f 100644
--- a/test/integration/component/test_lb_secondary_ip.py
+++ b/test/integration/component/test_lb_secondary_ip.py
@@ -49,7 +49,8 @@ from marvin.lib.common import (get_domain,
get_template,
verifyNetworkState,
wait_for_cleanup,
- add_netscaler
+ add_netscaler,
+ GetNetscalerInfoFromConfig
)
from marvin.lib.utils import (validateList,
@@ -1775,11 +1776,18 @@ class TestExternalLoadBalancer(cloudstackTestCase):
cls.testdata["virtual_machine"]["template"] = template.id
cls._cleanup = []
+ response = GetNetscalerInfoFromConfig(
+ cls.config
+ )
+ assert response[0] is not None, response[1]
+ cls.testdata["netscaler"] = response[0]
+ cls.testdata["netscaler"]["lbdevicededicated"] = False
+
try:
cls.netscaler = add_netscaler(
cls.api_client,
cls.zone.id,
- cls.testdata["netscaler_VPX"])
+ cls.testdata["netscaler"])
cls._cleanup.append(cls.netscaler)
except Exception as e:
raise unittest.SkipTest("Failed to add netscaler device: %s" % e)