def build_numbers(self): api = trackerbot.api() builds = trackerbot.depaginate( api, api.build.get(job_name=self.job_name, template=self.template)) build_numbers = [] # XXX relying on trackerbot giving us the most recent builds first, should be explicit for build in builds.get('objects', []): if (build['number'] not in self.exclude_builds and build['number'] >= self.minimum_build): build_numbers.append(build['number']) if self.num_builds and len(build_numbers) == self.num_builds: break if build_numbers: print('Pulling reports from builds {}'.format(', '.join( [str(n) for n in build_numbers]))) return build_numbers
def build_numbers(self): api = trackerbot.api() builds = trackerbot.depaginate(api, api.build.get(job_name=self.job_name, template=self.template) ) build_numbers = [] # XXX relying on trackerbot giving us the most recent builds first, should be explicit for build in builds.get('objects', []): if (build['number'] not in self.exclude_builds and build['number'] >= self.minimum_build): build_numbers.append(build['number']) if self.num_builds and len(build_numbers) == self.num_builds: break if build_numbers: print('Pulling reports from builds {}'.format( ', '.join([str(n) for n in build_numbers]))) return build_numbers
def main(trackerbot_url, mark_usable=None): api = trackerbot.api(trackerbot_url) thread_q = [] thread_lock = Lock() template_providers = defaultdict(list) all_providers = set(list_all_providers()) unresponsive_providers = set() # Queue up list_template calls for provider_key in all_providers: thread = Thread(target=get_provider_templates, args=(provider_key, template_providers, unresponsive_providers, thread_lock)) thread_q.append(thread) thread.start() # Join the queued calls for thread in thread_q: thread.join() seen_templates = set() if mark_usable is None: usable = {} else: usable = {'usable': mark_usable} existing_provider_templates = [ pt['id'] for pt in trackerbot.depaginate(api, api.providertemplate.get())['objects']] # Find some templates and update the API for template_name, providers in template_providers.items(): template_name = str(template_name) group_name, datestamp, stream = trackerbot.parse_template(template_name) # Don't want sprout templates if group_name in ('sprout', 'rhevm-internal'): print 'Ignoring %s from group %s' % (template_name, group_name) continue seen_templates.add(template_name) group = trackerbot.Group(group_name, stream=stream) template = trackerbot.Template(template_name, group, datestamp) for provider_key in providers: provider = trackerbot.Provider(provider_key) if '{}_{}'.format(template_name, provider_key) in existing_provider_templates: print 'Template %s already tracked for provider %s' % (template_name, provider_key) continue try: trackerbot.mark_provider_template(api, provider, template, **usable) print 'Added %s template %s on provider %s (datestamp: %s)' % ( group_name, template_name, provider_key, datestamp) except SlumberHttpBaseException as ex: print ex.response.status_code, ex.content # Remove provider relationships where they no longer exist, skipping unresponsive providers, # and providers not known to this environment for pt in trackerbot.depaginate(api, api.providertemplate.get())['objects']: provider_key, template_name = pt['provider']['key'], pt['template']['name'] if provider_key not in template_providers[template_name] \ and provider_key not in unresponsive_providers: if provider_key in all_providers: print "Cleaning up template %s on %s" % (template_name, provider_key) trackerbot.delete_provider_template(api, provider_key, template_name) else: print "Skipping template cleanup %s on unknown provider %s" % ( template_name, provider_key) # Remove templates that aren't on any providers anymore for template in trackerbot.depaginate(api, api.template.get())['objects']: if not template['providers']: print "Deleting template %s (no providers)" % template['name'] api.template(template['name']).delete()
def main(trackerbot_url, mark_usable=None): api = trackerbot.api(trackerbot_url) thread_q = [] thread_lock = Lock() template_providers = defaultdict(list) all_providers = set(list_provider_keys()) unresponsive_providers = set() # Queue up list_template calls for provider_key in all_providers: ipaddress = cfme_data['management_systems'][provider_key].get( 'ipaddress', None) if ipaddress and not net.is_pingable(ipaddress): continue thread = Thread(target=get_provider_templates, args=(provider_key, template_providers, unresponsive_providers, thread_lock)) thread_q.append(thread) thread.start() # Join the queued calls for thread in thread_q: thread.join() seen_templates = set() if mark_usable is None: usable = {} else: usable = {'usable': mark_usable} existing_provider_templates = [ pt['id'] for pt in trackerbot.depaginate( api, api.providertemplate.get())['objects'] ] # Find some templates and update the API for template_name, providers in template_providers.items(): template_name = str(template_name) group_name, datestamp, stream = trackerbot.parse_template( template_name) # Don't want sprout templates if group_name in ('sprout', 'rhevm-internal'): print('Ignoring {} from group {}'.format(template_name, group_name)) continue seen_templates.add(template_name) group = trackerbot.Group(group_name, stream=stream) template = trackerbot.Template(template_name, group, datestamp) for provider_key in providers: provider = trackerbot.Provider(provider_key) if '{}_{}'.format(template_name, provider_key) in existing_provider_templates: print('Template {} already tracked for provider {}'.format( template_name, provider_key)) continue try: trackerbot.mark_provider_template(api, provider, template, **usable) print('Added {} template {} on provider {} (datestamp: {})'. format(group_name, template_name, provider_key, datestamp)) except SlumberHttpBaseException as ex: print("{}\t{}".format(ex.response.status_code, ex.content)) # Remove provider relationships where they no longer exist, skipping unresponsive providers, # and providers not known to this environment for pt in trackerbot.depaginate(api, api.providertemplate.get())['objects']: provider_key, template_name = pt['provider']['key'], pt['template'][ 'name'] if provider_key not in template_providers[template_name] \ and provider_key not in unresponsive_providers: if provider_key in all_providers: print("Cleaning up template {} on {}".format( template_name, provider_key)) trackerbot.delete_provider_template(api, provider_key, template_name) else: print("Skipping template cleanup {} on unknown provider {}". format(template_name, provider_key)) # Remove templates that aren't on any providers anymore for template in trackerbot.depaginate(api, api.template.get())['objects']: if not template['providers']: print("Deleting template {} (no providers)".format( template['name'])) api.template(template['name']).delete()