Esempio n. 1
0
    def test_01_create_redundant_VPC_2tiers_4VMs_4IPs_4PF_ACL(self):
        """ Create a redundant VPC with two networks with two VMs in each network """
        self.logger.debug(
            "Starting test_01_create_redundant_VPC_2tiers_4VMs_4IPs_4PF_ACL")
        self.query_routers()
        net_off = get_default_network_offering(self.apiclient)
        self.networks.append(self.create_network(net_off, "10.1.1.1"))
        net_off_no_lb = get_default_network_offering_no_load_balancer(
            self.apiclient)
        self.networks.append(self.create_network(net_off_no_lb, "10.1.2.1"))
        self.check_routers_state()
        self.add_nat_rules()
        self.do_vpc_test(False)

        self.stop_router_by_type("MASTER")
        self.check_routers_state(1)
        self.do_vpc_test(False)

        self.delete_nat_rules()
        self.check_routers_state(count=1)
        self.do_vpc_test(True)
        self.delete_public_ip()

        self.start_routers()
        self.add_nat_rules()
        self.check_routers_state()
        self.do_vpc_test(False)
    def setUpClass(cls, redundant=False):
        cls.logger = MarvinLog(MarvinLog.LOGGER_TEST).get_logger()

        test_client = super(TestVpcVpn, cls).getClsTestClient()
        cls.apiclient = test_client.getApiClient()
        cls.services = test_client.getParsedTestDataConfig()

        cls.zone = get_zone(cls.apiclient, test_client.getZoneForTests())
        cls.domain = get_domain(cls.apiclient)

        cls.vpc_offering = get_default_redundant_vpc_offering(cls.apiclient) if redundant else get_default_vpc_offering(cls.apiclient)
        cls.logger.debug("VPC Offering '%s' selected", cls.vpc_offering.name)

        cls.network_offering = get_default_network_offering(cls.apiclient)
        cls.logger.debug("Network Offering '%s' selected", cls.network_offering.name)

        cls.virtual_machine_offering = get_default_virtual_machine_offering(cls.apiclient)
        cls.logger.debug("Virtual Machine Offering '%s' selected", cls.virtual_machine_offering.name)

        cls.account = Account.create(cls.apiclient, services=cls.services["account"])
        cls.logger.debug("Successfully created account: %s, id: %s" % (cls.account.name, cls.account.id))

        cls.hypervisor = test_client.getHypervisorInfo()

        cls._cleanup = [cls.account]

        cls.template = get_template(
            cls.apiclient,
            cls.zone.id
        )

        return
Esempio n. 3
0
    def perform_password_service_tests(self, vpc_off):

        if vpc_off is None:
            self.logger.debug("No need to create a VPC, creating isolated network")
            network_1 = self.createIsolatedNetwork()
            vpc_1 = None
        else:
            self.logger.debug("Creating VPC with offering ID %s" % vpc_off.id)
            vpc_1 = self.createVPC(vpc_off, cidr='10.0.0.0/16')
            self.logger.debug("Creating network inside VPC")
            net_off = get_default_network_offering(self.apiclient)
            network_1 = self.createNetwork(vpc_1, net_off, gateway='10.0.0.1')
            acl1 = self.createACL(vpc_1)
            self.createACLItem(acl1.id, cidr="0.0.0.0/0")
            self.replaceNetworkAcl(acl1.id, network_1)

        routers = list_routers(self.apiclient, account=self.account.name, domainid=self.account.domainid)
        for router in routers:
            self._perform_password_service_test(router, network_1)

        # Do the same after restart with cleanup
        if vpc_off is None:
            self.restart_network_with_cleanup(network_1, True)
        else:
            self.restart_vpc_with_cleanup(vpc_1, True)

        self.logger.debug("Getting the router info again after the cleanup (router names / ip addresses changed)")
        routers = list_routers(self.apiclient, account=self.account.name, domainid=self.account.domainid)

        self.assertEqual(isinstance(routers, list), True,
                         "Check for list routers response return valid data")
        self.logger.debug("Check whether routers are happy")

        for router in routers:
            self._perform_password_service_test(router, network_1)
    def test_01_create_redundant_VPC_2tiers_4VMs_4IPs_4PF_ACL(self):
        """ Create a redundant VPC with two networks with two VMs in each network """
        self.logger.debug("Starting test_01_create_redundant_VPC_2tiers_4VMs_4IPs_4PF_ACL")
        self.query_routers()
        net_off = get_default_network_offering(self.apiclient)
        self.networks.append(self.create_network(net_off, "10.1.1.1"))
        net_off_no_lb = get_default_network_offering_no_load_balancer(self.apiclient)
        self.networks.append(self.create_network(net_off_no_lb, "10.1.2.1"))
        self.check_routers_state()
        self.add_nat_rules()
        self.do_vpc_test(False)

        self.stop_router_by_type("MASTER")
        self.check_routers_state(1)
        self.do_vpc_test(False)

        self.delete_nat_rules()
        self.check_routers_state(count=1)
        self.do_vpc_test(True)
        self.delete_public_ip()

        self.start_routers()
        self.add_nat_rules()
        self.check_routers_state()
        self.do_vpc_test(False)
    def perform_dnsmasq_service_dns_tests(self, vpc_off):
        self.logger.debug("Creating VPC with offering ID %s" % vpc_off.id)
        vpc_1 = self.createVPC(vpc_off, cidr='10.0.0.0/16')
        self.logger.debug("Creating network inside VPC")
        net_off = get_default_network_offering(self.apiclient)
        network_1 = self.createNetwork(vpc_1, net_off, gateway='10.0.0.1')
        acl1 = self.createACL(vpc_1)
        self.createACLItem(acl1.id, cidr="0.0.0.0/0")
        self.replaceNetworkAcl(acl1.id, network_1)

        routers = list_routers(self.apiclient, account=self.account.name, domainid=self.account.domainid)
        for router in routers:
            if router.redundantstate == 'MASTER' or len(routers) == 1:
                self._perform_dnsmasq_service_dns_test(router, network_1)

        # Do the same after restart with cleanup
        self.restart_vpc_with_cleanup(vpc_1, True)

        self.logger.debug("Getting the router info again after the cleanup (router names / ip addresses changed)")
        routers = list_routers(self.apiclient, account=self.account.name, domainid=self.account.domainid)

        self.assertEqual(isinstance(routers, list), True,
                         "Check for list routers response return valid data")
        self.logger.debug("Check whether routers are happy")

        for router in routers:
            if router.redundantstate == 'MASTER' or len(routers) == 1:
                self._perform_dnsmasq_service_dns_test(router, network_1)
    def perform_password_service_tests(self, vpc_off):
        self.enable_template_password(
            template_id=self.template.id,
            passwordenabled=True)
        self.logger.debug("Creating VPC with offering ID %s" % vpc_off.id)
        vpc_1 = self.createVPC(vpc_off, cidr='10.0.0.0/16')
        self.logger.debug("Creating network inside VPC")
        net_off = get_default_network_offering(self.apiclient)
        network_1 = self.createNetwork(vpc_1, net_off, gateway='10.0.0.1')
        acl1 = self.createACL(vpc_1)
        self.createACLItem(acl1.id, cidr="0.0.0.0/0")
        self.replaceNetworkAcl(acl1.id, network_1)

        routers = list_routers(self.apiclient, account=self.account.name, domainid=self.account.domainid)
        for router in routers:
            if router.redundantstate == 'MASTER' or len(routers) == 1:
                self._perform_password_service_test(router, network_1)

        # Do the same after restart with cleanup
        self.restart_vpc_with_cleanup(vpc_1, True)

        self.logger.debug("Getting the router info again after the cleanup (router names / ip addresses changed)")
        routers = list_routers(self.apiclient, account=self.account.name, domainid=self.account.domainid)

        self.assertEqual(isinstance(routers, list), True,
                         "Check for list routers response return valid data")
        self.logger.debug("Check whether routers are happy")

        for router in routers:
            if router.redundantstate == 'MASTER' or len(routers) == 1:
                self._perform_password_service_test(router, network_1)
        self.enable_template_password(
            template_id=self.template.id,
            passwordenabled=False)
