Exemple #1
0
def generate_system_facts(name=None):
    """Generate random system facts for registration.

    :param str name: A valid FQDN for a system. If one is not
        provided, then a random value will be generated.
    :return: A dictionary with random system facts
    :rtype: dict
    """
    if name is None:
        name = u"{0}.example.net".format(FauxFactory.generate_alpha().lower())

    # Make a copy of the system facts 'template'
    new_facts = copy.deepcopy(SYSTEM_FACTS)
    # Select a random RHEL version...
    distro = FauxFactory.generate_choice(DISTRO_IDS)

    # ...and update our facts
    new_facts["distribution.id"] = distro["id"]
    new_facts["distribution.version"] = distro["version"]
    new_facts["dmi.bios.relase_date"] = _bios_date().strftime("%m/%d/%Y")
    new_facts["dmi.memory.maximum_capacity"] = FauxFactory.generate_choice(MEMORY_CAPACITY)
    new_facts["dmi.memory.size"] = FauxFactory.generate_choice(MEMORY_SIZE)
    new_facts["dmi.system.uuid"] = FauxFactory.generate_uuid()
    new_facts["dmi.system.version"] = u"RHEL"
    new_facts["lscpu.architecture"] = distro["architecture"]
    new_facts["net.interface.eth1.hwaddr"] = FauxFactory.generate_mac()
    new_facts["net.interface.eth1.ipaddr"] = FauxFactory.generate_ipaddr()
    new_facts["network.hostname"] = name
    new_facts["network.ipaddr"] = new_facts["net.interface.eth1.ipaddr"]
    new_facts["uname.machine"] = distro["architecture"]
    new_facts["uname.nodename"] = name
    new_facts["uname.release"] = distro["kernel"]
    new_facts["virt.uuid"] = new_facts["dmi.system.uuid"]

    return new_facts