Author Topic: Tip: Listing Worker host properties with python  (Read 3575 times)

Scot Brew

  • Hero Member
  • *****
  • Posts: 272
    • PipelineFX
Tip: Listing Worker host properties with python
« on: December 09, 2008, 08:58:40 AM »
Question: How can one best get at the number of CPUs on a host or other Worker host properties?

Solution: This can currently best be done by extracting the information from the properties string.
, you are correct Chris.  Parsing the host properties is currently the way to do this in python.  Here is a snippet that will take the hostinfo, extract the host properties, and print the number of cpus.

 
Code: [Select]
h = qb.hostinfo()[0]
props = h['properties'].split(',')
propDict = dict([i.split('=')[:2] for i in props])
print propDict['host.cpus']