CLOUDSTACK-7912: Remove hardcoded netscaler info and read it from config file

Signed-off-by: SrikanteswaraRao Talluri <talluri@apache.org>
This commit is contained in:
Gaurav Aradhye 2014-11-14 19:53:25 +05:30 committed by SrikanteswaraRao Talluri
parent d8d60f0172
commit 91ffaaa5a2
6 changed files with 3224 additions and 2986 deletions

View File

@ -49,7 +49,8 @@ from marvin.lib.common import (get_domain,
get_template, get_template,
verifyNetworkState, verifyNetworkState,
wait_for_cleanup, wait_for_cleanup,
add_netscaler add_netscaler,
GetNetscalerInfoFromConfig
) )
from marvin.lib.utils import (validateList, from marvin.lib.utils import (validateList,
@ -1775,11 +1776,18 @@ class TestExternalLoadBalancer(cloudstackTestCase):
cls.testdata["virtual_machine"]["template"] = template.id cls.testdata["virtual_machine"]["template"] = template.id
cls._cleanup = [] 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: try:
cls.netscaler = add_netscaler( cls.netscaler = add_netscaler(
cls.api_client, cls.api_client,
cls.zone.id, cls.zone.id,
cls.testdata["netscaler_VPX"]) cls.testdata["netscaler"])
cls._cleanup.append(cls.netscaler) cls._cleanup.append(cls.netscaler)
except Exception as e: except Exception as e:
raise unittest.SkipTest("Failed to add netscaler device: %s" % e) raise unittest.SkipTest("Failed to add netscaler device: %s" % e)

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -40,7 +40,8 @@ from marvin.lib.common import (get_domain,
get_template, get_template,
verifyNetworkState, verifyNetworkState,
add_netscaler, add_netscaler,
wait_for_cleanup) wait_for_cleanup,
GetNetscalerInfoFromConfig)
from nose.plugins.attrib import attr from nose.plugins.attrib import attr
from marvin.codes import PASS, FAIL, FAILED from marvin.codes import PASS, FAIL, FAILED
from marvin.sshClient import SshClient from marvin.sshClient import SshClient
@ -97,6 +98,13 @@ class TestPersistentNetworks(cloudstackTestCase):
cls.isolated_network_offering_netscaler = cls.createNetworkOffering( cls.isolated_network_offering_netscaler = cls.createNetworkOffering(
"nw_off_isolated_netscaler") "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 # Configure Netscaler device
# If configuration succeeds, set ns_configured to True so that # If configuration succeeds, set ns_configured to True so that
# Netscaler tests are executed # Netscaler tests are executed
@ -105,7 +113,7 @@ class TestPersistentNetworks(cloudstackTestCase):
cls.netscaler = add_netscaler( cls.netscaler = add_netscaler(
cls.api_client, cls.api_client,
cls.zone.id, cls.zone.id,
cls.services["netscaler_VPX"]) cls.services["netscaler"])
cls._cleanup.append(cls.netscaler) cls._cleanup.append(cls.netscaler)
cls.ns_configured = True cls.ns_configured = True
except Exception: except Exception:
@ -1500,6 +1508,13 @@ class TestAssignVirtualMachine(cloudstackTestCase):
cls.persistent_network_offering_netscaler = cls.createNetworkOffering( cls.persistent_network_offering_netscaler = cls.createNetworkOffering(
"nw_off_isolated_persistent_netscaler") "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 # Configure Netscaler device
# If configuration succeeds, set ns_configured to True so that # If configuration succeeds, set ns_configured to True so that
# Netscaler tests are executed # Netscaler tests are executed
@ -1508,7 +1523,7 @@ class TestAssignVirtualMachine(cloudstackTestCase):
cls.netscaler = add_netscaler( cls.netscaler = add_netscaler(
cls.api_client, cls.api_client,
cls.zone.id, cls.zone.id,
cls.services["netscaler_VPX"]) cls.services["netscaler"])
cls._cleanup.append(cls.netscaler) cls._cleanup.append(cls.netscaler)
cls.ns_configured = True cls.ns_configured = True
except Exception: except Exception:
@ -1964,6 +1979,13 @@ class TestRestartPersistentNetwork(cloudstackTestCase):
cls.api_client, cls.api_client,
state="enabled") 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 # Configure Netscaler device
# If configuration succeeds, set ns_configured to True so that # If configuration succeeds, set ns_configured to True so that
# Netscaler tests are executed # Netscaler tests are executed
@ -1972,7 +1994,7 @@ class TestRestartPersistentNetwork(cloudstackTestCase):
cls.netscaler = add_netscaler( cls.netscaler = add_netscaler(
cls.api_client, cls.api_client,
cls.zone.id, cls.zone.id,
cls.services["netscaler_VPX"]) cls.services["netscaler"])
cls._cleanup.append(cls.netscaler) cls._cleanup.append(cls.netscaler)
cls.ns_configured = True cls.ns_configured = True
except Exception: except Exception:

View File

@ -1376,3 +1376,21 @@ def isNetworkDeleted(apiclient, networkid, timeout=600):
time.sleep(60) time.sleep(60)
#end while #end while
return networkDeleted 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]