From 7e3f013e99b2572ecbc6a19ac8ff6b8a4253b014 Mon Sep 17 00:00:00 2001 From: Miguel Ferreira Date: Mon, 15 Aug 2016 13:28:38 +0200 Subject: [PATCH] Remove useless try except blocks --- .../test/integration/smoke/test_vpc_vpn.py | 135 ++++++++---------- 1 file changed, 57 insertions(+), 78 deletions(-) diff --git a/cosmic-core/test/integration/smoke/test_vpc_vpn.py b/cosmic-core/test/integration/smoke/test_vpc_vpn.py index 1697977776..39141eeb8e 100644 --- a/cosmic-core/test/integration/smoke/test_vpc_vpn.py +++ b/cosmic-core/test/integration/smoke/test_vpc_vpn.py @@ -497,115 +497,94 @@ def test_01_vpc_remote_access_vpn(self): vpc_offering = VpcOffering.list(self.apiclient, isdefault=True) self.assertTrue(vpc_offering is not None and len(vpc_offering) > 0, "No VPC offerings found") - try: - vpc = VPC.create( - apiclient=self.apiclient, - services=self.services["vpc"], - networkDomain="vpc.vpn", - vpcofferingid=vpc_offering[0].id, - zoneid=self.zone.id, - account=self.account.name, - domainid=self.domain.id - ) - except Exception as e: - self.fail(e) + vpc = VPC.create( + apiclient=self.apiclient, + services=self.services["vpc"], + networkDomain="vpc.vpn", + vpcofferingid=vpc_offering[0].id, + zoneid=self.zone.id, + account=self.account.name, + domainid=self.domain.id + ) self.assertIsNotNone(vpc, "VPC creation failed") self.logger.debug("VPC %s created" % (vpc.id)) self.cleanup.append(vpc) - try: - # 2) Create network in VPC - ntwk = Network.create( - apiclient=self.apiclient, - services=self.services["network_1"], - accountid=self.account.name, - domainid=self.domain.id, - networkofferingid=self.network_offerings[0].id, - zoneid=self.zone.id, - vpcid=vpc.id - ) - except Exception as e: - self.fail(e) + # 2) Create network in VPC + ntwk = Network.create( + apiclient=self.apiclient, + services=self.services["network_1"], + accountid=self.account.name, + domainid=self.domain.id, + networkofferingid=self.network_offerings[0].id, + zoneid=self.zone.id, + vpcid=vpc.id + ) self.assertIsNotNone(ntwk, "Network failed to create") self.logger.debug("Network %s created in VPC %s" % (ntwk.id, vpc.id)) self.cleanup.append(ntwk) - try: - # 3) Deploy a vm - vm = VirtualMachine.create(self.apiclient, services=self.services["virtual_machine"], - templateid=self.template.id, - zoneid=self.zone.id, - accountid=self.account.name, - domainid=self.domain.id, - serviceofferingid=self.compute_offering.id, - networkids=ntwk.id, - hypervisor=self.hypervisor - ) - self.assertIsNotNone(vm, "VM failed to deploy") - self.assertEquals(vm.state, 'Running', "VM is not running") - self.debug("VM %s deployed in VPC %s" % (vm.id, vpc.id)) - except Exception as e: - self.fail(e) + # 3) Deploy a vm + vm = VirtualMachine.create(self.apiclient, services=self.services["virtual_machine"], + templateid=self.template.id, + zoneid=self.zone.id, + accountid=self.account.name, + domainid=self.domain.id, + serviceofferingid=self.compute_offering.id, + networkids=ntwk.id, + hypervisor=self.hypervisor + ) + self.assertIsNotNone(vm, "VM failed to deploy") + self.assertEquals(vm.state, 'Running', "VM is not running") + self.debug("VM %s deployed in VPC %s" % (vm.id, vpc.id)) self.logger.debug("Deployed virtual machine: OK") self.cleanup.append(vm) - try: - # 4) Enable VPN for VPC - src_nat_list = PublicIPAddress.list( - self.apiclient, - account=self.account.name, - domainid=self.account.domainid, - listall=True, - issourcenat=True, - vpcid=vpc.id - ) - ip = src_nat_list[0] - except Exception as e: - self.fail(e) + # 4) Enable VPN for VPC + src_nat_list = PublicIPAddress.list( + self.apiclient, + account=self.account.name, + domainid=self.account.domainid, + listall=True, + issourcenat=True, + vpcid=vpc.id + ) + ip = src_nat_list[0] self.logger.debug("Acquired public ip address: OK") - try: - vpn = Vpn.create(self.apiclient, - publicipid=ip.id, - account=self.account.name, - domainid=self.account.domainid, - iprange=self.services["vpn"]["iprange"], - fordisplay=self.services["vpn"]["fordisplay"] - ) - except Exception as e: - self.fail(e) + vpn = Vpn.create(self.apiclient, + publicipid=ip.id, + account=self.account.name, + domainid=self.account.domainid, + iprange=self.services["vpn"]["iprange"], + fordisplay=self.services["vpn"]["fordisplay"] + ) self.assertIsNotNone(vpn, "Failed to create Remote Access VPN") self.logger.debug("Created Remote Access VPN: OK") vpn_user = None # 5) Add VPN user for VPC - try: - vpn_user = VpnUser.create(self.apiclient, - account=self.account.name, - domainid=self.account.domainid, - username=self.services["vpn"]["vpn_user"], - password=self.services["vpn"]["vpn_pass"] - ) - except Exception as e: - self.fail(e) + vpn_user = VpnUser.create(self.apiclient, + account=self.account.name, + domainid=self.account.domainid, + username=self.services["vpn"]["vpn_user"], + password=self.services["vpn"]["vpn_pass"] + ) self.assertIsNotNone(vpn_user, "Failed to create Remote Access VPN User") self.logger.debug("Created VPN User: OK") # TODO: Add an actual remote vpn connection test from a remote vpc - try: - # 9) Disable VPN for VPC - vpn.delete(self.apiclient) - except Exception as e: - self.fail(e) + # 9) Disable VPN for VPC + vpn.delete(self.apiclient) self.logger.debug("Deleted the Remote Access VPN: OK")