Example #1
0
def __get_storage_module(collection_type):
    """
    Look up serializer in /etc/cobbler/modules.conf
    """
    capi = cobbler_api.CobblerAPI()
    return capi.get_module_from_file("serializers", collection_type,
                                     "serializer_file")
Example #2
0
def log(logger, msg):
    if logger is not None:
        logger.info(msg)
    else:
        print >>sys.stderr, msg


def do_xmlrpc_rw(cobbler_api, settings, port):

    xinterface = remote.ProxiedXMLRPCInterface(cobbler_api, remote.CobblerXMLRPCInterface)
    server = remote.CobblerXMLRPCServer(('127.0.0.1', port))
    server.logRequests = 0      # don't print stuff
    xinterface.logger.debug("XMLRPC running on %s" % port)
    server.register_instance(xinterface)

    while True:
        try:
            print "SERVING!"
            server.serve_forever()
        except IOError:
            # interrupted? try to serve again
            time.sleep(0.5)


if __name__ == "__main__":
    cobbler_api = cobbler_api.CobblerAPI()
    settings = cobbler_api.settings()
    regen_ss_file()
    do_xmlrpc_rw(cobbler_api, settings, 25151)
Example #3
0
            traceback.print_exc()
            return False

    # perform a subtree search in basedn to find the full dn of the user
    # TODO: what if username is a CN?  maybe it goes into the config file as well?
    filter = prefix + username
    result = dir.search_s(basedn, ldap.SCOPE_SUBTREE, filter, [])
    if result:
        for dn, entry in result:
            # username _should_ be unique so we should only have one result
            # ignore entry; we don't need it
            pass
    else:
        return False

    try:
        # attempt to bind as the user
        dir.simple_bind_s(dn, password)
        dir.unbind()
        return True
    except:
        # traceback.print_exc()
        return False
    # catch-all
    return False


if __name__ == "__main__":
    api_handle = cobbler_api.CobblerAPI()
    print authenticate(api_handle, "guest", "guest")