Skip to content

Instantly share code, notes, and snippets.

Last active Feb 8, 2016
What would you like to do?
A light wrapper around GLPI webservice.
#!/usr/bin/env python
#-*- coding:utf-8 -*-
import xmlrpclib
class GLPI:
def __init__(self, url=None, login=None, password=None):
Open a connection
:type url: URL to the xmlrpc.php file (e.g:
:type login: login of the user
:type password: password of the user
self.server = xmlrpclib.Server(url, allow_none=True)
if login == None or password == None:
raise Exception("Credential required")
params = {
'login_name': login,
'username': login,
'login_password': password,
'password': password
response = self.server.glpi.doLogin(params)
self.session = response['session']
def __getattr__(self, name):
def remote(params={}):
params['session'] = self.session
func = self.server.glpi.__getattr__(name)
return func.__call__(params)
return remote
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment