OpenLM frequently receives requests for OpenLM API usage examples. Here is one that a client of ours has written, and was kind enough to share with us. Please note that the example is provided as is, and should be used at the customer’s discretion.

Thanks Nat.

The example was implemented in Python, and takes advantage of the ‘GetActiveProducts’ and ‘CloseApplication’ APIs, to obtain a list of ArcGIS Editor users and actively shut down these sessions as a batch job. The ‘CloseApplication’ API requires the installation of the OpenLM Agent and OpenLM Agent extension on the end users workstation. It is currently applicable to ESRI ArcGIS , Autodesk (AutoCAD) and Matlab.


import urllib2
from xml.etree.ElementTree import fromstring, ElementTree

# GetActiveProducts API request parameters
# Please replace OpenLM_Server_Hostname with your actual hostname.
xml_string = '<ULM><MESSAGE type="GetActiveProducts" /><SESSION sessionid="0" /></ULM>'
url = 'http://OpenLM_Server_Hostname:7014/OpenLMServer'

# compile the GetActiveProducts request: Obtain a list of currently consumed licenses
req = urllib2.Request(url=url,
                     headers={'Content-Type': 'application/xml'})
# Send the request, and obtain a response  
response = urllib2.urlopen(req)
readResponse =
ET_xml = ElementTree(fromstring(readResponse))

# Initialize the standardLicense as False. This variable will flag each 'Editor' license.
standardLicense = False
for node in ET_xml.iter('PRODUCT'):
   product = node.attrib.get('product')

# Identify 'Editor' license usage, and the respective workstation and user name.
       username = node.attrib.get('username')
       workstation = node.attrib.get('workstation')
       #print(username, workstation)

# Compile the CloseApplication to be sent to the OpenLM Agent on the specific workstation.
# Please replace License_Server_Descriptive_Name with the descriptive name configured on the OpenLM Server configuration tool.
       xmlCommand = '<ULM><MESSAGE type="CloseApplication" /><PARAMETERS><PARAM name="username">%s</PARAM><PARAM name="workstation">%s</PARAM><PARAM name="server">License_Server_Descriptive_Name</PARAM><PARAM name="vendor">ARCGIS</PARAM><PARAM name="feature">Editor</PARAM></PARAMETERS></ULM>' %(username, workstation)
       req2 = urllib2.Request(url=url,
                     headers={'Content-Type': 'application/xml'})

# Send the request, and obtain a response  
       response = urllib2.urlopen(req2)

# Print a summary.
   print('The user has been removed')
   print('No one is currently using the standard Editor license')

(Visited 67 times, 1 visits today)

Similar Posts