Esempio n. 7
0
    def test_04_rvpc_multi_tiers(self):
        """ Create a redundant VPC with 3 Tiers, 3 VMs, 3 PF rules"""
        self.logger.debug("Starting test_05_rvpc_multi_tiers")
        self.query_routers()

        net_off = get_default_network_offering(self.apiclient)
        network1 = self.create_network(net_off, "10.1.1.1", nr_vms=1)
        self.networks.append(network1)
        net_off_no_lb = get_default_network_offering_no_load_balancer(
            self.apiclient)
        self.networks.append(
            self.create_network(net_off_no_lb, "10.1.2.1", nr_vms=1))
        network2 = self.create_network(net_off_no_lb, "10.1.3.1", nr_vms=1)
        self.networks.append(network2)

        self.check_routers_state()
        self.add_nat_rules()
        self.do_vpc_test(False)

        self.destroy_vm(network1)
        network1.get_net().delete(self.apiclient)
        self.networks.remove(network1)

        self.check_routers_state(status_to_check="MASTER")
        self.do_vpc_test(False)

        self.destroy_vm(network2)
        network2.get_net().delete(self.apiclient)
        self.networks.remove(network2)

        self.check_routers_state(status_to_check="MASTER")
        self.do_vpc_test(False)
Esempio n. 8
0
    def test_01_VPC_nics_after_destroy(self):
        """ Create a VPC with two networks with one VM in each network and test nics after destroy"""
        self.logger.debug("Starting test_01_VPC_nics_after_destroy")
        self.query_routers()

        net_off = get_default_network_offering(self.apiclient)
        net1 = self.create_network(net_off, "10.1.1.1")
        net_off_no_lb = get_default_network_offering_no_load_balancer(
            self.apiclient)
        net2 = self.create_network(net_off_no_lb, "10.1.2.1")

        self.networks.append(net1)
        self.networks.append(net2)

        self.add_nat_rules()
        self.check_ssh_into_vm()

        self.destroy_routers()
        time.sleep(30)

        net1.add_vm(self.deployvm_in_network(net1.get_net()))
        self.query_routers()

        self.add_nat_rules()
        self.check_ssh_into_vm()
    def _test_04_rvpc_multi_tiers(self):
        """ Create a redundant VPC with 3 Tiers, 3 VMs, 3 PF rules"""
        self.logger.debug("Starting test_04_rvpc_multi_tiers")
        self.query_routers()

        net_off = get_default_network_offering(self.apiclient)
        network1 = self.create_network(net_off, "10.1.1.1", nr_vms=1)
        self.networks.append(network1)
        net_off_no_lb = get_default_network_offering_no_load_balancer(self.apiclient)
        self.networks.append(self.create_network(net_off_no_lb, "10.1.2.1", nr_vms=1))
        network2 = self.create_network(net_off_no_lb, "10.1.3.1", nr_vms=1)
        self.networks.append(network2)

        self.check_routers_state()
        self.add_nat_rules()
        self.do_vpc_test(False)

        self.destroy_vm(network1)
        network1.get_net().delete(self.apiclient)
        self.networks.remove(network1)

        self.check_routers_state(status_to_check="MASTER")
        self.do_vpc_test(False)

        self.destroy_vm(network2)
        network2.get_net().delete(self.apiclient)
        self.networks.remove(network2)

        self.check_routers_state(status_to_check="MASTER")
        self.do_vpc_test(False)
Esempio n. 10
0
    def test_04_rvpc_network_garbage_collector_nics(self):
        """ Create a redundant VPC with 1 Tier, 1 VM, 1 ACL, 1 PF and test Network GC Nics"""
        self.logger.debug("Starting test_04_rvpc_network_garbage_collector_nics")
        self.query_routers()
        net_off = get_default_network_offering(self.apiclient)
        self.networks.append(self.create_network(net_off, "10.1.1.1", nr_vms=1))
        self.check_routers_state()
        self.add_nat_rules()
        self.do_vpc_test(False)

        self.stop_vm()

        gc_wait = Configurations.list(self.apiclient, name="network.gc.wait")
        gc_interval = Configurations.list(self.apiclient, name="network.gc.interval")

        self.logger.debug("network.gc.wait is ==> %s" % gc_wait)
        self.logger.debug("network.gc.interval is ==> %s" % gc_wait)

        total_sleep = 120
        if gc_wait and gc_interval:
            total_sleep = int(gc_wait[0].value) + int(gc_interval[0].value)
        else:
            self.logger.debug("Could not retrieve the keys 'network.gc.interval' and 'network.gc.wait'. Sleeping for 2 minutes.")

        time.sleep(total_sleep * 3)

        self.check_routers_interface(interface_to_check="eth2", expected_exists=False)
        self.start_vm()
        self.check_routers_state(status_to_check="MASTER")
        self.check_routers_interface(interface_to_check="eth2", expected_exists=True)
    def setUpClass(cls):
        cls.logger = MarvinLog(MarvinLog.LOGGER_TEST).get_logger()

        # We want to fail quicker if it's failure
        socket.setdefaulttimeout(60)

        cls.testClient = super(TestRouterIpTablesPolicies, cls).getClsTestClient()
        cls.apiclient = cls.testClient.getApiClient()

        cls.services = cls.testClient.getParsedTestDataConfig()
        # Get Zone, Domain and templates
        cls.domain = get_domain(cls.apiclient)
        cls.zone = get_zone(cls.apiclient, cls.testClient.getZoneForTests())
        cls.template = get_template(
            cls.apiclient,
            cls.zone.id
        )
        cls.services["vpc"]["cidr"] = '10.1.1.1/16'
        cls.services["virtual_machine"]["zoneid"] = cls.zone.id
        cls.services["virtual_machine"]["template"] = cls.template.id
        cls.vpc_offering = get_default_vpc_offering(cls.apiclient)
        cls.logger.debug("VPC Offering '%s' selected", cls.vpc_offering.name)

        cls.network_offering = get_default_network_offering(cls.apiclient)
        cls.logger.debug("Network Offering '%s' selected", cls.network_offering.name)

        cls.default_allow_acl = get_network_acl(cls.apiclient, 'default_allow')
        cls.logger.debug("ACL '%s' selected", cls.default_allow_acl.name)

        cls.account = Account.create(
            cls.apiclient,
            cls.services["account"],
            admin=True,
            domainid=cls.domain.id)
        cls.vpc1 = VPC.create(cls.apiclient,
                               cls.services['vpcs']['vpc1'],
                               vpcofferingid=cls.vpc_offering.id,
                               zoneid=cls.zone.id,
                               domainid=cls.domain.id,
                               account=cls.account.name)
        cls.logger.debug("VPC '%s' created, CIDR: %s", cls.vpc1.name, cls.vpc1.cidr)

        cls.network1 = Network.create(cls.apiclient,
                                       cls.services['networks']['network1'],
                                       networkofferingid=cls.network_offering.id,
                                       aclid=cls.default_allow_acl.id,
                                       vpcid=cls.vpc1.id,
                                       zoneid=cls.zone.id,
                                       domainid=cls.domain.id,
                                       accountid=cls.account.name)
        cls.logger.debug("Network '%s' created, CIDR: %s, Gateway: %s", cls.network1.name, cls.network1.cidr, cls.network1.gateway)

        cls.service_offering = get_default_virtual_machine_offering(cls.apiclient)

        cls.entity_manager = EntityManager(cls.apiclient, cls.services, cls.service_offering, cls.account, cls.zone, cls.network1, cls.logger)

        cls._cleanup = [cls.account]
        return
    def test_01_single_VPC_iptables_policies(self):
        """ Test iptables default INPUT/FORWARD policies on VPC router """
        self.logger.debug("Starting test_01_single_VPC_iptables_policies")

        routers = self.entity_manager.query_routers()

        self.assertEqual(
            isinstance(routers, list), True,
            "Check for list routers response return valid data")

        net_off = get_default_network_offering(self.apiclient)
        self.entity_manager.create_network(net_off, self.vpc.id, "10.1.1.1")
        net_off_no_lb = get_default_network_offering_no_load_balancer(self.apiclient)
        self.entity_manager.create_network(net_off_no_lb, self.vpc.id, "10.1.2.1")

        self.entity_manager.add_nat_rules(self.vpc.id)
        self.entity_manager.do_vpc_test()

        for router in routers:
            if not router.isredundantrouter and router.vpcid:
                hosts = list_hosts(
                    self.apiclient,
                    id=router.hostid)
                self.assertEqual(
                    isinstance(hosts, list),
                    True,
                    "Check for list hosts response return valid data")

                host = hosts[0]
                host.user = self.services["configurableData"]["host"]["username"]
                host.passwd = self.services["configurableData"]["host"]["password"]
                host.port = self.services["configurableData"]["host"]["port"]
                tables = [self.services["configurableData"]["input"], self.services["configurableData"]["forward"]]

                for table in tables:
                    try:
                        result = get_process_status(
                            host.ipaddress,
                            host.port,
                            host.user,
                            host.passwd,
                            router.linklocalip,
                            'iptables -L %s' % table)
                    except KeyError:
                        self.skipTest(
                            "Provide a marvin config file with host\
                                    credentials to run %s" %
                            self._testMethodName)

                    self.logger.debug("iptables -L %s: %s" % (table, result))
                    res = str(result)

                    self.assertEqual(
                        res.count("policy DROP"),
                        1,
                        "%s Default Policy should be DROP" % table)
