CA on CA Tech Tip - Using UIM API to inventory probes

Document created by Alquin Employee on Nov 17, 2017Last modified by Alquin Employee on Nov 17, 2017
Version 2Show Document
  • View in full screen mode

Hi Community,


CA Unified Infrastructure Management offers a REST API that allows you to automate a number of tasks. We have used it for a few and we will share generic solutions that have helped us along the way. You are welcome to have the code and make modifications / improvements to it. I am sure the real programmers will take one look at what I have written and run screaming to fix it. 


To make this easier we have created and will continue to add to a library of Python functions. The library is available in GitHub for ease of sharing and modification just follow the link. In this first effort I needed to be able to get a list of all the probes in our environment and to ensure they are running. In a future share we will also extend this to show how to automatically check robots missing cdm probes and how to fix it.


To get a list of the probes we created this Python script. Let us walk through it so you are clear on what it is doing and potentially you can extend it other purposes or use as is.

# Init logging level

# Init the dict with UIM REST API information
uim_ws = {}
uim_ws['user'] = 'uim_web_service_user'
uim_ws['password'] = 'uim_web_service_user_password'
uim_ws['url'] = ''
uim_ws['domain'] = 'uim_domain'

In the lines above we are simply telling it how to connect to the UIM REST API. A user with Web Services in the ACL is required as well as the path to the REST API url (http or https will work). The UIM domain you can get from the top of the tree in Infrastructure Manager or Admin Console. If you need more assistance with the REST API review the documentation here

 # Setup csv file for output
with open('probesList.csv', 'wb') as probes_list:
   wout = writer(probes_list, delimiter=',')
   header = ['Hub', 'Robot', 'Probe', 'Status']

In the lines above we are just setting up CSV access to a file called probesList.csv and creating the header row. Once we have that we can first get the list of hubs

    # Get the list of hubs from UIM
   hubs = get_hubs(uim_ws)
   for hub in hubs:

Now that we have the hubs we can get the robots assigned to each of the hubs

      for robot in robots:
         # Get the list of probes assigned to the robot
         probes = get_probes(uim_ws, hub['name'], robot['name'])

Now we can get the probes from each robot

          if probes:
         for probe in probes:
            # Translate the probe state
            if probe['active'].lower() == 'true':
               state = 'Active'
               state = 'Inactive'
            wout.writerow([hub['name'], robot['name'], probe['name'], state])

Finally we write our list of probes and their status. All the work is done in the library and that is included at the top in the statement

from cauimws import get_hubs, get_robots, get_probes

As you can see this is not so bad. Take a look at the code, share it, change it, use it and see if it helps. You can learn more about Python in this Dzone article. I will add more as time permits


Disclaimer: I work for CA Technologies in the IT department in the Tools and Automation Group. However, neither can I share any insight into product futures (typically I learn of product changes when you do) nor can make the product management or development team change the product. I also recommend consulting with CA support and validating all changes in test environments.

5 people found this helpful