-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathcreate_computer.py
More file actions
33 lines (25 loc) · 861 Bytes
/
create_computer.py
File metadata and controls
33 lines (25 loc) · 861 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
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)