Esempio n. 13
0
    def test_01_single_VPC_iptables_policies(self):
        """ Test iptables default INPUT/FORWARD policies on VPC router """
        self.logger.debug("Starting test_01_single_VPC_iptables_policies")

        routers = self.entity_manager.query_routers()

        self.assertEqual(
            isinstance(routers, list), True,
            "Check for list routers response return valid data")

        net_off = get_default_network_offering(self.apiclient)
        self.entity_manager.create_network(net_off, self.vpc.id, "10.1.1.1")
        net_off_no_lb = get_default_network_offering_no_load_balancer(self.apiclient)
        self.entity_manager.create_network(net_off_no_lb, self.vpc.id, "10.1.2.1")

        self.entity_manager.add_nat_rules(self.vpc.id)
        self.entity_manager.do_vpc_test()

        for router in routers:
            if not router.isredundantrouter and router.vpcid:
                hosts = list_hosts(
                    self.apiclient,
                    id=router.hostid)
                self.assertEqual(
                    isinstance(hosts, list),
                    True,
                    "Check for list hosts response return valid data")

                host = hosts[0]
                host.user = self.services["configurableData"]["host"]["username"]
                host.passwd = self.services["configurableData"]["host"]["password"]
                host.port = self.services["configurableData"]["host"]["port"]
                tables = [self.services["configurableData"]["input"], self.services["configurableData"]["forward"]]

                for table in tables:
                    try:
                        result = get_process_status(
                            host.ipaddress,
                            host.port,
                            host.user,
                            host.passwd,
                            router.linklocalip,
                            'iptables -L %s' % table)
                    except KeyError:
                        self.skipTest(
                            "Provide a marvin config file with host\
                                    credentials to run %s" %
                            self._testMethodName)

                    self.logger.debug("iptables -L %s: %s" % (table, result))
                    res = str(result)

                    self.assertEqual(
                        res.count("DROP"),
                        1,
                        "%s Default Policy should be DROP" % table)
 def _test_02_redundant_VPC_default_routes(self):
     """ Create a redundant VPC with two networks with two VMs in each network and check default routes"""
     self.logger.debug("Starting test_02_redundant_VPC_default_routes")
     self.query_routers()
     net_off = get_default_network_offering(self.apiclient)
     self.networks.append(self.create_network(net_off, "10.1.1.1"))
     net_off_no_lb = get_default_network_offering_no_load_balancer(self.apiclient)
     self.networks.append(self.create_network(net_off_no_lb, "10.1.2.1"))
     self.check_routers_state()
     self.add_nat_rules()
     self.do_default_routes_test()
Esempio n. 15
0
 def test_02_redundant_VPC_default_routes(self):
     """ Create a redundant VPC with two networks with two VMs in each network and check default routes"""
     self.logger.debug("Starting test_02_redundant_VPC_default_routes")
     self.query_routers()
     net_off = get_default_network_offering(self.apiclient)
     self.networks.append(self.create_network(net_off, "10.1.1.1"))
     net_off_no_lb = get_default_network_offering_no_load_balancer(self.apiclient)
     self.networks.append(self.create_network(net_off_no_lb, "10.1.2.1"))
     self.check_routers_state()
     self.add_nat_rules()
     self.do_default_routes_test()
    def test_02_VPC_default_routes(self):
        """ Create a VPC with two networks with one VM in each network and test default routes"""
        self.logger.debug("Starting test_02_VPC_default_routes")
        self.query_routers()

        net_off = get_default_network_offering(self.apiclient)
        net1 = self.create_network(net_off, "10.1.1.1")
        net_off_no_lb = get_default_network_offering_no_load_balancer(self.apiclient)
        net2 = self.create_network(net_off_no_lb, "10.1.2.1")

        self.networks.append(net1)
        self.networks.append(net2)

        self.add_nat_rules()
        self.do_default_routes_test()
Esempio n. 17
0
    def test_02_VPC_default_routes(self):
        """ Create a VPC with two networks with one VM in each network and test default routes"""
        self.logger.debug("Starting test_02_VPC_default_routes")
        self.query_routers()

        net_off = get_default_network_offering(self.apiclient)
        net1 = self.create_network(net_off, "10.1.1.1")
        net_off_no_lb = get_default_network_offering_no_load_balancer(
            self.apiclient)
        net2 = self.create_network(net_off_no_lb, "10.1.2.1")

        self.networks.append(net1)
        self.networks.append(net2)

        self.add_nat_rules()
        self.do_default_routes_test()
    def _test_03_create_redundant_VPC_1tier_2VMs_2IPs_2PF_ACL_reboot_routers(self):
        """ Create a redundant VPC with two networks with two VMs in each network """
        self.logger.debug("Starting test_01_create_redundant_VPC_2tiers_4VMs_4IPs_4PF_ACL")
        self.query_routers()
        net_off = get_default_network_offering(self.apiclient)
        self.networks.append(self.create_network(net_off, "10.1.1.1"))
        self.check_routers_state()
        self.add_nat_rules()
        self.do_vpc_test(False)

        self.reboot_router_by_type("MASTER")
        self.check_routers_state()
        self.do_vpc_test(False)

        self.reboot_router_by_type("MASTER")
        self.check_routers_state()
        self.do_vpc_test(False)
