Example #1
0
def mark(api, provider_key, template, usable, diagnose):
    # set some defaults
    diagnosis = None
    build_number = None
    if not usable:
        build_number = os.environ.get('BUILD_NUMBER', None)
        if diagnose:
            # diagnose will return None on a usable appliance, so don't bother
            from utils.appliance import IPAppliance
            ipa = IPAppliance()
            diagnosis = ipa.diagnose_evm_failure()
            if diagnosis:
                logger.error('Appliance failed: {}'.format(diagnosis.split(os.linesep)[0]))
    trackerbot.mark_provider_template(api, provider_key, template, tested=True, usable=usable,
        diagnosis=diagnosis, build_number=build_number)
Example #2
0
def mark(api, provider_key, template, usable, diagnose):
    # set some defaults
    diagnosis = None
    build_number = None
    if not usable:
        build_number = os.environ.get('BUILD_NUMBER')

#   temporarily disabled; diagnosis is causing template marking to fail on downstream appliances :(
#         if diagnose:
#             # diagnose will return None on a usable appliance, so don't bother
#             from utils.appliance import IPAppliance
#             ipa = IPAppliance()
#             diagnosis = ipa.diagnose_evm_failure()
#             if diagnosis:
#                 logger.error('Appliance failed: {}'.format(diagnosis.split(os.linesep)[0]))

    trackerbot.mark_provider_template(api, provider_key, template, tested=True, usable=usable,
        diagnosis=diagnosis, build_number=build_number)
def main(trackerbot_url, mark_usable=None):
    api = trackerbot.api(trackerbot_url)

    thread_q = []
    thread_lock = Lock()
    template_providers = defaultdict(list)
    # Queue up list_template calls
    for provider_key in list_all_providers():
        if provider_key.startswith('ec2') or provider_key.startswith('rhevm'):
            continue
        thread = Thread(target=get_provider_templates,
            args=(provider_key, template_providers, thread_lock))
        thread_q.append(thread)
        thread.start()

    # Join the queued calls
    for thread in thread_q:
        thread.join()

    # Find some templates and update the API
    for template_name, providers in template_providers.items():
        try:
            stream, datestamp = trackerbot.parse_template(template_name)
        except ValueError:
            # No matches
            continue
        group = trackerbot.Group(stream)
        template = trackerbot.Template(template_name, group, datestamp)

        for provider_key in providers:
            provider = trackerbot.Provider(provider_key)

            try:
                trackerbot.mark_provider_template(api, provider, template,
                    usable=mark_usable, tested=False)
                print 'template %s updated -- %s %s %r, marked usable: %s' % (
                    template, stream, datestamp, providers, bool(mark_usable))
            except SlumberHttpBaseException as ex:
                print ex.response.status_code, ex.content
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()
Example #5
0
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 api.providertemplate.get(limit=0)['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 api.providertemplate.get(limit=0)['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 api.template.get(limit=0)['objects']:
        if not template['providers']:
            print "Deleting template %s (no providers)" % template['name']
            api.template(template['name']).delete()
Example #6
0
def retest(api, provider_key, template):
    trackerbot.mark_provider_template(api, provider_key, template, tested=False)
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()