Exemplo n.º 1
0
def spacewalk_sync(options):
    """
    Performs the data capture, translation and checkin to katello
    """

    dt = transforms.DataTransforms()
    consumers = []
    katello_client = KatelloConnection()
    kps = katello_sync.KatelloPushSync(katello_client=katello_client,
                                       num_threads=CONFIG.getint('main', 'num_threads'))

    _LOG.info("Started capturing system data from spacewalk")
    if not options.report_input:
        client = SpacewalkClient(host=CONFIG.get('spacewalk', 'host'),
                                 ssh_key_path=CONFIG.get('spacewalk', 'ssh_key_path'),
                                 login=CONFIG.get('spacewalk', 'login'))
    else:
        client = SpacewalkClient(local_dir=options.report_input)

    _LOG.info("retrieving data from spacewalk")
    sw_user_list = client.get_user_list()
    system_details = client.get_system_list()
    channel_details = client.get_channel_list()
    hosts_guests = client.get_host_guest_list()
    org_list = client.get_org_list()

    if not check_for_invalid_org_names(org_list):
        raise Exception("Invalid org names found. Check /var/log/splice/spacewalk_splice_tool.log for more detail.")

    update_system_channel(system_details, channel_details)

    kps.update_owners(org_list)
    kps.update_users(sw_user_list)
    kps.update_roles(sw_user_list)

    katello_consumer_list = katello_client.get_consumers()
    kps.delete_stale_consumers(katello_consumer_list, system_details)

    _LOG.info("adding installed products to %s spacewalk records" % len(system_details))
    # enrich with engineering product IDs
    map(lambda details:
        details.update({'installed_products': get_product_ids(details['software_channel'])}), system_details)

    # convert the system details to katello consumers
    consumers.extend(dt.transform_to_consumers(system_details))
    _LOG.info("found %s systems to upload into katello" % len(consumers))
    _LOG.info("uploading to katello...")
    kps.upload_to_katello(consumers)
    _LOG.info("upload completed. updating with guest info..")
    # refresh the consumer list. we need the full details here to get at the system ID
    katello_consumer_list = katello_client.get_consumers(with_details=False)
    kps.upload_host_guest_mapping(hosts_guests, katello_consumer_list)
    _LOG.info("guest upload completed")
    _LOG.info("starting async auto-attach on satellite orgs")
    kps.autoentitle_satellite_orgs()
Exemplo n.º 2
0
def spacewalk_sync(options):
    """
    Performs the data capture, translation and checkin to katello
    """
    _LOG.info("Started capturing system data from spacewalk")
    client = SpacewalkClient(CONFIG.get('spacewalk', 'host'),
                             CONFIG.get('spacewalk', 'ssh_key_path'))
    katello_client = KatelloConnection()
    consumers = []

    _LOG.info("retrieving data from spacewalk")
    sw_user_list = client.get_user_list()
    system_details = client.get_system_list()
    channel_details = client.get_channel_list()
    hosts_guests = client.get_host_guest_list()
    update_system_channel(system_details, channel_details)
    org_list = client.get_org_list()

    update_owners(katello_client, org_list)
    update_users(katello_client, sw_user_list)
    update_roles(katello_client, sw_user_list)

    katello_consumer_list = katello_client.getConsumers()
    delete_stale_consumers(katello_client, katello_consumer_list, system_details)

    _LOG.info("adding installed products to %s spacewalk records" % len(system_details))
    # enrich with engineering product IDs
    clone_mapping = []
    map(lambda details :
            details.update({'installed_products' : \
                            get_product_ids(details['software_channel'])}),
                           system_details)

    # convert the system details to katello consumers
    consumers.extend(transform_to_consumers(system_details))
    _LOG.info("found %s systems to upload into katello" % len(consumers))
    _LOG.info("uploading to katello...")
    upload_to_katello(consumers, katello_client)
    _LOG.info("upload completed")#. updating with guest info..")
Exemplo n.º 3
0
def get_katello_entitlements(uuid):
    katello_conn = KatelloConnection()
    return katello_conn.get_entitlements(uuid)
Exemplo n.º 4
0
def get_katello_deletions():
    katello_conn = KatelloConnection()
    return katello_conn.get_deleted_systems()
Exemplo n.º 5
0
def get_katello_consumers():
    katello_conn = KatelloConnection()
    return katello_conn.get_consumers()
Exemplo n.º 6
0
def spacewalk_sync(options):
    """
    Performs the data capture, translation and checkin to katello
    """

    dt = transforms.DataTransforms()
    katello_client = KatelloConnection()
    kps = katello_sync.KatelloPushSync(katello_client=katello_client,
                                       num_threads=CONFIG.getint('main', 'num_threads'))

    sw_clients = []
    _LOG.info("Started capturing system data from %s spacewalk(s)" % (len(utils.get_multi_sw_cfg(CONFIG))))
    for sw_section in utils.get_multi_sw_cfg(CONFIG):
        # the :10 slice is to strip the word "spacewalk_" from the section name to create the prefix
        sw_prefix = sw_section[10:]
        if CONFIG.has_option(sw_section, "type") and CONFIG.get(sw_section, "type") == 'file':
            sw_clients.append(SpacewalkClient(local_dir=CONFIG.get(sw_section, 'report_input'), prefix=sw_prefix))
            _LOG.debug("added file datasource for %s" % sw_prefix)
        else:
            # default "type" is ssh
            sw_clients.append(SpacewalkClient(host=CONFIG.get(sw_section, "host"),
                                              ssh_key_path=CONFIG.get(sw_section, "ssh_key_path"),
                                              login=CONFIG.get(sw_section, "login"),
                                              prefix=sw_prefix))
            _LOG.debug("added SSH datasource for %s" % sw_prefix)

    for client in sw_clients:
        consumers = []
        spacewalk_details = _pull_spacewalk_data(client, utils.get_flatten_orgs(CONFIG))
        kps.update_owners(spacewalk_details['org_list'], client.prefix)

        if CONFIG.has_option('main', 'sync_users') and CONFIG.getboolean('main', 'sync_users'):
            kps.update_users(spacewalk_details['sw_user_list'])
            kps.update_roles(spacewalk_details['sw_user_list'])

        katello_consumer_list = katello_client.get_consumers()

        def _find_prefixed_consumer(consumer):
            return consumer['facts']['systemid'].startswith(client.prefix)

        prefixed_katello_consumers = filter(_find_prefixed_consumer, katello_consumer_list)

        _LOG.info("found %s prefixed consumers" % len(prefixed_katello_consumers))

        kps.delete_stale_consumers(prefixed_katello_consumers, spacewalk_details['system_details'])

        # convert the system details to katello consumers
        consumers.extend(dt.transform_to_consumers(spacewalk_details['system_details'], client.prefix))

        _LOG.info("found %s systems to upload into katello" % len(consumers))
        _LOG.info("uploading to katello...")
        kps.upload_to_katello(consumers)
        _LOG.info("upload completed. updating with guest info..")
        # refresh the consumer list. we need the full details here to get at the system ID
        katello_consumer_list = katello_client.get_consumers(with_details=False)
        kps.upload_host_guest_mapping(spacewalk_details['hosts_guests'], katello_consumer_list)
        _LOG.info("guest upload completed")
        if utils.get_autoentitle(CONFIG):
            _LOG.info("starting async auto-attach on satellite orgs")
            kps.autoentitle_satellite_orgs()
        else:
            _LOG.info("skipping async auto-attach on satellite orgs")