Esempio n. 19
0
    def test_03_create_redundant_VPC_1tier_2VMs_2IPs_2PF_ACL_reboot_routers(self):
        """ Create a redundant VPC with two networks with two VMs in each network """
        self.logger.debug("Starting test_01_create_redundant_VPC_2tiers_4VMs_4IPs_4PF_ACL")
        self.query_routers()
        net_off = get_default_network_offering(self.apiclient)
        self.networks.append(self.create_network(net_off, "10.1.1.1"))
        self.check_routers_state()
        self.add_nat_rules()
        self.do_vpc_test(False)

        self.reboot_router_by_type("MASTER")
        self.check_routers_state()
        self.do_vpc_test(False)

        self.reboot_router_by_type("MASTER")
        self.check_routers_state()
        self.do_vpc_test(False)
Esempio n. 20
0
    def setUpClass(cls, redundant=False):
        cls.logger = MarvinLog(MarvinLog.LOGGER_TEST).get_logger()

        test_client = super(TestVpcVpn, cls).getClsTestClient()
        cls.apiclient = test_client.getApiClient()
        cls.services = test_client.getParsedTestDataConfig()

        cls.zone = get_zone(cls.apiclient, test_client.getZoneForTests())
        cls.domain = get_domain(cls.apiclient)

        cls.vpc_offering = get_default_redundant_vpc_offering(
            cls.apiclient) if redundant else get_default_vpc_offering(
                cls.apiclient)
        cls.logger.debug("VPC Offering '%s' selected", cls.vpc_offering.name)

        cls.network_offering = get_default_network_offering(cls.apiclient)
        cls.logger.debug("Network Offering '%s' selected",
                         cls.network_offering.name)

        cls.virtual_machine_offering = get_default_virtual_machine_offering(
            cls.apiclient)
        cls.logger.debug("Virtual Machine Offering '%s' selected",
                         cls.virtual_machine_offering.name)

        cls.account = Account.create(cls.apiclient,
                                     services=cls.services["account"])
        cls.logger.debug("Successfully created account: %s, id: %s" %
                         (cls.account.name, cls.account.id))

        cls.hypervisor = test_client.getHypervisorInfo()

        cls._cleanup = [cls.account]

        cls.template = get_template(cls.apiclient, cls.zone.id)

        return
    def test_01_VPC_nics_after_destroy(self):
        """ Create a VPC with two networks with one VM in each network and test nics after destroy"""
        self.logger.debug("Starting test_01_VPC_nics_after_destroy")
        self.query_routers()

        net_off = get_default_network_offering(self.apiclient)
        net1 = self.create_network(net_off, "10.1.1.1")
        net_off_no_lb = get_default_network_offering_no_load_balancer(self.apiclient)
        net2 = self.create_network(net_off_no_lb, "10.1.2.1")

        self.networks.append(net1)
        self.networks.append(net2)

        self.add_nat_rules()
        self.check_ssh_into_vm()

        self.destroy_routers()
        time.sleep(30)

        net1.add_vm(self.deployvm_in_network(net1.get_net()))
        self.query_routers()

        self.add_nat_rules()
        self.check_ssh_into_vm()
    def setUpClass(cls):
        cls.logger = MarvinLog(MarvinLog.LOGGER_TEST).get_logger()
        testClient = super(TestLoadBalance, cls).getClsTestClient()
        cls.apiclient = testClient.getApiClient()
        cls.services = testClient.getParsedTestDataConfig()

        # Get Zone, Domain and templates
        cls.domain = get_domain(cls.apiclient)
        cls.zone = get_zone(cls.apiclient, testClient.getZoneForTests())
        cls.template = get_template(
            cls.apiclient,
            cls.zone.id
        )
        if cls.template == FAILED:
            assert False, "get_template() failed to return template with description %s" % cls.services["ostype"]

        cls.services["virtual_machine"]["zoneid"] = cls.zone.id

        # Create an account, network, VM and IP addresses
        cls.account = Account.create(
            cls.apiclient,
            cls.services["account"],
            admin=True,
            domainid=cls.domain.id
        )
        cls.service_offering = get_default_virtual_machine_offering(cls.apiclient)

        cls.network_offering = get_default_network_offering(cls.apiclient)
        cls.logger.debug("Network Offering '%s' selected", cls.network_offering.name)

        cls.vpc_offering = get_default_vpc_offering(cls.apiclient)
        cls.logger.debug("VPC Offering '%s' selected", cls.vpc_offering.name)

        cls.vpc1 = VPC.create(cls.apiclient,
                               cls.services['vpcs']['vpc1'],
                               vpcofferingid=cls.vpc_offering.id,
                               zoneid=cls.zone.id,
                               domainid=cls.domain.id,
                               account=cls.account.name)
        cls.logger.debug("VPC '%s' created, CIDR: %s", cls.vpc1.name, cls.vpc1.cidr)

        cls.default_allow_acl = get_network_acl(cls.apiclient, 'default_allow')
        cls.logger.debug("ACL '%s' selected", cls.default_allow_acl.name)

        cls.network1 = Network.create(cls.apiclient,
                                       cls.services['networks']['network1'],
                                       networkofferingid=cls.network_offering.id,
                                       aclid=cls.default_allow_acl.id,
                                       vpcid=cls.vpc1.id,
                                       zoneid=cls.zone.id,
                                       domainid=cls.domain.id,
                                       accountid=cls.account.name)
        cls.logger.debug("Network '%s' created, CIDR: %s, Gateway: %s", cls.network1.name, cls.network1.cidr, cls.network1.gateway)

        cls.vm_1 = VirtualMachine.create(
            cls.apiclient,
            cls.services["virtual_machine"],
            templateid=cls.template.id,
            accountid=cls.account.name,
            domainid=cls.account.domainid,
            serviceofferingid=cls.service_offering.id,
            networkids=[cls.network1.id]
        )
        cls.vm_2 = VirtualMachine.create(
            cls.apiclient,
            cls.services["virtual_machine"],
            templateid=cls.template.id,
            accountid=cls.account.name,
            domainid=cls.account.domainid,
            serviceofferingid=cls.service_offering.id,
            networkids=[cls.network1.id]
        )
        cls.vm_3 = VirtualMachine.create(
            cls.apiclient,
            cls.services["virtual_machine"],
            templateid=cls.template.id,
            accountid=cls.account.name,
            domainid=cls.account.domainid,
            serviceofferingid=cls.service_offering.id,
            networkids=[cls.network1.id]
        )

        cls.non_src_nat_ip = PublicIPAddress.create(cls.apiclient,
            zoneid=cls.zone.id,
            domainid=cls.account.domainid,
            accountid=cls.account.name,
            vpcid=cls.vpc1.id,
            networkid=cls.network1.id)
        cls.logger.debug("Public IP '%s' acquired, VPC: %s, Network: %s", cls.non_src_nat_ip.ipaddress.ipaddress, cls.vpc1.name, cls.network1.name)

        command = replaceNetworkACLList.replaceNetworkACLListCmd()
        command.aclid = cls.default_allow_acl.id
        command.publicipid = cls.non_src_nat_ip.ipaddress.id
        cls.apiclient.replaceNetworkACLList(command)

        cls._cleanup = [
            cls.account
        ]
    def setUpClass(cls):
        cls.logger = MarvinLog(MarvinLog.LOGGER_TEST).get_logger()

        # We want to fail quicker if it's failure
        socket.setdefaulttimeout(60)

        cls.testClient = super(TestRouterIpTablesPolicies,
                               cls).getClsTestClient()
        cls.apiclient = cls.testClient.getApiClient()

        cls.services = cls.testClient.getParsedTestDataConfig()
        # Get Zone, Domain and templates
        cls.domain = get_domain(cls.apiclient)
        cls.zone = get_zone(cls.apiclient, cls.testClient.getZoneForTests())
        cls.template = get_template(cls.apiclient, cls.zone.id)
        cls.services["vpc"]["cidr"] = '10.1.1.1/16'
        cls.services["virtual_machine"]["zoneid"] = cls.zone.id
        cls.services["virtual_machine"]["template"] = cls.template.id
        cls.vpc_offering = get_default_vpc_offering(cls.apiclient)
        cls.logger.debug("VPC Offering '%s' selected", cls.vpc_offering.name)

        cls.network_offering = get_default_network_offering(cls.apiclient)
        cls.logger.debug("Network Offering '%s' selected",
                         cls.network_offering.name)

        cls.default_allow_acl = get_network_acl(cls.apiclient, 'default_allow')
        cls.logger.debug("ACL '%s' selected", cls.default_allow_acl.name)

        cls.account = Account.create(cls.apiclient,
                                     cls.services["account"],
                                     admin=True,
                                     domainid=cls.domain.id)
        cls.vpc1 = VPC.create(cls.apiclient,
                              cls.services['vpcs']['vpc1'],
                              vpcofferingid=cls.vpc_offering.id,
                              zoneid=cls.zone.id,
                              domainid=cls.domain.id,
                              account=cls.account.name)
        cls.logger.debug("VPC '%s' created, CIDR: %s", cls.vpc1.name,
                         cls.vpc1.cidr)

        cls.network1 = Network.create(
            cls.apiclient,
            cls.services['networks']['network1'],
            networkofferingid=cls.network_offering.id,
            aclid=cls.default_allow_acl.id,
            vpcid=cls.vpc1.id,
            zoneid=cls.zone.id,
            domainid=cls.domain.id,
            accountid=cls.account.name)
        cls.logger.debug("Network '%s' created, CIDR: %s, Gateway: %s",
                         cls.network1.name, cls.network1.cidr,
                         cls.network1.gateway)

        cls.service_offering = get_default_virtual_machine_offering(
            cls.apiclient)

        cls.entity_manager = EntityManager(cls.apiclient, cls.services,
                                           cls.service_offering, cls.account,
                                           cls.zone, cls.network1, cls.logger)

        cls._cleanup = [cls.account]
        return
    def setUp(self):
        self.logger = MarvinLog(MarvinLog.LOGGER_TEST).get_logger()

        self.apiclient = self.testClient.getApiClient()
        self.services = self.testClient.getParsedTestDataConfig()
        self.vpc_offering = get_default_vpc_offering(self.apiclient)
        self.network_offering = get_default_network_offering(self.apiclient)

        # Get Zone, Domain and templates
        self.domain = get_domain(self.apiclient)
        self.zone = get_zone(self.apiclient, self.testClient.getZoneForTests())
        template = get_template(
            self.apiclient,
            self.zone.id
        )
        self.services["virtual_machine"]["zoneid"] = self.zone.id

        # Create an account, network, VM, Port forwarding rule, LB rules
        self.account = Account.create(
            self.apiclient,
            self.services["account"],
            admin=True,
            domainid=self.domain.id
        )

        self.service_offering = get_default_virtual_machine_offering(self.apiclient)
        self.vpc = VPC.create(
            self.apiclient,
            self.services["vpc"],
            vpcofferingid=self.vpc_offering.id,
            zoneid=self.zone.id,
            account=self.account.name,
            domainid=self.account.domainid)

        ntwk = Network.create(
            api_client=self.apiclient,
            services=self.services["network_1"],
            accountid=self.account.name,
            domainid=self.domain.id,
            networkofferingid=self.network_offering.id,
            zoneid=self.zone.id,
            vpcid=self.vpc.id
        )

        networkids = []
        networkids.append(ntwk.id)

        self.virtual_machine = VirtualMachine.create(
            self.apiclient,
            self.services["virtual_machine"],
            templateid=template.id,
            accountid=self.account.name,
            domainid=self.account.domainid,
            serviceofferingid=self.service_offering.id,
            networkids=networkids
        )

        self.ip_address = PublicIPAddress.create(
            self.apiclient,
            self.account.name,
            self.zone.id,
            self.account.domainid,
            vpcid=self.vpc.id
        )

        ip_addrs = list_public_ip(
            self.apiclient,
            account=self.account.name,
            domainid=self.account.domainid,
            issourcenat=False
        )

        try:
            self.ip_addr = ip_addrs[0]
        except Exception as e:
            raise Exception(
                "Failed: During acquiring source NAT for account: %s, :%s" %
                (self.account.name, e))

        self.nat_rule = NATRule.create(
            self.apiclient,
            self.virtual_machine,
            self.services["natrule"],
            self.ip_addr.id,
            networkid=ntwk.id
        )
        self.lb_rule = LoadBalancerRule.create(
            self.apiclient,
            self.services["lbrule"],
            self.ip_addr.id,
            accountid=self.account.name,
            networkid=ntwk.id
        )
        self.cleanup = [
            self.virtual_machine,
            self.account
        ]
        return
