mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
CLOUDSTACK-8935 - Clean up network resources in the right order
This commit is contained in:
parent
3eb6ba0699
commit
3ead9d7229
@ -29,6 +29,7 @@ from marvin.lib.common import *
|
||||
from marvin.sshClient import SshClient
|
||||
import datetime
|
||||
|
||||
import logging
|
||||
|
||||
class Services:
|
||||
"""Test inter VLAN services
|
||||
@ -163,6 +164,12 @@ class TestVPCOffering(cloudstackTestCase):
|
||||
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
|
||||
cls.logger = logging.getLogger('TestVPCOffering')
|
||||
cls.stream_handler = logging.StreamHandler()
|
||||
cls.logger.setLevel(logging.DEBUG)
|
||||
cls.logger.addHandler(cls.stream_handler)
|
||||
|
||||
cls.testClient = super(TestVPCOffering, cls).getClsTestClient()
|
||||
cls.api_client = cls.testClient.getApiClient()
|
||||
|
||||
@ -197,7 +204,7 @@ class TestVPCOffering(cloudstackTestCase):
|
||||
return
|
||||
|
||||
def setUp(self):
|
||||
self.debug("test_vpc_offering#setUp")
|
||||
self.logger.debug("test_vpc_offering#setUp")
|
||||
self.apiclient = self.testClient.getApiClient()
|
||||
self.dbclient = self.testClient.getDbConnection()
|
||||
self.account = Account.create(
|
||||
@ -211,7 +218,7 @@ class TestVPCOffering(cloudstackTestCase):
|
||||
return
|
||||
|
||||
def tearDown(self):
|
||||
self.debug("test_vpc_offering#tearDown")
|
||||
self.logger.debug("test_vpc_offering#tearDown")
|
||||
try:
|
||||
cleanup_resources(self.apiclient, self.cleanup)
|
||||
except Exception as e:
|
||||
@ -221,7 +228,7 @@ class TestVPCOffering(cloudstackTestCase):
|
||||
def validate_vpc_offering(self, vpc_offering):
|
||||
"""Validates the VPC offering"""
|
||||
|
||||
self.debug("Check if the VPC offering is created successfully?")
|
||||
self.logger.debug("Check if the VPC offering is created successfully?")
|
||||
vpc_offs = VpcOffering.list(
|
||||
self.apiclient,
|
||||
id=vpc_offering.id
|
||||
@ -236,7 +243,7 @@ class TestVPCOffering(cloudstackTestCase):
|
||||
vpc_offs[0].name,
|
||||
"Name of the VPC offering should match with listVPCOff data"
|
||||
)
|
||||
self.debug(
|
||||
self.logger.debug(
|
||||
"VPC offering is created successfully - %s" %
|
||||
vpc_offering.name)
|
||||
return
|
||||
@ -244,7 +251,7 @@ class TestVPCOffering(cloudstackTestCase):
|
||||
def validate_vpc_network(self, network):
|
||||
"""Validates the VPC network"""
|
||||
|
||||
self.debug("Check if the VPC network is created successfully?")
|
||||
self.logger.debug("Check if the VPC network is created successfully?")
|
||||
vpc_networks = VPC.list(
|
||||
self.apiclient,
|
||||
id=network.id
|
||||
@ -259,7 +266,7 @@ class TestVPCOffering(cloudstackTestCase):
|
||||
vpc_networks[0].name,
|
||||
"Name of the VPC network should match with listVPC data"
|
||||
)
|
||||
self.debug("VPC network created successfully - %s" % network.name)
|
||||
self.logger.debug("VPC network created successfully - %s" % network.name)
|
||||
return
|
||||
|
||||
@attr(tags=["advanced", "intervlan"], required_hardware="false")
|
||||
@ -271,13 +278,13 @@ class TestVPCOffering(cloudstackTestCase):
|
||||
# 1. Create VPC Offering by specifying all supported Services
|
||||
# 2. VPC offering should be created successfully.
|
||||
|
||||
self.debug("Creating inter VPC offering")
|
||||
self.logger.debug("Creating inter VPC offering")
|
||||
vpc_off = VpcOffering.create(
|
||||
self.apiclient,
|
||||
self.services["vpc_offering"]
|
||||
)
|
||||
|
||||
self.debug("Check if the VPC offering is created successfully?")
|
||||
self.logger.debug("Check if the VPC offering is created successfully?")
|
||||
self.cleanup.append(vpc_off)
|
||||
self.validate_vpc_offering(vpc_off)
|
||||
return
|
||||
@ -299,7 +306,7 @@ class TestVPCOffering(cloudstackTestCase):
|
||||
# 9. Create Egress Network ACL for this network to access google.com.
|
||||
# 10. Enable VPN services
|
||||
|
||||
self.debug("Creating a VPC offering..")
|
||||
self.logger.debug("Creating a VPC offering..")
|
||||
vpc_off = VpcOffering.create(
|
||||
self.apiclient,
|
||||
self.services["vpc_offering"]
|
||||
@ -307,10 +314,10 @@ class TestVPCOffering(cloudstackTestCase):
|
||||
|
||||
self.validate_vpc_offering(vpc_off)
|
||||
|
||||
self.debug("Enabling the VPC offering created")
|
||||
self.logger.debug("Enabling the VPC offering created")
|
||||
vpc_off.update(self.apiclient, state='Enabled')
|
||||
|
||||
self.debug("creating a VPC network in the account: %s" %
|
||||
self.logger.debug("creating a VPC network in the account: %s" %
|
||||
self.account.name)
|
||||
vpc = VPC.create(
|
||||
self.apiclient,
|
||||
@ -336,7 +343,7 @@ class TestVPCOffering(cloudstackTestCase):
|
||||
# Gateway = 10.0.0.1
|
||||
|
||||
# Creating network using the network offering created
|
||||
self.debug("Creating network with network offering: %s" %
|
||||
self.logger.debug("Creating network with network offering: %s" %
|
||||
self.network_offering.id)
|
||||
network = Network.create(
|
||||
self.apiclient,
|
||||
@ -348,7 +355,7 @@ class TestVPCOffering(cloudstackTestCase):
|
||||
gateway=gateway,
|
||||
vpcid=vpc.id
|
||||
)
|
||||
self.debug("Created network with ID: %s" % network.id)
|
||||
self.logger.debug("Created network with ID: %s" % network.id)
|
||||
# Spawn an instance in that network
|
||||
virtual_machine = VirtualMachine.create(
|
||||
self.apiclient,
|
||||
@ -358,9 +365,9 @@ class TestVPCOffering(cloudstackTestCase):
|
||||
serviceofferingid=self.service_offering.id,
|
||||
networkids=[str(network.id)]
|
||||
)
|
||||
self.debug("Deployed VM in network: %s" % network.id)
|
||||
self.logger.debug("Deployed VM in network: %s" % network.id)
|
||||
|
||||
self.debug("Associating public IP for network: %s" % network.name)
|
||||
self.logger.debug("Associating public IP for network: %s" % network.name)
|
||||
public_ip = PublicIPAddress.create(
|
||||
self.apiclient,
|
||||
accountid=self.account.name,
|
||||
@ -369,12 +376,12 @@ class TestVPCOffering(cloudstackTestCase):
|
||||
networkid=network.id,
|
||||
vpcid=vpc.id
|
||||
)
|
||||
self.debug("Associated %s with network %s" % (
|
||||
self.logger.debug("Associated %s with network %s" % (
|
||||
public_ip.ipaddress.ipaddress,
|
||||
network.id
|
||||
))
|
||||
|
||||
self.debug("Creating LB rule for IP address: %s" %
|
||||
self.logger.debug("Creating LB rule for IP address: %s" %
|
||||
public_ip.ipaddress.ipaddress)
|
||||
|
||||
lb_rule = LoadBalancerRule.create(
|
||||
@ -387,7 +394,7 @@ class TestVPCOffering(cloudstackTestCase):
|
||||
domainid=self.account.domainid
|
||||
)
|
||||
|
||||
self.debug("Associating public IP for network: %s" % vpc.name)
|
||||
self.logger.debug("Associating public IP for network: %s" % vpc.name)
|
||||
public_ip_2 = PublicIPAddress.create(
|
||||
self.apiclient,
|
||||
accountid=self.account.name,
|
||||
@ -396,7 +403,7 @@ class TestVPCOffering(cloudstackTestCase):
|
||||
networkid=network.id,
|
||||
vpcid=vpc.id
|
||||
)
|
||||
self.debug("Associated %s with network %s" % (
|
||||
self.logger.debug("Associated %s with network %s" % (
|
||||
public_ip_2.ipaddress.ipaddress,
|
||||
network.id
|
||||
))
|
||||
@ -411,7 +418,7 @@ class TestVPCOffering(cloudstackTestCase):
|
||||
vpcid=vpc.id
|
||||
)
|
||||
|
||||
self.debug("Adding NetwrokACl rules to make PF and LB accessible")
|
||||
self.logger.debug("Adding NetwrokACl rules to make PF and LB accessible")
|
||||
networkacl_1 = NetworkACL.create(
|
||||
self.apiclient,
|
||||
networkid=network.id,
|
||||
@ -425,17 +432,17 @@ class TestVPCOffering(cloudstackTestCase):
|
||||
services=self.services["lbrule"],
|
||||
traffictype='Ingress'
|
||||
)
|
||||
self.debug("Checking if we can SSH into VM?")
|
||||
self.logger.debug("Checking if we can SSH into VM?")
|
||||
try:
|
||||
virtual_machine.get_ssh_client(
|
||||
ipaddress=public_ip_2.ipaddress.ipaddress,
|
||||
)
|
||||
self.debug("SSH into VM is successfully")
|
||||
self.logger.debug("SSH into VM is successfully")
|
||||
except Exception as e:
|
||||
self.fail("Failed to SSH into VM - %s, %s" %
|
||||
(public_ip_2.ipaddress.ipaddress, e))
|
||||
|
||||
self.debug("Associating public IP for network: %s" % network.name)
|
||||
self.logger.debug("Associating public IP for network: %s" % network.name)
|
||||
public_ip_3 = PublicIPAddress.create(
|
||||
self.apiclient,
|
||||
accountid=self.account.name,
|
||||
@ -444,11 +451,11 @@ class TestVPCOffering(cloudstackTestCase):
|
||||
networkid=network.id,
|
||||
vpcid=vpc.id
|
||||
)
|
||||
self.debug("Associated %s with network %s" % (
|
||||
self.logger.debug("Associated %s with network %s" % (
|
||||
public_ip_3.ipaddress.ipaddress,
|
||||
network.id
|
||||
))
|
||||
self.debug("Enabling static NAT for IP: %s" %
|
||||
self.logger.debug("Enabling static NAT for IP: %s" %
|
||||
public_ip_3.ipaddress.ipaddress)
|
||||
try:
|
||||
StaticNATRule.enable(
|
||||
@ -457,7 +464,7 @@ class TestVPCOffering(cloudstackTestCase):
|
||||
virtualmachineid=virtual_machine.id,
|
||||
networkid=network.id
|
||||
)
|
||||
self.debug("Static NAT enabled for IP: %s" %
|
||||
self.logger.debug("Static NAT enabled for IP: %s" %
|
||||
public_ip_3.ipaddress.ipaddress)
|
||||
except Exception as e:
|
||||
self.fail("Failed to enable static NAT on IP: %s - %s" % (
|
||||
@ -496,7 +503,7 @@ class TestVPCOffering(cloudstackTestCase):
|
||||
# 4. Deploy few Vms.
|
||||
# 5. Try to create a LB rule for this VM. LB creation should fail
|
||||
|
||||
self.debug(
|
||||
self.logger.debug(
|
||||
"Creating a VPC offering with Vpn,dhcpdns,UserData," +
|
||||
" SourceNat,Static NAT and PF services"
|
||||
)
|
||||
@ -521,20 +528,21 @@ class TestVPCOffering(cloudstackTestCase):
|
||||
)
|
||||
# Enable Network offering
|
||||
self.network_offering.update(self.apiclient, state='Enabled')
|
||||
self.cleanup.append(self.network_offering)
|
||||
self.cleanup.insert(0, self.network_offering)
|
||||
|
||||
vpc_off = VpcOffering.create(
|
||||
self.apiclient,
|
||||
self.services["vpc_offering"]
|
||||
)
|
||||
|
||||
self.cleanup.append(vpc_off)
|
||||
self.validate_vpc_offering(vpc_off)
|
||||
|
||||
self.debug("Enabling the VPC offering created")
|
||||
self.logger.debug("Enabling the VPC offering created")
|
||||
vpc_off.update(self.apiclient, state='Enabled')
|
||||
|
||||
self.cleanup.insert(0, vpc_off)
|
||||
|
||||
self.debug("creating a VPC network in the account: %s" %
|
||||
self.logger.debug("creating a VPC network in the account: %s" %
|
||||
self.account.name)
|
||||
vpc = VPC.create(
|
||||
self.apiclient,
|
||||
@ -545,6 +553,7 @@ class TestVPCOffering(cloudstackTestCase):
|
||||
domainid=self.account.domainid
|
||||
)
|
||||
self.validate_vpc_network(vpc)
|
||||
self.cleanup.insert(0, vpc)
|
||||
|
||||
gateway = vpc.cidr.split('/')[0]
|
||||
# Split the cidr to retrieve gateway
|
||||
@ -552,7 +561,7 @@ class TestVPCOffering(cloudstackTestCase):
|
||||
# Gateway = 10.0.0.1
|
||||
|
||||
# Creating network using the network offering created
|
||||
self.debug("Creating network with network offering: %s" %
|
||||
self.logger.debug("Creating network with network offering: %s" %
|
||||
self.network_offering.id)
|
||||
network = Network.create(
|
||||
self.apiclient,
|
||||
@ -564,9 +573,10 @@ class TestVPCOffering(cloudstackTestCase):
|
||||
gateway=gateway,
|
||||
vpcid=vpc.id
|
||||
)
|
||||
self.debug("Created network with ID: %s" % network.id)
|
||||
self.logger.debug("Created network with ID: %s" % network.id)
|
||||
self.cleanup.insert(0, network)
|
||||
|
||||
self.debug("Deploying virtual machines in network: %s" % vpc.name)
|
||||
self.logger.debug("Deploying virtual machines in network: %s" % vpc.name)
|
||||
# Spawn an instance in that network
|
||||
virtual_machine = VirtualMachine.create(
|
||||
self.apiclient,
|
||||
@ -576,9 +586,10 @@ class TestVPCOffering(cloudstackTestCase):
|
||||
serviceofferingid=self.service_offering.id,
|
||||
networkids=[str(network.id)]
|
||||
)
|
||||
self.debug("Deployed VM in network: %s" % network.id)
|
||||
self.logger.debug("Deployed VM in network: %s" % network.id)
|
||||
self.cleanup.insert(0, virtual_machine)
|
||||
|
||||
self.debug("Associating public IP for network: %s" % network.name)
|
||||
self.logger.debug("Associating public IP for network: %s" % network.name)
|
||||
public_ip = PublicIPAddress.create(
|
||||
self.apiclient,
|
||||
accountid=self.account.name,
|
||||
@ -587,12 +598,12 @@ class TestVPCOffering(cloudstackTestCase):
|
||||
networkid=network.id,
|
||||
vpcid=vpc.id
|
||||
)
|
||||
self.debug("Associated %s with network %s" % (
|
||||
self.logger.debug("Associated %s with network %s" % (
|
||||
public_ip.ipaddress.ipaddress,
|
||||
vpc.id
|
||||
))
|
||||
|
||||
self.debug("Trying to LB rule for IP address: %s" %
|
||||
self.logger.debug("Trying to LB rule for IP address: %s" %
|
||||
public_ip.ipaddress.ipaddress)
|
||||
with self.assertRaises(Exception):
|
||||
LoadBalancerRule.create(
|
||||
@ -617,7 +628,7 @@ class TestVPCOffering(cloudstackTestCase):
|
||||
# 4. Deploy few Vms
|
||||
# 5. Try to create NAT rule for this VMStatic NAT creation should fail
|
||||
|
||||
self.debug("Creating a VPC offering with Vpn,dhcpdns,UserData," +
|
||||
self.logger.debug("Creating a VPC offering with Vpn,dhcpdns,UserData," +
|
||||
"SourceNat,lb and PF services")
|
||||
|
||||
self.services["vpc_offering"]["supportedservices"] = 'Vpn,Dhcp,Dns,SourceNat,Lb,UserData,PortForwarding,NetworkACL'
|
||||
@ -640,20 +651,20 @@ class TestVPCOffering(cloudstackTestCase):
|
||||
)
|
||||
# Enable Network offering
|
||||
self.network_offering.update(self.apiclient, state='Enabled')
|
||||
self.cleanup.append(self.network_offering)
|
||||
self.cleanup.insert(0, self.network_offering)
|
||||
|
||||
vpc_off = VpcOffering.create(
|
||||
self.apiclient,
|
||||
self.services["vpc_offering"]
|
||||
)
|
||||
|
||||
self.cleanup.append(vpc_off)
|
||||
self.validate_vpc_offering(vpc_off)
|
||||
|
||||
self.debug("Enabling the VPC offering created")
|
||||
self.logger.debug("Enabling the VPC offering created")
|
||||
vpc_off.update(self.apiclient, state='Enabled')
|
||||
self.cleanup.insert(0, vpc_off)
|
||||
|
||||
self.debug("creating a VPC network in the account: %s" %
|
||||
self.logger.debug("creating a VPC network in the account: %s" %
|
||||
self.account.name)
|
||||
vpc = VPC.create(
|
||||
self.apiclient,
|
||||
@ -664,6 +675,7 @@ class TestVPCOffering(cloudstackTestCase):
|
||||
domainid=self.account.domainid
|
||||
)
|
||||
self.validate_vpc_network(vpc)
|
||||
self.cleanup.insert(0, vpc)
|
||||
|
||||
gateway = vpc.cidr.split('/')[0]
|
||||
# Split the cidr to retrieve gateway
|
||||
@ -671,7 +683,7 @@ class TestVPCOffering(cloudstackTestCase):
|
||||
# Gateway = 10.0.0.1
|
||||
|
||||
# Creating network using the network offering created
|
||||
self.debug("Creating network with network offering: %s" %
|
||||
self.logger.debug("Creating network with network offering: %s" %
|
||||
self.network_offering.id)
|
||||
network = Network.create(
|
||||
self.apiclient,
|
||||
@ -683,9 +695,10 @@ class TestVPCOffering(cloudstackTestCase):
|
||||
gateway=gateway,
|
||||
vpcid=vpc.id
|
||||
)
|
||||
self.debug("Created network with ID: %s" % network.id)
|
||||
self.logger.debug("Created network with ID: %s" % network.id)
|
||||
self.cleanup.insert(0, network)
|
||||
|
||||
self.debug("Deploying virtual machines in network: %s" % vpc.name)
|
||||
self.logger.debug("Deploying virtual machines in network: %s" % vpc.name)
|
||||
# Spawn an instance in that network
|
||||
virtual_machine = VirtualMachine.create(
|
||||
self.apiclient,
|
||||
@ -695,9 +708,10 @@ class TestVPCOffering(cloudstackTestCase):
|
||||
serviceofferingid=self.service_offering.id,
|
||||
networkids=[str(network.id)]
|
||||
)
|
||||
self.debug("Deployed VM in network: %s" % network.id)
|
||||
self.logger.debug("Deployed VM in network: %s" % network.id)
|
||||
self.cleanup.insert(0, virtual_machine)
|
||||
|
||||
self.debug("Associating public IP for network: %s" % network.name)
|
||||
self.logger.debug("Associating public IP for network: %s" % network.name)
|
||||
public_ip = PublicIPAddress.create(
|
||||
self.apiclient,
|
||||
accountid=self.account.name,
|
||||
@ -706,7 +720,7 @@ class TestVPCOffering(cloudstackTestCase):
|
||||
networkid=network.id,
|
||||
vpcid=vpc.id
|
||||
)
|
||||
self.debug("Associated %s with network %s" % (
|
||||
self.logger.debug("Associated %s with network %s" % (
|
||||
public_ip.ipaddress.ipaddress,
|
||||
network.id
|
||||
))
|
||||
@ -736,7 +750,7 @@ class TestVPCOffering(cloudstackTestCase):
|
||||
# 4. Deploy few Vms.
|
||||
# 5. Try to create a PF rule for this VM. PF creation should fail
|
||||
|
||||
self.debug(
|
||||
self.logger.debug(
|
||||
"Creating a VPC offering with Vpn,dhcpdns,UserData," +
|
||||
"SourceNat,Static NAT and lb services"
|
||||
)
|
||||
@ -761,20 +775,20 @@ class TestVPCOffering(cloudstackTestCase):
|
||||
)
|
||||
# Enable Network offering
|
||||
self.network_offering.update(self.apiclient, state='Enabled')
|
||||
self.cleanup.append(self.network_offering)
|
||||
self.cleanup.insert(0, self.network_offering)
|
||||
|
||||
vpc_off = VpcOffering.create(
|
||||
self.apiclient,
|
||||
self.services["vpc_offering"]
|
||||
)
|
||||
|
||||
self.cleanup.append(vpc_off)
|
||||
self.validate_vpc_offering(vpc_off)
|
||||
|
||||
self.debug("Enabling the VPC offering created")
|
||||
self.logger.debug("Enabling the VPC offering created")
|
||||
vpc_off.update(self.apiclient, state='Enabled')
|
||||
self.cleanup.insert(0, vpc_off)
|
||||
|
||||
self.debug("creating a VPC network in the account: %s" %
|
||||
self.logger.debug("creating a VPC network in the account: %s" %
|
||||
self.account.name)
|
||||
vpc = VPC.create(
|
||||
self.apiclient,
|
||||
@ -785,6 +799,7 @@ class TestVPCOffering(cloudstackTestCase):
|
||||
domainid=self.account.domainid
|
||||
)
|
||||
self.validate_vpc_network(vpc)
|
||||
self.cleanup.insert(0, vpc)
|
||||
|
||||
gateway = vpc.cidr.split('/')[0]
|
||||
# Split the cidr to retrieve gateway
|
||||
@ -792,7 +807,7 @@ class TestVPCOffering(cloudstackTestCase):
|
||||
# Gateway = 10.0.0.1
|
||||
|
||||
# Creating network using the network offering created
|
||||
self.debug("Creating network with network offering: %s" %
|
||||
self.logger.debug("Creating network with network offering: %s" %
|
||||
self.network_offering.id)
|
||||
network = Network.create(
|
||||
self.apiclient,
|
||||
@ -804,7 +819,9 @@ class TestVPCOffering(cloudstackTestCase):
|
||||
gateway=gateway,
|
||||
vpcid=vpc.id
|
||||
)
|
||||
self.debug("Deploying virtual machines in network: %s" % vpc.name)
|
||||
self.logger.debug("Deploying virtual machines in network: %s" % vpc.name)
|
||||
self.cleanup.insert(0, network)
|
||||
|
||||
# Spawn an instance in that network
|
||||
virtual_machine = VirtualMachine.create(
|
||||
self.apiclient,
|
||||
@ -814,9 +831,10 @@ class TestVPCOffering(cloudstackTestCase):
|
||||
serviceofferingid=self.service_offering.id,
|
||||
networkids=[str(network.id)]
|
||||
)
|
||||
self.debug("Deployed VM in network: %s" % network.id)
|
||||
self.logger.debug("Deployed VM in network: %s" % network.id)
|
||||
self.cleanup.insert(0, virtual_machine)
|
||||
|
||||
self.debug("Associating public IP for network: %s" % network.name)
|
||||
self.logger.debug("Associating public IP for network: %s" % network.name)
|
||||
public_ip = PublicIPAddress.create(
|
||||
self.apiclient,
|
||||
accountid=self.account.name,
|
||||
@ -825,12 +843,12 @@ class TestVPCOffering(cloudstackTestCase):
|
||||
networkid=network.id,
|
||||
vpcid=vpc.id
|
||||
)
|
||||
self.debug("Associated %s with network %s" % (
|
||||
self.logger.debug("Associated %s with network %s" % (
|
||||
public_ip.ipaddress.ipaddress,
|
||||
network.id
|
||||
))
|
||||
|
||||
self.debug("Trying to create NAT rule for the IP: %s" %
|
||||
self.logger.debug("Trying to create NAT rule for the IP: %s" %
|
||||
public_ip.ipaddress.ipaddress)
|
||||
with self.assertRaises(Exception):
|
||||
NATRule.create(
|
||||
@ -850,7 +868,7 @@ class TestVPCOffering(cloudstackTestCase):
|
||||
# 1. Creating VPC Offering with services NOT supported by VPC
|
||||
# like Firewall should not be allowed
|
||||
|
||||
self.debug("Creating a VPC offering with Firewall")
|
||||
self.logger.debug("Creating a VPC offering with Firewall")
|
||||
self.services["vpc_offering"]["supportedservices"] = 'Dhcp,Dns,PortForwarding,Firewall,Vpn,SourceNat,Lb,UserData,StaticNat'
|
||||
|
||||
with self.assertRaises(Exception):
|
||||
@ -859,7 +877,7 @@ class TestVPCOffering(cloudstackTestCase):
|
||||
self.services["vpc_offering"]
|
||||
)
|
||||
|
||||
self.debug("Creating a VPC offering with only sourceNAT service")
|
||||
self.logger.debug("Creating a VPC offering with only sourceNAT service")
|
||||
self.services["vpc_offering"]["supportedservices"] = 'SourceNat'
|
||||
|
||||
try:
|
||||
@ -887,7 +905,7 @@ class TestVPCOffering(cloudstackTestCase):
|
||||
# 5. Change name and displaytext of the VPCOffering. Name and
|
||||
# displaytext chnages should be reflected in listVPCPffering call
|
||||
|
||||
self.debug("Creating a VPC offering..")
|
||||
self.logger.debug("Creating a VPC offering..")
|
||||
vpc_off = VpcOffering.create(
|
||||
self.apiclient,
|
||||
self.services["vpc_offering"]
|
||||
@ -896,10 +914,10 @@ class TestVPCOffering(cloudstackTestCase):
|
||||
self.cleanup.append(vpc_off)
|
||||
self.validate_vpc_offering(vpc_off)
|
||||
|
||||
self.debug("Enabling the VPC offering created")
|
||||
self.logger.debug("Enabling the VPC offering created")
|
||||
vpc_off.update(self.apiclient, state='Disabled')
|
||||
|
||||
self.debug("creating a VPC network in the account: %s" %
|
||||
self.logger.debug("creating a VPC network in the account: %s" %
|
||||
self.account.name)
|
||||
with self.assertRaises(Exception):
|
||||
VPC.create(
|
||||
@ -910,11 +928,11 @@ class TestVPCOffering(cloudstackTestCase):
|
||||
account=self.account.name,
|
||||
domainid=self.account.domainid
|
||||
)
|
||||
self.debug("VPC network creation failed! (Test succeeded)")
|
||||
self.debug("Enabling the VPC offering created")
|
||||
self.logger.debug("VPC network creation failed! (Test succeeded)")
|
||||
self.logger.debug("Enabling the VPC offering created")
|
||||
vpc_off.update(self.apiclient, state='Enabled')
|
||||
|
||||
self.debug("creating a VPC network in the account: %s" %
|
||||
self.logger.debug("creating a VPC network in the account: %s" %
|
||||
self.account.name)
|
||||
vpc = VPC.create(
|
||||
self.apiclient,
|
||||
@ -926,7 +944,7 @@ class TestVPCOffering(cloudstackTestCase):
|
||||
)
|
||||
self.validate_vpc_network(vpc)
|
||||
|
||||
self.debug("Updating name & display text of the vpc offering created")
|
||||
self.logger.debug("Updating name & display text of the vpc offering created")
|
||||
new_name = random_gen()
|
||||
new_displaytext = random_gen()
|
||||
|
||||
@ -939,7 +957,7 @@ class TestVPCOffering(cloudstackTestCase):
|
||||
except Exception as e:
|
||||
self.fail("Failed to update VPC offering- %s" % e)
|
||||
|
||||
self.debug("Cheking if the changes are reflected to listVPC call?")
|
||||
self.logger.debug("Cheking if the changes are reflected to listVPC call?")
|
||||
vpc_offs = vpc_off.list(
|
||||
self.apiclient,
|
||||
id=vpc_off.id,
|
||||
@ -982,7 +1000,7 @@ class TestVPCOffering(cloudstackTestCase):
|
||||
# 8. All VPC offering in "Enabled" state should get listed.
|
||||
# 9. All VPC offering in "Disabled" state should get listed
|
||||
|
||||
self.debug("Creating multiple VPC offerings")
|
||||
self.logger.debug("Creating multiple VPC offerings")
|
||||
self.services["vpc_offering"]["supportedservices"] = 'SourceNat'
|
||||
|
||||
vpc_off_1 = VpcOffering.create(
|
||||
@ -991,7 +1009,7 @@ class TestVPCOffering(cloudstackTestCase):
|
||||
)
|
||||
self.cleanup.append(vpc_off_1)
|
||||
self.validate_vpc_offering(vpc_off_1)
|
||||
self.debug("Disabling the VPC offering created")
|
||||
self.logger.debug("Disabling the VPC offering created")
|
||||
vpc_off_1.update(self.apiclient, state='Disabled')
|
||||
|
||||
vpc_off_2 = VpcOffering.create(
|
||||
@ -1001,7 +1019,7 @@ class TestVPCOffering(cloudstackTestCase):
|
||||
|
||||
self.cleanup.append(vpc_off_2)
|
||||
self.validate_vpc_offering(vpc_off_2)
|
||||
self.debug("Enabling the VPC offering created")
|
||||
self.logger.debug("Enabling the VPC offering created")
|
||||
vpc_off_2.update(self.apiclient, state='Enabled')
|
||||
|
||||
vpc_off_3 = VpcOffering.create(
|
||||
@ -1011,20 +1029,20 @@ class TestVPCOffering(cloudstackTestCase):
|
||||
|
||||
self.cleanup.append(vpc_off_3)
|
||||
self.validate_vpc_offering(vpc_off_3)
|
||||
self.debug("Enabling the VPC offering created")
|
||||
self.logger.debug("Enabling the VPC offering created")
|
||||
vpc_off_3.update(self.apiclient, state='Enabled')
|
||||
|
||||
vpc_off_4 = VpcOffering.create(
|
||||
self.apiclient,
|
||||
self.services["vpc_offering"]
|
||||
)
|
||||
self.debug("Enabling the VPC offering created")
|
||||
self.logger.debug("Enabling the VPC offering created")
|
||||
vpc_off_4.update(self.apiclient, state='Enabled')
|
||||
|
||||
self.debug("Deleting the VPC offering: %s" % vpc_off_4.name)
|
||||
self.logger.debug("Deleting the VPC offering: %s" % vpc_off_4.name)
|
||||
vpc_off_4.delete(self.apiclient)
|
||||
|
||||
self.debug("Cheking if listVPCOff return the deleted VPC off")
|
||||
self.logger.debug("Cheking if listVPCOff return the deleted VPC off")
|
||||
vpc_offs = VpcOffering.list(
|
||||
self.apiclient,
|
||||
id=vpc_off_4.id,
|
||||
@ -1036,10 +1054,10 @@ class TestVPCOffering(cloudstackTestCase):
|
||||
"List VPC offerings should nt return any response for deleted offering"
|
||||
)
|
||||
|
||||
self.debug("Validating the listVPCOfferings repsonse by ids")
|
||||
self.logger.debug("Validating the listVPCOfferings repsonse by ids")
|
||||
self.validate_vpc_offering(vpc_off_3)
|
||||
|
||||
self.debug("ListVPCOfferings by displaytext & verifying the response")
|
||||
self.logger.debug("ListVPCOfferings by displaytext & verifying the response")
|
||||
vpc_offs = VpcOffering.list(
|
||||
self.apiclient,
|
||||
displaytext=vpc_off_3.displaytext,
|
||||
@ -1057,7 +1075,7 @@ class TestVPCOffering(cloudstackTestCase):
|
||||
"ListVPC Off with displaytext should return same VPC off"
|
||||
)
|
||||
|
||||
self.debug("ListVPCOfferings by name and verifying the response")
|
||||
self.logger.debug("ListVPCOfferings by name and verifying the response")
|
||||
vpc_offs = VpcOffering.list(
|
||||
self.apiclient,
|
||||
name=vpc_off_2.name,
|
||||
@ -1075,7 +1093,7 @@ class TestVPCOffering(cloudstackTestCase):
|
||||
"ListVPC Off with name should return same VPC off"
|
||||
)
|
||||
|
||||
self.debug(
|
||||
self.logger.debug(
|
||||
"ListVPCOfferings by supported services & verifying the response")
|
||||
vpc_offs = VpcOffering.list(
|
||||
self.apiclient,
|
||||
@ -1088,14 +1106,14 @@ class TestVPCOffering(cloudstackTestCase):
|
||||
"List VPC offerings shall return a valid response"
|
||||
)
|
||||
for vpc_off in vpc_offs:
|
||||
self.debug(vpc_off)
|
||||
self.logger.debug(vpc_off)
|
||||
self.assertEqual(
|
||||
'SourceNat' in str(vpc_off),
|
||||
True,
|
||||
"ListVPC Off with name should return same VPC off"
|
||||
)
|
||||
|
||||
self.debug("ListVPCOfferings by state & verifying the response")
|
||||
self.logger.debug("ListVPCOfferings by state & verifying the response")
|
||||
vpc_offs = VpcOffering.list(
|
||||
self.apiclient,
|
||||
state='Enabled',
|
||||
@ -1113,7 +1131,7 @@ class TestVPCOffering(cloudstackTestCase):
|
||||
"List VPC offering should return only offerings that are enabled"
|
||||
)
|
||||
|
||||
self.debug("ListVPCOfferings by state & verifying the response")
|
||||
self.logger.debug("ListVPCOfferings by state & verifying the response")
|
||||
vpc_offs = VpcOffering.list(
|
||||
self.apiclient,
|
||||
state='Disabled',
|
||||
@ -1135,21 +1153,21 @@ class TestVPCOffering(cloudstackTestCase):
|
||||
@attr(tags=["advanced", "redundancy"], required_hardware="false")
|
||||
def test_09_create_redundant_vpc_offering(self):
|
||||
|
||||
self.debug("Creating Redundant VPC offering")
|
||||
self.logger.debug("Creating Redundant VPC offering")
|
||||
vpc_off = VpcOffering.create(
|
||||
self.apiclient,
|
||||
self.services["redundant_vpc_offering"]
|
||||
)
|
||||
self.cleanup.append(vpc_off)
|
||||
|
||||
self.debug("Check if the Redundant VPC offering is created successfully?")
|
||||
self.logger.debug("Check if the Redundant VPC offering is created successfully?")
|
||||
self.validate_vpc_offering(vpc_off)
|
||||
|
||||
self.debug("Enabling the created Redundant VPC offering")
|
||||
self.logger.debug("Enabling the created Redundant VPC offering")
|
||||
vpc_off.update(self.apiclient, state='Enabled')
|
||||
|
||||
|
||||
self.debug("Creating a Redundant VPC network in the account: %s" %
|
||||
self.logger.debug("Creating a Redundant VPC network in the account: %s" %
|
||||
self.account.name)
|
||||
vpc = VPC.create(
|
||||
self.apiclient,
|
||||
@ -1159,7 +1177,7 @@ class TestVPCOffering(cloudstackTestCase):
|
||||
account=self.account.name,
|
||||
domainid=self.account.domainid
|
||||
)
|
||||
self.debug("Validating Redundant VPC Nw creation")
|
||||
self.logger.debug("Validating Redundant VPC Nw creation")
|
||||
self.validate_vpc_network(vpc)
|
||||
|
||||
vpcs = VPC.list(
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user