default teardown methods with reversed() handling (#4289)

Co-authored-by: Daan Hoogland <dahn@onecht.net>
This commit is contained in:
dahn 2020-11-13 08:56:28 +01:00 committed by GitHub
parent fb78fb24c7
commit a348afe91b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 153 additions and 277 deletions

View File

@ -1454,11 +1454,7 @@ class TestMigrateVolume(cloudstackTestCase):
@classmethod @classmethod
def tearDownClass(cls): def tearDownClass(cls):
try: super(TestMigrateVolume,cls).tearDownClass()
cleanup_resources(cls.api_client, cls._cleanup)
except Exception as e:
raise Exception("Warning: Exception during cleanup : %s" % e)
return
def setUp(self): def setUp(self):
self.apiclient = self.testClient.getApiClient() self.apiclient = self.testClient.getApiClient()
@ -1470,8 +1466,7 @@ class TestMigrateVolume(cloudstackTestCase):
return return
def tearDown(self): def tearDown(self):
cleanup_resources(self.apiclient, self.cleanup) super(TestMigrateVolume,self).tearDown()
return
@attr(tags=["advanced", "sg", "advancedsg"], required_hardware='true') @attr(tags=["advanced", "sg", "advancedsg"], required_hardware='true')
def test_01_migrateVolume(self): def test_01_migrateVolume(self):

View File

@ -153,12 +153,7 @@ class TestAccounts(cloudstackTestCase):
@classmethod @classmethod
def tearDownClass(cls): def tearDownClass(cls):
try: super(TestAccounts,cls).tearDownClass()
# Cleanup resources used
cleanup_resources(cls.api_client, reversed(cls._cleanup))
except Exception as e:
raise Exception("Warning: Exception during cleanup : %s" % e)
return
def setUp(self): def setUp(self):
self.apiclient = self.testClient.getApiClient() self.apiclient = self.testClient.getApiClient()
@ -167,12 +162,7 @@ class TestAccounts(cloudstackTestCase):
return return
def tearDown(self): def tearDown(self):
try: super(TestAccounts,self).tearDown()
# Clean up, terminate the created accounts, domains etc
cleanup_resources(self.apiclient, reversed(self.cleanup))
except Exception as e:
raise Exception("Warning: Exception during cleanup : %s" % e)
return
@attr( @attr(
tags=[ tags=[
@ -352,12 +342,7 @@ class TestRemoveUserFromAccount(cloudstackTestCase):
@classmethod @classmethod
def tearDownClass(cls): def tearDownClass(cls):
try: super(TestRemoveUserFromAccount,cls).tearDownClass()
# Cleanup resources used
cleanup_resources(cls.api_client, reversed(cls._cleanup))
except Exception as e:
raise Exception("Warning: Exception during cleanup : %s" % e)
return
def setUp(self): def setUp(self):
self.apiclient = self.testClient.getApiClient() self.apiclient = self.testClient.getApiClient()
@ -366,12 +351,7 @@ class TestRemoveUserFromAccount(cloudstackTestCase):
return return
def tearDown(self): def tearDown(self):
try: super(TestRemoveUserFromAccount,self).tearDown()
# Clean up, terminate the created instance, users etc
cleanup_resources(self.apiclient, reversed(self.cleanup))
except Exception as e:
raise Exception("Warning: Exception during cleanup : %s" % e)
return
@attr( @attr(
tags=[ tags=[
@ -513,12 +493,7 @@ class TestNonRootAdminsPrivileges(cloudstackTestCase):
@classmethod @classmethod
def tearDownClass(cls): def tearDownClass(cls):
try: super(TestNonRootAdminsPrivileges,cls).tearDownClass()
# Cleanup resources used
cleanup_resources(cls.api_client, reversed(cls._cleanup))
except Exception as e:
raise Exception("Warning: Exception during cleanup : %s" % e)
return
def setUp(self): def setUp(self):
self.apiclient = self.testClient.getApiClient() self.apiclient = self.testClient.getApiClient()
@ -527,12 +502,7 @@ class TestNonRootAdminsPrivileges(cloudstackTestCase):
return return
def tearDown(self): def tearDown(self):
try: super(TestNonRootAdminsPrivileges,self).tearDown()
# Clean up, terminate the created accounts
cleanup_resources(self.apiclient, reversed(self.cleanup))
except Exception as e:
raise Exception("Warning: Exception during cleanup : %s" % e)
return
@attr( @attr(
tags=[ tags=[
@ -642,12 +612,7 @@ class TestServiceOfferingSiblings(cloudstackTestCase):
@classmethod @classmethod
def tearDownClass(cls): def tearDownClass(cls):
try: super(TestServiceOfferingSiblings,cls).tearDownClass()
# Cleanup resources used
cleanup_resources(cls.api_client, reversed(cls._cleanup))
except Exception as e:
raise Exception("Warning: Exception during cleanup : %s" % e)
return
def setUp(self): def setUp(self):
self.apiclient = self.testClient.getApiClient() self.apiclient = self.testClient.getApiClient()
@ -656,12 +621,7 @@ class TestServiceOfferingSiblings(cloudstackTestCase):
return return
def tearDown(self): def tearDown(self):
try: super(TestServiceOfferingSiblings,self).tearDown()
# Clean up, terminate the created domains, accounts
cleanup_resources(self.apiclient, reversed(self.cleanup))
except Exception as e:
raise Exception("Warning: Exception during cleanup : %s" % e)
return
@attr( @attr(
tags=[ tags=[
@ -766,12 +726,7 @@ class TestServiceOfferingHierarchy(cloudstackTestCase):
@classmethod @classmethod
def tearDownClass(cls): def tearDownClass(cls):
try: super(TestServiceOfferingHierarchy,cls).tearDownClass()
# Cleanup resources used
cleanup_resources(cls.api_client, reversed(cls._cleanup))
except Exception as e:
raise Exception("Warning: Exception during cleanup : %s" % e)
return
def setUp(self): def setUp(self):
self.apiclient = self.testClient.getApiClient() self.apiclient = self.testClient.getApiClient()
@ -780,12 +735,7 @@ class TestServiceOfferingHierarchy(cloudstackTestCase):
return return
def tearDown(self): def tearDown(self):
try: super(TestServiceOfferingHierarchy,self).tearDown()
# Clean up, terminate the created instance, volumes and snapshots
cleanup_resources(self.apiclient, reversed(self.cleanup))
except Exception as e:
raise Exception("Warning: Exception during cleanup : %s" % e)
return
@attr( @attr(
tags=[ tags=[
@ -908,12 +858,7 @@ class TestTemplateHierarchy(cloudstackTestCase):
@classmethod @classmethod
def tearDownClass(cls): def tearDownClass(cls):
try: super(TestTemplateHierarchy,cls).tearDownClass()
# Cleanup resources used
cleanup_resources(cls.api_client, reversed(cls._cleanup))
except Exception as e:
raise Exception("Warning: Exception during cleanup : %s" % e)
return
def setUp(self): def setUp(self):
self.apiclient = self.testClient.getApiClient() self.apiclient = self.testClient.getApiClient()
@ -922,12 +867,7 @@ class TestTemplateHierarchy(cloudstackTestCase):
return return
def tearDown(self): def tearDown(self):
try: super(TestTemplateHierarchy,self).tearDown()
# Clean up, terminate the created instance, volumes and snapshots
cleanup_resources(self.apiclient, reversed(self.cleanup))
except Exception as e:
raise Exception("Warning: Exception during cleanup : %s" % e)
return
@attr(tags=["advanced", "basic", "eip", "advancedns", "sg"], required_hardware="true") @attr(tags=["advanced", "basic", "eip", "advancedns", "sg"], required_hardware="true")
def test_01_template_hierarchy(self): def test_01_template_hierarchy(self):
@ -1064,12 +1004,7 @@ class TestAddVmToSubDomain(cloudstackTestCase):
@classmethod @classmethod
def tearDownClass(cls): def tearDownClass(cls):
try: super(TestAddVmToSubDomain,cls).tearDownClass()
# Clean up, terminate the created resources
cleanup_resources(cls.api_client, reversed(cls._cleanup))
except Exception as e:
raise Exception("Warning: Exception during cleanup : %s" % e)
return
def setUp(self): def setUp(self):
self.apiclient = self.testClient.getApiClient() self.apiclient = self.testClient.getApiClient()
@ -1078,12 +1013,7 @@ class TestAddVmToSubDomain(cloudstackTestCase):
return return
def tearDown(self): def tearDown(self):
try: super(TestAddVmToSubDomain,self).tearDown()
# Clean up, terminate the created resources
cleanup_resources(self.apiclient, reversed(self.cleanup))
except Exception as e:
raise Exception("Warning: Exception during cleanup : %s" % e)
return
@attr( @attr(
tags=[ tags=[
@ -1160,12 +1090,7 @@ class TestUserDetails(cloudstackTestCase):
@classmethod @classmethod
def tearDownClass(cls): def tearDownClass(cls):
try: super(TestUserDetails,cls).tearDownClass()
# Cleanup resources used
cleanup_resources(cls.api_client, reversed(cls._cleanup))
except Exception as e:
raise Exception("Warning: Exception during cleanup : %s" % e)
return
def setUp(self): def setUp(self):
self.apiclient = self.testClient.getApiClient() self.apiclient = self.testClient.getApiClient()
@ -1174,12 +1099,7 @@ class TestUserDetails(cloudstackTestCase):
return return
def tearDown(self): def tearDown(self):
try: super(TestUserDetails,self).tearDown()
# Clean up, terminate the created network offerings
cleanup_resources(self.apiclient, reversed(self.cleanup))
except Exception as e:
raise Exception("Warning: Exception during cleanup : %s" % e)
return
@attr(tags=[ @attr(tags=[
"role", "role",
@ -1459,12 +1379,7 @@ class TestUserLogin(cloudstackTestCase):
@classmethod @classmethod
def tearDownClass(cls): def tearDownClass(cls):
try: super(TestUserLogin,cls).tearDownClass()
# Cleanup resources used
cleanup_resources(cls.api_client, reversed(cls._cleanup))
except Exception as e:
raise Exception("Warning: Exception during cleanup : %s" % e)
return
def setUp(self): def setUp(self):
self.apiclient = self.testClient.getApiClient() self.apiclient = self.testClient.getApiClient()
@ -1473,12 +1388,7 @@ class TestUserLogin(cloudstackTestCase):
return return
def tearDown(self): def tearDown(self):
try: super(TestUserLogin,self).tearDown()
# Clean up, terminate the created network offerings
cleanup_resources(self.apiclient, reversed(self.cleanup))
except Exception as e:
raise Exception("Warning: Exception during cleanup : %s" % e)
return
@attr(tags=["login", "accounts", "simulator", "advanced", @attr(tags=["login", "accounts", "simulator", "advanced",
"advancedns", "basic", "eip", "sg"]) "advancedns", "basic", "eip", "sg"])
@ -1716,12 +1626,7 @@ class TestUserAPIKeys(cloudstackTestCase):
@classmethod @classmethod
def tearDownClass(cls): def tearDownClass(cls):
try: super(TestUserAPIKeys,cls).tearDownClass()
# Cleanup resources used
cleanup_resources(cls.api_client, reversed(cls._cleanup))
except Exception as e:
raise Exception("Warning: Exception during cleanup : %s" % e)
return
def setUp(self): def setUp(self):
self.apiclient = self.testClient.getApiClient() self.apiclient = self.testClient.getApiClient()
@ -1730,12 +1635,7 @@ class TestUserAPIKeys(cloudstackTestCase):
return return
def tearDown(self): def tearDown(self):
try: super(TestUserAPIKeys,self).tearDown()
# Clean up, terminate the created network offerings
cleanup_resources(self.apiclient, reversed(self.cleanup))
except Exception as e:
raise Exception("Warning: Exception during cleanup : %s" % e)
return
@attr(tags=[ @attr(tags=[
"role", "role",
@ -1868,13 +1768,7 @@ class TestDomainForceRemove(cloudstackTestCase):
@classmethod @classmethod
def tearDownClass(cls): def tearDownClass(cls):
try: super(TestDomainForceRemove,cls).tearDownClass()
# Clean up, terminate the created resources
cleanup_resources(cls.api_client, reversed(cls._cleanup))
except Exception as e:
raise Exception("Warning: Exception during cleanup : %s" % e)
return
def setUp(self): def setUp(self):
self.apiclient = self.testClient.getApiClient() self.apiclient = self.testClient.getApiClient()
@ -1883,12 +1777,7 @@ class TestDomainForceRemove(cloudstackTestCase):
return return
def tearDown(self): def tearDown(self):
try: super(TestDomainForceRemove,self).tearDown()
# Clean up, terminate the created resources
cleanup_resources(self.apiclient, reversed(self.cleanup))
except Exception as e:
raise Exception("Warning: Exception during cleanup : %s" % e)
return
@attr( @attr(
tags=[ tags=[
@ -2247,13 +2136,7 @@ class TestMoveUser(cloudstackTestCase):
@classmethod @classmethod
def tearDownClass(cls): def tearDownClass(cls):
try: super(TestMoveUser,cls).tearDownClass()
# Clean up, terminate the created resources
cleanup_resources(cls.api_client, reversed(cls._cleanup))
except Exception as e:
raise Exception("Warning: Exception during cleanup : %s" % e)
return
def setUp(self): def setUp(self):
self.apiclient = self.testClient.getApiClient() self.apiclient = self.testClient.getApiClient()
@ -2284,12 +2167,7 @@ class TestMoveUser(cloudstackTestCase):
return return
def tearDown(self): def tearDown(self):
try: super(TestMoveUser,self).tearDownClass()
# Clean up, terminate the created resources
cleanup_resources(self.apiclient, reversed(self.cleanup))
except Exception as e:
raise Exception("Warning: Exception during cleanup : %s" % e)
return
@attr(tags=["domains", "advanced", "advancedns", "simulator","dvs"], required_hardware="false") @attr(tags=["domains", "advanced", "advancedns", "simulator","dvs"], required_hardware="false")
def test_move_user_to_accountID(self): def test_move_user_to_accountID(self):

View File

@ -33,9 +33,6 @@ from marvin.lib.base import (Account,
Host, Host,
GuestOs) GuestOs)
# utils - utility classes for common cleanup, external library wrappers etc
from marvin.lib.utils import cleanup_resources, get_hypervisor_type, validateList
# common - commonly used methods for all tests are listed here # common - commonly used methods for all tests are listed here
from marvin.lib.common import get_zone, get_domain, get_pod from marvin.lib.common import get_zone, get_domain, get_pod
@ -96,7 +93,7 @@ class TestDeployVirtioSCSIVM(cloudstackTestCase):
cls.zone = get_zone(cls.apiclient, testClient.getZoneForTests()) cls.zone = get_zone(cls.apiclient, testClient.getZoneForTests())
cls.pod = get_pod(cls.apiclient, cls.zone.id) cls.pod = get_pod(cls.apiclient, cls.zone.id)
cls.services['mode'] = cls.zone.networktype cls.services['mode'] = cls.zone.networktype
cls.cleanup = [] cls._cleanup = []
if cls.hypervisor.lower() not in ['kvm']: if cls.hypervisor.lower() not in ['kvm']:
cls.hypervisorNotSupported = True cls.hypervisorNotSupported = True
return return
@ -108,6 +105,7 @@ class TestDeployVirtioSCSIVM(cloudstackTestCase):
hypervisor=cls.hypervisor.lower(), hypervisor=cls.hypervisor.lower(),
domainid=cls.domain.id) domainid=cls.domain.id)
cls.template.download(cls.apiclient) cls.template.download(cls.apiclient)
cls._cleanup.append(cls.template)
if cls.template == FAILED: if cls.template == FAILED:
assert False, "get_template() failed to return template" assert False, "get_template() failed to return template"
@ -120,16 +118,19 @@ class TestDeployVirtioSCSIVM(cloudstackTestCase):
cls.services["account"], cls.services["account"],
domainid=cls.domain.id domainid=cls.domain.id
) )
cls._cleanup.append(cls.account)
cls.service_offering = ServiceOffering.create( cls.service_offering = ServiceOffering.create(
cls.apiclient, cls.apiclient,
cls.services["service_offerings"]["small"] cls.services["service_offerings"]["small"]
) )
cls._cleanup.append(cls.service_offering)
cls.sparse_disk_offering = DiskOffering.create( cls.sparse_disk_offering = DiskOffering.create(
cls.apiclient, cls.apiclient,
cls.services["sparse_disk_offering"] cls.services["sparse_disk_offering"]
) )
cls._cleanup.append(cls.sparse_disk_offering)
cls.virtual_machine = VirtualMachine.create( cls.virtual_machine = VirtualMachine.create(
cls.apiclient, cls.apiclient,
@ -158,29 +159,20 @@ class TestDeployVirtioSCSIVM(cloudstackTestCase):
# Start VM after password reset # Start VM after password reset
cls.virtual_machine.start(cls.apiclient) cls.virtual_machine.start(cls.apiclient)
cls._cleanup.append(cls.virtual_machine)
cls.cleanup = [
cls.template,
cls.service_offering,
cls.sparse_disk_offering,
cls.account
]
@classmethod @classmethod
def tearDownClass(cls): def tearDownClass(cls):
try: super(TestDeployVirtioSCSIVM, cls).tearDownClass()
cls.apiclient = super(
TestDeployVirtioSCSIVM,
cls
).getClsTestClient().getApiClient()
# Cleanup resources used
cleanup_resources(cls.apiclient, cls.cleanup)
except Exception as e:
raise Exception("Warning: Exception during cleanup : %s" % e)
def setUp(self): def setUp(self):
self.apiclient = self.testClient.getApiClient() self.apiclient = self.testClient.getApiClient()
self.dbclient = self.testClient.getDbConnection() self.dbclient = self.testClient.getDbConnection()
self.cleanup = []
def tearDown(self):
super(TestDeployVirtioSCSIVM, self).tearDown()
def verifyVirshState(self, diskcount): def verifyVirshState(self, diskcount):
host = self.vmhost.ipaddress host = self.vmhost.ipaddress

View File

@ -19,7 +19,6 @@ from marvin.codes import FAILED
from marvin.cloudstackTestCase import cloudstackTestCase from marvin.cloudstackTestCase import cloudstackTestCase
from marvin.lib.base import Account, VirtualMachine, ServiceOffering, Host, Cluster from marvin.lib.base import Account, VirtualMachine, ServiceOffering, Host, Cluster
from marvin.lib.common import get_zone, get_domain, get_test_template from marvin.lib.common import get_zone, get_domain, get_test_template
from marvin.lib.utils import cleanup_resources
from nose.plugins.attrib import attr from nose.plugins.attrib import attr
class TestDeployVmWithVariedPlanners(cloudstackTestCase): class TestDeployVmWithVariedPlanners(cloudstackTestCase):
@ -57,9 +56,8 @@ class TestDeployVmWithVariedPlanners(cloudstackTestCase):
) )
cls.hosts = Host.list(cls.apiclient, type='Routing') cls.hosts = Host.list(cls.apiclient, type='Routing')
cls.clusters = Cluster.list(cls.apiclient) cls.clusters = Cluster.list(cls.apiclient)
cls.cleanup = [ cls._cleanup = []
cls.account cls._cleanup.append(cls.account)
]
@attr(tags=["advanced", "basic", "sg"], required_hardware="false") @attr(tags=["advanced", "basic", "sg"], required_hardware="false")
def test_deployvm_firstfit(self): def test_deployvm_firstfit(self):
@ -230,7 +228,4 @@ class TestDeployVmWithVariedPlanners(cloudstackTestCase):
@classmethod @classmethod
def tearDownClass(cls): def tearDownClass(cls):
try: super(TestDeployVmWithVariedPlanners,cls).tearDownClass()
cleanup_resources(cls.apiclient, cls.cleanup)
except Exception as e:
raise Exception("Warning: Exception during cleanup : %s" % e)

View File

@ -30,7 +30,6 @@ from marvin.lib.common import (get_domain,
get_test_template, get_test_template,
list_ssvms, list_ssvms,
list_routers) list_routers)
from marvin.lib.utils import (cleanup_resources)
from nose.plugins.attrib import attr from nose.plugins.attrib import attr
@ -61,16 +60,20 @@ class TestRemoteDiagnostics(cloudstackTestCase):
cls.services["virtual_machine"]["zoneid"] = cls.zone.id cls.services["virtual_machine"]["zoneid"] = cls.zone.id
cls._cleanup = []
# Create an account, network, VM and IP addresses # Create an account, network, VM and IP addresses
cls.account = Account.create( cls.account = Account.create(
cls.apiclient, cls.apiclient,
cls.services["account"], cls.services["account"],
domainid=cls.domain.id domainid=cls.domain.id
) )
cls._cleanup.append(cls.account)
cls.service_offering = ServiceOffering.create( cls.service_offering = ServiceOffering.create(
cls.apiclient, cls.apiclient,
cls.services["service_offerings"]["tiny"] cls.services["service_offerings"]["tiny"]
) )
cls._cleanup.append(cls.service_offering)
cls.vm_1 = VirtualMachine.create( cls.vm_1 = VirtualMachine.create(
cls.apiclient, cls.apiclient,
cls.services["virtual_machine"], cls.services["virtual_machine"],
@ -79,27 +82,19 @@ class TestRemoteDiagnostics(cloudstackTestCase):
domainid=cls.account.domainid, domainid=cls.account.domainid,
serviceofferingid=cls.service_offering.id serviceofferingid=cls.service_offering.id
) )
cls.cleanup = [ cls._cleanup.append(cls.vm_1)
cls.account,
cls.service_offering
]
@classmethod @classmethod
def tearDownClass(cls): def tearDownClass(cls):
try: super(TestRemoteDiagnostics,cls).tearDownClass()
cls.apiclient = super(
TestRemoteDiagnostics,
cls
).getClsTestClient().getApiClient()
# Clean up, terminate the created templates
cleanup_resources(cls.apiclient, cls.cleanup)
except Exception as e:
raise Exception("Warning: Exception during cleanup : %s" % e)
def setUp(self): def setUp(self):
self.apiclient = self.testClient.getApiClient() self.apiclient = self.testClient.getApiClient()
self.hypervisor = self.testClient.getHypervisorInfo() self.hypervisor = self.testClient.getHypervisorInfo()
self.cleanup = []
def tearDown(self):
super(TestRemoteDiagnostics,self).tearDown()
@attr(tags=["advanced", "advancedns", "ssh", "smoke"], required_hardware="true") @attr(tags=["advanced", "advancedns", "ssh", "smoke"], required_hardware="true")
def test_01_ping_in_vr_success(self): def test_01_ping_in_vr_success(self):

View File

@ -69,16 +69,20 @@ class TestRouterServices(cloudstackTestCase):
cls.services["virtual_machine"]["zoneid"] = cls.zone.id cls.services["virtual_machine"]["zoneid"] = cls.zone.id
cls._cleanup = []
# Create an account, network, VM and IP addresses # Create an account, network, VM and IP addresses
cls.account = Account.create( cls.account = Account.create(
cls.apiclient, cls.apiclient,
cls.services["account"], cls.services["account"],
domainid=cls.domain.id domainid=cls.domain.id
) )
cls._cleanup.append(cls.account)
cls.service_offering = ServiceOffering.create( cls.service_offering = ServiceOffering.create(
cls.apiclient, cls.apiclient,
cls.services["service_offerings"]["tiny"] cls.services["service_offerings"]["tiny"]
) )
cls._cleanup.append(cls.service_offering)
cls.vm_1 = VirtualMachine.create( cls.vm_1 = VirtualMachine.create(
cls.apiclient, cls.apiclient,
cls.services["virtual_machine"], cls.services["virtual_machine"],
@ -87,30 +91,20 @@ class TestRouterServices(cloudstackTestCase):
domainid=cls.account.domainid, domainid=cls.account.domainid,
serviceofferingid=cls.service_offering.id serviceofferingid=cls.service_offering.id
) )
cls.cleanup = [ cls._cleanup.append(cls.vm_1)
cls.account,
cls.service_offering
]
return return
@classmethod @classmethod
def tearDownClass(cls): def tearDownClass(cls):
try: super(TestRouterServices, cls).tearDownClass()
cls.apiclient = super(
TestRouterServices,
cls
).getClsTestClient().getApiClient()
# Clean up, terminate the created templates
cleanup_resources(cls.apiclient, cls.cleanup)
except Exception as e:
raise Exception("Warning: Exception during cleanup : %s" % e)
return
def setUp(self): def setUp(self):
self.apiclient = self.testClient.getApiClient() self.apiclient = self.testClient.getApiClient()
self.hypervisor = self.testClient.getHypervisorInfo() self.hypervisor = self.testClient.getHypervisorInfo()
return self.cleanup = []
def tearDown(self):
super(TestRouterServices, self).tearDown()
@attr(tags=["advanced", "basic", "sg", "smoke"], required_hardware="true") @attr(tags=["advanced", "basic", "sg", "smoke"], required_hardware="true")
def test_01_router_internal_basic(self): def test_01_router_internal_basic(self):

View File

@ -20,13 +20,9 @@
from marvin.codes import PASS, FAILED from marvin.codes import PASS, FAILED
from marvin.cloudstackTestCase import cloudstackTestCase from marvin.cloudstackTestCase import cloudstackTestCase
from marvin.lib.utils import (validateList, from marvin.lib.utils import (validateList,
cleanup_resources,
get_process_status,
wait_until) wait_until)
from marvin.lib.base import (Domain, from marvin.lib.base import (Account,
Account,
Configurations,
VPC, VPC,
VpcOffering, VpcOffering,
ServiceOffering, ServiceOffering,
@ -34,14 +30,8 @@ from marvin.lib.base import (Domain,
Network, Network,
PublicIPAddress, PublicIPAddress,
NATRule, NATRule,
NetworkACL,
NetworkACLList, NetworkACLList,
LoadBalancerRule,
ApplicationLoadBalancer,
VirtualMachine, VirtualMachine,
Template,
FireWallRule,
StaticNATRule,
Vpn, Vpn,
VpnCustomerGateway, VpnCustomerGateway,
VpnUser VpnUser
@ -52,8 +42,7 @@ from marvin.sshClient import SshClient
from marvin.lib.common import (get_zone, from marvin.lib.common import (get_zone,
get_domain, get_domain,
get_test_template, get_test_template)
list_network_offerings)
from nose.plugins.attrib import attr from nose.plugins.attrib import attr
@ -236,12 +225,16 @@ class TestVpcRemoteAccessVpn(cloudstackTestCase):
cls.zone = get_zone(cls.apiclient, testClient.getZoneForTests()) cls.zone = get_zone(cls.apiclient, testClient.getZoneForTests())
cls.domain = get_domain(cls.apiclient) cls.domain = get_domain(cls.apiclient)
cls._cleanup = []
cls.compute_offering = ServiceOffering.create( cls.compute_offering = ServiceOffering.create(
cls.apiclient, cls.apiclient,
cls.services["compute_offering"] cls.services["compute_offering"]
) )
cls._cleanup.append(cls.compute_offering)
cls.account = Account.create( cls.account = Account.create(
cls.apiclient, services=cls.services["account"]) cls.apiclient, services=cls.services["account"])
cls._cleanup.append(cls.account)
cls.hypervisor = testClient.getHypervisorInfo() cls.hypervisor = testClient.getHypervisorInfo()
@ -253,7 +246,6 @@ class TestVpcRemoteAccessVpn(cloudstackTestCase):
%s" % (cls.account.name, %s" % (cls.account.name,
cls.account.id)) cls.account.id))
cls.cleanup = [cls.account, cls.compute_offering]
return return
@attr(tags=["advanced"], required_hardware="true") @attr(tags=["advanced"], required_hardware="true")
@ -285,6 +277,7 @@ class TestVpcRemoteAccessVpn(cloudstackTestCase):
account=self.account.name, account=self.account.name,
domainid=self.domain.id domainid=self.domain.id
) )
self.cleanup.append(vpc)
except Exception as e: except Exception as e:
self.fail(e) self.fail(e)
finally: finally:
@ -306,6 +299,7 @@ class TestVpcRemoteAccessVpn(cloudstackTestCase):
self.fail(e) self.fail(e)
finally: finally:
self.assertIsNotNone(ntwk, "Network failed to create") self.assertIsNotNone(ntwk, "Network failed to create")
self.cleanup.append(ntwk)
self.logger.debug( self.logger.debug(
"Network %s created in VPC %s" % (ntwk.id, vpc.id)) "Network %s created in VPC %s" % (ntwk.id, vpc.id))
@ -321,6 +315,7 @@ class TestVpcRemoteAccessVpn(cloudstackTestCase):
hypervisor=self.hypervisor hypervisor=self.hypervisor
) )
self.assert_(vm is not None, "VM failed to deploy") self.assert_(vm is not None, "VM failed to deploy")
self.cleanup.append(vm)
self.assert_(vm.state == 'Running', "VM is not running") self.assert_(vm.state == 'Running', "VM is not running")
self.debug("VM %s deployed in VPC %s" % (vm.id, vpc.id)) self.debug("VM %s deployed in VPC %s" % (vm.id, vpc.id))
except Exception as e: except Exception as e:
@ -387,12 +382,15 @@ class TestVpcRemoteAccessVpn(cloudstackTestCase):
@classmethod @classmethod
def tearDownClass(cls): def tearDownClass(cls):
super(TestVpcRemoteAccessVpn, cls).tearDownClass()
try: def setUp(self):
cls.logger.debug("Cleaning up resources") self.apiclient = self.testClient.getApiClient()
cleanup_resources(cls.apiclient, cls.cleanup) self.hypervisor = self.testClient.getHypervisorInfo()
except Exception, e: self.cleanup = []
raise Exception("Cleanup failed with %s" % e)
def tearDown(self):
super(TestVpcRemoteAccessVpn, self).tearDown()
class TestVpcSite2SiteVpn(cloudstackTestCase): class TestVpcSite2SiteVpn(cloudstackTestCase):
@ -411,13 +409,17 @@ class TestVpcSite2SiteVpn(cloudstackTestCase):
cls.zone = get_zone(cls.apiclient, testClient.getZoneForTests()) cls.zone = get_zone(cls.apiclient, testClient.getZoneForTests())
cls.domain = get_domain(cls.apiclient) cls.domain = get_domain(cls.apiclient)
cls._cleanup = []
cls.compute_offering = ServiceOffering.create( cls.compute_offering = ServiceOffering.create(
cls.apiclient, cls.apiclient,
cls.services["compute_offering"] cls.services["compute_offering"]
) )
cls._cleanup.append(cls.compute_offering)
cls.account = Account.create( cls.account = Account.create(
cls.apiclient, services=cls.services["account"]) cls.apiclient, services=cls.services["account"])
cls._cleanup.append(cls.account)
cls.hypervisor = testClient.getHypervisorInfo() cls.hypervisor = testClient.getHypervisorInfo()
@ -428,10 +430,13 @@ class TestVpcSite2SiteVpn(cloudstackTestCase):
cls.logger.debug("Successfully created account: %s, id: \ cls.logger.debug("Successfully created account: %s, id: \
%s" % (cls.account.name, %s" % (cls.account.name,
cls.account.id)) cls.account.id))
cls.cleanup = [cls.account, cls.compute_offering]
return return
def setUp(self):
self.apiclient = self.testClient.getApiClient()
self.hypervisor = self.testClient.getHypervisorInfo()
self.cleanup = []
def _get_ssh_client(self, virtual_machine, services, retries): def _get_ssh_client(self, virtual_machine, services, retries):
""" Setup ssh client connection and return connection """ Setup ssh client connection and return connection
vm requires attributes public_ip, public_port, username, password """ vm requires attributes public_ip, public_port, username, password """
@ -547,7 +552,7 @@ class TestVpcSite2SiteVpn(cloudstackTestCase):
self.fail(e) self.fail(e)
finally: finally:
self.assert_(vpc1 is not None, "VPC1 creation failed") self.assert_(vpc1 is not None, "VPC1 creation failed")
self.cleanup.append(vpc1)
self.logger.debug("VPC1 %s created" % vpc1.id) self.logger.debug("VPC1 %s created" % vpc1.id)
vpc2 = None vpc2 = None
@ -566,7 +571,7 @@ class TestVpcSite2SiteVpn(cloudstackTestCase):
self.fail(e) self.fail(e)
finally: finally:
self.assert_(vpc2 is not None, "VPC2 creation failed") self.assert_(vpc2 is not None, "VPC2 creation failed")
self.cleanup.append(vpc2)
self.logger.debug("VPC2 %s created" % vpc2.id) self.logger.debug("VPC2 %s created" % vpc2.id)
default_acl = NetworkACLList.list( default_acl = NetworkACLList.list(
@ -589,7 +594,7 @@ class TestVpcSite2SiteVpn(cloudstackTestCase):
self.fail(e) self.fail(e)
finally: finally:
self.assertIsNotNone(ntwk1, "Network failed to create") self.assertIsNotNone(ntwk1, "Network failed to create")
self.cleanup.append(ntwk1)
self.logger.debug("Network %s created in VPC %s" % (ntwk1.id, vpc1.id)) self.logger.debug("Network %s created in VPC %s" % (ntwk1.id, vpc1.id))
ntwk2 = None ntwk2 = None
@ -609,7 +614,7 @@ class TestVpcSite2SiteVpn(cloudstackTestCase):
self.fail(e) self.fail(e)
finally: finally:
self.assertIsNotNone(ntwk2, "Network failed to create") self.assertIsNotNone(ntwk2, "Network failed to create")
self.cleanup.append(ntwk2)
self.logger.debug("Network %s created in VPC %s" % (ntwk2.id, vpc2.id)) self.logger.debug("Network %s created in VPC %s" % (ntwk2.id, vpc2.id))
vm1 = None vm1 = None
@ -629,7 +634,7 @@ class TestVpcSite2SiteVpn(cloudstackTestCase):
finally: finally:
self.assert_(vm1 is not None, "VM failed to deploy") self.assert_(vm1 is not None, "VM failed to deploy")
self.assert_(vm1.state == 'Running', "VM is not running") self.assert_(vm1.state == 'Running', "VM is not running")
self.cleanup.append(vm1)
self.logger.debug("VM %s deployed in VPC %s" % (vm1.id, vpc1.id)) self.logger.debug("VM %s deployed in VPC %s" % (vm1.id, vpc1.id))
vm2 = None vm2 = None
@ -649,7 +654,7 @@ class TestVpcSite2SiteVpn(cloudstackTestCase):
finally: finally:
self.assert_(vm2 is not None, "VM failed to deploy") self.assert_(vm2 is not None, "VM failed to deploy")
self.assert_(vm2.state == 'Running', "VM is not running") self.assert_(vm2.state == 'Running', "VM is not running")
self.cleanup.append(vm2)
self.debug("VM %s deployed in VPC %s" % (vm2.id, vpc2.id)) self.debug("VM %s deployed in VPC %s" % (vm2.id, vpc2.id))
# 4) Enable Site-to-Site VPN for VPC # 4) Enable Site-to-Site VPN for VPC
@ -758,10 +763,10 @@ class TestVpcSite2SiteVpn(cloudstackTestCase):
@classmethod @classmethod
def tearDownClass(cls): def tearDownClass(cls):
try: super(TestVpcSite2SiteVpn, cls).tearDownClass()
cleanup_resources(cls.apiclient, cls.cleanup)
except Exception, e: def tearDown(self):
raise Exception("Cleanup failed with %s" % e) super(TestVpcSite2SiteVpn, self).tearDown()
class TestRVPCSite2SiteVpn(cloudstackTestCase): class TestRVPCSite2SiteVpn(cloudstackTestCase):
@ -779,14 +784,17 @@ class TestRVPCSite2SiteVpn(cloudstackTestCase):
cls.zone = get_zone(cls.apiclient, testClient.getZoneForTests()) cls.zone = get_zone(cls.apiclient, testClient.getZoneForTests())
cls.domain = get_domain(cls.apiclient) cls.domain = get_domain(cls.apiclient)
cls._cleanup = []
cls.compute_offering = ServiceOffering.create( cls.compute_offering = ServiceOffering.create(
cls.apiclient, cls.apiclient,
cls.services["compute_offering"] cls.services["compute_offering"]
) )
cls._cleanup.append(cls.compute_offering)
cls.account = Account.create( cls.account = Account.create(
cls.apiclient, services=cls.services["account"]) cls.apiclient, services=cls.services["account"])
cls._cleanup.append(cls.account)
cls.hypervisor = testClient.getHypervisorInfo() cls.hypervisor = testClient.getHypervisorInfo()
@ -797,8 +805,6 @@ class TestRVPCSite2SiteVpn(cloudstackTestCase):
cls.logger.debug("Successfully created account: %s, id: \ cls.logger.debug("Successfully created account: %s, id: \
%s" % (cls.account.name, %s" % (cls.account.name,
cls.account.id)) cls.account.id))
cls.cleanup = [cls.account, cls.compute_offering]
return return
def _validate_vpc_offering(self, vpc_offering): def _validate_vpc_offering(self, vpc_offering):
@ -901,7 +907,6 @@ class TestRVPCSite2SiteVpn(cloudstackTestCase):
'redundant_vpc_offering') 'redundant_vpc_offering')
self.assert_(redundant_vpc_offering is not None, self.assert_(redundant_vpc_offering is not None,
"Failed to create redundant VPC Offering") "Failed to create redundant VPC Offering")
redundant_vpc_offering.update(self.apiclient, state='Enabled') redundant_vpc_offering.update(self.apiclient, state='Enabled')
# Create VPC 1 # Create VPC 1
@ -920,7 +925,7 @@ class TestRVPCSite2SiteVpn(cloudstackTestCase):
self.fail(e) self.fail(e)
finally: finally:
self.assert_(vpc1 is not None, "VPC1 creation failed") self.assert_(vpc1 is not None, "VPC1 creation failed")
self.cleanup.append(vpc1)
self.logger.debug("VPC1 %s created" % vpc1.id) self.logger.debug("VPC1 %s created" % vpc1.id)
# Create VPC 2 # Create VPC 2
@ -939,7 +944,7 @@ class TestRVPCSite2SiteVpn(cloudstackTestCase):
self.fail(e) self.fail(e)
finally: finally:
self.assert_(vpc2 is not None, "VPC2 creation failed") self.assert_(vpc2 is not None, "VPC2 creation failed")
self.cleanup.append(vpc2)
self.logger.debug("VPC2 %s created" % vpc2.id) self.logger.debug("VPC2 %s created" % vpc2.id)
default_acl = NetworkACLList.list( default_acl = NetworkACLList.list(
@ -962,7 +967,7 @@ class TestRVPCSite2SiteVpn(cloudstackTestCase):
self.fail(e) self.fail(e)
finally: finally:
self.assertIsNotNone(ntwk1, "Network failed to create") self.assertIsNotNone(ntwk1, "Network failed to create")
self.cleanup.append(ntwk1)
self.logger.debug("Network %s created in VPC %s" % (ntwk1.id, vpc1.id)) self.logger.debug("Network %s created in VPC %s" % (ntwk1.id, vpc1.id))
# Create network in VPC 2 # Create network in VPC 2
@ -982,7 +987,7 @@ class TestRVPCSite2SiteVpn(cloudstackTestCase):
self.fail(e) self.fail(e)
finally: finally:
self.assertIsNotNone(ntwk2, "Network failed to create") self.assertIsNotNone(ntwk2, "Network failed to create")
self.cleanup.append(ntwk2)
self.logger.debug("Network %s created in VPC %s" % (ntwk2.id, vpc2.id)) self.logger.debug("Network %s created in VPC %s" % (ntwk2.id, vpc2.id))
# Deploy a vm in network 2 # Deploy a vm in network 2
@ -1002,7 +1007,7 @@ class TestRVPCSite2SiteVpn(cloudstackTestCase):
finally: finally:
self.assert_(vm1 is not None, "VM failed to deploy") self.assert_(vm1 is not None, "VM failed to deploy")
self.assert_(vm1.state == 'Running', "VM is not running") self.assert_(vm1.state == 'Running', "VM is not running")
self.cleanup.append(vm1)
self.logger.debug("VM %s deployed in VPC %s" % (vm1.id, vpc1.id)) self.logger.debug("VM %s deployed in VPC %s" % (vm1.id, vpc1.id))
# Deploy a vm in network 2 # Deploy a vm in network 2
@ -1022,7 +1027,7 @@ class TestRVPCSite2SiteVpn(cloudstackTestCase):
finally: finally:
self.assert_(vm2 is not None, "VM failed to deploy") self.assert_(vm2 is not None, "VM failed to deploy")
self.assert_(vm2.state == 'Running', "VM is not running") self.assert_(vm2.state == 'Running', "VM is not running")
self.cleanup.append(vm2)
self.debug("VM %s deployed in VPC %s" % (vm2.id, vpc2.id)) self.debug("VM %s deployed in VPC %s" % (vm2.id, vpc2.id))
# 4) Enable Site-to-Site VPN for VPC # 4) Enable Site-to-Site VPN for VPC
@ -1130,11 +1135,15 @@ class TestRVPCSite2SiteVpn(cloudstackTestCase):
@classmethod @classmethod
def tearDownClass(cls): def tearDownClass(cls):
try: super(TestRVPCSite2SiteVpn, cls).tearDownClass()
cleanup_resources(cls.apiclient, cls.cleanup)
except Exception, e:
raise Exception("Cleanup failed with %s" % e)
def setUp(self):
self.apiclient = self.testClient.getApiClient()
self.hypervisor = self.testClient.getHypervisorInfo()
self.cleanup = []
def tearDown(self):
super(TestRVPCSite2SiteVpn, self).tearDown()
class TestVPCSite2SiteVPNMultipleOptions(cloudstackTestCase): class TestVPCSite2SiteVPNMultipleOptions(cloudstackTestCase):
@ -1152,13 +1161,17 @@ class TestVPCSite2SiteVPNMultipleOptions(cloudstackTestCase):
cls.zone = get_zone(cls.apiclient, testClient.getZoneForTests()) cls.zone = get_zone(cls.apiclient, testClient.getZoneForTests())
cls.domain = get_domain(cls.apiclient) cls.domain = get_domain(cls.apiclient)
cls._cleanup = []
cls.compute_offering = ServiceOffering.create( cls.compute_offering = ServiceOffering.create(
cls.apiclient, cls.apiclient,
cls.services["compute_offering"] cls.services["compute_offering"]
) )
cls._cleanup.append(cls.compute_offering)
cls.account = Account.create( cls.account = Account.create(
cls.apiclient, services=cls.services["account"]) cls.apiclient, services=cls.services["account"])
cls._cleanup.append(cls.account)
cls.hypervisor = testClient.getHypervisorInfo() cls.hypervisor = testClient.getHypervisorInfo()
@ -1169,10 +1182,13 @@ class TestVPCSite2SiteVPNMultipleOptions(cloudstackTestCase):
cls.logger.debug("Successfully created account: %s, id: \ cls.logger.debug("Successfully created account: %s, id: \
%s" % (cls.account.name, %s" % (cls.account.name,
cls.account.id)) cls.account.id))
cls.cleanup = [cls.account, cls.compute_offering]
return return
def setUp(self):
self.apiclient = self.testClient.getApiClient()
self.hypervisor = self.testClient.getHypervisorInfo()
self.cleanup = []
def _get_ssh_client(self, virtual_machine, services, retries): def _get_ssh_client(self, virtual_machine, services, retries):
""" Setup ssh client connection and return connection """ Setup ssh client connection and return connection
vm requires attributes public_ip, public_port, username, password """ vm requires attributes public_ip, public_port, username, password """
@ -1288,7 +1304,7 @@ class TestVPCSite2SiteVPNMultipleOptions(cloudstackTestCase):
self.fail(e) self.fail(e)
finally: finally:
self.assert_(vpc1 is not None, "VPC1 creation failed") self.assert_(vpc1 is not None, "VPC1 creation failed")
self.cleanup.append(vpc1)
self.logger.debug("VPC1 %s created" % vpc1.id) self.logger.debug("VPC1 %s created" % vpc1.id)
vpc2 = None vpc2 = None
@ -1307,7 +1323,7 @@ class TestVPCSite2SiteVPNMultipleOptions(cloudstackTestCase):
self.fail(e) self.fail(e)
finally: finally:
self.assert_(vpc2 is not None, "VPC2 creation failed") self.assert_(vpc2 is not None, "VPC2 creation failed")
self.cleanup.append(vpc2)
self.logger.debug("VPC2 %s created" % vpc2.id) self.logger.debug("VPC2 %s created" % vpc2.id)
default_acl = NetworkACLList.list( default_acl = NetworkACLList.list(
@ -1330,7 +1346,7 @@ class TestVPCSite2SiteVPNMultipleOptions(cloudstackTestCase):
self.fail(e) self.fail(e)
finally: finally:
self.assertIsNotNone(ntwk1, "Network failed to create") self.assertIsNotNone(ntwk1, "Network failed to create")
self.cleanup.append(ntwk1)
self.logger.debug("Network %s created in VPC %s" % (ntwk1.id, vpc1.id)) self.logger.debug("Network %s created in VPC %s" % (ntwk1.id, vpc1.id))
ntwk2 = None ntwk2 = None
@ -1350,7 +1366,7 @@ class TestVPCSite2SiteVPNMultipleOptions(cloudstackTestCase):
self.fail(e) self.fail(e)
finally: finally:
self.assertIsNotNone(ntwk2, "Network failed to create") self.assertIsNotNone(ntwk2, "Network failed to create")
self.cleanup.append(ntwk2)
self.logger.debug("Network %s created in VPC %s" % (ntwk2.id, vpc2.id)) self.logger.debug("Network %s created in VPC %s" % (ntwk2.id, vpc2.id))
vm1 = None vm1 = None
@ -1370,7 +1386,7 @@ class TestVPCSite2SiteVPNMultipleOptions(cloudstackTestCase):
finally: finally:
self.assert_(vm1 is not None, "VM failed to deploy") self.assert_(vm1 is not None, "VM failed to deploy")
self.assert_(vm1.state == 'Running', "VM is not running") self.assert_(vm1.state == 'Running', "VM is not running")
self.cleanup.append(vm1)
self.logger.debug("VM %s deployed in VPC %s" % (vm1.id, vpc1.id)) self.logger.debug("VM %s deployed in VPC %s" % (vm1.id, vpc1.id))
vm2 = None vm2 = None
@ -1390,7 +1406,7 @@ class TestVPCSite2SiteVPNMultipleOptions(cloudstackTestCase):
finally: finally:
self.assert_(vm2 is not None, "VM failed to deploy") self.assert_(vm2 is not None, "VM failed to deploy")
self.assert_(vm2.state == 'Running', "VM is not running") self.assert_(vm2.state == 'Running', "VM is not running")
self.cleanup.append(vm2)
self.debug("VM %s deployed in VPC %s" % (vm2.id, vpc2.id)) self.debug("VM %s deployed in VPC %s" % (vm2.id, vpc2.id))
# default config # default config
@ -1567,10 +1583,6 @@ class TestVPCSite2SiteVPNMultipleOptions(cloudstackTestCase):
out['esplifetime'] = c['esp_life'] out['esplifetime'] = c['esp_life']
return out return out
@classmethod @classmethod
def tearDownClass(cls): def tearDownClass(cls):
try: super(TestVPCSite2SiteVPNMultipleOptions, cls).tearDownClass()
cleanup_resources(cls.apiclient, cls.cleanup)
except Exception, e:
raise Exception("Cleanup failed with %s" % e)

View File

@ -324,7 +324,7 @@ class TestStorageMigration(cloudstackTestCase):
@classmethod @classmethod
def tearDownClass(cls): def tearDownClass(cls):
try: try:
cleanup_resources(cls.apiclient, cls._cleanup) cleanup_resources(cls.apiclient, reversed(cls._cleanup))
except Exception as e: except Exception as e:
raise Exception("Warning: Exception during cleanup : %s" % e) raise Exception("Warning: Exception during cleanup : %s" % e)
@ -335,13 +335,9 @@ class TestStorageMigration(cloudstackTestCase):
self.cleanup = [] self.cleanup = []
def tearDown(self): def tearDown(self):
try: for storagePool in self.pools:
for storagePool in self.pools: StoragePool.update(self.apiclient, id=storagePool.id, tags="")
StoragePool.update(self.apiclient, id=storagePool.id, tags="") super(TestStorageMigration,self).tearDown()
cleanup_resources(self.apiclient, self.cleanup)
except Exception as e:
raise Exception("Warning: Exception during cleanup : %s" % e)
return
@attr(tags=["advanced", "basic"], required_hardware="true") @attr(tags=["advanced", "basic"], required_hardware="true")
def test_01_migrate_root_and_data_disk_nonlive(self): def test_01_migrate_root_and_data_disk_nonlive(self):

View File

@ -16,7 +16,7 @@
# under the License. # under the License.
import unittest import unittest
from marvin.lib.utils import verifyElementInList from marvin.lib.utils import verifyElementInList, cleanup_resources
from marvin.codes import PASS from marvin.codes import PASS
@ -56,3 +56,22 @@ class cloudstackTestCase(unittest.case.TestCase):
@classmethod @classmethod
def getClsConfig(cls): def getClsConfig(cls):
return cls.config return cls.config
@classmethod
def tearDownClass(cls):
try:
if hasattr(cls,'_cleanup'):
if hasattr(cls,'apiclient'):
cleanup_resources(cls.apiclient, reversed(cls._cleanup))
elif hasattr(cls,'api_client'):
cleanup_resources(cls.api_client, reversed(cls._cleanup))
except Exception as e:
raise Exception("Warning: Exception during cleanup : %s" % e)
def tearDown(self):
try:
if hasattr(self,'apiclient') and hasattr(self,'cleanup'):
cleanup_resources(self.apiclient, reversed(self.cleanup))
except Exception as e:
raise Exception("Warning: Exception during cleanup : %s" % e)
return