Esempio n. 25
0
    def setUpClass(cls):
        cls.logger = MarvinLog(MarvinLog.LOGGER_TEST).get_logger()
        testClient = super(TestLoadBalance, cls).getClsTestClient()
        cls.apiclient = testClient.getApiClient()
        cls.services = testClient.getParsedTestDataConfig()

        # Get Zone, Domain and templates
        cls.domain = get_domain(cls.apiclient)
        cls.zone = get_zone(cls.apiclient, testClient.getZoneForTests())
        cls.template = get_template(cls.apiclient, cls.zone.id)
        if cls.template == FAILED:
            assert False, "get_template() failed to return template with description %s" % cls.services[
                "ostype"]

        cls.services["virtual_machine"]["zoneid"] = cls.zone.id

        # Create an account, network, VM and IP addresses
        cls.account = Account.create(cls.apiclient,
                                     cls.services["account"],
                                     admin=True,
                                     domainid=cls.domain.id)
        cls.service_offering = get_default_virtual_machine_offering(
            cls.apiclient)

        cls.network_offering = get_default_network_offering(cls.apiclient)
        cls.logger.debug("Network Offering '%s' selected",
                         cls.network_offering.name)

        cls.vpc_offering = get_default_vpc_offering(cls.apiclient)
        cls.logger.debug("VPC Offering '%s' selected", cls.vpc_offering.name)

        cls.vpc1 = VPC.create(cls.apiclient,
                              cls.services['vpcs']['vpc1'],
                              vpcofferingid=cls.vpc_offering.id,
                              zoneid=cls.zone.id,
                              domainid=cls.domain.id,
                              account=cls.account.name)
        cls.logger.debug("VPC '%s' created, CIDR: %s", cls.vpc1.name,
                         cls.vpc1.cidr)

        cls.default_allow_acl = get_network_acl(cls.apiclient, 'default_allow')
        cls.logger.debug("ACL '%s' selected", cls.default_allow_acl.name)

        cls.network1 = Network.create(
            cls.apiclient,
            cls.services['networks']['network1'],
            networkofferingid=cls.network_offering.id,
            aclid=cls.default_allow_acl.id,
            vpcid=cls.vpc1.id,
            zoneid=cls.zone.id,
            domainid=cls.domain.id,
            accountid=cls.account.name)
        cls.logger.debug("Network '%s' created, CIDR: %s, Gateway: %s",
                         cls.network1.name, cls.network1.cidr,
                         cls.network1.gateway)

        cls.vm_1 = VirtualMachine.create(
            cls.apiclient,
            cls.services["virtual_machine"],
            templateid=cls.template.id,
            accountid=cls.account.name,
            domainid=cls.account.domainid,
            serviceofferingid=cls.service_offering.id,
            networkids=[cls.network1.id])
        cls.vm_2 = VirtualMachine.create(
            cls.apiclient,
            cls.services["virtual_machine"],
            templateid=cls.template.id,
            accountid=cls.account.name,
            domainid=cls.account.domainid,
            serviceofferingid=cls.service_offering.id,
            networkids=[cls.network1.id])
        cls.vm_3 = VirtualMachine.create(
            cls.apiclient,
            cls.services["virtual_machine"],
            templateid=cls.template.id,
            accountid=cls.account.name,
            domainid=cls.account.domainid,
            serviceofferingid=cls.service_offering.id,
            networkids=[cls.network1.id])

        cls.non_src_nat_ip = PublicIPAddress.create(
            cls.apiclient,
            zoneid=cls.zone.id,
            domainid=cls.account.domainid,
            accountid=cls.account.name,
            vpcid=cls.vpc1.id,
            networkid=cls.network1.id)
        cls.logger.debug("Public IP '%s' acquired, VPC: %s, Network: %s",
                         cls.non_src_nat_ip.ipaddress.ipaddress, cls.vpc1.name,
                         cls.network1.name)

        command = replaceNetworkACLList.replaceNetworkACLListCmd()
        command.aclid = cls.default_allow_acl.id
        command.publicipid = cls.non_src_nat_ip.ipaddress.id
        cls.apiclient.replaceNetworkACLList(command)

        cls._cleanup = [cls.account]
