예제 #1
0
def _puppet(ip_address, messages=[]):
    '''
    Similar to ``_puppet`` function, but it gets data from first resolved
    provider (provider also MUST return data), instead of passed provider
    (as param) like ``_puppet`` do.
    '''
    ip_addresses_set, hostnames_set = _get_ip_addresses_hostnames_sets(
        ip_address, )
    providers_chain = get_puppet_providers()
    for provider in providers_chain:
        facts = provider.get_facts(ip_addresses_set, hostnames_set, messages)
        if facts:
            break
    else:
        msg = "Could not find facts for ip address: {}".format(ip_address)
        raise Error(msg)
    is_virtual = _is_host_virtual(facts)
    if 'lshw' in facts:
        device_info = _parse_lshw(facts['lshw'], is_virtual)
    else:
        device_info = _parse_facts(facts, is_virtual)
    ip_addresses = handle_facts_ip_addresses(facts)
    if ip_addresses:
        device_info['system_ip_addresses'] = ip_addresses
    else:
        device_info['system_ip_addresses'] = [ip_address]
    disk_shares = handle_facts_wwn(facts)
    if disk_shares:
        device_info['disk_shares'] = disk_shares
    disks = device_info.get('disks', [])
    disks = _merge_disks_results(
        disks,
        handle_facts_3ware_disks(facts),
    )
    disks = _merge_disks_results(
        disks,
        handle_facts_smartctl(facts),
    )
    disks = _merge_disks_results(
        disks,
        handle_facts_hpacu(facts),
    )
    disks = _merge_disks_results(
        disks,
        handle_facts_megaraid(facts),
    )
    device_info['disks'] = disks
    installed_software = handle_facts_packages(facts)
    if installed_software:
        device_info['installed_software'] = installed_software
    device_info.update(handle_facts_os(facts, is_virtual))
    return device_info
예제 #2
0
def _puppet(provider, ip_address, messages=[]):
    ip_addresses_set, hostnames_set = _get_ip_addresses_hostnames_sets(
        ip_address,
    )
    facts = provider.get_facts(ip_addresses_set, hostnames_set, messages)
    if not facts:
        raise Error('Host config not found.')
    is_virtual = _is_host_virtual(facts)
    if 'lshw' in facts:
        device_info = _parse_lshw(facts['lshw'], is_virtual)
    else:
        device_info = _parse_facts(facts, is_virtual)
    ip_addresses = handle_facts_ip_addresses(facts)
    if ip_addresses:
        device_info['system_ip_addresses'] = ip_addresses
    else:
        device_info['system_ip_addresses'] = [ip_address]
    disk_shares = handle_facts_wwn(facts)
    if disk_shares:
        device_info['disk_shares'] = disk_shares
    disks = device_info.get('disks', [])
    disks = _merge_disks_results(
        disks,
        handle_facts_3ware_disks(facts),
    )
    disks = _merge_disks_results(
        disks,
        handle_facts_smartctl(facts),
    )
    disks = _merge_disks_results(
        disks,
        handle_facts_hpacu(facts),
    )
    disks = _merge_disks_results(
        disks,
        handle_facts_megaraid(facts),
    )
    device_info['disks'] = disks
    installed_software = handle_facts_packages(facts)
    if installed_software:
        device_info['installed_software'] = installed_software
    device_info.update(handle_facts_os(facts, is_virtual))
    return device_info
예제 #3
0
파일: puppet.py 프로젝트: pydubreucq/ralph
def _puppet(ip_address, messages=[]):
    """
    Similar to ``_puppet`` function, but it gets data from first resolved
    provider (provider also MUST return data), instead of passed provider
    (as param) like ``_puppet`` do.
    """
    ip_addresses_set, hostnames_set = _get_ip_addresses_hostnames_sets(ip_address)
    providers_chain = get_puppet_providers()
    for provider in providers_chain:
        facts = provider.get_facts(ip_addresses_set, hostnames_set, messages)
        if facts:
            break
    else:
        msg = "Could not find facts for ip address: {}".format(ip_address)
        raise Error(msg)
    is_virtual = _is_host_virtual(facts)
    if "lshw" in facts:
        device_info = _parse_lshw(facts["lshw"], is_virtual)
    else:
        device_info = _parse_facts(facts, is_virtual)
    ip_addresses = handle_facts_ip_addresses(facts)
    if ip_addresses:
        device_info["system_ip_addresses"] = ip_addresses
    else:
        device_info["system_ip_addresses"] = [ip_address]
    disk_shares = handle_facts_wwn(facts)
    if disk_shares:
        device_info["disk_shares"] = disk_shares
    disks = device_info.get("disks", [])
    disks = _merge_disks_results(disks, handle_facts_3ware_disks(facts))
    disks = _merge_disks_results(disks, handle_facts_smartctl(facts))
    disks = _merge_disks_results(disks, handle_facts_hpacu(facts))
    disks = _merge_disks_results(disks, handle_facts_megaraid(facts))
    device_info["disks"] = disks
    installed_software = handle_facts_packages(facts)
    if installed_software:
        device_info["installed_software"] = installed_software
    device_info.update(handle_facts_os(facts, is_virtual))
    return device_info