def browser_setup(get_appliance, provider, vm_to_analyze, fs_type, mgmt_sys_api_clients): '''Overrides env.conf and points a browser to the appliance IP passed to it. Once finished with the test, it checks if any tests need the appliance and delete it if not the appliance specified in conf/env.yaml. ''' global appliance_vm_name global test_list test_list.remove(['', provider, vm_to_analyze, fs_type]) with browser_session(base_url='https://' + get_appliance): yield nav.home_page_logged_in(testsetup) # cleanup provisioned appliance if not more tests for it if ('appliances_provider' not in cfme_data['basic_info'].keys() or provider != cfme_data['basic_info']['appliances_provider']): more_same_provider_tests = False for outstanding_test in test_list: if outstanding_test[1] == provider: logger.debug("More provider tests found") more_same_provider_tests = True break if not more_same_provider_tests: # if rhev, remove direct_lun disk before delete if cfme_data['management_systems'][provider]['type'] == 'rhevm': logger.info('Removing RHEV direct_lun hook...') run_command("./scripts/connect_directlun.py --remove --provider " + provider + " --vm_name " + appliance_vm_name) # delete appliance logger.info("Delete provisioned appliance: " + appliance_list[provider]) destroy_cmd = ('./scripts/clone_template.py --provider ' + provider + ' ' '--destroy --vm_name ' + appliance_vm_name + ' ') run_command(destroy_cmd)
def browser_session(self): """Creates browser session connected to this appliance Returns: Browser session connected to this appliance. Usage: with appliance.browser_session() as browser: browser.do_stuff(TM) """ return browser_session(base_url='https://' + self.address)
def browser_setup(get_appliance, provider, vm_to_analyze, fs_type, mgmt_sys_api_clients): '''Overrides env.conf and points a browser to the appliance IP passed to it. Once finished with the test, it checks if any tests need the appliance and delete it if not the appliance specified in conf/env.yaml. ''' global appliance_vm_name global test_list test_list.remove(['', provider, vm_to_analyze, fs_type]) with browser_session(base_url='https://' + get_appliance): yield nav.home_page_logged_in(testsetup) # cleanup provisioned appliance if not more tests for it if ('appliances_provider' not in cfme_data['basic_info'].keys() or provider != cfme_data['basic_info']['appliances_provider']): more_same_provider_tests = False for outstanding_test in test_list: if outstanding_test[1] == provider: logger.debug("More provider tests found") more_same_provider_tests = True break if not more_same_provider_tests: # if rhev, remove direct_lun disk before delete if cfme_data['management_systems'][provider][ 'type'] == 'rhevm': logger.info('Removing RHEV direct_lun hook...') run_command( "./scripts/connect_directlun.py --remove --provider " + provider + " --vm_name " + appliance_vm_name) # delete appliance logger.info("Delete provisioned appliance: " + appliance_list[provider]) destroy_cmd = ('./scripts/clone_template.py --provider ' + provider + ' ' '--destroy --vm_name ' + appliance_vm_name + ' ') run_command(destroy_cmd)
#!/usr/bin/env python2 from IPython import embed from fixtures import navigation as nav from utils.browser import browser_session, testsetup with browser_session() as browser: pg = nav.home_page_logged_in(testsetup) embed()