Esempio n. 26
0
    def setUp(self):
        self.logger = MarvinLog(MarvinLog.LOGGER_TEST).get_logger()

        self.apiclient = self.testClient.getApiClient()
        self.services = self.testClient.getParsedTestDataConfig()
        self.vpc_offering = get_default_vpc_offering(self.apiclient)
        self.network_offering = get_default_network_offering(self.apiclient)

        # Get Zone, Domain and templates
        self.domain = get_domain(self.apiclient)
        self.zone = get_zone(self.apiclient, self.testClient.getZoneForTests())
        template = get_template(self.apiclient, self.zone.id)
        self.services["virtual_machine"]["zoneid"] = self.zone.id

        # Create an account, network, VM, Port forwarding rule, LB rules
        self.account = Account.create(self.apiclient,
                                      self.services["account"],
                                      admin=True,
                                      domainid=self.domain.id)

        self.service_offering = get_default_virtual_machine_offering(
            self.apiclient)
        self.vpc = VPC.create(self.apiclient,
                              self.services["vpc"],
                              vpcofferingid=self.vpc_offering.id,
                              zoneid=self.zone.id,
                              account=self.account.name,
                              domainid=self.account.domainid)

        ntwk = Network.create(api_client=self.apiclient,
                              services=self.services["network_1"],
                              accountid=self.account.name,
                              domainid=self.domain.id,
                              networkofferingid=self.network_offering.id,
                              zoneid=self.zone.id,
                              vpcid=self.vpc.id)

        networkids = []
        networkids.append(ntwk.id)

        self.virtual_machine = VirtualMachine.create(
            self.apiclient,
            self.services["virtual_machine"],
            templateid=template.id,
            accountid=self.account.name,
            domainid=self.account.domainid,
            serviceofferingid=self.service_offering.id,
            networkids=networkids)

        self.ip_address = PublicIPAddress.create(self.apiclient,
                                                 self.account.name,
                                                 self.zone.id,
                                                 self.account.domainid,
                                                 vpcid=self.vpc.id)

        ip_addrs = list_public_ip(self.apiclient,
                                  account=self.account.name,
                                  domainid=self.account.domainid,
                                  issourcenat=False)

        try:
            self.ip_addr = ip_addrs[0]
        except Exception as e:
            raise Exception(
                "Failed: During acquiring source NAT for account: %s, :%s" %
                (self.account.name, e))

        self.nat_rule = NATRule.create(self.apiclient,
                                       self.virtual_machine,
                                       self.services["natrule"],
                                       self.ip_addr.id,
                                       networkid=ntwk.id)
        self.lb_rule = LoadBalancerRule.create(self.apiclient,
                                               self.services["lbrule"],
                                               self.ip_addr.id,
                                               accountid=self.account.name,
                                               networkid=ntwk.id)
        self.cleanup = [self.virtual_machine, self.account]
        return
