def populate_config_from_appliances(appliance_data): """populates env.local.yaml with the appliances just obtained args: appliance_data: the data of the appliances as taken from sprout """ file_name = conf_path.join('env.local.yaml').strpath if os.path.exists(file_name): with open(file_name) as f: y_data = yaml.load(f) if not y_data: y_data = {} else: y_data = {} if y_data: with open(conf_path.join('env.local.backup').strpath, 'w') as f: yaml.dump(y_data, f, default_flow_style=False) y_data['appliances'] = [] for app in appliance_data: y_data['appliances'].append({'base_url': 'https://{}/'.format(app['ip_address'])}) with open(file_name, 'w') as f: try: del y_data['base_url'] except KeyError: pass yaml.dump(y_data, f, default_flow_style=False)
def populate_config_from_appliances(appliance_data): """populates env.local.yaml with the appliances just obtained args: appliance_data: the data of the appliances as taken from sprout """ file_name = conf_path.join('env.local.yaml').strpath if os.path.exists(file_name): with open(file_name) as f: y_data = yaml.safe_load(f) if not y_data: y_data = {} else: y_data = {} if y_data: with open(conf_path.join('env.local.backup').strpath, 'w') as f: yaml.safe_dump(y_data, f, default_flow_style=False) y_data['appliances'] = [] for app in appliance_data: app_config = dict( hostname=app['ip_address'], ui_protocol="https", version=str(app['template_version']), ) y_data['appliances'].append(app_config) with open(file_name, 'w') as f: # Use safe dump to avoid !!python/unicode tags yaml.safe_dump(y_data, f, default_flow_style=False)
def populate_config_from_appliances(appliance_data): """populates env.local.yaml with the appliances just obtained args: appliance_data: the data of the appliances as taken from sprout """ file_name = conf_path.join('env.local.yaml').strpath if os.path.exists(file_name): with open(file_name) as f: y_data = yaml.load(f) if not y_data: y_data = {} else: y_data = {} if y_data: with open(conf_path.join('env.local.backup').strpath, 'w') as f: yaml.dump(y_data, f, default_flow_style=False) y_data['appliances'] = [] for app in appliance_data: app_config = dict( hostname=app['ip_address'], ui_protocol="https", version=str(app['template_version']), ) y_data['appliances'].append(app_config) with open(file_name, 'w') as f: # Use safe dump to avoid !!python/unicode tags yaml.safe_dump(y_data, f, default_flow_style=False)
def main(): """Use quickstart to ensure we have correct env, then execute imports in ipython and done.""" quickstart.main( quickstart.parser.parse_args(['--mk-virtualenv', sys.prefix])) print('Welcome to IPython designed for running CFME QE code.') ipython = TerminalInteractiveShell.instance() from cfme.utils import appliance appliance.CREATE_IS_PEDANTIC = False for code_import in IMPORTS: print('> {}'.format(code_import)) ipython.run_cell(code_import) from cfme.utils.path import conf_path custom_import_path = conf_path.join('miq_python_startup.py') if custom_import_path.exists(): with open(custom_import_path.strpath, 'r') as custom_import_file: custom_import_code = custom_import_file.read() print('Importing custom code:\n{}'.format(custom_import_code.strip())) ipython.run_cell(custom_import_code) else: print( 'You can create your own python file with imports you use frequently. ' 'Just create a conf/miq_python_startup.py file in your repo. ' 'This file can contain arbitrary python code that is executed in this context.' ) ipython.interact()
def main(no_quickstart): """Use quickstart to ensure we have correct env, then execute imports in ipython and done.""" if not no_quickstart: from cfme.scripting import quickstart quickstart.main(quickstart.args_for_current_venv()) print('Welcome to IPython designed for running CFME QE code.') ipython = TerminalInteractiveShell.instance() for code_import in IMPORTS: print('> {}'.format(code_import)) ipython.run_cell(code_import) from cfme.utils.path import conf_path custom_import_path = conf_path.join('miq_python_startup.py') if custom_import_path.exists(): with open(custom_import_path.strpath, 'r') as custom_import_file: custom_import_code = custom_import_file.read() print('Importing custom code:\n{}'.format(custom_import_code.strip())) ipython.run_cell(custom_import_code) else: print( 'You can create your own python file with imports you use frequently. ' 'Just create a conf/miq_python_startup.py file in your repo. ' 'This file can contain arbitrary python code that is executed in this context.' ) ipython.interact()
def __init__(self, config, appliances): self.config = config self.session = None self.session_finished = False self.countfailures = 0 self.collection = [] self.sent_tests = 0 self.log = create_sublogger('master') self.maxfail = config.getvalue("maxfail") self._failed_collection_errors = {} self.terminal = store.terminalreporter self.trdist = None self.slaves = {} self.test_groups = self._test_item_generator() self._pool = [] from cfme.utils.conf import cfme_data self.provs = sorted(set(cfme_data['management_systems'].keys()), key=len, reverse=True) self.used_prov = set() self.failed_slave_test_groups = deque() self.slave_spawn_count = 0 self.appliances = appliances # set up the ipc socket zmq_endpoint = 'ipc://{}'.format( config.cache.makedir('parallelize').join(str(os.getpid()))) ctx = zmq.Context.instance() self.sock = ctx.socket(zmq.ROUTER) self.sock.bind(zmq_endpoint) # clean out old slave config if it exists slave_config = conf_path.join('slave_config.yaml') slave_config.check() and slave_config.remove() # write out the slave config conf.runtime['slave_config'] = { 'args': self.config.args, 'options': dict( # copy to avoid aliasing self.config.option.__dict__, use_sprout=False, # Slaves don't use sprout ), 'zmq_endpoint': zmq_endpoint, } if hasattr(self, "slave_appliances_data"): conf.runtime['slave_config']["appliance_data"] = self.slave_appliances_data conf.save('slave_config') for appliance in self.appliances: slave_data = SlaveDetail(appliance=appliance) self.slaves[slave_data.id] = slave_data for slave in sorted(self.slaves): self.print_message("using appliance {}".format(self.slaves[slave].appliance.url), slave, green=True)
def __init__(self, config, appliances): self.config = config self.session = None self.session_finished = False self.countfailures = 0 self.collection = [] self.sent_tests = 0 self.log = create_sublogger('master') self.maxfail = config.getvalue("maxfail") self._failed_collection_errors = {} self.terminal = store.terminalreporter self.trdist = None self.slaves = {} self.test_groups = self._test_item_generator() self._pool = [] from cfme.utils.conf import cfme_data self.provs = sorted(set(cfme_data['management_systems'].keys()), key=len, reverse=True) self.used_prov = set() self.failed_slave_test_groups = deque() self.slave_spawn_count = 0 self.appliances = appliances # set up the ipc socket zmq_endpoint = 'ipc://{}'.format( config.cache.makedir('parallelize').join(str(os.getpid()))) ctx = zmq.Context.instance() self.sock = ctx.socket(zmq.ROUTER) self.sock.bind(zmq_endpoint) # clean out old slave config if it exists slave_config = conf_path.join('slave_config.yaml') slave_config.check() and slave_config.remove() # write out the slave config conf.runtime['slave_config'] = { 'args': self.config.args, 'options': dict( # copy to avoid aliasing self.config.option.__dict__, use_sprout=False, # Slaves don't use sprout ), 'zmq_endpoint': zmq_endpoint, } if hasattr(self, "slave_appliances_data"): conf.runtime['slave_config']["appliance_data"] = self.slave_appliances_data conf.save('slave_config') for appliance in self.appliances: slave_data = SlaveDetail(appliance=appliance) self.slaves[slave_data.id] = slave_data for slave in sorted(self.slaves): self.print_message("using appliance {}".format(self.slaves[slave].appliance.url), slave, green=True)
def main(): """Use quickstart to ensure we have correct env, then execute imports in ipython and done.""" quickstart.main(quickstart.parser.parse_args(['--mk-virtualenv', sys.prefix])) print('Welcome to IPython designed for running CFME QE code.') ipython = TerminalInteractiveShell.instance() for code_import in IMPORTS: print('> {}'.format(code_import)) ipython.run_cell(code_import) from cfme.utils.path import conf_path custom_import_path = conf_path.join('miq_python_startup.py') if custom_import_path.exists(): with open(custom_import_path.strpath, 'r') as custom_import_file: custom_import_code = custom_import_file.read() print('Importing custom code:\n{}'.format(custom_import_code.strip())) ipython.run_cell(custom_import_code) else: print( 'You can create your own python file with imports you use frequently. ' 'Just create a conf/miq_python_startup.py file in your repo. ' 'This file can contain arbitrary python code that is executed in this context.') ipython.interact()
# on the appliance #: Corresponds to Rails.root in the rails env rails_root = local('/var/www/miq/vmdb') #: coverage root, should match what's in the coverage hook and merger scripts appliance_coverage_root = rails_root.join('coverage') # local coverage_data = scripts_data_path.join('coverage') gemfile = coverage_data.join('coverage_gem.rb') bundler_d = rails_root.join('bundler.d') coverage_hook_file_name = 'coverage_hook.rb' coverage_hook = coverage_data.join(coverage_hook_file_name) coverage_merger = coverage_data.join('coverage_merger.rb') coverage_output_dir = log_path.join('coverage') coverage_results_archive = coverage_output_dir.join('coverage-results.tgz') coverage_appliance_conf = conf_path.join('.ui-coverage') # This is set in sessionfinish, and should be reliably readable # in post-yield sessionfinish hook wrappers and all hooks thereafter ui_coverage_percent = None def clean_coverage_dir(): try: coverage_output_dir.remove(ignore_errors=True) except ENOENT: pass coverage_output_dir.ensure(dir=True) def manager():
# on the appliance #: Corresponds to Rails.root in the rails env rails_root = local('/var/www/miq/vmdb') #: coverage root, should match what's in the coverage hook and merger scripts appliance_coverage_root = rails_root.join('coverage') # local coverage_data = scripts_data_path.join('coverage') gemfile = coverage_data.join('coverage_gem.rb') bundler_d = rails_root.join('bundler.d') coverage_hook_file_name = 'coverage_hook.rb' coverage_hook = coverage_data.join(coverage_hook_file_name) coverage_merger = coverage_data.join('coverage_merger.rb') coverage_output_dir = log_path.join('coverage') coverage_results_archive = coverage_output_dir.join('coverage-results.tgz') coverage_appliance_conf = conf_path.join('.ui-coverage') # This is set in sessionfinish, and should be reliably readable # in post-yield sessionfinish hook wrappers and all hooks thereafter ui_coverage_percent = None def clean_coverage_dir(): try: coverage_output_dir.remove(ignore_errors=True) except ENOENT: pass coverage_output_dir.ensure(dir=True) def manager():
with those derived from the given CLI options The default behavior is to write to polarion_tools.local.yaml in the conf_path directory cfme_testcases_upload will combine local.yaml and polarion_tools.yaml """ pass @main.command( 'populate', help='Populate template with credentials and version based testrun data.' 'Does NOT overwrite anything already set in the given template') @click.option( '--template', help='YAML template to start with', default=conf_path.join('polarion_tools.local.yaml.template').strpath) @click.option('--output', help='YAML file to write to', default=conf_path.join('polarion_tools.local.yaml').strpath) @click.option( '--credentials-key', help='Key for utils.conf.credentials used for polarion authentication', default='polarion-upload') @click.option( '--vstring', help='version string that can be parsed for series and template selection') @click.option('--polarion-project-id', help='The polarion project ID to inject', default=None) @click.option('--polarion-url', help='The polarion URL to inject',
The default behavior is to write to polarion_tools.local.yaml in the conf_path directory cfme_testcases_upload will combine local.yaml and polarion_tools.yaml """ pass @main.command( 'populate', help='Populate template with credentials and version based testrun data.' 'Does NOT overwrite anything already set in the given template' ) @click.option( '--template', help='YAML template to start with', default=conf_path.join('polarion_tools.local.yaml.template').strpath ) @click.option( '--output', help='YAML file to write to', default=conf_path.join('polarion_tools.local.yaml').strpath ) @click.option( '--credentials-key', help='Key for utils.conf.credentials used for polarion authentication', default='polarion-upload' ) @click.option( '--vstring', help='version string that can be parsed for series and template selection' )