def setUp(self): self.apiclient = self.testClient.getApiClient() self.account = Account.create(self.apiclient, self.services["account"], admin=True, domainid=self.domain.id) self.cleanup = [self.account] self.debug("Creating a VPC offering..") self.vpc_off = VpcOffering.create(self.apiclient, self.services["vpc_offering"]) self.cleanup.append(self.vpc_off) self.debug("Enabling the VPC offering created") self.vpc_off.update(self.apiclient, state='Enabled') self.debug("Creating a VPC network in the account: %s" % self.account.name) self.services["vpc"]["cidr"] = '10.1.1.1/16' self.vpc = VPC.create(self.apiclient, self.services["vpc"], vpcofferingid=self.vpc_off.id, zoneid=self.zone.id, account=self.account.name, domainid=self.account.domainid) self.cleanup.append(self.vpc) return
def setUpClass(cls): cls.testClient = super(TestVPC, cls).getClsTestClient() cls.api_client = cls.testClient.getApiClient() cls.hypervisor = cls.testClient.getHypervisorInfo() cls.mgtSvrDetails = cls.config.__dict__["mgtSvr"][0].__dict__ cls.unsupportedHypervisor = False if cls.hypervisor.lower() == 'hyperv': cls._cleanup = [] cls.unsupportedHypervisor = True return cls.services = Services().services # Get Zone, Domain and templates 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.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.vpc_off = VpcOffering.create( cls.api_client, cls.services["vpc_offering"] ) cls.vpc_off.update(cls.api_client, state='Enabled') cls._cleanup = [ cls.service_offering, ] return
def test_04_vpc_private_gateway_with_invalid_lswitch(self): self.logger.debug('Adding NSX device') self.add_nicira_device(self.nicira_master_controller) self.logger.debug('Creating VPC offering') self.vpc_offering = VpcOffering.create(self.api_client, self.vpc_offering_services) self.vpc_offering.update(self.api_client, state='Enabled') self.test_cleanup.append(self.vpc_offering) self.logger.debug('Creating VPC tier offering') self.vpc_tier_offering = NetworkOffering.create(self.api_client, self.vpc_tier_offering_services, conservemode=False) self.vpc_tier_offering.update(self.api_client, state='Enabled') self.test_cleanup.append(self.vpc_tier_offering) self.logger.debug('Creating private network offering') self.private_network_offering = NetworkOffering.create(self.api_client, self.private_network_offering_services) self.private_network_offering.update(self.api_client, state='Enabled') self.test_cleanup.append(self.private_network_offering) allow_all_acl_id = 'bd6d44f8-fc11-11e5-8fe8-5254001daa61' bad_lswitch = 'lswitch:xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx' vpc = self.create_vpc() network = self.create_vpc_tier(vpc) virtual_machine = self.create_virtual_machine(network) self.logger.debug('Creating private gateway') with self.assertRaises(CloudstackAPIException) as cm: self.create_private_gateway(vpc, "10.0.3.99", "10.0.3.100", allow_all_acl_id, bad_lswitch) the_exception = cm.exception the_message_matcher = "^.*Refusing to design this network because the specified lswitch (%s) does not exist.*$" % bad_lswitch self.assertRegexpMatches(str(the_exception), the_message_matcher)
def setUp(self): self.routers = [] self.networks = [] self.ips = [] self.apiclient = self.testClient.getApiClient() self.hypervisor = self.testClient.getHypervisorInfo() self.account = Account.create( self.apiclient, self.services["account"], admin=True, domainid=self.domain.id) self.logger.debug("Creating a VPC offering..") self.vpc_off = VpcOffering.create( self.apiclient, self.services["vpc_offering"]) self.logger.debug("Enabling the VPC offering created") self.vpc_off.update(self.apiclient, state='Enabled') self.logger.debug("Creating a VPC network in the account: %s" % self.account.name) self.services["vpc"]["cidr"] = '10.1.1.1/16' self.vpc = VPC.create( self.apiclient, self.services["vpc"], vpcofferingid=self.vpc_off.id, zoneid=self.zone.id, account=self.account.name, domainid=self.account.domainid) self.cleanup = [self.vpc, self.vpc_off, self.account] return
def test_02_create_vpc_from_offering_with_regionlevelvpc_service_capability(self): """ Test create VPC offering """ # Steps for validation # 1. Create VPC Offering by specifying all supported Services # 2. VPC offering should be created successfully. if not self.isOvsPluginEnabled: self.skipTest("OVS plugin should be enabled to run this test case") self.debug("Creating inter VPC offering") vpc_off = VpcOffering.create( self.apiclient, self.services["vpc_offering"] ) vpc_off.update(self.apiclient, state='Enabled') vpc = VPC.create( self.apiclient, self.services["vpc"], vpcofferingid=vpc_off.id, zoneid=self.zone.id, account=self.account.name, domainid=self.account.domainid, networkDomain=self.account.domainid ) self.assertEqual(vpc.distributedvpcrouter, True, "VPC created should have 'distributedvpcrouter' set to True") try: vpc.delete(self.apiclient) except Exception as e: self.fail("Failed to delete VPC network - %s" % e) return
def test_02_create_vpc_from_offering_with_distributedrouter_service_capability( self): """ Test create VPC offering """ # Steps for validation # 1. Create VPC Offering by specifying all supported Services # 2. VPC offering should be created successfully. if not self.isOvsPluginEnabled: self.skipTest("OVS plugin should be enabled to run this test case") self.debug("Creating inter VPC offering") vpc_off = VpcOffering.create(self.apiclient, self.services["vpc_offering"]) vpc_off.update(self.apiclient, state='Enabled') vpc = VPC.create(self.apiclient, self.services["vpc"], vpcofferingid=vpc_off.id, zoneid=self.zone.id, account=self.account.name, domainid=self.account.domainid) self.assertEqual( vpc.distributedvpcrouter, True, "VPC created should have 'distributedvpcrouter' set to True") try: vpc.delete(self.apiclient) except Exception as e: self.fail("Failed to delete VPC network - %s" % e) return
def setUpClass(cls): cls.testClient = super(TestIPResourceCountVPC, cls).getClsTestClient() cls.api_client = cls.testClient.getApiClient() cls.services = Services().services # Get Zone, Domain and templates 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.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.vpc_off = VpcOffering.create( cls.api_client, cls.services["vpc_offering"] ) cls.vpc_off.update(cls.api_client, state='Enabled') cls._cleanup = [ cls.service_offering, cls.vpc_off ] return
def setUpClass(cls): testClient = super(TestDomainsVpcOfferings, cls).getClsTestClient() cls.apiclient = testClient.getApiClient() cls.localservices = Services().services cls.services = testClient.getParsedTestDataConfig() # Create domains cls.domain_1 = Domain.create(cls.apiclient, cls.services["acl"]["domain1"]) cls.domain_11 = Domain.create(cls.apiclient, cls.services["acl"]["domain11"], parentdomainid=cls.domain_1.id) cls.domain_2 = Domain.create(cls.apiclient, cls.services["acl"]["domain2"]) cls.domain_3 = Domain.create(cls.apiclient, cls.services["acl"]["domain12"]) cls.zone = get_zone(cls.apiclient, testClient.getZoneForTests()) cls.vpc_offering = VpcOffering.create(cls.apiclient, cls.services["vpc_offering"]) # Enable Vpc offering cls.vpc_offering.update(cls.apiclient, state='Enabled') cls._cleanup = [ cls.vpc_offering, cls.domain_11, cls.domain_1, cls.domain_2, cls.domain_3 ] return
def create_VpcOffering(self, vpc_offering, suffix=None): self.debug('Create VpcOffering') if suffix: vpc_offering["name"] = "VPC_OFF-" + str(suffix) vpc_off = VpcOffering.create(self.api_client, vpc_offering) # Enable VPC offering vpc_off.update(self.api_client, state='Enabled') self.cleanup.append(vpc_off) self.debug('Created and Enabled VpcOffering') return vpc_off
def setUpClass(cls): cls.testClient = super(TestVPCRoutersBasic, cls).getClsTestClient() cls.api_client = cls.testClient.getApiClient() cls.hypervisor = cls.testClient.getHypervisorInfo() cls.vpcSupported = True cls._cleanup = [] if cls.hypervisor.lower() == 'hyperv': cls.vpcSupported = False return cls.services = Services().services # Get Zone, Domain and templates 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.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.vpc_off = VpcOffering.create( cls.api_client, cls.services["vpc_offering"] ) cls.vpc_off.update(cls.api_client, state='Enabled') cls.account = Account.create( cls.api_client, cls.services["account"], admin=True, domainid=cls.domain.id ) cls._cleanup = [cls.account] cls._cleanup.append(cls.vpc_off) #cls.debug("Enabling the VPC offering created") cls.vpc_off.update(cls.api_client, state='Enabled') # cls.debug("creating a VPC network in the account: %s" % # cls.account.name) cls.services["vpc"]["cidr"] = '10.1.1.1/16' cls.vpc = VPC.create( cls.api_client, cls.services["vpc"], vpcofferingid=cls.vpc_off.id, zoneid=cls.zone.id, account=cls.account.name, domainid=cls.account.domainid ) cls._cleanup.append(cls.service_offering) return
def create_VpcOffering(cls, vpc_offering, suffix=None): cls.debug("Creating VPC offering") if suffix: vpc_offering["name"] = "VPC_OFF-" + str(suffix) vpc_off = VpcOffering.create(cls.api_client, vpc_offering ) # Enable VPC offering vpc_off.update(cls.api_client, state="Enabled") cls.debug("Created and Enabled VPC offering") return vpc_off
def _create_vpc_offering(self, offering_name): vpc_off = None if offering_name is not None: self.logger.debug("Creating VPC offering: %s", offering_name) vpc_off = VpcOffering.create(self.apiclient, self.services[offering_name]) self._validate_vpc_offering(vpc_off) return vpc_off
def create_VpcOffering(self, vpc_offering, suffix=None): self.debug("Creating VPC offering") if suffix: vpc_offering["name"] = "VPC_OFF-" + str(suffix) vpc_off = VpcOffering.create(self.api_client, vpc_offering ) # Enable VPC offering vpc_off.update(self.api_client, state="Enabled") self.cleanup.append(vpc_off) self.debug("Created and Enabled VPC offering") return vpc_off
def setUpClass(cls): cls.testClient = super(TestVPCHostMaintenance, cls).getClsTestClient() cls.api_client = cls.testClient.getApiClient() cls._cleanup = [] cls.hosts = [] cls.vpcSupported = True cls.hypervisor = cls.testClient.getHypervisorInfo() if cls.hypervisor.lower() in ['hyperv']: cls.vpcSupported = False return cls.services = cls.testClient.getParsedTestDataConfig() # Get Zone, Domain and templates 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.services["virtual_machine"]["zoneid"] = cls.zone.id cls.services["virtual_machine"]["template"] = cls.template.id cls.services["mode"] = cls.zone.networktype cls.vpc_off = VpcOffering.create(cls.api_client, cls.services["vpc_offering"]) cls._cleanup.append(cls.vpc_off) cls.vpc_off.update(cls.api_client, state='Enabled') cls.hosts = Host.list(cls.api_client, zoneid=cls.zone.id, listall=True, type='Routing') if isinstance(cls.hosts, list): for host in cls.hosts: Host.enableMaintenance(cls.api_client, id=host.id) timeout = cls.services["timeout"] while True: time.sleep(cls.services["sleep"]) hosts_states = Host.list(cls.api_client, id=host.id, listall=True) if hosts_states[ 0].resourcestate == 'PrepareForMaintenance': # Wait for sometimetill host goes in maintenance state time.sleep(cls.services["sleep"]) elif hosts_states[0].resourcestate == 'Maintenance': time.sleep(cls.services["sleep"]) break elif timeout == 0: raise unittest.SkipTest( "Failed to enable maintenance mode on %s" % host.name) timeout = timeout - 1 return
def _create_vpc_offering(self, offering_name): vpc_off = None if offering_name is not None: self.logger.debug("Creating VPC offering: %s", offering_name) vpc_off = VpcOffering.create( self.apiclient, self.services[offering_name] ) self._validate_vpc_offering(vpc_off) return vpc_off
def test_02_internallb_roundrobin_1RVPC_3VM_HTTP_port80(self): """ Test create, assign, remove of an Internal LB with roundrobin http traffic to 3 vm's in a Redundant VPC """ self.logger.debug("Starting test_02_internallb_roundrobin_1RVPC_3VM_HTTP_port80") self.logger.debug("Creating a Redundant VPC offering..") redundant_vpc_offering = VpcOffering.create(self.apiclient, self.services["redundant_vpc_offering"]) self.logger.debug("Enabling the Redundant VPC offering created") redundant_vpc_offering.update(self.apiclient, state="Enabled") self.cleanup.insert(0, redundant_vpc_offering) self.execute_internallb_roundrobin_tests(redundant_vpc_offering)
def test_01_create_vpc_offering_with_distributedrouter_service_capability(self): """ Test create VPC offering """ # Steps for validation # 1. Create VPC Offering by specifying all supported Services # 2. VPC offering should be created successfully. self.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.cleanup.append(vpc_off) self.validate_vpc_offering(vpc_off) return
def setUpClass(cls): try: cls._cleanup = [] cls.testClient = super(TestPortForwardingRules, cls).getClsTestClient() cls.api_client = cls.testClient.getApiClient() cls.services = cls.testClient.getParsedTestDataConfig() cls.hypervisor = cls.testClient.getHypervisorInfo() # Get Domain, Zone, Template 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"] ) if cls.zone.localstorageenabled: cls.storagetype = 'local' cls.services["service_offerings"][ "tiny"]["storagetype"] = 'local' else: cls.storagetype = 'shared' cls.services["service_offerings"][ "tiny"]["storagetype"] = 'shared' cls.services['mode'] = cls.zone.networktype cls.services["virtual_machine"][ "hypervisor"] = cls.hypervisor 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_offerings"]["tiny"] ) cls._cleanup.append(cls.service_offering) cls.services['mode'] = cls.zone.networktype cls.vpc_offering = VpcOffering.create(cls.api_client, cls.services["vpc_offering"] ) cls.vpc_offering.update(cls.api_client, state='Enabled') cls._cleanup.append(cls.vpc_offering) except Exception as e: cls.tearDownClass() raise Exception("Warning: Exception in setup : %s" % e) return
def setUpClass(cls): try: cls._cleanup = [] cls.testClient = super(TestPortForwardingRules, cls).getClsTestClient() cls.api_client = cls.testClient.getApiClient() cls.services = cls.testClient.getParsedTestDataConfig() cls.hypervisor = cls.testClient.getHypervisorInfo() # Get Domain, Zone, Template cls.domain = get_domain(cls.api_client) cls.zone = get_zone( cls.api_client, cls.testClient.getZoneForTests()) cls.template = get_test_template( cls.api_client, cls.zone.id, cls.hypervisor ) if cls.zone.localstorageenabled: cls.storagetype = 'local' cls.services["service_offerings"][ "tiny"]["storagetype"] = 'local' else: cls.storagetype = 'shared' cls.services["service_offerings"][ "tiny"]["storagetype"] = 'shared' cls.services['mode'] = cls.zone.networktype cls.services["virtual_machine"][ "hypervisor"] = cls.hypervisor 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_offerings"]["tiny"] ) cls._cleanup.append(cls.service_offering) cls.services['mode'] = cls.zone.networktype cls.vpc_offering = VpcOffering.create(cls.api_client, cls.services["vpc_offering"] ) cls.vpc_offering.update(cls.api_client, state='Enabled') cls._cleanup.append(cls.vpc_offering) except Exception as e: cls.tearDownClass() raise Exception("Warning: Exception in setup : %s" % e) return
def test_02_internallb_roundrobin_1RVPC_3VM_HTTP_port80(self): """ Test create, assign, remove of an Internal LB with roundrobin http traffic to 3 vm's in a Redundant VPC """ self.logger.debug("Starting test_02_internallb_roundrobin_1RVPC_3VM_HTTP_port80") self.logger.debug("Creating a Redundant VPC offering..") redundant_vpc_offering = VpcOffering.create( self.apiclient, self.services["redundant_vpc_offering"]) self.logger.debug("Enabling the Redundant VPC offering created") redundant_vpc_offering.update(self.apiclient, state='Enabled') self.cleanup.insert(0, redundant_vpc_offering) self.execute_internallb_roundrobin_tests(redundant_vpc_offering)
def test_01_internallb_roundrobin_1VPC_3VM_HTTP_port80(self): """ Test create, assign, remove of an Internal LB with roundrobin http traffic to 3 vm's in a Single VPC """ self.logger.debug( "Starting test_01_internallb_roundrobin_1VPC_3VM_HTTP_port80") self.logger.debug("Creating a VPC offering..") vpc_offering = VpcOffering.create(self.apiclient, self.services["vpc_offering"]) self.cleanup.append(vpc_offering) self.logger.debug("Enabling the VPC offering created") vpc_offering.update(self.apiclient, state='Enabled') self.execute_internallb_roundrobin_tests(vpc_offering)
def test_04_rvpc_internallb_haproxy_stats_on_all_interfaces(self): """ Test to verify access to loadbalancer haproxy admin stats page when global setting network.loadbalancer.haproxy.stats.visibility is set to 'all' with credentials from global setting network.loadbalancer.haproxy.stats.auth using the uri from global setting network.loadbalancer.haproxy.stats.uri. It uses a Redundant Routers VPC """ self.logger.debug("Starting test_04_rvpc_internallb_haproxy_stats_on_all_interfaces") self.logger.debug("Creating a Redundant VPC offering..") redundant_vpc_offering = VpcOffering.create(self.apiclient, self.services["redundant_vpc_offering"]) self.logger.debug("Enabling the Redundant VPC offering created") redundant_vpc_offering.update(self.apiclient, state="Enabled") self.execute_internallb_haproxy_tests(redundant_vpc_offering)
def test_01_create_vpc_offering_with_regionlevelvpc_service_capability( self): """ Test create VPC offering """ # Steps for validation # 1. Create VPC Offering by specifying all supported Services # 2. VPC offering should be created successfully. self.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.cleanup.append(vpc_off) self.validate_vpc_offering(vpc_off) return
def setUpClass(cls): cls.testClient = super(TestVPCRoutersBasic, cls).getClsTestClient() cls.api_client = cls.testClient.getApiClient() cls.hypervisor = cls.testClient.getHypervisorInfo() cls.vpcSupported = True cls._cleanup = [] if cls.hypervisor.lower() == 'hyperv': cls.vpcSupported = False return cls.services = Services().services # Get Zone, Domain and templates 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.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.vpc_off = VpcOffering.create(cls.api_client, cls.services["vpc_offering"]) cls.vpc_off.update(cls.api_client, state='Enabled') cls.account = Account.create(cls.api_client, cls.services["account"], admin=True, domainid=cls.domain.id) cls._cleanup = [cls.account] cls._cleanup.append(cls.vpc_off) #cls.debug("Enabling the VPC offering created") cls.vpc_off.update(cls.api_client, state='Enabled') # cls.debug("creating a VPC network in the account: %s" % # cls.account.name) cls.services["vpc"]["cidr"] = '10.1.1.1/16' cls.vpc = VPC.create(cls.api_client, cls.services["vpc"], vpcofferingid=cls.vpc_off.id, zoneid=cls.zone.id, account=cls.account.name, domainid=cls.account.domainid) cls._cleanup.append(cls.service_offering) return
def test_03_create_ipv6_vpc_offering(self): """Test to create network offering # Validate the following: # 1. createVpcOffering should return valid info for new offering # 2. The Cloud Database contains the valid information """ Configurations.update(self.apiclient, ipv6_offering_config_name, "true") ipv6_service = self.services["vpc_offering"] ipv6_service["internetprotocol"] = "dualstack" vpc_offering = VpcOffering.create( self.apiclient, ipv6_service ) self.cleanup.append(vpc_offering) self.debug("Created VPC offering with ID: %s" % vpc_offering.id) list_vpc_off_response = VpcOffering.list(self.apiclient, id=vpc_offering.id) self.assertEqual( isinstance(list_vpc_off_response, list), True, "Check list response returns a valid list" ) self.assertNotEqual( len(list_vpc_off_response), 0, "Check VPC offering is created" ) vpc_off_response = list_vpc_off_response[0] self.assertEqual( vpc_off_response.id, vpc_offering.id, "Check server id in listVpcOfferings" ) self.assertEqual( vpc_off_response.internetprotocol.lower(), ipv6_service["internetprotocol"].lower(), "Check internetprotocol in listVpcOfferings" ) return
def setUp(self): self.logger.debug("Creating a VPC offering.") self.vpc_off = VpcOffering.create(self.apiclient, self.services["vpc_offering"]) self.logger.debug("Enabling the VPC offering created") self.vpc_off.update(self.apiclient, state="Enabled") self.logger.debug("Creating a VPC network in the account: %s" % self.account.name) self.vpc = VPC.create( self.apiclient, self.services["vpc"], vpcofferingid=self.vpc_off.id, zoneid=self.zone.id, account=self.account.name, domainid=self.account.domainid, ) return
def test_04_rvpc_internallb_haproxy_stats_on_all_interfaces(self): """ Test to verify access to loadbalancer haproxy admin stats page when global setting network.loadbalancer.haproxy.stats.visibility is set to 'all' with credentials from global setting network.loadbalancer.haproxy.stats.auth using the uri from global setting network.loadbalancer.haproxy.stats.uri. It uses a Redundant Routers VPC """ self.logger.debug("Starting test_04_rvpc_internallb_haproxy_stats_on_all_interfaces") self.logger.debug("Creating a Redundant VPC offering..") redundant_vpc_offering = VpcOffering.create( self.apiclient, self.services["redundant_vpc_offering"]) self.logger.debug("Enabling the Redundant VPC offering created") redundant_vpc_offering.update(self.apiclient, state='Enabled') self.execute_internallb_haproxy_tests(redundant_vpc_offering)
def setUp(self): self.logger.debug("Creating a VPC offering.") self.vpc_off = VpcOffering.create( self.apiclient, self.services["vpc_offering"]) self.logger.debug("Enabling the VPC offering created") self.vpc_off.update(self.apiclient, state='Enabled') self.logger.debug("Creating a VPC network in the account: %s" % self.account.name) self.vpc = VPC.create( self.apiclient, self.services["vpc"], vpcofferingid=self.vpc_off.id, zoneid=self.zone.id, account=self.account.name, domainid=self.account.domainid) return
def create_VPC(self, cidr='10.1.2.1/16'): self.debug("Creating a VPC offering..") self.services["vpc_offering"][ "name"] = self.services["vpc_offering"]["name"] + str(cidr) vpc_off = VpcOffering.create(self.apiclient, self.services["vpc_offering"]) self.cleanup.append(vpc_off) self.debug("Enabling the VPC offering created") vpc_off.update(self.apiclient, state='Enabled') self.debug("Creating a VPC network in the account: %s" % self.account.name) self.services["vpc"]["cidr"] = cidr vpc = VPC.create(self.apiclient, self.services["vpc"], vpcofferingid=vpc_off.id, zoneid=self.zone.id, account=self.account.name, domainid=self.account.domainid) self.cleanup.append(vpc) return vpc
def test_04_create_ipv6_vpc_offering_fail(self): """Test to create VPC offering failure # Validate the following: # 1. createVpcOffering should fail """ Configurations.update(self.apiclient, ipv6_offering_config_name, "false") ipv6_service = self.services["vpc_offering"] ipv6_service["internetprotocol"] = "dualstack" try: vpc_offering = VpcOffering.create( self.apiclient, ipv6_service ) self.cleanup.append(vpc_offering) self.fail("VPC offering created despite global setting - %s set to false" % ipv6_offering_config_name) except CloudstackAPIException as e: self.debug("VPC offering creation failed as expected %s " % e) return
def test_04_vpc_private_gateway_with_invalid_lswitch(self): self.logger.debug('Adding NSX device') self.add_nicira_device(self.nicira_master_controller) self.logger.debug('Creating VPC offering') self.vpc_offering = VpcOffering.create(self.api_client, self.vpc_offering_services) self.vpc_offering.update(self.api_client, state='Enabled') self.test_cleanup.append(self.vpc_offering) self.logger.debug('Creating VPC tier offering') self.vpc_tier_offering = NetworkOffering.create( self.api_client, self.vpc_tier_offering_services, conservemode=False) self.vpc_tier_offering.update(self.api_client, state='Enabled') self.test_cleanup.append(self.vpc_tier_offering) self.logger.debug('Creating private network offering') self.private_network_offering = NetworkOffering.create( self.api_client, self.private_network_offering_services) self.private_network_offering.update(self.api_client, state='Enabled') self.test_cleanup.append(self.private_network_offering) allow_all_acl_id = 'bd6d44f8-fc11-11e5-8fe8-5254001daa61' bad_lswitch = 'lswitch:xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx' vpc = self.create_vpc() network = self.create_vpc_tier(vpc) virtual_machine = self.create_virtual_machine(network) self.logger.debug('Creating private gateway') with self.assertRaises(CloudstackAPIException) as cm: self.create_private_gateway(vpc, "10.0.3.99", "10.0.3.100", allow_all_acl_id, bad_lswitch) the_exception = cm.exception the_message_matcher = "^.*Refusing to design this network because the specified lswitch (%s) does not exist.*$" % bad_lswitch self.assertRegexpMatches(str(the_exception), the_message_matcher)
def setUp(self): self.hypervisor = self.testClient.getHypervisorInfo() self.logger.debug("Creating a VPC offering.") self.vpc_off = VpcOffering.create(self.apiclient, self.services["vpc_offering"]) self.logger.debug("Enabling the VPC offering created") self.vpc_off.update(self.apiclient, state="Enabled") self.logger.debug("Creating a VPC network in the account: %s" % self.account.name) self.vpc = VPC.create( self.apiclient, self.services["vpc"], vpcofferingid=self.vpc_off.id, zoneid=self.zone.id, account=self.account.name, domainid=self.account.domainid, ) self.cleanup = [self.vpc, self.vpc_off] self.entity_manager.set_cleanup(self.cleanup) return
def setUp(self): self.hypervisor = self.testClient.getHypervisorInfo() self.logger.debug("Creating a VPC offering.") self.vpc_off = VpcOffering.create(self.apiclient, self.services["vpc_offering"]) self.logger.debug("Enabling the VPC offering created") self.vpc_off.update(self.apiclient, state='Enabled') self.logger.debug("Creating a VPC network in the account: %s" % self.account.name) self.vpc = VPC.create(self.apiclient, self.services["vpc"], vpcofferingid=self.vpc_off.id, zoneid=self.zone.id, account=self.account.name, domainid=self.account.domainid) self.cleanup = [self.vpc, self.vpc_off] self.entity_manager.set_cleanup(self.cleanup) return
def create_vpc(self, cidr='10.1.2.1/16'): self.debug("Creating a VPC offering..") self.services["vpc_offering"]["name"] = self.services["vpc_offering"]["name"] + str(cidr) vpc_off = VpcOffering.create( self.apiclient, self.services["vpc_offering"] ) self._cleanup.append(vpc_off) self.debug("Enabling the VPC offering created") vpc_off.update(self.apiclient, state='Enabled') self.debug("Creating a VPC network in the account: %s" % self.account.name) self.services["vpc"]["cidr"] = cidr vpc = VPC.create( self.apiclient, self.services["vpc"], vpcofferingid=vpc_off.id, zoneid=self.zone.id, account=self.account.name, domainid=self.account.domainid ) return vpc
def setUpClass(cls): """ Create the following domain tree and accounts that are required for executing Nuage VSP SDN plugin test cases for shared networks: Under ROOT - create domain D1 Under domain D1 - Create two subdomains D11 and D12 Under each of the domains - create one admin user and couple of regular users. Create shared network with the following scope: 1. Network with scope="all" 2. Network with scope="domain" with no subdomain access 3. Network with scope="domain" with subdomain access 4. Network with scope="account" """ super(TestNuageSharedNetworkVpcVmMonitor, cls).setUpClass() cls.sharednetworkdata = cls.test_data["acl"] cls.nuagenetworkdata = cls.test_data["nuagevsp"] cls.domain_1 = None cls.domain_2 = None try: # backup default apikey and secretkey cls.default_apikey = cls.api_client.connection.apiKey cls.default_secretkey = cls.api_client.connection.securityKey # Create domains cls.domain_1 = Domain.create(cls.api_client, cls.sharednetworkdata["domain1"]) cls.domain_11 = Domain.create(cls.api_client, cls.sharednetworkdata["domain11"], parentdomainid=cls.domain_1.id) cls.domain_12 = Domain.create(cls.api_client, cls.sharednetworkdata["domain12"], parentdomainid=cls.domain_1.id) # Create 1 admin account and 2 user accounts for doamin_1 cls.account_d1 = Account.create(cls.api_client, cls.sharednetworkdata["accountD1"], admin=True, domainid=cls.domain_1.id) user = cls.generateKeysForUser(cls.api_client, cls.account_d1) cls.user_d1_apikey = user.apikey cls.user_d1_secretkey = user.secretkey cls.account_d1a = Account.create( cls.api_client, cls.sharednetworkdata["accountD1A"], admin=False, domainid=cls.domain_1.id) user = cls.generateKeysForUser(cls.api_client, cls.account_d1a) cls.user_d1a_apikey = user.apikey cls.user_d1a_secretkey = user.secretkey cls.account_d1b = Account.create( cls.api_client, cls.sharednetworkdata["accountD1B"], admin=False, domainid=cls.domain_1.id) user = cls.generateKeysForUser(cls.api_client, cls.account_d1b) cls.user_d1b_apikey = user.apikey cls.user_d1b_secretkey = user.secretkey # Create 1 admin and 2 user accounts for doamin_11 cls.account_d11 = Account.create( cls.api_client, cls.sharednetworkdata["accountD11"], admin=True, domainid=cls.domain_11.id) user = cls.generateKeysForUser(cls.api_client, cls.account_d11) cls.user_d11_apikey = user.apikey cls.user_d11_secretkey = user.secretkey cls.account_d11a = Account.create( cls.api_client, cls.sharednetworkdata["accountD11A"], admin=False, domainid=cls.domain_11.id) user = cls.generateKeysForUser(cls.api_client, cls.account_d11a) cls.user_d11a_apikey = user.apikey cls.user_d11a_secretkey = user.secretkey cls.account_d11b = Account.create( cls.api_client, cls.sharednetworkdata["accountD11B"], admin=False, domainid=cls.domain_11.id) user = cls.generateKeysForUser(cls.api_client, cls.account_d11b) cls.user_d11b_apikey = user.apikey cls.user_d11b_secretkey = user.secretkey # Create 2 user accounts for doamin_12 cls.account_d12a = Account.create( cls.api_client, cls.sharednetworkdata["accountD12A"], admin=False, domainid=cls.domain_12.id) user = cls.generateKeysForUser(cls.api_client, cls.account_d12a) cls.user_d12a_apikey = user.apikey cls.user_d12a_secretkey = user.secretkey cls.account_d12b = Account.create( cls.api_client, cls.sharednetworkdata["accountD12B"], admin=False, domainid=cls.domain_12.id) user = cls.generateKeysForUser(cls.api_client, cls.account_d12b) cls.user_d12b_apikey = user.apikey cls.user_d12b_secretkey = user.secretkey # Create 1 user account and admin account in "ROOT" domain cls.account_roota = Account.create( cls.api_client, cls.sharednetworkdata["accountROOTA"], admin=False, ) user = cls.generateKeysForUser(cls.api_client, cls.account_roota) cls.user_roota_apikey = user.apikey cls.user_roota_secretkey = user.secretkey cls.account_root = Account.create( cls.api_client, cls.sharednetworkdata["accountROOTA"], admin=True, ) user = cls.generateKeysForUser(cls.api_client, cls.account_root) cls.user_root_apikey = user.apikey cls.user_root_secretkey = user.secretkey # service offering is already created in Nuagetestcase cls.sharednetworkdata['mode'] = cls.zone.networktype # As admin user , create shared network with scope "all", "domain" # with subdomain access , "domain" without subdomain access and # "account" cls.api_client.connection.apiKey = cls.default_apikey cls.api_client.connection.securityKey = cls.default_secretkey cls.shared_network_offering = NetworkOffering.create( cls.api_client, cls.test_data["nuagevsp"]["shared_nuage_network_offering"], conservemode=False) # Enable Network offering cls.shared_network_offering.update(cls.api_client, state='Enabled') cls.shared_network_offering_id = cls.shared_network_offering.id cls.shared_network_all = Network.create( cls.api_client, cls.test_data["nuagevsp"]["network_all"], networkofferingid=cls.shared_network_offering_id, zoneid=cls.zone.id) cls.shared_network_domain_d11 = Network.create( cls.api_client, cls.test_data["nuagevsp"] ["network_domain_with_no_subdomain_access"], networkofferingid=cls.shared_network_offering_id, zoneid=cls.zone.id, domainid=cls.domain_11.id, subdomainaccess=False) cls.shared_network_domain_with_subdomain_d11 = Network.create( cls.api_client, cls.test_data["nuagevsp"] ["network_domain_with_subdomain_access"], networkofferingid=cls.shared_network_offering_id, zoneid=cls.zone.id, domainid=cls.domain_11.id, subdomainaccess=True) cls.shared_network_account_d111a = Network.create( cls.api_client, cls.test_data["nuagevsp"]["network_account"], networkofferingid=cls.shared_network_offering_id, zoneid=cls.zone.id, domainid=cls.domain_11.id, accountid=cls.account_d11a.user[0].username) cls.debug("Creating Nuage VSP VPC offering...") cls.vpc_offering = VpcOffering.create( cls.api_client, cls.test_data["nuagevsp"]["vpc_offering"]) cls.vpc_offering.update(cls.api_client, state="Enabled") # Creating a VPC cls.debug("Creating a VPC with Nuage VSP VPC offering...") cls.test_data["vpc"]["cidr"] = '10.1.0.0/16' cls.vpcd11 = VPC.create(cls.api_client, cls.test_data["vpc"], vpcofferingid=cls.vpc_offering.id, zoneid=cls.zone.id, account=cls.account_d11a.name, domainid=cls.account_d11a.domainid) # Creating a network offering cls.debug("Creating Nuage Vsp VPC Network offering...") cls.network_offering = NetworkOffering.create( cls.api_client, cls.test_data["nuagevsp"]["vpc_network_offering"], conservemode=False) cls.network_offering.update(cls.api_client, state="Enabled") # Creating two VPC network in the VPC cls.debug("Creating a VPC network with Nuage Vsp VPC Network " "offering...") cls.test_data["network"]["netmask"] = "255.255.255.0" cls.vpc_network1 = Network.create( cls.api_client, cls.test_data["network"], accountid=cls.account_d11a.name, domainid=cls.account_d11a.domainid, networkofferingid=cls.network_offering.id, zoneid=cls.zone.id, gateway="10.1.1.1", vpcid=cls.vpcd11.id) cls.debug( "Creating a VPC Tier2 network with Nuage Vsp VPC Network " "offering...") cls.test_data["network"]["name"] = "Tier2" cls.vpc_network2 = Network.create( cls.api_client, cls.test_data["network"], accountid=cls.account_d11a.name, domainid=cls.account_d11a.domainid, networkofferingid=cls.network_offering.id, zoneid=cls.zone.id, gateway="10.1.2.1", vpcid=cls.vpcd11.id) cls.vmdata = {"name": "vmvpc1", "displayname": "vmvpc1"} # Deploying a VM in the VPC network cls.vmvpc1 = VirtualMachine.create( cls.api_client, cls.vmdata, zoneid=cls.zone.id, serviceofferingid=cls.service_offering.id, templateid=cls.template.id, networkids=cls.vpc_network1.id, accountid=cls.account_d11a.name, domainid=cls.account_d11a.domainid) cls.vmdata = {"name": "vmvpc2", "displayname": "vmvpc2"} cls.vmvpc2 = VirtualMachine.create( cls.api_client, cls.vmdata, zoneid=cls.zone.id, serviceofferingid=cls.service_offering.id, templateid=cls.template.id, networkids=cls.vpc_network2.id, accountid=cls.account_d11a.name, domainid=cls.account_d11a.domainid) cls._cleanup = [ cls.account_root, cls.account_roota, cls.shared_network_all, cls.shared_network_offering, cls.network_offering, cls.vpc_offering, cls.service_offering, ] except Exception as e: cls.domain_1.delete(cls.api_client, cleanup="true") cleanup_resources(cls.api_client, cls._cleanup) raise Exception( "Failed to create the setup required to execute the test " "cases: %s" % e) return
def setUpClass(cls): cls._cleanup = [] cls.testClient = super(TestBigSwitchBcf, cls).getClsTestClient() cls.api_client = cls.testClient.getApiClient() cls.services = Services().services # Get Zone, Domain and templates 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.services["virtual_machine"]["zoneid"] = cls.zone.id cls.services["virtual_machine"]["template"] = cls.template.id # Get test parameters cls.bigswitch_services = cls.services["big_switch_bcf_device"] try: # Get physical network resp = listPhysicalNetworks.listPhysicalNetworksCmd() resp.zoneid = cls.zone.id physical_networks = cls.api_client.listPhysicalNetworks(resp) if isinstance(physical_networks, list): cls.debug("phy net %s" % physical_networks) physical_network = physical_networks[1] # Get bigswitch network service provider resp = listNetworkServiceProviders.listNetworkServiceProvidersCmd() resp.name = 'BigSwitchBcf' resp.physicalnetworkid = physical_network.id nw_service_providers = cls.api_client.listNetworkServiceProviders(resp) if isinstance(nw_service_providers, list): bigswitch_provider = nw_service_providers[0] cls.debug("net serv prov %s" % nw_service_providers) else: # Create bigswitch provider if not already existent resp_add_nsp = addNetworkServiceProvider.addNetworkServiceProviderCmd() resp_add_nsp.name = 'BigSwitchBcf' resp_add_nsp.physicalnetworkid = physical_network.id bigswitch_provider = cls.api_client.addNetworkServiceProvider(resp_add_nsp) # add BCF controller resp_add_device = addBigSwitchBcfDevice.addBigSwitchBcfDeviceCmd() resp_add_device.physicalnetworkid = physical_network.id resp_add_device.username = cls.bigswitch_services["username"] resp_add_device.password = cls.bigswitch_services["password"] resp_add_device.hostname = cls.bigswitch_services["hostname"] resp_add_device.retrycount = cls.bigswitch_services["retrycount"] resp_add_device.retryinterval = cls.bigswitch_services["retryinterval"] cls.bigswitch = cls.api_client.addBigSwitchBcfDevice(resp_add_device) if bigswitch_provider.state != 'Enabled': cmd = updateNetworkServiceProvider.updateNetworkServiceProviderCmd() cmd.id = bigswitch_provider.id cmd.state = 'Enabled' cls.api_client.updateNetworkServiceProvider(cmd) # Create non-VPC network offering cls.network_offering = NetworkOffering.create( cls.api_client, cls.services["network_offering"], conservemode=True ) cls._cleanup.append(cls.network_offering) cls.network_offering.update(cls.api_client, state='Enabled') # Create VPC network offering cls.vpc_network_offering = NetworkOffering.create( cls.api_client, cls.services["vpc_network_offering"], conservemode=False ) cls._cleanup.append(cls.vpc_network_offering) cls.vpc_network_offering.update(cls.api_client, state='Enabled') # Create VPC offering cls.vpc_offering = VpcOffering.create( cls.api_client, cls.services["vpc_offering"] ) cls._cleanup.append(cls.vpc_offering) cls.vpc_offering.update(cls.api_client, state='Enabled') # Create compute service offering 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) return
def test_03_deploy_vms_in_vpc_with_regionlevelvpc(self): """Test deploy virtual machines in VPC networks""" # 1. Create VPC Offering by specifying all supported Services # (Vpn,dhcpdns,UserData, SourceNat,Static NAT and PF,LB,NetworkAcl) # 2. Create a VPC using the above VPC offering # 3. Create a network as part of this VPC. # 4. Deploy few Vms. # 5. Create a LB rule for this VM. # 6. Create a PF rule for this VM. # 7. Create a Static Nat rule for this VM. # 8. Create Ingress rules on the network to open the above created # LB PF and Static Nat rule # 9. Create Egress Network ACL for this network to access google.com. # 10. Enable VPN services if not self.isOvsPluginEnabled: self.skipTest("OVS plugin should be enabled to run this test case") self.debug("Creating a VPC offering..") vpc_off = VpcOffering.create(self.apiclient, self.services["vpc_offering"]) vpc_off.update(self.apiclient, state='Enabled') self.debug("creating a VPC network in the account: %s" % self.account.name) vpc = VPC.create(self.apiclient, self.services["vpc"], vpcofferingid=vpc_off.id, zoneid=self.zone.id, account=self.account.name, domainid=self.account.domainid, networkDomain=self.account.domainid) self.validate_vpc_network(vpc) self.network_offering = NetworkOffering.create( self.apiclient, self.services["network_offering"], conservemode=False) # Enable Network offering self.network_offering.update(self.apiclient, state='Enabled') gateway = vpc.cidr.split('/')[0] # Split the cidr to retrieve gateway # for eg. cidr = 10.0.0.1/24 # Gateway = 10.0.0.1 # Creating network using the network offering created self.debug("Creating network with network offering: %s" % self.network_offering.id) 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, gateway=gateway, vpcid=vpc.id) self.debug("Created network with ID: %s" % network.id) # Spawn an instance in that network 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(network.id)]) self.debug("Deployed VM in network: %s" % network.id) self.debug("Associating public IP for network: %s" % network.name) public_ip = PublicIPAddress.create(self.apiclient, accountid=self.account.name, zoneid=self.zone.id, domainid=self.account.domainid, networkid=network.id, vpcid=vpc.id) self.debug("Associated %s with network %s" % (public_ip.ipaddress.ipaddress, network.id)) self.debug("Creating LB rule for IP address: %s" % public_ip.ipaddress.ipaddress) LoadBalancerRule.create(self.apiclient, self.services["lbrule"], ipaddressid=public_ip.ipaddress.id, accountid=self.account.name, networkid=network.id, vpcid=vpc.id, domainid=self.account.domainid) self.debug("Associating public IP for network: %s" % vpc.name) public_ip_2 = PublicIPAddress.create(self.apiclient, accountid=self.account.name, zoneid=self.zone.id, domainid=self.account.domainid, networkid=network.id, vpcid=vpc.id) self.debug("Associated %s with network %s" % (public_ip_2.ipaddress.ipaddress, network.id)) NATRule.create(self.apiclient, virtual_machine, self.services["natrule"], ipaddressid=public_ip_2.ipaddress.id, openfirewall=False, networkid=network.id, vpcid=vpc.id) self.debug("Adding NetwrokACl rules to make PF and LB accessible") NetworkACL.create(self.apiclient, networkid=network.id, services=self.services["natrule"], traffictype='Ingress') NetworkACL.create(self.apiclient, networkid=network.id, services=self.services["lbrule"], traffictype='Ingress') self.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") 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) public_ip_3 = PublicIPAddress.create(self.apiclient, accountid=self.account.name, zoneid=self.zone.id, domainid=self.account.domainid, networkid=network.id, vpcid=vpc.id) self.debug("Associated %s with network %s" % (public_ip_3.ipaddress.ipaddress, network.id)) self.debug("Enabling static NAT for IP: %s" % public_ip_3.ipaddress.ipaddress) try: StaticNATRule.enable(self.apiclient, ipaddressid=public_ip_3.ipaddress.id, virtualmachineid=virtual_machine.id, networkid=network.id) self.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" % (public_ip_3.ipaddress.ipaddress, e)) public_ips = PublicIPAddress.list(self.apiclient, networkid=network.id, listall=True, isstaticnat=True, account=self.account.name, domainid=self.account.domainid) self.assertEqual(isinstance(public_ips, list), True, "List public Ip for network should list the Ip addr") self.assertEqual(public_ips[0].ipaddress, public_ip_3.ipaddress.ipaddress, "List public Ip for network should list the Ip addr") # TODO: Remote Access VPN is not yet supported in VPC return
def test_02_native_to_native_vpc_migration(self): """ Verify Migration for a vpc network nativeOnly 1. create native vpc with 2 tier networks 2. migrate to native vpc, check VR state 3. deploy VM in vpc tier network 4. acquire ip and enable staticnat 5. migrate to native vpc network """ self.debug("Creating Native VSP VPC offering with Static NAT service " "provider as VPCVR...") native_vpc_off = VpcOffering.create( self.apiclient, self.test_data["vpc_offering_reduced"]) self.debug("Enabling the VPC offering created") native_vpc_off.update(self.apiclient, state='Enabled') self.debug("Creating a VPC with Static NAT service provider as " "VpcVirtualRouter") self.services["vpc"]["cidr"] = '10.1.1.1/16' vpc = VPC.create( self.apiclient, self.services["vpc"], vpcofferingid=native_vpc_off.id, zoneid=self.zone.id, account=self.account.name, domainid=self.account.domainid ) self.debug("Creating native VPC Network Tier offering " "with Static NAT service provider as VPCVR") native_tiernet_off = \ NetworkOffering.create(self.apiclient, self.test_data ["nw_offering_reduced_vpc"], conservemode=False) native_tiernet_off.update(self.apiclient, state='Enabled') self.debug("Creating a VPC tier network with Static NAT service") vpc_tier = Network.create(self.apiclient, self.services["network"], accountid=self.account.name, domainid=self.account.domainid, networkofferingid=native_tiernet_off.id, zoneid=self.zone.id, gateway='10.1.1.1', vpcid=vpc.id if vpc else self.vpc.id ) self.debug("Created network with ID: %s" % vpc_tier.id) network_offering_map = \ [{"networkid": vpc_tier.id, "networkofferingid": self.native_vpc_network_offering.id}] self.migrate_vpc(vpc, native_vpc_off, network_offering_map, resume=False) network_offering_map = \ [{"networkid": vpc_tier.id, "networkofferingid": native_tiernet_off.id}] self.migrate_vpc(vpc, native_vpc_off, network_offering_map, resume=False) self.debug('Creating VM in network=%s' % native_tiernet_off.name) vm = VirtualMachine.create( self.apiclient, self.services["virtual_machine"], accountid=self.account.name, domainid=self.account.domainid, serviceofferingid=self.service_offering.id, networkids=[str(vpc_tier.id)], templateid=self.template.id, zoneid=self.zone.id ) self.debug('Created VM=%s in network=%s' % (vm.id, native_tiernet_off.name)) network_offering_map = \ [{"networkid": vpc_tier.id, "networkofferingid": self.native_vpc_network_offering.id}] self.migrate_vpc(vpc, native_vpc_off, network_offering_map, resume=False) network_offering_map = \ [{"networkid": vpc_tier.id, "networkofferingid": native_tiernet_off.id}] self.migrate_vpc(vpc, native_vpc_off, network_offering_map, resume=False)
def setUpClass(cls): testClient = super(TestPathVMLC, cls).getClsTestClient() cls.apiclient = testClient.getApiClient() cls.testdata = testClient.getParsedTestDataConfig() cls.hypervisor = testClient.getHypervisorInfo() # Get Zone, Domain and templates cls.domain = get_domain(cls.apiclient) cls.zone = get_zone(cls.apiclient) cls._cleanup = [] try: # Create an account cls.account = Account.create(cls.apiclient, cls.testdata["account"], domainid=cls.domain.id) cls._cleanup.append(cls.account) # If local storage is enabled, alter the offerings to use # localstorage if cls.zone.localstorageenable: cls.testdata["service_offering"]["storagetype"] = 'local' # Create 3 service offerings with different values for # for cpunumber, cpuspeed, and memory cls.testdata["service_offering"]["cpuspeed"] = 128 cls.testdata["service_offering"]["memory"] = 256 cls.testdata["service_offering"]["cpunumber"] = 1 cls.service_offering_1 = ServiceOffering.create( cls.apiclient, cls.testdata["service_offering"]) cls._cleanup.append(cls.service_offering_1) cls.testdata["service_offering"]["cpunumber"] = 2 cls.service_offering_2 = ServiceOffering.create( cls.apiclient, cls.testdata["service_offering"]) cls._cleanup.append(cls.service_offering_2) # Create isolated network offering cls.isolated_network_offering = CreateEnabledNetworkOffering( cls.apiclient, cls.testdata["isolated_network_offering"]) cls._cleanup.append(cls.isolated_network_offering) # Create shared network offering cls.testdata["shared_network_offering_all_services"][ "specifyVlan"] = "True" cls.testdata["shared_network_offering_all_services"][ "specifyIpRanges"] = "True" cls.shared_network_offering = CreateEnabledNetworkOffering( cls.apiclient, cls.testdata["shared_network_offering_all_services"]) cls._cleanup.append(cls.shared_network_offering) cls.isolated_network_offering_vpc = CreateEnabledNetworkOffering( cls.apiclient, cls.testdata["nw_offering_isolated_vpc"]) cls._cleanup.append(cls.isolated_network_offering_vpc) cls.vpc_off = VpcOffering.create(cls.apiclient, cls.testdata["vpc_offering"]) cls.vpc_off.update(cls.apiclient, state='Enabled') cls._cleanup.append(cls.vpc_off) # This variable will store the id of vpc network whenever # test case creates it # If not created, it will be None and will not be used cls.vpcid = None # Create user api client of the account cls.userapiclient = testClient.getUserApiClient( UserName=cls.account.name, DomainName=cls.account.domain) # Register a private template in the account builtin_info = get_builtin_template_info(cls.apiclient, cls.zone.id) cls.testdata["privatetemplate"]["url"] = builtin_info[0] cls.testdata["privatetemplate"]["hypervisor"] = builtin_info[1] cls.testdata["privatetemplate"]["format"] = builtin_info[2] # Register new template cls.template = Template.register(cls.userapiclient, cls.testdata["privatetemplate"], zoneid=cls.zone.id, account=cls.account.name, domainid=cls.account.domainid) # Wait for template to download cls.template.download(cls.apiclient) # Check that we are able to login to the created account respose = User.login(cls.apiclient, username=cls.account.name, password=cls.testdata["account"]["password"]) assert respose.sessionkey is not None,\ "Login to the CloudStack should be successful\ response shall have non Null key" except Exception as e: cls.tearDownClass() raise e return
def setUpClass(cls): testClient = super(TestPathVMLC, cls).getClsTestClient() cls.apiclient = testClient.getApiClient() cls.testdata = testClient.getParsedTestDataConfig() cls.hypervisor = testClient.getHypervisorInfo() # Get Zone, Domain and templates cls.domain = get_domain(cls.apiclient) cls.zone = get_zone(cls.apiclient) cls._cleanup = [] try: # Create an account cls.account = Account.create( cls.apiclient, cls.testdata["account"], domainid=cls.domain.id ) cls._cleanup.append(cls.account) # If local storage is enabled, alter the offerings to use # localstorage if cls.zone.localstorageenable: cls.testdata["service_offering"]["storagetype"] = 'local' # Create 3 service offerings with different values for # for cpunumber, cpuspeed, and memory cls.testdata["service_offering"]["cpuspeed"] = 128 cls.testdata["service_offering"]["memory"] = 256 cls.testdata["service_offering"]["cpunumber"] = 1 cls.service_offering_1 = ServiceOffering.create( cls.apiclient, cls.testdata["service_offering"] ) cls._cleanup.append(cls.service_offering_1) cls.testdata["service_offering"]["cpunumber"] = 2 cls.service_offering_2 = ServiceOffering.create( cls.apiclient, cls.testdata["service_offering"] ) cls._cleanup.append(cls.service_offering_2) # Create isolated network offering cls.isolated_network_offering = CreateEnabledNetworkOffering( cls.apiclient, cls.testdata["isolated_network_offering"] ) cls._cleanup.append(cls.isolated_network_offering) # Create shared network offering cls.testdata["shared_network_offering_all_services"][ "specifyVlan"] = "True" cls.testdata["shared_network_offering_all_services"][ "specifyIpRanges"] = "True" cls.shared_network_offering = CreateEnabledNetworkOffering( cls.apiclient, cls.testdata["shared_network_offering_all_services"] ) cls._cleanup.append(cls.shared_network_offering) cls.isolated_network_offering_vpc = CreateEnabledNetworkOffering( cls.apiclient, cls.testdata["nw_offering_isolated_vpc"] ) cls._cleanup.append(cls.isolated_network_offering_vpc) cls.vpc_off = VpcOffering.create(cls.apiclient, cls.testdata["vpc_offering"] ) cls.vpc_off.update(cls.apiclient, state='Enabled') cls._cleanup.append(cls.vpc_off) # This variable will store the id of vpc network whenever # test case creates it # If not created, it will be None and will not be used cls.vpcid = None # Create user api client of the account cls.userapiclient = testClient.getUserApiClient( UserName=cls.account.name, DomainName=cls.account.domain ) # Register a private template in the account builtin_info = get_builtin_template_info(cls.apiclient, cls.zone.id) cls.testdata["privatetemplate"]["url"] = builtin_info[0] cls.testdata["privatetemplate"]["hypervisor"] = builtin_info[1] cls.testdata["privatetemplate"]["format"] = builtin_info[2] # Register new template cls.template = Template.register( cls.userapiclient, cls.testdata["privatetemplate"], zoneid=cls.zone.id, account=cls.account.name, domainid=cls.account.domainid ) # Wait for template to download cls.template.download(cls.apiclient) # Check that we are able to login to the created account respose = User.login( cls.apiclient, username=cls.account.name, password=cls.testdata["account"]["password"] ) assert respose.sessionkey is not None,\ "Login to the CloudStack should be successful\ response shall have non Null key" except Exception as e: cls.tearDownClass() raise e return
def test_01_ip_resouce_count_vpc_network(self): """ Test IP count in VPC networks """ self.debug("Creating a VPC offering..") vpc_off = VpcOffering.create(self.apiclient, self.services["vpc_offering"]) self.validate_vpc_offering(vpc_off) self.debug("Enabling the VPC offering created") vpc_off.update(self.apiclient, state='Enabled') self.debug("creating a VPC network in the account: %s" % self.account.name) self.services["vpc"]["cidr"] = '10.1.1.1/16' vpc = VPC.create(self.apiclient, self.services["vpc"], vpcofferingid=vpc_off.id, zoneid=self.zone.id, account=self.account.name, domainid=self.account.domainid) self.validate_vpc_network(vpc) nw_off = NetworkOffering.create(self.apiclient, self.services["network_offering"], conservemode=False) # Enable Network offering nw_off.update(self.apiclient, state='Enabled') self._cleanup.append(nw_off) # Creating network using the network offering created self.debug("Creating network with network offering: %s" % nw_off.id) network_1 = Network.create(self.apiclient, self.services["network"], accountid=self.account.name, domainid=self.account.domainid, networkofferingid=nw_off.id, zoneid=self.zone.id, gateway='10.1.1.1', vpcid=vpc.id) self.debug("Created network with ID: %s" % network_1.id) account_list = Account.list(self.apiclient, id=self.account.id) totalip_1 = account_list[0].iptotal self.debug("Total IP: %s" % totalip_1) public_ip_1 = self.acquire_publicip(network_1, vpc) public_ip_2 = self.acquire_publicip(network_1, vpc) public_ip_3 = self.acquire_publicip(network_1, vpc) account_list = Account.list(self.apiclient, id=self.account.id) totalip = account_list[0].iptotal self.debug("Total IP: %s" % totalip) self.assertTrue(totalip - totalip_1 == 3, "publicip count is 3") self.updateIPCount() account_list = Account.list(self.apiclient, id=self.account.id) totalip = account_list[0].iptotal self.assertTrue(totalip - totalip_1 == 3, "publicip count is 3")
def setUpClass(cls): cls.testClient = super(TestVMLifeCycleHostmaintenance, cls).getClsTestClient() cls.api_client = cls.testClient.getApiClient() cls.services = Services().services # Get Zone, Domain and templates 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.hypervisor = cls.testClient.getHypervisorInfo() cls.services["virtual_machine"]["zoneid"] = cls.zone.id cls.services["virtual_machine"]["template"] = cls.template.id clusterWithSufficientHosts = None clusters = Cluster.list(cls.api_client, zoneid=cls.zone.id) for cluster in clusters: cls.hosts = Host.list(cls.api_client, clusterid=cluster.id) if len(cls.hosts) >= 2: clusterWithSufficientHosts = cluster break if clusterWithSufficientHosts is None: raise unittest.SkipTest("No Cluster with 2 hosts found") Host.update(cls.api_client, id=cls.hosts[0].id, hosttags="hosttag1") Host.update(cls.api_client, id=cls.hosts[1].id, hosttags="hosttag2") cls.service_offering_1 = ServiceOffering.create( cls.api_client, cls.services["service_offering_1"] ) cls.service_offering_2 = ServiceOffering.create( cls.api_client, cls.services["service_offering_2"] ) cls.vpc_off = VpcOffering.create( cls.api_client, cls.services["vpc_offering"] ) cls.vpc_off.update(cls.api_client, state='Enabled') cls.account = Account.create( cls.api_client, cls.services["account"], admin=True, domainid=cls.domain.id ) cls.vpc_off = VpcOffering.create( cls.api_client, cls.services["vpc_offering"] ) cls.vpc_off.update(cls.api_client, state='Enabled') cls.services["vpc"]["cidr"] = '10.1.1.1/16' cls.vpc = VPC.create( cls.api_client, cls.services["vpc"], vpcofferingid=cls.vpc_off.id, zoneid=cls.zone.id, account=cls.account.name, domainid=cls.account.domainid ) cls.nw_off = NetworkOffering.create( cls.api_client, cls.services["network_offering"], conservemode=False ) # Enable Network offering cls.nw_off.update(cls.api_client, state='Enabled') # Creating network using the network offering created cls.network_1 = Network.create( cls.api_client, cls.services["network"], accountid=cls.account.name, domainid=cls.account.domainid, networkofferingid=cls.nw_off.id, zoneid=cls.zone.id, gateway='10.1.1.1', vpcid=cls.vpc.id ) cls.nw_off_no_lb = NetworkOffering.create( cls.api_client, cls.services["network_offering_no_lb"], conservemode=False ) # Enable Network offering cls.nw_off_no_lb.update(cls.api_client, state='Enabled') # Creating network using the network offering created cls.network_2 = Network.create( cls.api_client, cls.services["network"], accountid=cls.account.name, domainid=cls.account.domainid, networkofferingid=cls.nw_off_no_lb.id, zoneid=cls.zone.id, gateway='10.1.2.1', vpcid=cls.vpc.id ) # Spawn an instance in that network cls.vm_1 = VirtualMachine.create( cls.api_client, cls.services["virtual_machine"], accountid=cls.account.name, domainid=cls.account.domainid, serviceofferingid=cls.service_offering_1.id, networkids=[str(cls.network_1.id)] ) # Spawn an instance in that network cls.vm_2 = VirtualMachine.create( cls.api_client, cls.services["virtual_machine"], accountid=cls.account.name, domainid=cls.account.domainid, serviceofferingid=cls.service_offering_1.id, networkids=[str(cls.network_1.id)] ) cls.vm_3 = VirtualMachine.create( cls.api_client, cls.services["virtual_machine"], accountid=cls.account.name, domainid=cls.account.domainid, serviceofferingid=cls.service_offering_2.id, networkids=[str(cls.network_2.id)] ) routers = Router.list( cls.api_client, account=cls.account.name, domainid=cls.account.domainid, listall=True ) if isinstance(routers, list): cls.vpcvr = routers[0] cls._cleanup = [ cls.service_offering_1, cls.service_offering_2, cls.nw_off, cls.nw_off_no_lb, ] return
def setUpClass(cls): cls._cleanup = [] cls.testClient = super(TestVPCRouterOneNetwork, cls).getClsTestClient() cls.api_client = cls.testClient.getApiClient() cls.hypervisor = cls.testClient.getHypervisorInfo() cls.vpcSupported = True cls._cleanup = [] cls.services = Services().services # Get Zone, Domain and templates 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.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) cls.vpc_off = VpcOffering.create( cls.api_client, cls.services["vpc_offering"] ) cls.vpc_off.update(cls.api_client, state='Enabled') cls._cleanup.append(cls.vpc_off) cls.account = Account.create( cls.api_client, cls.services["account"], admin=True, domainid=cls.domain.id ) cls._cleanup.insert(0, cls.account) cls.services["vpc"]["cidr"] = '10.1.1.1/16' cls.vpc = VPC.create( cls.api_client, cls.services["vpc"], vpcofferingid=cls.vpc_off.id, zoneid=cls.zone.id, account=cls.account.name, domainid=cls.account.domainid ) private_gateway = PrivateGateway.create( cls.api_client, gateway='10.1.3.1', ipaddress='10.1.3.100', netmask='255.255.255.0', vlan=678, vpcid=cls.vpc.id ) cls.gateways = PrivateGateway.list( cls.api_client, id=private_gateway.id, listall=True ) static_route = StaticRoute.create( cls.api_client, cidr='11.1.1.1/24', gatewayid=private_gateway.id ) cls.static_routes = StaticRoute.list( cls.api_client, id=static_route.id, listall=True ) cls.nw_off = NetworkOffering.create( cls.api_client, cls.services["network_offering"], conservemode=False ) # Enable Network offering cls.nw_off.update(cls.api_client, state='Enabled') cls._cleanup.append(cls.nw_off) # Creating network using the network offering created cls.network_1 = Network.create( cls.api_client, cls.services["network"], accountid=cls.account.name, domainid=cls.account.domainid, networkofferingid=cls.nw_off.id, zoneid=cls.zone.id, gateway='10.1.1.1', vpcid=cls.vpc.id ) # Spawn an instance in that network vm_1 = 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_1.id)] ) vm_2 = 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_1.id)] ) # Spawn an instance in that network vm_3 = 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_1.id)] ) VirtualMachine.list( cls.api_client, account=cls.account.name, domainid=cls.account.domainid, listall=True ) public_ip_1 = PublicIPAddress.create( cls.api_client, accountid=cls.account.name, zoneid=cls.zone.id, domainid=cls.account.domainid, networkid=cls.network_1.id, vpcid=cls.vpc.id ) NATRule.create( cls.api_client, vm_1, cls.services["natrule"], ipaddressid=public_ip_1.ipaddress.id, openfirewall=False, networkid=cls.network_1.id, vpcid=cls.vpc.id ) NetworkACL.create( cls.api_client, networkid=cls.network_1.id, services=cls.services["natrule"], traffictype='Ingress' ) public_ip_2 = PublicIPAddress.create( cls.api_client, accountid=cls.account.name, zoneid=cls.zone.id, domainid=cls.account.domainid, networkid=cls.network_1.id, vpcid=cls.vpc.id ) try: StaticNATRule.enable( cls.api_client, ipaddressid=public_ip_2.ipaddress.id, virtualmachineid=vm_2.id, networkid=cls.network_1.id ) except Exception as e: cls.fail("Failed to enable static NAT on IP: %s - %s" % ( public_ip_2.ipaddress.ipaddress, e)) PublicIPAddress.list( cls.api_client, networkid=cls.network_1.id, listall=True, isstaticnat=True, account=cls.account.name, domainid=cls.account.domainid ) public_ip_3 = PublicIPAddress.create( cls.api_client, accountid=cls.account.name, zoneid=cls.zone.id, domainid=cls.account.domainid, networkid=cls.network_1.id, vpcid=cls.vpc.id ) lb_rule = LoadBalancerRule.create( cls.api_client, cls.services["lbrule"], ipaddressid=public_ip_3.ipaddress.id, accountid=cls.account.name, networkid=cls.network_1.id, vpcid=cls.vpc.id, domainid=cls.account.domainid ) lb_rule.assign(cls.api_client, [vm_3]) NetworkACL.create( cls.api_client, networkid=cls.network_1.id, services=cls.services["lbrule"], traffictype='Ingress' ) NetworkACL.create( cls.api_client, networkid=cls.network_1.id, services=cls.services["http_rule"], traffictype='Egress' )
def test_03_deploy_vms_in_vpc_with_regionlevelvpc(self): """Test deploy virtual machines in VPC networks""" # 1. Create VPC Offering by specifying all supported Services # (Vpn,dhcpdns,UserData, SourceNat,Static NAT and PF,LB,NetworkAcl) # 2. Create a VPC using the above VPC offering # 3. Create a network as part of this VPC. # 4. Deploy few Vms. # 5. Create a LB rule for this VM. # 6. Create a PF rule for this VM. # 7. Create a Static Nat rule for this VM. # 8. Create Ingress rules on the network to open the above created # LB PF and Static Nat rule # 9. Create Egress Network ACL for this network to access google.com. # 10. Enable VPN services if not self.isOvsPluginEnabled: self.skipTest("OVS plugin should be enabled to run this test case") self.debug("Creating a VPC offering..") vpc_off = VpcOffering.create( self.apiclient, self.services["vpc_offering"] ) vpc_off.update(self.apiclient, state='Enabled') self.debug("creating a VPC network in the account: %s" % self.account.name) vpc = VPC.create( self.apiclient, self.services["vpc"], vpcofferingid=vpc_off.id, zoneid=self.zone.id, account=self.account.name, domainid=self.account.domainid, networkDomain=self.account.domainid ) self.validate_vpc_network(vpc) self.network_offering = NetworkOffering.create( self.apiclient, self.services["network_offering"], conservemode=False ) # Enable Network offering self.network_offering.update(self.apiclient, state='Enabled') gateway = vpc.cidr.split('/')[0] # Split the cidr to retrieve gateway # for eg. cidr = 10.0.0.1/24 # Gateway = 10.0.0.1 # Creating network using the network offering created self.debug("Creating network with network offering: %s" % self.network_offering.id) 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, gateway=gateway, vpcid=vpc.id ) self.debug("Created network with ID: %s" % network.id) # Spawn an instance in that network 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(network.id)] ) self.debug("Deployed VM in network: %s" % network.id) self.debug("Associating public IP for network: %s" % network.name) public_ip = PublicIPAddress.create( self.apiclient, accountid=self.account.name, zoneid=self.zone.id, domainid=self.account.domainid, networkid=network.id, vpcid=vpc.id ) self.debug("Associated %s with network %s" % ( public_ip.ipaddress.ipaddress, network.id )) self.debug("Creating LB rule for IP address: %s" % public_ip.ipaddress.ipaddress) LoadBalancerRule.create( self.apiclient, self.services["lbrule"], ipaddressid=public_ip.ipaddress.id, accountid=self.account.name, networkid=network.id, vpcid=vpc.id, domainid=self.account.domainid ) self.debug("Associating public IP for network: %s" % vpc.name) public_ip_2 = PublicIPAddress.create( self.apiclient, accountid=self.account.name, zoneid=self.zone.id, domainid=self.account.domainid, networkid=network.id, vpcid=vpc.id ) self.debug("Associated %s with network %s" % ( public_ip_2.ipaddress.ipaddress, network.id )) NATRule.create( self.apiclient, virtual_machine, self.services["natrule"], ipaddressid=public_ip_2.ipaddress.id, openfirewall=False, networkid=network.id, vpcid=vpc.id ) self.debug("Adding NetwrokACl rules to make PF and LB accessible") NetworkACL.create( self.apiclient, networkid=network.id, services=self.services["natrule"], traffictype='Ingress' ) NetworkACL.create( self.apiclient, networkid=network.id, services=self.services["lbrule"], traffictype='Ingress' ) self.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") 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) public_ip_3 = PublicIPAddress.create( self.apiclient, accountid=self.account.name, zoneid=self.zone.id, domainid=self.account.domainid, networkid=network.id, vpcid=vpc.id ) self.debug("Associated %s with network %s" % ( public_ip_3.ipaddress.ipaddress, network.id )) self.debug("Enabling static NAT for IP: %s" % public_ip_3.ipaddress.ipaddress) try: StaticNATRule.enable( self.apiclient, ipaddressid=public_ip_3.ipaddress.id, virtualmachineid=virtual_machine.id, networkid=network.id ) self.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" % ( public_ip_3.ipaddress.ipaddress, e)) public_ips = PublicIPAddress.list( self.apiclient, networkid=network.id, listall=True, isstaticnat=True, account=self.account.name, domainid=self.account.domainid ) self.assertEqual( isinstance(public_ips, list), True, "List public Ip for network should list the Ip addr" ) self.assertEqual( public_ips[0].ipaddress, public_ip_3.ipaddress.ipaddress, "List public Ip for network should list the Ip addr" ) # TODO: Remote Access VPN is not yet supported in VPC return
def setUpClass(cls): """ Create the following domain tree and accounts that are required for executing Nuage VSP SDN plugin test cases for shared networks: Under ROOT - create domain D1 Under domain D1 - Create two subdomains D11 and D12 Under each of the domains - create one admin user and couple of regular users. Create shared network with the following scope: 1. Network with scope="all" 2. Network with scope="domain" with no subdomain access 3. Network with scope="domain" with subdomain access 4. Network with scope="account" """ super(TestNuageSharedNetworkVpcVmMonitor, cls).setUpClass() cls.sharednetworkdata = cls.test_data["acl"] cls.nuagenetworkdata = cls.test_data["nuagevsp"] cls.domain_1 = None cls.domain_2 = None try: # backup default apikey and secretkey cls.default_apikey = cls.api_client.connection.apiKey cls.default_secretkey = cls.api_client.connection.securityKey # Create domains cls.domain_1 = Domain.create( cls.api_client, cls.sharednetworkdata["domain1"] ) cls.domain_11 = Domain.create( cls.api_client, cls.sharednetworkdata["domain11"], parentdomainid=cls.domain_1.id ) cls.domain_12 = Domain.create( cls.api_client, cls.sharednetworkdata["domain12"], parentdomainid=cls.domain_1.id ) # Create 1 admin account and 2 user accounts for doamin_1 cls.account_d1 = Account.create( cls.api_client, cls.sharednetworkdata["accountD1"], admin=True, domainid=cls.domain_1.id ) user = cls.generateKeysForUser(cls.api_client, cls.account_d1) cls.user_d1_apikey = user.apikey cls.user_d1_secretkey = user.secretkey cls.account_d1a = Account.create( cls.api_client, cls.sharednetworkdata["accountD1A"], admin=False, domainid=cls.domain_1.id ) user = cls.generateKeysForUser(cls.api_client, cls.account_d1a) cls.user_d1a_apikey = user.apikey cls.user_d1a_secretkey = user.secretkey cls.account_d1b = Account.create( cls.api_client, cls.sharednetworkdata["accountD1B"], admin=False, domainid=cls.domain_1.id ) user = cls.generateKeysForUser(cls.api_client, cls.account_d1b) cls.user_d1b_apikey = user.apikey cls.user_d1b_secretkey = user.secretkey # Create 1 admin and 2 user accounts for doamin_11 cls.account_d11 = Account.create( cls.api_client, cls.sharednetworkdata["accountD11"], admin=True, domainid=cls.domain_11.id ) user = cls.generateKeysForUser(cls.api_client, cls.account_d11) cls.user_d11_apikey = user.apikey cls.user_d11_secretkey = user.secretkey cls.account_d11a = Account.create( cls.api_client, cls.sharednetworkdata["accountD11A"], admin=False, domainid=cls.domain_11.id ) user = cls.generateKeysForUser(cls.api_client, cls.account_d11a) cls.user_d11a_apikey = user.apikey cls.user_d11a_secretkey = user.secretkey cls.account_d11b = Account.create( cls.api_client, cls.sharednetworkdata["accountD11B"], admin=False, domainid=cls.domain_11.id ) user = cls.generateKeysForUser(cls.api_client, cls.account_d11b) cls.user_d11b_apikey = user.apikey cls.user_d11b_secretkey = user.secretkey # Create 2 user accounts for doamin_12 cls.account_d12a = Account.create( cls.api_client, cls.sharednetworkdata["accountD12A"], admin=False, domainid=cls.domain_12.id ) user = cls.generateKeysForUser(cls.api_client, cls.account_d12a) cls.user_d12a_apikey = user.apikey cls.user_d12a_secretkey = user.secretkey cls.account_d12b = Account.create( cls.api_client, cls.sharednetworkdata["accountD12B"], admin=False, domainid=cls.domain_12.id ) user = cls.generateKeysForUser(cls.api_client, cls.account_d12b) cls.user_d12b_apikey = user.apikey cls.user_d12b_secretkey = user.secretkey # Create 1 user account and admin account in "ROOT" domain cls.account_roota = Account.create( cls.api_client, cls.sharednetworkdata["accountROOTA"], admin=False, ) user = cls.generateKeysForUser(cls.api_client, cls.account_roota) cls.user_roota_apikey = user.apikey cls.user_roota_secretkey = user.secretkey cls.account_root = Account.create( cls.api_client, cls.sharednetworkdata["accountROOTA"], admin=True, ) user = cls.generateKeysForUser(cls.api_client, cls.account_root) cls.user_root_apikey = user.apikey cls.user_root_secretkey = user.secretkey # service offering is already created in Nuagetestcase cls.sharednetworkdata['mode'] = cls.zone.networktype # As admin user , create shared network with scope "all", "domain" # with subdomain access , "domain" without subdomain access and # "account" cls.api_client.connection.apiKey = cls.default_apikey cls.api_client.connection.securityKey = cls.default_secretkey cls.shared_network_offering = NetworkOffering.create( cls.api_client, cls.test_data["nuagevsp"]["shared_nuage_network_offering"], conservemode=False ) # Enable Network offering cls.shared_network_offering.update(cls.api_client, state='Enabled') cls.shared_network_offering_id = cls.shared_network_offering.id cls.shared_network_all = Network.create( cls.api_client, cls.test_data["nuagevsp"]["network_all"], networkofferingid=cls.shared_network_offering_id, zoneid=cls.zone.id ) cls.shared_network_domain_d11 = Network.create( cls.api_client, cls.test_data["nuagevsp"][ "network_domain_with_no_subdomain_access"], networkofferingid=cls.shared_network_offering_id, zoneid=cls.zone.id, domainid=cls.domain_11.id, subdomainaccess=False ) cls.shared_network_domain_with_subdomain_d11 = Network.create( cls.api_client, cls.test_data["nuagevsp"][ "network_domain_with_subdomain_access"], networkofferingid=cls.shared_network_offering_id, zoneid=cls.zone.id, domainid=cls.domain_11.id, subdomainaccess=True ) cls.shared_network_account_d111a = Network.create( cls.api_client, cls.test_data["nuagevsp"]["network_account"], networkofferingid=cls.shared_network_offering_id, zoneid=cls.zone.id, domainid=cls.domain_11.id, accountid=cls.account_d11a.user[0].username ) cls.debug("Creating Nuage VSP VPC offering...") cls.vpc_offering = VpcOffering.create(cls.api_client, cls.test_data["nuagevsp"][ "vpc_offering"] ) cls.vpc_offering.update(cls.api_client, state="Enabled") # Creating a VPC cls.debug("Creating a VPC with Nuage VSP VPC offering...") cls.test_data["vpc"]["cidr"] = '10.1.0.0/16' cls.vpcd11 = VPC.create(cls.api_client, cls.test_data["vpc"], vpcofferingid=cls.vpc_offering.id, zoneid=cls.zone.id, account=cls.account_d11a.name, domainid=cls.account_d11a.domainid ) # Creating a network offering cls.debug("Creating Nuage Vsp VPC Network offering...") cls.network_offering = NetworkOffering.create( cls.api_client, cls.test_data["nuagevsp"]["vpc_network_offering"], conservemode=False ) cls.network_offering.update(cls.api_client, state="Enabled") # Creating two VPC network in the VPC cls.debug( "Creating a VPC network with Nuage Vsp VPC Network " "offering...") cls.test_data["network"]["netmask"] = "255.255.255.0" cls.vpc_network1 = Network.create( cls.api_client, cls.test_data["network"], accountid=cls.account_d11a.name, domainid=cls.account_d11a.domainid, networkofferingid=cls.network_offering.id, zoneid=cls.zone.id, gateway="10.1.1.1", vpcid=cls.vpcd11.id ) cls.debug( "Creating a VPC Tier2 network with Nuage Vsp VPC Network " "offering...") cls.test_data["network"]["name"] = "Tier2" cls.vpc_network2 = Network.create( cls.api_client, cls.test_data["network"], accountid=cls.account_d11a.name, domainid=cls.account_d11a.domainid, networkofferingid=cls.network_offering.id, zoneid=cls.zone.id, gateway="10.1.2.1", vpcid=cls.vpcd11.id ) cls.vmdata = {"name": "vmvpc1", "displayname": "vmvpc1" } # Deploying a VM in the VPC network cls.vmvpc1 = VirtualMachine.create( cls.api_client, cls.vmdata, zoneid=cls.zone.id, serviceofferingid=cls.service_offering.id, templateid=cls.template.id, networkids=cls.vpc_network1.id, accountid=cls.account_d11a.name, domainid=cls.account_d11a.domainid ) cls.vmdata = {"name": "vmvpc2", "displayname": "vmvpc2" } cls.vmvpc2 = VirtualMachine.create( cls.api_client, cls.vmdata, zoneid=cls.zone.id, serviceofferingid=cls.service_offering.id, templateid=cls.template.id, networkids=cls.vpc_network2.id, accountid=cls.account_d11a.name, domainid=cls.account_d11a.domainid ) cls._cleanup = [ cls.account_root, cls.account_roota, cls.shared_network_all, cls.shared_network_offering, cls.network_offering, cls.vpc_offering, cls.service_offering, ] except Exception as e: cls.domain_1.delete(cls.api_client, cleanup="true") cleanup_resources(cls.api_client, cls._cleanup) raise Exception( "Failed to create the setup required to execute the test " "cases: %s" % e) return
def setUpClass(cls): cloudstackTestClient = super( TestMultipleVPNAccessonVPC, cls ).getClsTestClient() cls.debug("Obtain the Admin's API Client") cls.api_client = cloudstackTestClient.getApiClient() cls.debug("Get the dictionary information that will be used during CCP tests, from test_data.py present on the Client") cls.services = cloudstackTestClient.getParsedTestDataConfig() if cls.services is None: cls.debug("Services Object is None") raise Exception("Services Object is None") cls.debug("Procure the CloudStack Setup configuration Information") with open(cls.services["config_path"], 'rb') as fp: cls.pullconfig = json.load(fp) cls.debug("Update 'remote.access.vpn.client.iprange','remote.access.vpn.user.limit','max.account.primary.storage','max.account.public.ips','max.account.user.vms','max.account.volumes','max.account.cpus', Global Configuration Parameters") update_vpn_client_iprange = Configurations.update( cls.api_client, name="remote.access.vpn.client.iprange", value="10.1.2.1-10.1.2.120") cls.debug("'remote.access.vpn.client.iprange' Global Configuration Parameter Updated Successfully") update_vpn_user_limit = Configurations.update( cls.api_client, name="remote.access.vpn.user.limit", value=str(int(cls.services["vpnclient_count"]*2)) ) cls.debug("'remote.access.vpn.user.limit' Global Configuration Parameter Updated Successfully") update_max_account_primary_stg_limit = Configurations.update( cls.api_client, name="max.account.primary.storage", value=str(int(cls.services["vpnclient_count"]*20 + 100)) ) cls.debug("'max.account.primary.storage' Global Configuration Parameter Updated Successfully") update_max_account_public_ips_limit = Configurations.update( cls.api_client, name="max.account.public.ips", value=str(int(cls.services["vpnclient_count"]*2 + 10)) ) cls.debug("'max.account.public.ips' Global Configuration Parameter Updated Successfully") update_max_account_user_vms_limit = Configurations.update( cls.api_client, name="max.account.user.vms", value=str(int(cls.services["vpnclient_count"]*2)) ) cls.debug("'max.account.user.vms' Global Configuration Parameter Updated Successfully") update_max_account_volumes_limit = Configurations.update( cls.api_client, name="max.account.volumes", value=str(int(cls.services["vpnclient_count"]*2)) ) cls.debug("'max.account.volumes' Global Configuration Parameter Updated Successfully") update_max_account_cpus_limit = Configurations.update( cls.api_client, name="max.account.cpus", value=str(int(cls.services["vpnclient_count"]*2)) ) cls.debug("'max.account.cpus' Global Configuration Parameter Updated Successfully") cls.debug("Restart the Management Server") TestMultipleVPNAccessonVPC.restart_mgmt_server(cls.services["config_path"]) cls.debug("Completed restarting the Management Server") cls.debug("Wait for 120 seconds...") time.sleep(120) cls.debug("End of 120 seconds wait time....") # Get Zone, Domain and templates cls.domain = get_domain(cls.api_client) cls.zone = get_zone( cls.api_client, zone_name = cls.services["zone_vpn"]["name"]) cls.debug("Use an Existing 'Tiny Instance' Service Offering on the Setup") list_service_offerings = [] list_service_offerings = list_service_offering( cls.api_client, keyword="Tiny Instance", ) cls._cleanup = [] if list_service_offerings is not None: cls.debug("Found an Existing 'Tiny Instance' Service Offering on the Setup") cls.service_offering = list_service_offerings[0] else: cls.debug("Create a service offering which will be used for VM deployments in this test") cls.service_offering = ServiceOffering.create( cls.api_client, cls.services["service_offering"] ) cls.debug("Add the created service offering to the _cleanup queue") cls._cleanup.append(cls.service_offering) try: cls.debug("Create or Use Existing Account to own the VPN Clients, which is used to test Remote VPN Access to VPC") cls.api_client_vpn_client_reg_user = cloudstackTestClient.getUserApiClient( UserName="******", DomainName="ROOT" ) list_vpn_client_regular_user = User.list( cls.api_client, username="******" ) cls.debug("Procure the Account Name and DomainID Information of the Regular Account") cls.vpn_client_reg_acct_name = list_vpn_client_regular_user[0].account cls.vpn_client_reg_domain_id = list_vpn_client_regular_user[0].domainid list_vpn_client_regular_user_acct = Account.list( cls.api_client, name = cls.vpn_client_reg_acct_name, listall = True ) cls._cleanup.append(Account(list_vpn_client_regular_user_acct[0].__dict__)) # Register a Template that already has VPN client installed on it. The template registered here # has extra scripts to facilitate automated operations to execute Test Cases. # Template has pre-configured configuration files required for the VPN Client operations. # The following files are present on the registered template. The location of the files are locations # on a VM deployed from this template # 1. "/tmp/ipsec.conf" # 2. "/tmp/ipsec.secrets" # 3. "/tmp/options.xl2tpd.client" # 4. "/tmp/xl2tpd.conf" # 5 "/tmp/vpnclient_services.sh" # 6. "/tmp/firstconn_expectscript.exp" # 7. "/tmp/secondconn_expectscript.exp" cls.debug("Use an Existing VPN Client Template on the Setup") list_vpn_client_templates = list_templates( cls.api_client_vpn_client_reg_user, keyword="VPNClient", templatefilter="featured", zoneid = cls.zone.id ) if list_vpn_client_templates is not None: cls.debug("Found an Existing VPN Client Template on the Setup") cls.template = list_vpn_client_templates[0] else: cls.debug("Register a Template that already has VPN client installed on it") cls.template = Template.register( cls.api_client, cls.services["vpn_template"], zoneid=cls.zone.id, hypervisor='XenServer' ) cls._cleanup.append(cls.template) cls.debug("Sleep for {0} seconds specified in the dictionary before checking for Template's Availability".format(cls.services["sleep"])) time.sleep(cls.services["sleep"]) cls.debug("Procure Timeout Value from the dictionary") timeout = cls.services["timeout"] while True: list_template_response = list_templates( cls.api_client_vpn_client_reg_user, templatefilter='featured', id=cls.template.id, ) if isinstance(list_template_response, list): break elif timeout == 0: raise Exception("List template failed!") time.sleep(5) timeout = timeout - 1 cls.debug("Verify template response to check whether template is present") if list_template_response is None: raise Exception("Check whether the VPN Client Template is available") template_response = list_template_response[0] if template_response.isready == False: raise Exception("Template state is not ready, it is %r" % template_response.isready) # Queue that holds all the VPN Client VMs Information cls.vpnclientvms = [] cls.debug("Deploy {0} VPN Clients in the account".format(int(cls.services["vpnclient_count"]))) for vm in xrange(0,int(cls.services["vpnclient_count"])): cls.debug("Deploy a new VM {0} in first account. This VM which will be configured as VPN Client".format(int(vm))) new_vpnclient_vm = VirtualMachine.create( cls.api_client_vpn_client_reg_user, cls.services["virtual_machine"], zoneid=cls.zone.id, serviceofferingid=cls.service_offering.id, templateid=cls.template.id, ) cls.debug("Add new VM {0} to the vpnclientvms Queue".format(int(vm))) cls.vpnclientvms.append(new_vpnclient_vm) cls.debug("Allow SSH Access to the new VPN Client VM {0}".format(int(vm))) new_vpnclient_vm.access_ssh_over_nat( cls.api_client_vpn_client_reg_user, cls.services, new_vpnclient_vm, allow_egress=True ) cls.debug("VM for VPNClient Access Got Created with Public IP Address %s" % new_vpnclient_vm.public_ip) cls.debug("Create or Use existing Account in which we deploy VPCs and test remote access to them from the First Account's VMs present on isolated Network") cls.api_client_vpn_server_reg_user = cloudstackTestClient.getUserApiClient( UserName="******", DomainName="ROOT" ) list_vpn_server_regular_user = User.list( cls.api_client, username="******" ) cls.debug("Procure the Account Name and DomainID Information of the Regular Account") cls.vpn_server_reg_acct_name = list_vpn_server_regular_user[0].account cls.vpn_server_reg_domain_id = list_vpn_server_regular_user[0].domainid list_vpn_server_regular_user_acct = Account.list( cls.api_client, name = cls.vpn_server_reg_acct_name, listall = True ) cls._cleanup.append(Account(list_vpn_server_regular_user_acct[0].__dict__)) cls.debug("Use an Existing 'VPC off-' Service Offering on the Setup") list_available_vpc_offerings = list_vpc_offerings( cls.api_client, keyword="VPC off-", ) if list_available_vpc_offerings is not None: cls.debug("Found an Existing 'VPC off-' Service Offering on the Setup") cls.vpc_offering = VpcOffering(list_available_vpc_offerings[0].__dict__) else: cls.debug("Creating a VPC offering..") cls.vpc_offering = VpcOffering.create( cls.api_client, cls.services["vpc_offering"] ) # Add the created VPC Offering to __cleanup queue cls._cleanup.append(cls.vpc_offering) # Enable to created VPC Offering inorder to deploy VPCs with it cls.debug("Enabling the VPC offering created") cls.vpc_offering.update(cls.api_client, state='Enabled') cls.debug("Enabled the VPC Offering") # Create a VPC for the second account cls.debug("Creating a VPC in the account: %s" % cls.vpn_server_reg_acct_name) cls.firstvpc = VPC.create( cls.api_client_vpn_server_reg_user, cls.services["vpc_remote_vpn"], vpcofferingid=cls.vpc_offering.id, zoneid=cls.zone.id ) cls.debug("Use an Existing 'NET_OFF-RemoteAccessVPNTest-' Network Offering on the Setup") list_available_network_offerings = list_network_offerings( cls.api_client, keyword="NET_OFF-RemoteAccessVPNTest-", ) if list_available_network_offerings is not None: cls.debug("Found an Existing 'NET_OFF-RemoteAccessVPNTest-' Network Offering on the Setup") cls.network_off = NetworkOffering(list_available_network_offerings[0].__dict__) else: cls.debug('Create NetworkOffering for Networks in VPC') cls.services["vpc_network_offering"]["name"] = "NET_OFF-RemoteAccessVPNTest-"+ random_gen() cls.network_off = NetworkOffering.create( cls.api_client, cls.services["vpc_network_offering"], conservemode=False ) # Add the created Network Offering to __cleanup queue cls._cleanup.append(cls.network_off) # Enable Network offering cls.network_off.update(cls.api_client, state='Enabled') cls.debug('Created and Enabled NetworkOffering') cls.services["network"]["name"] = "NETWORK-" + random_gen() # Create First Network Tier in the First VPC created for second account using the network offering created above. cls.debug('Adding Network=%s' % cls.services["network"]) cls.firstnetworktier = Network.create( cls.api_client_vpn_server_reg_user, cls.services["network"], networkofferingid=cls.network_off.id, zoneid=cls.zone.id, gateway=cls.services["firstnetwork_tier"]["gateway"], netmask=cls.services["firstnetwork_tier"]["netmask"], vpcid=cls.firstvpc.id ) cls.debug("Created network with ID: %s" % cls.firstnetworktier.id) # Create Ingress and Egress NetworkACL rules for First Network Tier in the First VPC created for second account. cls.debug("Adding NetworkACL rules to make Network accessible for all Protocols and all CIDRs ") NetworkACL.create( cls.api_client_vpn_server_reg_user, cls.services["all_rule"], networkid=cls.firstnetworktier.id, traffictype='Ingress' ) NetworkACL.create( cls.api_client_vpn_server_reg_user, cls.services["all_rule"], networkid=cls.firstnetworktier.id, traffictype='Egress' ) listFirstVPC = VPC.list( cls.api_client_vpn_server_reg_user, id=cls.firstvpc.id ) cls.debug("Information about the VPC: {0}".format(str(listFirstVPC))) cls.debug("Obtain the source nat IP Address of the first VPC.") cls.listFirstVPCPublicIpAddress = list_publicIP( cls.api_client_vpn_server_reg_user, issourcenat="true", vpcid=listFirstVPC[0].id, listall="true" ) cls.debug("Information about the VPC's Source NAT IP Address: {0}".format(str(cls.listFirstVPCPublicIpAddress))) cls.debug("Enable Remote Access VPN on the source nat Public IP Address of the first VPC") cls.FirstVPNonFirstVPC = Vpn.create( cls.api_client_vpn_server_reg_user, cls.listFirstVPCPublicIpAddress[0].id ) cls.debug("Successfully Created First VPN on VPC with preshared key:"+ cls.FirstVPNonFirstVPC.presharedkey) cls.listfirstNetworkTier = list_networks( cls.api_client_vpn_server_reg_user, id=cls.firstnetworktier.id, listall=True ) cls.debug("Create a VM using the default template on the First Network Tier in the First VPC of the Second Account") cls.vm1 = VirtualMachine.create( cls.api_client_vpn_server_reg_user, cls.services["virtual_machine"], zoneid=cls.zone.id, serviceofferingid=cls.service_offering.id, templateid=cls.template.id, networkids=[str(cls.firstnetworktier.id)] ) cls.debug("First VM deployed in the first Network Tier") except Exception as e: cleanup_resources(cls.api_client, cls._cleanup) printex = traceback.format_exc() cls.debug("Exception Occurred : {0}".format(printex)) raise Exception("Warning: Exception during Setting Up the Test Suite Configuration : %s" % e) return
def setUpClass(cls): cls._cleanup = [] cls.testClient = super(TestVPCRouterOneNetwork, cls).getClsTestClient() cls.api_client = cls.testClient.getApiClient() cls.hypervisor = cls.testClient.getHypervisorInfo() cls.vpcSupported = True cls._cleanup = [] cls.services = Services().services # Get Zone, Domain and templates 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.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) cls.vpc_off = VpcOffering.create(cls.api_client, cls.services["vpc_offering"]) cls.vpc_off.update(cls.api_client, state='Enabled') cls._cleanup.append(cls.vpc_off) cls.account = Account.create(cls.api_client, cls.services["account"], admin=True, domainid=cls.domain.id) cls._cleanup.insert(0, cls.account) cls.services["vpc"]["cidr"] = '10.1.1.1/16' cls.vpc = VPC.create(cls.api_client, cls.services["vpc"], vpcofferingid=cls.vpc_off.id, zoneid=cls.zone.id, account=cls.account.name, domainid=cls.account.domainid) private_gateway = PrivateGateway.create(cls.api_client, gateway='10.1.3.1', ipaddress='10.1.3.100', netmask='255.255.255.0', vlan=678, vpcid=cls.vpc.id) cls.gateways = PrivateGateway.list(cls.api_client, id=private_gateway.id, listall=True) static_route = StaticRoute.create(cls.api_client, cidr='11.1.1.1/24', gatewayid=private_gateway.id) cls.static_routes = StaticRoute.list(cls.api_client, id=static_route.id, listall=True) cls.nw_off = NetworkOffering.create(cls.api_client, cls.services["network_offering"], conservemode=False) # Enable Network offering cls.nw_off.update(cls.api_client, state='Enabled') cls._cleanup.append(cls.nw_off) # Creating network using the network offering created cls.network_1 = Network.create(cls.api_client, cls.services["network"], accountid=cls.account.name, domainid=cls.account.domainid, networkofferingid=cls.nw_off.id, zoneid=cls.zone.id, gateway='10.1.1.1', vpcid=cls.vpc.id) # Spawn an instance in that network vm_1 = 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_1.id)]) vm_2 = 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_1.id)]) # Spawn an instance in that network vm_3 = 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_1.id)]) VirtualMachine.list(cls.api_client, account=cls.account.name, domainid=cls.account.domainid, listall=True) public_ip_1 = PublicIPAddress.create(cls.api_client, accountid=cls.account.name, zoneid=cls.zone.id, domainid=cls.account.domainid, networkid=cls.network_1.id, vpcid=cls.vpc.id) NATRule.create(cls.api_client, vm_1, cls.services["natrule"], ipaddressid=public_ip_1.ipaddress.id, openfirewall=False, networkid=cls.network_1.id, vpcid=cls.vpc.id) NetworkACL.create(cls.api_client, networkid=cls.network_1.id, services=cls.services["natrule"], traffictype='Ingress') public_ip_2 = PublicIPAddress.create(cls.api_client, accountid=cls.account.name, zoneid=cls.zone.id, domainid=cls.account.domainid, networkid=cls.network_1.id, vpcid=cls.vpc.id) try: StaticNATRule.enable(cls.api_client, ipaddressid=public_ip_2.ipaddress.id, virtualmachineid=vm_2.id, networkid=cls.network_1.id) except Exception as e: cls.fail("Failed to enable static NAT on IP: %s - %s" % (public_ip_2.ipaddress.ipaddress, e)) PublicIPAddress.list(cls.api_client, networkid=cls.network_1.id, listall=True, isstaticnat=True, account=cls.account.name, domainid=cls.account.domainid) public_ip_3 = PublicIPAddress.create(cls.api_client, accountid=cls.account.name, zoneid=cls.zone.id, domainid=cls.account.domainid, networkid=cls.network_1.id, vpcid=cls.vpc.id) lb_rule = LoadBalancerRule.create(cls.api_client, cls.services["lbrule"], ipaddressid=public_ip_3.ipaddress.id, accountid=cls.account.name, networkid=cls.network_1.id, vpcid=cls.vpc.id, domainid=cls.account.domainid) lb_rule.assign(cls.api_client, [vm_3]) NetworkACL.create(cls.api_client, networkid=cls.network_1.id, services=cls.services["lbrule"], traffictype='Ingress') NetworkACL.create(cls.api_client, networkid=cls.network_1.id, services=cls.services["http_rule"], traffictype='Egress')
def setUpClass(cls): cls.testClient = super(TestVPCHostMaintenance, cls).getClsTestClient() cls.api_client = cls.testClient.getApiClient() cls.services = Services().services # Get Zone, Domain and templates 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.services["virtual_machine"]["zoneid"] = cls.zone.id cls.services["virtual_machine"]["template"] = cls.template.id cls.services["mode"] = cls.zone.networktype cls.vpc_off = VpcOffering.create( cls.api_client, cls.services["vpc_offering"] ) cls.vpc_off.update(cls.api_client, state='Enabled') cls.hosts = Host.list( cls.api_client, zoneid=cls.zone.id, listall=True, type='Routing' ) if isinstance(cls.hosts, list): for host in cls.hosts: Host.enableMaintenance( cls.api_client, id=host.id ) timeout = cls.services["timeout"] while True: time.sleep(cls.services["sleep"]) hosts_states = Host.list( cls.api_client, id=host.id, listall=True ) if hosts_states[ 0].resourcestate == 'PrepareForMaintenance': # Wait for sometimetill host goes in maintenance state time.sleep(cls.services["sleep"]) elif hosts_states[0].resourcestate == 'Maintenance': time.sleep(cls.services["sleep"]) break elif timeout == 0: raise unittest.SkipTest( "Failed to enable maintenance mode on %s" % host.name) timeout = timeout - 1 cls._cleanup = [ cls.vpc_off ] return
def setUpClass(cls): cls.testClient = super(TestVMLifeCycleHostmaintenance, cls).getClsTestClient() cls.api_client = cls.testClient.getApiClient() cls.services = Services().services # Get Zone, Domain and templates 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.services["virtual_machine"]["zoneid"] = cls.zone.id cls.services["virtual_machine"]["template"] = cls.template.id clusterWithSufficientHosts = None clusters = Cluster.list(cls.api_client, zoneid=cls.zone.id) for cluster in clusters: cls.hosts = Host.list(cls.api_client, clusterid=cluster.id) if len(cls.hosts) >= 2: clusterWithSufficientHosts = cluster if clusterWithSufficientHosts is None: raise unittest.SkipTest("No Cluster with 2 hosts found") Host.update(cls.api_client, id=cls.hosts[0].id, hosttags="hosttag1") Host.update(cls.api_client, id=cls.hosts[1].id, hosttags="hosttag2") cls.service_offering_1 = ServiceOffering.create(cls.api_client, cls.services["service_offering_1"]) cls.service_offering_2 = ServiceOffering.create(cls.api_client, cls.services["service_offering_2"]) cls.vpc_off = VpcOffering.create(cls.api_client, cls.services["vpc_offering"]) cls.vpc_off.update(cls.api_client, state="Enabled") cls.account = Account.create(cls.api_client, cls.services["account"], admin=True, domainid=cls.domain.id) cls.vpc_off = VpcOffering.create(cls.api_client, cls.services["vpc_offering"]) cls.vpc_off.update(cls.api_client, state="Enabled") cls.services["vpc"]["cidr"] = "10.1.1.1/16" cls.vpc = VPC.create( cls.api_client, cls.services["vpc"], vpcofferingid=cls.vpc_off.id, zoneid=cls.zone.id, account=cls.account.name, domainid=cls.account.domainid, ) cls.nw_off = NetworkOffering.create(cls.api_client, cls.services["network_offering"], conservemode=False) # Enable Network offering cls.nw_off.update(cls.api_client, state="Enabled") # Creating network using the network offering created cls.network_1 = Network.create( cls.api_client, cls.services["network"], accountid=cls.account.name, domainid=cls.account.domainid, networkofferingid=cls.nw_off.id, zoneid=cls.zone.id, gateway="10.1.1.1", vpcid=cls.vpc.id, ) cls.nw_off_no_lb = NetworkOffering.create( cls.api_client, cls.services["network_offering_no_lb"], conservemode=False ) # Enable Network offering cls.nw_off_no_lb.update(cls.api_client, state="Enabled") # Creating network using the network offering created cls.network_2 = Network.create( cls.api_client, cls.services["network"], accountid=cls.account.name, domainid=cls.account.domainid, networkofferingid=cls.nw_off_no_lb.id, zoneid=cls.zone.id, gateway="10.1.2.1", vpcid=cls.vpc.id, ) # Spawn an instance in that network cls.vm_1 = VirtualMachine.create( cls.api_client, cls.services["virtual_machine"], accountid=cls.account.name, domainid=cls.account.domainid, serviceofferingid=cls.service_offering_1.id, networkids=[str(cls.network_1.id)], ) # Spawn an instance in that network cls.vm_2 = VirtualMachine.create( cls.api_client, cls.services["virtual_machine"], accountid=cls.account.name, domainid=cls.account.domainid, serviceofferingid=cls.service_offering_1.id, networkids=[str(cls.network_1.id)], ) cls.vm_3 = VirtualMachine.create( cls.api_client, cls.services["virtual_machine"], accountid=cls.account.name, domainid=cls.account.domainid, serviceofferingid=cls.service_offering_2.id, networkids=[str(cls.network_2.id)], ) routers = Router.list(cls.api_client, account=cls.account.name, domainid=cls.account.domainid, listall=True) if isinstance(routers, list): cls.vpcvr = routers[0] cls._cleanup = [cls.service_offering_1, cls.service_offering_2, cls.nw_off, cls.nw_off_no_lb] return
def setUpClass(cls): cls.testClient = super(TestUserPrivateGateways, cls).getClsTestClient() cls.apiclient = cls.testClient.getApiClient() cls.apiclient = cls.testClient.getApiClient() cls.services = cls.testClient.getParsedTestDataConfig() zone = get_zone(cls.apiclient, cls.testClient.getZoneForTests()) cls.zone = Zone(zone.__dict__) cls.template = get_template(cls.apiclient, cls.zone.id) cls._cleanup = [] cls.logger = logging.getLogger("TestUserPrivateGateways") cls.stream_handler = logging.StreamHandler() cls.logger.setLevel(logging.DEBUG) cls.logger.addHandler(cls.stream_handler) cls.domain = get_domain(cls.apiclient) # Create small service offering cls.service_offering = ServiceOffering.create( cls.apiclient, cls.services["service_offerings"]["small"]) cls._cleanup.append(cls.service_offering) # Create network offering for isolated networks cls.network_offering_isolated = NetworkOffering.create( cls.apiclient, cls.services["network_offering"]) cls.network_offering_isolated.update(cls.apiclient, state='Enabled') cls._cleanup.append(cls.network_offering_isolated) # Create vpc offering cls.vpc_offering = VpcOffering.create( cls.apiclient, cls.services["vpc_offering_multi_lb"]) cls.vpc_offering.update(cls.apiclient, state='Enabled') cls._cleanup.append(cls.vpc_offering) # Create network offering for vpc tiers cls.network_offering_vpc = NetworkOffering.create( cls.apiclient, cls.services["nw_offering_isolated_vpc"], conservemode=False) cls.network_offering_vpc.update(cls.apiclient, state='Enabled') cls._cleanup.append(cls.network_offering_vpc) # Create sub-domain cls.sub_domain = Domain.create(cls.apiclient, cls.services["acl"]["domain1"]) cls._cleanup.append(cls.sub_domain) # Create domain admin and normal user cls.domain_admin = Account.create(cls.apiclient, cls.services["acl"]["accountD1A"], admin=True, domainid=cls.sub_domain.id) cls._cleanup.append(cls.domain_admin) cls.normal_user = Account.create(cls.apiclient, cls.services["acl"]["accountD1B"], domainid=cls.sub_domain.id) cls._cleanup.append(cls.normal_user) # Create project cls.project = Project.create(cls.apiclient, cls.services["project"], account=cls.domain_admin.name, domainid=cls.domain_admin.domainid) cls._cleanup.append(cls.project) # Create api clients for domain admin and normal user cls.domainadmin_user = cls.domain_admin.user[0] cls.domainapiclient = cls.testClient.getUserApiClient( cls.domainadmin_user.username, cls.sub_domain.name) cls.normaluser_user = cls.normal_user.user[0] cls.normaluser_apiclient = cls.testClient.getUserApiClient( cls.normaluser_user.username, cls.sub_domain.name)
def setUpClass(cls): cls.testClient = super(TestPublicIp, cls).getClsTestClient() cls.apiclient = cls.testClient.getApiClient() cls.services = cls.testClient.getParsedTestDataConfig() # Get Zone, Domain and templates cls.zone = get_zone(cls.apiclient, cls.testClient.getZoneForTests()) cls.services['mode'] = cls.zone.networktype cls.logger = logging.getLogger("TestPublicIp") cls.domain = get_domain(cls.apiclient) cls.services["virtual_machine"]["zoneid"] = cls.zone.id cls.template = get_template( cls.apiclient, cls.zone.id, cls.services["ostype"] ) cls.use_system_ips_config_name = "use.system.public.ips" cls.use_system_ips_config = Configurations.list( cls.apiclient, name=cls.use_system_ips_config_name ) cls.use_system_ips_config_value = cls.use_system_ips_config[0].value Configurations.update( cls.apiclient, name=cls.use_system_ips_config_name, value="false" ) cls._cleanup = [] cls.unsupportedHypervisor = False cls.hypervisor = cls.testClient.getHypervisorInfo() if cls.hypervisor.lower() in ['lxc']: cls.unsupportedHypervisor = True return # Create new domain1 cls.domain1 = Domain.create( cls.apiclient, services=cls.services["acl"]["domain1"], parentdomainid=cls.domain.id) # Create account1 cls.account1 = Account.create( cls.apiclient, cls.services["account"], # cls.services["acl"]["accountD1"], admin=True, domainid=cls.domain1.id ) # Create new sub-domain cls.sub_domain = Domain.create( cls.apiclient, services=cls.services["acl"]["domain11"], parentdomainid=cls.domain1.id) # Create account for sub-domain cls.sub_account = Account.create( cls.apiclient, cls.services["acl"]["accountD11"], domainid=cls.sub_domain.id ) # Create new domain2 cls.domain2 = Domain.create( cls.apiclient, services=cls.services["acl"]["domain2"], parentdomainid=cls.domain.id) # Create account2 cls.account2 = Account.create( cls.apiclient, cls.services["acl"]["accountD2"], domainid=cls.domain2.id ) cls.services["publiciprange"]["zoneid"] = cls.zone.id cls.services["publiciprange"]["forvirtualnetwork"] = "true" # Create public ip range 1 cls.services["publiciprange"]["vlan"] = get_free_vlan( cls.apiclient, cls.zone.id)[1] random_subnet_number = random.randrange(10,20) cls.services["publiciprange"]["gateway"] = "10.100." + \ str(random_subnet_number) + ".254" cls.services["publiciprange"]["startip"] = "10.100." + \ str(random_subnet_number) + ".1" cls.services["publiciprange"]["endip"] = "10.100." + \ str(random_subnet_number) + ".10" cls.services["publiciprange"]["netmask"] = "255.255.255.0" cls.public_ip_range1 = PublicIpRange.create( cls.apiclient, cls.services["publiciprange"], account=cls.account1.name, domainid=cls.account1.domainid ) # dedicate ip range to sub domain cls.services["publiciprange"]["vlan"] = get_free_vlan( cls.apiclient, cls.zone.id)[1] random_subnet_number = random.randrange(10,20) cls.services["publiciprange"]["gateway"] = "10.110." + \ str(random_subnet_number) + ".254" cls.services["publiciprange"]["startip"] = "10.110." + \ str(random_subnet_number) + ".1" cls.services["publiciprange"]["endip"] = "10.110." + \ str(random_subnet_number) + ".10" cls.services["publiciprange"]["netmask"] = "255.255.255.0" cls.public_ip_range2 = PublicIpRange.create( cls.apiclient, cls.services["publiciprange"], account=cls.sub_account.name, domainid=cls.sub_account.domainid ) # dedicate ip range to second domain cls.services["publiciprange"]["vlan"] = get_free_vlan( cls.apiclient, cls.zone.id)[1] random_subnet_number = random.randrange(10,20) cls.services["publiciprange"]["gateway"] = "10.120." + \ str(random_subnet_number) + ".254" cls.services["publiciprange"]["startip"] = "10.120." + \ str(random_subnet_number) + ".1" cls.services["publiciprange"]["endip"] = "10.120." + \ str(random_subnet_number) + ".10" cls.services["publiciprange"]["netmask"] = "255.255.255.0" cls.public_ip_range3 = PublicIpRange.create( cls.apiclient, cls.services["publiciprange"], account=cls.account2.name, domainid=cls.account2.domainid ) # create vpc offering and VPC cls.vpc_off = VpcOffering.create( cls.apiclient, cls.services["vpc_offering"] ) cls.vpc_off.update(cls.apiclient, state='Enabled') # create network offering cls.isolated_network_offering = NetworkOffering.create( cls.apiclient, cls.services["isolated_network_offering"], conservemode=False ) NetworkOffering.update( cls.isolated_network_offering, cls.apiclient, id=cls.isolated_network_offering.id, state="enabled" ) physical_network, shared_vlan = get_free_vlan( cls.apiclient, cls.zone.id) if shared_vlan is None: cls.fail("Failed to get free vlan id for shared network") cls.services["shared_network_offering"]["specifyVlan"] = "True" cls.services["shared_network_offering"]["specifyIpRanges"] = "True" cls.shared_network_offering = NetworkOffering.create( cls.apiclient, cls.services["shared_network_offering"], conservemode=False ) NetworkOffering.update( cls.shared_network_offering, cls.apiclient, id=cls.shared_network_offering.id, state="enabled" ) # create network using the shared network offering created cls.services["shared_network"]["acltype"] = "Domain" cls.services["shared_network"][ "networkofferingid"] = cls.shared_network_offering.id cls.services["shared_network"][ "physicalnetworkid"] = physical_network.id cls.services["shared_network"]["vlan"] = shared_vlan shared_network_subnet_number = random.randrange(1, 254) cls.services["shared_network"]["netmask"] = "255.255.255.0" cls.services["shared_network"]["gateway"] = "172.16." + \ str(shared_network_subnet_number) + ".254" cls.services["shared_network"]["startip"] = "172.16." + \ str(shared_network_subnet_number) + ".1" cls.services["shared_network"]["endip"] = "172.16." + \ str(shared_network_subnet_number) + ".10" cls.guest_network = Network.create( cls.apiclient, cls.services["shared_network"], networkofferingid=cls.shared_network_offering.id, zoneid=cls.zone.id ) cls._cleanup.append(cls.guest_network) cls._cleanup.append(cls.shared_network_offering) cls._cleanup.append(cls.account1) cls._cleanup.append(cls.account2) cls._cleanup.append(cls.sub_account) cls._cleanup.append(cls.sub_domain) cls._cleanup.append(cls.domain1) cls._cleanup.append(cls.domain2) cls._cleanup.append(cls.public_ip_range1) cls._cleanup.append(cls.public_ip_range2) cls._cleanup.append(cls.public_ip_range3)