Esempio n. 27
0
    def setUp(self):
        self.logger = MarvinLog(MarvinLog.LOGGER_TEST).get_logger()

        self.apiclient = self.testClient.getApiClient()
        self.services = self.testClient.getParsedTestDataConfig()

        # Get Zone, Domain and templates
        self.domain = get_domain(self.apiclient)
        self.zone = get_zone(self.apiclient, self.testClient.getZoneForTests())
        template = get_template(
            self.apiclient,
            self.zone.id
        )
        self.services["virtual_machine"]["zoneid"] = self.zone.id

        # Create an account, network, VM and IP addresses
        self.account = Account.create(
            self.apiclient,
            self.services["account"],
            admin=True,
            domainid=self.domain.id
        )

        self.vpc_offering = get_default_vpc_offering(self.apiclient)
        self.logger.debug("VPC Offering '%s' selected", self.vpc_offering.name)

        self.network_offering = get_default_network_offering(self.apiclient)
        self.logger.debug("Network Offering '%s' selected", self.network_offering.name)

        self.virtual_machine_offering = get_default_virtual_machine_offering(self.apiclient)
        self.logger.debug("Virtual Machine Offering '%s' selected", self.virtual_machine_offering.name)

        self.default_allow_acl = get_network_acl(self.apiclient, 'default_allow')
        self.logger.debug("ACL '%s' selected", self.default_allow_acl.name)

        self.template = get_template(self.apiclient, self.zone.id)
        self.logger.debug("Template '%s' selected" % self.template.name)

        self.vpc1 = VPC.create(self.apiclient,
                              self.services['vpcs']['vpc1'],
                              vpcofferingid=self.vpc_offering.id,
                              zoneid=self.zone.id,
                              domainid=self.domain.id,
                              account=self.account.name)
        self.logger.debug("VPC '%s' created, CIDR: %s", self.vpc1.name, self.vpc1.cidr)

        self.network1 = Network.create(self.apiclient,
                                      self.services['networks']['network1'],
                                      networkofferingid=self.network_offering.id,
                                      aclid=self.default_allow_acl.id,
                                      vpcid=self.vpc1.id,
                                      zoneid=self.zone.id,
                                      domainid=self.domain.id,
                                      accountid=self.account.name)
        self.logger.debug("Network '%s' created, CIDR: %s, Gateway: %s", self.network1.name, self.network1.cidr, self.network1.gateway)

        self.vm1 = VirtualMachine.create(self.apiclient,
                                        self.services['vms']['vm1'],
                                        templateid=self.template.id,
                                        serviceofferingid=self.virtual_machine_offering.id,
                                        networkids=[self.network1.id],
                                        zoneid=self.zone.id,
                                        domainid=self.domain.id,
                                        accountid=self.account.name)
        self.logger.debug("VM '%s' created, Network: %s, IP %s", self.vm1.name, self.network1.name, self.vm1.nic[0].ipaddress)

        src_nat_ip_addrs = list_public_ip(
            self.apiclient,
            account=self.account.name,
            domainid=self.account.domainid
        )

        try:
            src_nat_ip_addr = src_nat_ip_addrs[0]
        except Exception as e:
            self.fail("SSH failed for VM with IP: %s %s" %
                      (src_nat_ip_addr.ipaddress, e))

        self.lb_rule = LoadBalancerRule.create(
            self.apiclient,
            self.services["lbrule"],
            src_nat_ip_addr.id,
            self.account.name,
            self.network1.id,
            self.vpc1.id
        )
        self.lb_rule.assign(self.apiclient, [self.vm1])

        self.nat_rule = NATRule.create(
            self.apiclient,
            self.vm1,
            self.services["natrule"],
            src_nat_ip_addr.id
        )
        self.cleanup = []
        return
