Exemple #1
0
def read_machineinfo():
    s = rhnserver.RhnServer()
    if not s.capabilities.hasCapability('machine_info'):
        return
    machineinfo = {}
    machineinfo["class"] = "MACHINEINFO"
    machine_id = getMachineId()
    if machine_id:
        machineinfo["machine_id"] = machine_id
    return machineinfo
Exemple #2
0
def read_machineinfo():
    s = rhnserver.RhnServer()
    if not s.capabilities.hasCapability('machine_info'):
        return
    machineinfo = {}
    machineinfo["class"] = "MACHINEINFO"
    machine_id = getMachineId()
    if machine_id:
        machineinfo["machine_id"] = machine_id
    return machineinfo
Exemple #3
0
def getSystemId():
    log.log_debug("getSystemId invoked")
    cfg = config.initUp2dateConfig()
    path = cfg["systemIdPath"]
    ret = None
    if os.access(path, os.R_OK):
        try:
            # add machine_id on the fly
            cert = rpclib.xmlrpclib.loads(open(path, "r").read())
            machine_id = getMachineId()
            if machine_id:
                # do not append machine_id to fields to avoid breaking
                # the checksum and authentication.
                cert[0][0]["machine_id"] = machine_id
            ret = rpclib.xmlrpclib.dumps(cert[0])
        except Exception:
            log.log_me("ERROR - Unable to read XML in %s - %s" % (path, sys.exc_info()[1]))
    return ret
Exemple #4
0
def registerSystem(username=None,
                   password=None,
                   profileName=None,
                   token=None,
                   other=None):
    """Wrapper for the old xmlrpc to register a system. Activates subscriptions
    if a reg num is given.

    """
    auth_dict = {
        "profile_name": profileName,
        "os_release": up2dateUtils.getVersion(),
        "release_name": up2dateUtils.getOSRelease(),
        "architecture": up2dateUtils.getArch()
    }

    machine_id = up2dateUtils.getMachineId()
    if machine_id:
        auth_dict["machine_id"] = machine_id

    # dict of other bits to send
    if other:
        for (key, item) in other.items():
            auth_dict[key] = item
    if token:
        auth_dict["token"] = token
    else:
        auth_dict["username"] = username
        auth_dict["password"] = password

    if cfg['supportsSMBIOS']:
        auth_dict["smbios"] = _encode_characters(hardware.get_smbios())

    s = rhnserver.RhnServer()
    registerSystemAddProductProfile(s, auth_dict)
    ret = s.registration.new_system(auth_dict)

    return ret