def main(args): ctx = FakeNamespace(args) if ctx.verbose: teuthology.log.setLevel(logging.DEBUG) info = {} if ctx.archive: ctx.config = config_file(ctx.archive + '/config.yaml') ifn = os.path.join(ctx.archive, 'info.yaml') if os.path.exists(ifn): with open(ifn, 'r') as fd: info = yaml.safe_load(fd.read()) if not ctx.pid: ctx.pid = info.get('pid') if not ctx.pid: ctx.pid = int(open(ctx.archive + '/pid').read().rstrip('\n')) if not ctx.owner: ctx.owner = info.get('owner') if not ctx.owner: ctx.owner = open(ctx.archive + '/owner').read().rstrip('\n') if ctx.targets: ctx.config = merge_configs(ctx.targets) if ctx.stale: stale_nodes = find_stale_locks(ctx.owner) targets = dict() for node in stale_nodes: targets[node['name']] = node['ssh_pub_key'] ctx.config = dict(targets=targets) if ctx.stale_openstack: stale_openstack(ctx) return log.info( '\n '.join( ['targets:', ] + yaml.safe_dump( ctx.config['targets'], default_flow_style=False).splitlines())) if ctx.dry_run: log.info("Not actually nuking anything since --dry-run was passed") return if ctx.owner is None: ctx.owner = get_user() if ctx.pid: if ctx.archive: log.info('Killing teuthology process at pid %d', ctx.pid) os.system('grep -q %s /proc/%d/cmdline && sudo kill -9 %d' % ( ctx.archive, ctx.pid, ctx.pid)) else: subprocess.check_call(["kill", "-9", str(ctx.pid)]) nuke(ctx, ctx.unlock, ctx.synch_clocks, ctx.noipmi, ctx.keep_logs, not ctx.no_reboot)
def setup(self): self.ctx = FakeNamespace() self.ctx.cluster = Cluster() self.ctx.cluster.add(Remote('user@remote1'), ['role1']) self.ctx.cluster.add(Remote('user@remote2'), ['role2']) self.ctx.config = dict() self.task_config = dict(playbook=[])
def setup_method(self, method): self.ctx = FakeNamespace() self.ctx.cluster = Cluster() self.ctx.cluster.add(Remote('user@remote1'), ['role1']) self.ctx.cluster.add(Remote('user@remote2'), ['role2']) self.ctx.config = dict() self.ctx.summary = dict() self.task_config = dict(playbook=[]) self.start_patchers()
def setup(self): self.ctx = FakeNamespace() self.ctx.cluster = Cluster() self.ctx.cluster.add(Remote('user@remote1'), ['mon.0']) self.ctx.cluster.add(Remote('user@remote2'), ['mds.0']) self.ctx.cluster.add(Remote('user@remote3'), ['osd.0']) self.ctx.config = dict() self.task_config = dict() self.start_patchers()
def setup(self): teuth_config.ipmi_domain = 'ipmi.domain' teuth_config.ipmi_user = '******' teuth_config.ipmi_password = '******' self.ctx = FakeNamespace() self.ctx.cluster = Cluster() self.ctx.cluster.add(Remote('user@remote1'), ['role1']) self.ctx.cluster.add(Remote('user@remote2'), ['role2']) self.ctx.config = dict() self.ctx.archive = '/fake/path' self.task_config = dict() self.start_patchers()
def create_fake_context(job_config, block=False): owner = job_config.get('owner', get_user()) os_version = job_config.get('os_version', None) ctx_args = { 'config': job_config, 'block': block, 'owner': owner, 'archive': job_config['archive_path'], 'machine_type': job_config['machine_type'], 'os_type': job_config.get('os_type', 'ubuntu'), 'os_version': os_version, 'name': job_config['name'], } return FakeNamespace(ctx_args)
def setup(self): self.ctx = FakeNamespace() self.ctx.cluster = Cluster() self.ctx.cluster.add(Remote('user@remote1'), ['role1']) self.ctx.cluster.add(Remote('user@remote2'), ['role2']) self.ctx.config = dict() self.task_config = dict() self.patcher_fetch_repo = patch('teuthology.task.ansible.fetch_repo') self.patcher_fetch_repo.return_value = 'PATH' self.patcher_fetch_repo.start() def fake_get_playbook(self): self.playbook_file = Mock() self.playbook_file.name = 'cephlab.yml' self.patcher_get_playbook = patch( 'teuthology.task.ansible.CephLab.get_playbook', new=fake_get_playbook, ) self.patcher_get_playbook.start()
def main(args): verbose = args["--verbose"] archive = args["--archive"] owner = args["--owner"] config = args["<config>"] name = args["--name"] description = args["--description"] machine_type = args["--machine-type"] block = args["--block"] lock = args["--lock"] suite_path = args["--suite-path"] os_type = args["--os-type"] os_version = args["--os-version"] set_up_logging(verbose, archive) # print the command being ran log.debug("Teuthology command: {0}".format(get_teuthology_command(args))) if owner is None: args["--owner"] = owner = get_user() config = setup_config(config) if archive is not None and 'archive_path' not in config: config['archive_path'] = archive write_initial_metadata(archive, config, name, description, owner) report.try_push_job_info(config, dict(status='running')) machine_type = get_machine_type(machine_type, config) args["--machine-type"] = machine_type if block: assert lock, \ 'the --block option is only supported with the --lock option' log.info('\n '.join([ 'Config:', ] + yaml.safe_dump(config, default_flow_style=False).splitlines())) args["summary"] = get_summary(owner, description) ceph_repo = config.get('repo') if ceph_repo: teuth_config.ceph_git_url = ceph_repo suite_repo = config.get('suite_repo') if suite_repo: teuth_config.ceph_qa_suite_git_url = suite_repo # overwrite the config values of os_{type,version} if corresponding # command-line arguments are provided if os_type: config["os_type"] = os_type if os_version: config["os_version"] = os_version config["tasks"] = validate_tasks(config) init_tasks = get_initial_tasks(lock, config, machine_type) # prepend init_tasks to the front of the task list config['tasks'][:0] = init_tasks if suite_path is not None: config['suite_path'] = suite_path # fetches the tasks and returns a new suite_path if needed config["suite_path"] = fetch_tasks_if_needed(config) # If the job has a 'use_shaman' key, use that value to override the global # config's value. if config.get('use_shaman') is not None: teuth_config.use_shaman = config['use_shaman'] # create a FakeNamespace instance that mimics the old argparse way of doing # things we do this so we can pass it to run_tasks without porting those # tasks to the new way of doing things right now args["<config>"] = config fake_ctx = FakeNamespace(args) # store on global config if interactive-on-error, for contextutil.nested() # FIXME this should become more generic, and the keys should use # '_' uniformly if fake_ctx.config.get('interactive-on-error'): teuthology.config.config.ctx = fake_ctx try: run_tasks(tasks=config['tasks'], ctx=fake_ctx) finally: # print to stdout the results and possibly send an email on any errors report_outcome(config, archive, fake_ctx.summary, fake_ctx)
def setup(self): self.ctx = FakeNamespace() self.ctx.cluster = Cluster() self.ctx.cluster.add(Remote('remote1'), ['mon.a', 'client.0']) self.ctx.cluster.add(Remote('remote2'), ['osd.0', 'osd.1', 'osd.2']) self.ctx.cluster.add(Remote('remote3'), ['client.1'])
def setup(self): self.ctx = FakeNamespace() self.ctx.config = dict() self.task_config = dict()