Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
811 changes: 518 additions & 293 deletions pyglpi/GLPI/GLPIClient.py

Large diffs are not rendered by default.

33 changes: 33 additions & 0 deletions pyglpi/examples/create_computer.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#!/usr/bin/env python
#-*- coding:utf-8 -*-

import sys
import os

# nothing is packaged yet, and I'm trying to not depend on my custom
# environment vars for everthing, so.....
glpimodpath = os.path.dirname(os.path.abspath(__file__))
sys.path.insert(0,os.path.split(glpimodpath)[0])

# now this part should work:
from GLPI import GLPIClient

if __name__ == '__main__':

import warnings
import getpass
import pprint

username = "glpi"
password = "glpi"
glpi = GLPIClient.Client('http://localhost/plugins/webservices/xmlrpc.php')
glpi.connect(username,password)

pprint.pprint(glpi.create_objects({
'Computer': [{
'name': 'python-computer'
}]
}))
result = glpi.list_objects('Computer', name='python-computer')

print "%d python-computer computer created!" % len(result)
16 changes: 2 additions & 14 deletions pyglpi/examples/get_computer.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,8 @@
import getpass
import pprint

try:
host = os.environ['GLPI_SERVERNAME']
username = os.environ['GLPI_USERNAME']
except:
warnings.warn("GLPI environment variables not locally set", RuntimeWarning)
host = raw_input("Enter your GLPI hostname: ")
username = raw_input("Enter your GLPI username: ")

password = getpass.getpass("Enter your password: ")
glpi = GLPIClient.RESTClient()
# my servers are configured with the glpi root under VirtualHost
# configurations, BASEURL changed accordingly on next line.
glpi.BASEURL = ''
glpi.connect(host,username,password)
glpi = GLPIClient.Client('http://localhost/plugins/webservices/xmlrpc.php')
glpi.connect("glpi", "glpi")

print "\nGetting Computer\n"
pprint.pprint(glpi.get_computer(29))
Expand Down
13 changes: 2 additions & 11 deletions pyglpi/examples/get_server_status.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,7 @@
import getpass
import pprint

try:
host = os.environ['GLPI_SERVERNAME']
except:
warnings.warn("GLPI environment variables not locally set", RuntimeWarning)
host = raw_input("Enter your GLPI hostname: ")

glpi = GLPIClient.RESTClient()
# my servers are configured with the glpi root under VirtualHost
# configurations, BASEURL changed accordingly on next line.
glpi.BASEURL = ''
glpi.connect(host)
glpi = GLPIClient.Client('http://localhost/plugins/webservices/xmlrpc.php')
glpi.connect()

pprint.pprint(glpi.get_server_status())
13 changes: 13 additions & 0 deletions pyglpi/examples/glpi_connect.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/usr/bin/env python
#-*- coding:utf-8 -*-

from GLPI import GLPIClient

# Init the object
glpi=GLPIClient.Client('http://localhost/plugins/webservices/xmlrpc.php')

# Connect
glpi.connect(host,username,password)

# Who am I ?
glpi.get_my_info()
11 changes: 2 additions & 9 deletions pyglpi/examples/glpi_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,9 @@
import getpass
import pprint

try:
host = os.environ['GLPI_SERVERNAME']
except:
warnings.warn("GLPI environment variables not locally set", RuntimeWarning)
host = raw_input("Enter your GLPI hostname: ")

glpi = GLPIClient.RESTClient()
glpi = GLPIClient.Client('http://localhost/plugins/webservices/xmlrpc.php')
# my servers are configured with the glpi root under VirtualHost
# configurations, BASEURL changed accordingly on next line.
glpi.BASEURL = ''
glpi.connect(host)
glpi.connect()

pprint.pprint(glpi.test())
2 changes: 1 addition & 1 deletion pyglpi/examples/list_all_methods.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
warnings.warn("GLPI environment variables not locally set", RuntimeWarning)
host = raw_input("Enter your GLPI hostname: ")

glpi = GLPIClient.RESTClient()
glpi = GLPIClient.Client(http://localhost/plugins/webservices/xmlrpc.php)
# my servers are configured with the glpi root under VirtualHost
# configurations, BASEURL changed accordingly on next line.
glpi.BASEURL = ''
Expand Down
2 changes: 1 addition & 1 deletion pyglpi/examples/list_computers.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
username = raw_input("Enter your GLPI username: ")

password = getpass.getpass("Enter your password: ")
glpi = GLPIClient.RESTClient()
glpi = GLPIClient.Client(http://localhost/plugins/webservices/xmlrpc.php)
# my servers are configured with the glpi root under VirtualHost
# configurations, BASEURL changed accordingly on next line.
glpi.BASEURL = ''
Expand Down
2 changes: 1 addition & 1 deletion pyglpi/examples/list_objects.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
username = raw_input("Enter your GLPI username: ")

password = getpass.getpass("Enter your password: ")
glpi = GLPIClient.RESTClient()
glpi = GLPIClient.Client(http://localhost/plugins/webservices/xmlrpc.php)
# my servers are configured with the glpi root under VirtualHost
# configurations, BASEURL changed accordingly on next line.
glpi.BASEURL = ''
Expand Down
2 changes: 1 addition & 1 deletion pyglpi/examples/list_tickets.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
username = raw_input("Enter your GLPI username: ")

password = getpass.getpass("Enter your password: ")
glpi = GLPIClient.RESTClient()
glpi = GLPIClient.Client(http://localhost/plugins/webservices/xmlrpc.php)
# my servers are configured with the glpi root under VirtualHost
# configurations, BASEURL changed accordingly on next line.
glpi.BASEURL = ''
Expand Down