def setUpClass(cls): cls.logger = MarvinLog(MarvinLog.LOGGER_TEST).get_logger() cls.test_client = super(TestScenario1, cls).getClsTestClient() cls.api_client = cls.test_client.getApiClient() cls.scenario_manager = cls.test_client.getScenarioManager('scenario_1') cls.class_cleanup = []
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()) self.services["virtual_machine"]["zoneid"] = self.zone.id # Create an account with normal domain admin rights self.account_admin = Account.create(self.apiclient, self.services["account"], admin=True, domainid=self.domain.id) # Create an account with readonly domain admin rights self.services["account"]["accounttype"] = 4 self.account_ro_admin = Account.create(self.apiclient, self.services["account"], admin=True, domainid=self.domain.id) regusrkey_cmd = registerUserKeys.registerUserKeysCmd() regusrkey_cmd.id = self.account_admin.user[0].id self.user_admin = self.apiclient.registerUserKeys(regusrkey_cmd) regusrkey_cmd = registerUserKeys.registerUserKeysCmd() regusrkey_cmd.id = self.account_ro_admin.user[0].id self.user_ro_admin = self.apiclient.registerUserKeys(regusrkey_cmd) self.cleanup = [self.account_admin, self.account_ro_admin] return
def __init__(self): self.__identifier = None self.__testClient = None self.__logFolderPath = None self.__parsedConfig = None ''' Contains Config File ''' self.__configFile = None ''' Signifies the Zone against which all tests will be Run ''' self.__zoneForTests = None ''' Signifies the flag whether to deploy the New DC or Not ''' self.__deployDcFlag = None self.conf = None self.__resultStream = stdout self.__testRunner = None self.__testResult = SUCCESS self.__startTime = None self.__testName = None self.__tcRunLogger = MarvinLog('marvin').get_logger() self.__testModName = '' self.__hypervisorType = None self.__halt_on_failure = False Plugin.__init__(self)
def __init__(self, mgmt_details, dbsvr_details, async_timeout=3600, test_data_filepath=None, zone=None, hypervisor_type=None, halt_on_failure=False): self.__mgmtDetails = mgmt_details self.__dbSvrDetails = dbsvr_details self.__csConnection = None self.__dbConnection = None self.__testClient = None self.__asyncTimeOut = async_timeout self.__logger = MarvinLog('marvin').get_logger() self.__apiClient = None self.__userApiClient = None self.__asyncJobMgr = None self.__id = None self.__hypervisor = hypervisor_type self.__testDataFilePath = test_data_filepath self.__parsedTestDataConfig = None self.__zone = zone self.__setHypervisorInfo() self.__scenarioManager = None self.__halt_on_failure = halt_on_failure
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.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.entity_manager = EntityManager(cls.apiclient, cls.services, cls.service_offering, cls.account, cls.zone, cls.logger) cls._cleanup = [cls.account] return
def setUpClass(cls): cls.logger = MarvinLog(MarvinLog.LOGGER_TEST).get_logger() cls.test_client = super(TestPublicIpAcl, cls).getClsTestClient() cls.api_client = cls.test_client.getApiClient() cls.attributes = cls.test_client.getParsedTestDataConfig() cls.class_cleanup = []
def setUpClass(cls): cls.logger = MarvinLog(MarvinLog.LOGGER_TEST).get_logger() cls.testClient = super(TestIsolatedNetworks, cls).getClsTestClient() cls.api_client = cls.testClient.getApiClient() 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.services['mode'] = cls.zone.networktype cls.template = get_template(cls.api_client, cls.zone.id) cls.services["virtual_machine"]["zoneid"] = cls.zone.id # Create an account, network, VM and IP addresses cls.account = Account.create(cls.api_client, cls.services["account"], admin=True, domainid=cls.domain.id) cls.service_offering = get_default_virtual_machine_offering( cls.api_client) cls.services["egress_443"] = { "startport": 443, "endport": 443, "protocol": "TCP", "cidrlist": ["0.0.0.0/0"] } cls._cleanup = [cls.account] return
def __init__(self, host, port, user, password, retries=60, delay=10, key_pair_files=None, timeout=10.0): self.host = None self.port = 22 self.user = user self.passwd = password self.keyPairFiles = key_pair_files self.ssh = SSHClient() self.ssh.set_missing_host_key_policy(AutoAddPolicy()) self.retryCnt = 0 self.delay = 0 self.timeout = 3.0 self.logger = MarvinLog('ssh').get_logger() # Check invalid host value and raise exception # At least host is required for connection if host is not None and host != '': self.host = host if retries is not None and retries > 0: self.retryCnt = retries if delay is not None and delay > 0: self.delay = delay if timeout is not None and timeout > 0: self.timeout = timeout if port is not None and port >= 0: self.port = port if self.create_connection() == FAILED: raise internalError("Connection Failed")
def setUpClass(cls): cls.logger = MarvinLog(MarvinLog.LOGGER_TEST).get_logger() testClient = super(TestPortForwarding, cls).getClsTestClient() cls.apiclient = testClient.getApiClient() cls.services = testClient.getParsedTestDataConfig() cls.hypervisor = testClient.getHypervisorInfo() # Get Zone, Domain and templates cls.domain = get_domain(cls.apiclient) cls.zone = get_zone(cls.apiclient, testClient.getZoneForTests()) template = get_template(cls.apiclient, cls.zone.id) if template == FAILED: assert False, "get_template() failed to return template with description %s" % cls.services[ "ostype"] # Create an account, network, VM and IP addresses cls.account = Account.create(cls.apiclient, cls.services["account"], admin=True, domainid=cls.domain.id) cls.services["virtual_machine"]["zoneid"] = cls.zone.id cls.service_offering = get_default_virtual_machine_offering( cls.apiclient) cls.virtual_machine = VirtualMachine.create( cls.apiclient, cls.services["virtual_machine"], templateid=template.id, accountid=cls.account.name, domainid=cls.account.domainid, serviceofferingid=cls.service_offering.id) cls._cleanup = [cls.virtual_machine, cls.account]
def setUpClass(cls): cls.logger = MarvinLog(MarvinLog.LOGGER_TEST).get_logger() cls.test_client = super(TestIpExclusionList, cls).getClsTestClient() cls.api_client = cls.test_client.getApiClient() cls.test_data = cls.test_client.getParsedTestDataConfig() cls.class_cleanup = []
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.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) 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) 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) cls.non_src_nat_ip = PublicIPAddress.create( cls.apiclient, cls.account.name, cls.zone.id, cls.account.domainid, cls.services["virtual_machine"]) # Open up firewall port for SSH cls.fw_rule = FireWallRule.create( cls.apiclient, ipaddressid=cls.non_src_nat_ip.ipaddress.id, protocol=cls.services["lbrule"]["protocol"], cidrlist=['0.0.0.0/0'], startport=cls.services["lbrule"]["publicport"], endport=cls.services["lbrule"]["publicport"]) cls._cleanup = [cls.account]
def setUpClass(cls): cls.logger = MarvinLog(MarvinLog.LOGGER_TEST).get_logger() cls.test_client = super(eval(cls.__name__), cls).getClsTestClient() cls.api_client = cls.test_client.getApiClient() cls.scenario_manager = cls.test_client.getScenarioManager('scenario_2') cls.class_cleanup = [] cls.ssh_timer = None cls.test_data = cls.scenario_manager.test_data cls.specific_test_data = cls.test_data[cls.__name__]
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, 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.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) self.ip_address = PublicIPAddress.create(self.apiclient, self.account.name, self.zone.id, self.account.domainid) 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) self.lb_rule = LoadBalancerRule.create(self.apiclient, self.services["lbrule"], self.ip_addr.id, accountid=self.account.name) self.cleanup = [self.virtual_machine, self.account] return
def setUp(self): self.logger = MarvinLog(MarvinLog.LOGGER_TEST).get_logger() self.apiclient = self.testClient.getApiClient() self.hypervisor = self.testClient.getHypervisorInfo() self.cleanup = [] self.services = self.testClient.getParsedTestDataConfig() self.zone = get_zone(self.apiclient, self.testClient.getZoneForTests()) self.services["sleep"] = 5 self.services["timeout"] = 180 return
def setUp(self): self.logger = MarvinLog(MarvinLog.LOGGER_TEST).get_logger() self.apiclient = self.testClient.getApiClient() self.hypervisor = self.testClient.getHypervisorInfo() self.cleanup = [] self.services = self.testClient.getParsedTestDataConfig() self.zone = get_zone(self.apiclient, self.testClient.getZoneForTests()) self.services["sleep"] = 2 self.services["timeout"] = 240 # Default value is 120 seconds. That's just too much. self.services["configurableData"]["systemVmDelay"] = 60 return
def __init__(self, api_client, scenario_data, test_data, zone, randomizeNames, cleanup): self.api_client = api_client self.scenario_data = scenario_data self.test_data = test_data self.zone = zone self.logger = MarvinLog(MarvinLog.LOGGER_TEST).get_logger() self.dynamic_names = { 'accounts': {}, 'vpcs': {}, 'vms': {}, } self.randomizeNames = randomizeNames self.resources_to_cleanup = [] self.cleanup = cleanup
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.service_offering = get_default_virtual_machine_offering( self.apiclient) self.vm_1 = VirtualMachine.create( self.apiclient, self.services["virtual_machine"], templateid=template.id, accountid=self.account.name, domainid=self.account.domainid, serviceofferingid=self.service_offering.id) 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.lb_rule.assign(self.apiclient, [self.vm_1]) self.nat_rule = NATRule.create(self.apiclient, self.vm_1, self.services["natrule"], src_nat_ip_addr.id) self.cleanup = [] return
def __init__(self, config_file, deploy_dc_flag=False, test_mod_name="deploydc", zone=None, hypervisor_type=None): self.__configFile = config_file self.__deployFlag = deploy_dc_flag self.__tcRunLogger = MarvinLog('marvin').get_logger() self.__tcRunLogger.info("=== Marvin Init Logging Successful ===") self.__testModName = test_mod_name self.__testClient = None self.__tcResultFile = None self.__testDataFilePath = None self.__zoneForTests = zone self.__parsedConfig = None self.__hypervisorType = hypervisor_type
def setUpClass(cls): cls.logger = MarvinLog(MarvinLog.LOGGER_TEST).get_logger() testClient = super(TestPublicIP, 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.services['mode'] = cls.zone.networktype # Create Accounts & networks cls.account = Account.create(cls.apiclient, cls.services["account"], admin=True, domainid=cls.domain.id) cls.user = Account.create(cls.apiclient, cls.services["account"], domainid=cls.domain.id) cls.services["network"]["zoneid"] = cls.zone.id cls.network_offering = get_default_guest_network_offering( cls.apiclient) cls.services["network"]["networkoffering"] = cls.network_offering.id cls.account_network = Network.create(cls.apiclient, cls.services["network"], cls.account.name, cls.account.domainid) cls.user_network = Network.create(cls.apiclient, cls.services["network"], cls.user.name, cls.user.domainid) # Create Source NAT IP addresses PublicIPAddress.create(cls.apiclient, cls.account.name, cls.zone.id, cls.account.domainid) PublicIPAddress.create(cls.apiclient, cls.user.name, cls.zone.id, cls.user.domainid) cls._cleanup = [ cls.account_network, cls.user_network, cls.account, cls.user ] return
def setUpClass(cls): cls.logger = MarvinLog(MarvinLog.LOGGER_TEST).get_logger() cls.testClient = super(TestPasswordService, 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.services['mode'] = cls.zone.networktype cls.template = get_template(cls.api_client, cls.zone.id) cls.services["virtual_machine"]["zoneid"] = cls.zone.id cls.services["virtual_machine"]["template"] = cls.template.id cls.service_offering = get_default_virtual_machine_offering( cls.api_client) cls._cleanup = []
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(TestVPCRedundancy, cls).getClsTestClient() cls.api_client = cls.testClient.getApiClient() 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["virtual_machine"]["zoneid"] = cls.zone.id cls.services["virtual_machine"]["template"] = cls.template.id cls.service_offering = get_default_virtual_machine_offering( cls.api_client) return
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 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 __options_for_remove_data_center_are_invalid(self, options): return self.__option_is_set( options.remove) and not self.__path_points_to_file(options.remove) @staticmethod def __deploy_and_remove_data_center(options): return options.input and options.remove @staticmethod def __nothing_to_do(options): return options.input is None and options.remove is None @staticmethod def __option_is_set(flag): return flag is not None @staticmethod def __path_points_to_file(path): return os.path.isfile(path) if __name__ == "__main__": logger = MarvinLog('marvin').get_logger() try: Application().main(sys.argv[1:]) except Exception as e: logger.exception("Aborting run due to: %s" % e) exit(1) exit(0)
def __init__(self, test_client, cfg): self.__cfg = cfg self.__test_client = test_client self.__logger = MarvinLog('marvin').get_logger() self.__apiClient = None
def test_create_marvin_log_with_name(self): name = 'test-log' marvin_log = MarvinLog(name) self.assertIsNotNone(marvin_log) self.assertEquals(name, marvin_log.get_logger().name)
def test_create_marvin_log_with_default_name(self): marvin_log = MarvinLog() self.assertIsNotNone(marvin_log) self.assertEquals('marvin.utils.MarvinLog', marvin_log.get_logger().name)
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
def setUpClass(cls): cls.logger = MarvinLog(MarvinLog.LOGGER_TEST).get_logger() cls.testClient = super(TestRouterDHCPHosts, cls).getClsTestClient() cls.api_client = cls.testClient.getApiClient() 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.services['mode'] = cls.zone.networktype cls.template = get_template(cls.api_client, cls.zone.id) cls.services["virtual_machine"]["zoneid"] = cls.zone.id cls.logger.debug("Creating Admin Account for domain %s on zone %s" % (cls.domain.id, cls.zone.id)) # Create an account, network, VM and IP addresses cls.account = Account.create(cls.api_client, cls.services["account"], admin=True, domainid=cls.domain.id) cls.service_offering = get_default_virtual_machine_offering( cls.api_client) cls.network_offering = get_default_isolated_network_offering_with_egress( cls.api_client) cls.logger.debug("Creating Network for Account %s using offering %s" % (cls.account.name, cls.network_offering.id)) cls.network = Network.create(cls.api_client, cls.services["network"], accountid=cls.account.name, domainid=cls.account.domainid, networkofferingid=cls.network_offering.id, zoneid=cls.zone.id) cls.logger.debug( "Creating VM1 for Account %s using offering %s with IP 10.1.1.50" % (cls.account.name, cls.service_offering.id)) cls.vm_1 = VirtualMachine.create( cls.api_client, cls.services["virtual_machine"], templateid=cls.template.id, accountid=cls.account.name, domainid=cls.domain.id, serviceofferingid=cls.service_offering.id, networkids=[str(cls.network.id)], ipaddress="10.1.1.50") cls.logger.debug( "Creating VM2 for Account %s using offering %s with IP 10.1.1.51" % (cls.account.name, cls.service_offering.id)) cls.vm_2 = VirtualMachine.create( cls.api_client, cls.services["virtual_machine"], templateid=cls.template.id, accountid=cls.account.name, domainid=cls.domain.id, serviceofferingid=cls.service_offering.id, networkids=[str(cls.network.id)], ipaddress="10.1.1.51") cls.services["natrule1"] = { "privateport": 22, "publicport": 222, "protocol": "TCP" } cls.services["natrule2"] = { "privateport": 22, "publicport": 223, "protocol": "TCP" } cls.services["configurableData"] = { "host": { "password": "******", "username": "******", "port": 22 }, "input": "INPUT", "forward": "FORWARD" } cls._cleanup = [cls.vm_2, cls.network, cls.account] return
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]