Add, Update or Delete Device Maintenance Schedule
Applies To
API Parameters for Adding/Updating Maintenance Schedule
API Parameters for Deleting Maintenance Schedule
Sample Code to Add/Update a Device Maintenance Schedule
Sample XML Input File
Sample Python Script
Sample Code to Delete a Device Maintenance Schedule Sample Python Script
Applies To
<Enterprise and multitenant deployments.>
<Enterprise deployments.> <Multitenant deployments>
API Parameters for Adding/Updating Maintenance Schedule
Methodology | REST API based: make an HTTP(S) request with an input XML (optional). An output XML is returned. |
Input URL | https:// |
Input Parameters | An XML file |
Input Credentials | Username and password of any AccelOps account |
Output | An XML file |
API Parameters for Deleting Maintenance Schedule
Methodology | REST API based: make an HTTP(S) request with an input XML (optional). An output XML is returned. |
Input URL | https:// |
Input Parameters | An XML file |
Input Credentials | Username and password of any AccelOps account |
Output | An XML file |
Sample Code to Add/Update a Device Maintenance Schedule
Sample XML Input File
Sample Python Script
AddMaint.py Script | Usage |
import sys, base64, urllib, urllib2 def restPost(appServer, user, password, file):
f = open(file, ‘r’) content = f.read() f.close() url = “https://” + appServer + “/phoenix/rest/deviceMaint/update” auth = “Basic %s” % base64.encodestring(user + “:” + password) request = urllib2.Request(url, content) request.add_header(‘Authorization’, auth) request.add_header(‘Content-Type’, ‘text/xml’) # ‘application/xml’ request.add_header(‘Content-Length’, len(content)+2) request.add_header(‘User-Agent’, ‘Python-urllib2/2.7’) request.get_method = lambda: ‘PUT’ try: handle = urllib2.urlopen(request) except urllib2.HTTPError, error: if (error.code != 204): print error if __name__==’__main__’: if len(sys.argv) != 5: print “Usage: AddMaint.py appServer user password scheduleDefFile” print “Example: python AddMaint.py 192.168.20.116 super/admin adm1n scheduleDef.xml” sys.exit() restPost(sys.argv[1], sys.argv[2], sys.argv[3], sys.argv[4]) |
python AddMaint.py <AccelOps_IP> <user> <password> <maintenance schedule xml file name> Sample Query
python AddMaint.py 172.16.20.210 “super/admin” “admin*1” MaintenanceSchedule.xml Super_user needs to be explicitly stated in organization/user format, for example “super/admi n” or “super/admin” instead of just “admin” |
Sample Code to Delete a Device Maintenance Schedule
Sample Python Script
DeleteMaint.py Script | Usage |
import sys, base64, urllib, urllib2 def restPost(appServer, user, password, file):
f = open(file, ‘r’) content = f.read() f.close() url = “https://” + appServer + “/phoenix/rest/deviceMaint/delete” auth = “Basic %s” % base64.encodestring(user + “:” + password) request = urllib2.Request(url, content) request.add_header(‘Authorization’, auth) request.add_header(‘Content-Type’, ‘text/xml’) # ‘application/xml’ request.add_header(‘Content-Length’, len(content)+2) request.add_header(‘User-Agent’, ‘Python-urllib2/2.7’) request.get_method = lambda: ‘PUT’ try: handle = urllib2.urlopen(request) except urllib2.HTTPError, error: if (error.code != 204): print error if __name__==’__main__’: if len(sys.argv) != 5: print “Usage: DeleteMaint.py appServer user password scheduleDefFile” print “Example: python DeleteMaint.py 192.168.20.116 “super/admin” “adm1n” scheduleDef.xml” sys.exit() restPost(sys.argv[1], sys.argv[2], sys.argv[3], sys.argv[4]) |
python DeleteMaint.py <AccelOps_IP> <user> <password> <maintenance schedule xml file name> Sample Query
python DeleteMaint.py 172.16.20.210 “super/admin” “admin*1” MaintenanceSchedule.xml Super_user needs to be explicitly stated in organization/user format, for example “super/admi n” or “super/admin” instead of just “admin” |