Esempio n. 28
0
    def setup_infra(cls, redundant=False):

        if len(cls.class_cleanup) > 0:
            cleanup_resources(cls.api_client, cls.class_cleanup, cls.logger)
            cls.class_cleanup = []

        cls.zone = get_zone(cls.api_client, cls.test_client.getZoneForTests())
        cls.logger.debug("Zone '%s' selected" % cls.zone.name)

        cls.domain = get_domain(cls.api_client)
        cls.logger.debug("Domain '%s' selected" % cls.domain.name)

        cls.template = get_template(cls.api_client, cls.zone.id)

        cls.logger.debug("Template '%s' selected" % cls.template.name)

        cls.account = Account.create(cls.api_client,
                                     cls.attributes['account'],
                                     admin=True,
                                     domainid=cls.domain.id)

        cls.class_cleanup += [cls.account]
        cls.logger.debug("Account '%s' created", cls.account.name)

        cls.vpc_offering = get_default_redundant_vpc_offering(
            cls.api_client) if redundant else get_default_vpc_offering(
                cls.api_client)
        cls.logger.debug("VPC Offering '%s' selected", cls.vpc_offering.name)

        cls.network_offering = get_default_network_offering(cls.api_client)
        cls.logger.debug("Network Offering '%s' selected",
                         cls.network_offering.name)

        cls.virtual_machine_offering = get_default_virtual_machine_offering(
            cls.api_client)
        cls.logger.debug("Virtual Machine Offering '%s' selected",
                         cls.virtual_machine_offering.name)

        cls.default_allow_acl = get_network_acl(cls.api_client,
                                                'default_allow')
        cls.logger.debug("ACL '%s' selected", cls.default_allow_acl.name)

        cls.default_deny_acl = get_network_acl(cls.api_client, 'default_deny')
        cls.logger.debug("ACL '%s' selected", cls.default_deny_acl.name)

        cls.vpc1 = VPC.create(cls.api_client,
                              cls.attributes['vpcs']['vpc1'],
                              vpcofferingid=cls.vpc_offering.id,
                              zoneid=cls.zone.id,
                              domainid=cls.domain.id,
                              account=cls.account.name)
        cls.logger.debug("VPC '%s' created, CIDR: %s", cls.vpc1.name,
                         cls.vpc1.cidr)

        cls.network1 = Network.create(
            cls.api_client,
            cls.attributes['networks']['network1'],
            networkofferingid=cls.network_offering.id,
            aclid=cls.default_allow_acl.id,
            vpcid=cls.vpc1.id,
            zoneid=cls.zone.id,
            domainid=cls.domain.id,
            accountid=cls.account.name)
        cls.logger.debug("Network '%s' created, CIDR: %s, Gateway: %s",
                         cls.network1.name, cls.network1.cidr,
                         cls.network1.gateway)

        cls.vm1 = VirtualMachine.create(
            cls.api_client,
            cls.attributes['vms']['vm1'],
            templateid=cls.template.id,
            serviceofferingid=cls.virtual_machine_offering.id,
            networkids=[cls.network1.id],
            zoneid=cls.zone.id,
            domainid=cls.domain.id,
            accountid=cls.account.name)
        cls.logger.debug("VM '%s' created, Network: %s, IP %s", cls.vm1.name,
                         cls.network1.name, cls.vm1.nic[0].ipaddress)

        cls.public_ip1 = PublicIPAddress.create(cls.api_client,
                                                zoneid=cls.zone.id,
                                                domainid=cls.account.domainid,
                                                accountid=cls.account.name,
                                                vpcid=cls.vpc1.id,
                                                networkid=cls.network1.id)
        cls.logger.debug("Public IP '%s' acquired, VPC: %s, Network: %s",
                         cls.public_ip1.ipaddress.ipaddress, cls.vpc1.name,
                         cls.network1.name)

        cls.nat_rule1 = NATRule.create(cls.api_client,
                                       cls.vm1,
                                       cls.attributes['nat_rule'],
                                       vpcid=cls.vpc1.id,
                                       networkid=cls.network1.id,
                                       ipaddressid=cls.public_ip1.ipaddress.id)
        cls.logger.debug("Port Forwarding Rule '%s (%s) %s => %s' created",
                         cls.nat_rule1.ipaddress, cls.nat_rule1.protocol,
                         cls.nat_rule1.publicport, cls.nat_rule1.privateport)
    def setup_infra(cls, redundant=False):

        if len(cls.class_cleanup) > 0:
            cleanup_resources(cls.api_client, cls.class_cleanup, cls.logger)
            cls.class_cleanup = []

        cls.zone = get_zone(cls.api_client, cls.test_client.getZoneForTests())
        cls.logger.debug("Zone '%s' selected" % cls.zone.name)

        cls.domain = get_domain(cls.api_client)
        cls.logger.debug("Domain '%s' selected" % cls.domain.name)

        cls.template = get_template(
            cls.api_client,
            cls.zone.id)

        cls.logger.debug("Template '%s' selected" % cls.template.name)

        cls.account = Account.create(
            cls.api_client,
            cls.attributes['account'],
            admin=True,
            domainid=cls.domain.id)

        cls.class_cleanup += [cls.account]
        cls.logger.debug("Account '%s' created", cls.account.name)

        cls.vpc_offering = get_default_redundant_vpc_offering(cls.api_client) if redundant else get_default_vpc_offering(cls.api_client)
        cls.logger.debug("VPC Offering '%s' selected", cls.vpc_offering.name)

        cls.network_offering = get_default_network_offering(cls.api_client)
        cls.logger.debug("Network Offering '%s' selected", cls.network_offering.name)

        cls.virtual_machine_offering = get_default_virtual_machine_offering(cls.api_client)
        cls.logger.debug("Virtual Machine Offering '%s' selected", cls.virtual_machine_offering.name)

        cls.private_network_offering = get_default_private_network_offering(cls.api_client)
        cls.logger.debug("Private Network Offering '%s' selected", cls.private_network_offering.name)

        cls.default_allow_acl = get_network_acl(cls.api_client, 'default_allow')
        cls.logger.debug("ACL '%s' selected", cls.default_allow_acl.name)

        cls.vpc1 = VPC.create(cls.api_client,
            cls.attributes['vpcs']['vpc1'],
            vpcofferingid=cls.vpc_offering.id,
            zoneid=cls.zone.id,
            domainid=cls.domain.id,
            account=cls.account.name)
        cls.logger.debug("VPC '%s' created, CIDR: %s", cls.vpc1.name, cls.vpc1.cidr)

        cls.network1 = Network.create(cls.api_client,
            cls.attributes['networks']['network1'],
            networkofferingid=cls.network_offering.id,
            aclid=cls.default_allow_acl.id,
            vpcid=cls.vpc1.id,
            zoneid=cls.zone.id,
            domainid=cls.domain.id,
            accountid=cls.account.name)
        cls.logger.debug("Network '%s' created, CIDR: %s, Gateway: %s", cls.network1.name, cls.network1.cidr, cls.network1.gateway)

        cls.vm1 = VirtualMachine.create(cls.api_client,
            cls.attributes['vms']['vm1'],
            templateid=cls.template.id,
            serviceofferingid=cls.virtual_machine_offering.id,
            networkids=[cls.network1.id],
            zoneid=cls.zone.id,
            domainid=cls.domain.id,
            accountid=cls.account.name)
        cls.logger.debug("VM '%s' created, Network: %s, IP %s", cls.vm1.name, cls.network1.name, cls.vm1.nic[0].ipaddress)

        cls.public_ip1 = PublicIPAddress.create(cls.api_client,
            zoneid=cls.zone.id,
            domainid=cls.account.domainid,
            accountid=cls.account.name,
            vpcid=cls.vpc1.id,
            networkid=cls.network1.id)
        cls.logger.debug("Public IP '%s' acquired, VPC: %s, Network: %s", cls.public_ip1.ipaddress.ipaddress, cls.vpc1.name, cls.network1.name)

        cls.nat_rule1 = NATRule.create(cls.api_client,
            cls.vm1,
            cls.attributes['nat_rule'],
            vpcid=cls.vpc1.id,
            networkid=cls.network1.id,
            ipaddressid=cls.public_ip1.ipaddress.id)
        cls.logger.debug("Port Forwarding Rule '%s (%s) %s => %s' created",
            cls.nat_rule1.ipaddress,
            cls.nat_rule1.protocol,
            cls.nat_rule1.publicport,
            cls.nat_rule1.privateport)

        cls.vpc2 = VPC.create(cls.api_client,
            cls.attributes['vpcs']['vpc2'],
            vpcofferingid=cls.vpc_offering.id,
            zoneid=cls.zone.id,
            domainid=cls.domain.id,
            account=cls.account.name)
        cls.logger.debug("VPC '%s' created, CIDR: %s", cls.vpc2.name, cls.vpc2.cidr)

        cls.network2 = Network.create(cls.api_client,
            cls.attributes['networks']['network3'],
            networkofferingid=cls.network_offering.id,
            aclid=cls.default_allow_acl.id,
            vpcid=cls.vpc2.id,
            zoneid=cls.zone.id,
            domainid=cls.domain.id,
            accountid=cls.account.name)
        cls.logger.debug("Network '%s' created, CIDR: %s, Gateway: %s", cls.network2.name, cls.network2.cidr, cls.network2.gateway)

        cls.vm2 = VirtualMachine.create(cls.api_client,
            cls.attributes['vms']['vm2'],
            templateid=cls.template.id,
            serviceofferingid=cls.virtual_machine_offering.id,
            networkids=[cls.network2.id],
            zoneid=cls.zone.id,
            domainid=cls.domain.id,
            accountid=cls.account.name)
        cls.logger.debug("VM '%s' created, Network: %s, IP: %s", cls.vm2.name, cls.network2.name, cls.vm2.nic[0].ipaddress)

        cls.public_ip2 = PublicIPAddress.create(cls.api_client,
            zoneid=cls.zone.id,
            domainid=cls.account.domainid,
            accountid=cls.account.name,
            vpcid=cls.vpc2.id,
            networkid=cls.network2.id)
        cls.logger.debug("Public IP '%s' acquired, VPC: %s, Network: %s", cls.public_ip2.ipaddress.ipaddress, cls.vpc2.name, cls.network2.name)

        cls.nat_rule2 = NATRule.create(cls.api_client,
            cls.vm2,
            cls.attributes['nat_rule'],
            vpcid=cls.vpc2.id,
            networkid=cls.network2.id,
            ipaddressid=cls.public_ip2.ipaddress.id)
        cls.logger.debug("Port Forwarding Rule '%s (%s) %s => %s' created",
            cls.nat_rule2.ipaddress,
            cls.nat_rule2.protocol,
            cls.nat_rule2.publicport,
            cls.nat_rule2.privateport)

        cls.private_gateways_network = Network.create(cls.api_client,
            cls.attributes['networks']['private_gateways_network'],
            networkofferingid=cls.private_network_offering.id,
            aclid=cls.default_allow_acl.id,
            zoneid=cls.zone.id,
            domainid=cls.domain.id,
            accountid=cls.account.name)
        cls.logger.debug("Network '%s' created, CIDR: %s", cls.private_gateways_network.name, cls.private_gateways_network.cidr)

        cls.private_gateway1 = PrivateGateway.create(cls.api_client,
            ipaddress=cls.attributes['private_gateways']['private_gateway1'],
            networkid=cls.private_gateways_network.id,
            aclid=cls.default_allow_acl.id,
            vpcid=cls.vpc1.id)
        cls.logger.debug("Private Gateway '%s' created, Network: %s, VPC: %s", cls.private_gateway1.ipaddress, cls.private_gateways_network.name, cls.vpc1.name)

        cls.static_route1 = StaticRoute.create(cls.api_client,
            cls.attributes['static_routes']['static_route1'],
            vpcid=cls.vpc1.id)
        cls.logger.debug("Static Route '%s => %s' created, VPC: %s", cls.static_route1.cidr, cls.static_route1.nexthop, cls.vpc1.name)

        cls.private_gateway2 = PrivateGateway.create(cls.api_client,
            ipaddress=cls.attributes['private_gateways']['private_gateway2'],
            networkid=cls.private_gateways_network.id,
            aclid=cls.default_allow_acl.id,
            vpcid=cls.vpc2.id)
        cls.logger.debug("Private Gateway '%s' created, Network: %s, VPC: %s", cls.private_gateway2.ipaddress, cls.private_gateways_network.name, cls.vpc2.name)

        cls.static_route2 = StaticRoute.create(cls.api_client,
            cls.attributes['static_routes']['static_route2'],
            vpcid=cls.vpc2.id)
        cls.logger.debug("Static Route '%s => %s' created, VPC: %s", cls.static_route2.cidr, cls.static_route2.nexthop, cls.vpc2.name)