[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [HTCondor-users] Querying Startd classad from python bindings



Ok, got it.

Thank you both!

Antonio


On 10/20/2017 11:40 PM, Jason Patton wrote:
I was talking with Todd, I think we both confused a few things here and possibly exposed a bug.

1. The directQuery() method takes a daemon type argument, not ad type, e.g. htcondor.DaemonTypes.Startd

2. htcondor.Collector().directQuery() will only return the ClassAd for slot1@<startd_host>:

>>> startd_ad = htcondor.Collector().directQuery(htcondor.DaemonTypes.Startd) # returns a single ClassAd
>>> startd_ad['TotalSlots'] # even though there are two slots
2L
>>> startd_ad['Name']
'slot1@xxxxxxxxxxxxxxxxxxxxx'

Here's the bug:

>>> startd_ad = htcondor.Collector().directQuery(htcondor.DaemonTypes.Startd, name='slot2@xxxxxxxxxxxxxxxxxxxxx')
>>> startd_ad['Name'] # should return slot2@xxxxxxxxxxxxxxxxxxxxx... uh oh!
'slot1@xxxxxxxxxxxxxxxxxxxxx'

3. There's one unique address to the Startd, which is passed when constructing the Collector() object, and you can use that object to query all the Startd ads:

>>> startd_addr = startd_ad['MyAddress'] # get the address in whatever manner you like
>>> startd = htcondor.Collector(startd_addr)
>>> startd_ads = startd.query(htcondor.AdTypes.Startd)
>>> len(startd_ads) # should get ads for both slots
2
>>> for ad in startd_ads: print ad['Name']
...
slot1@xxxxxxxxxxxxxxxxxxxxx
slot2@xxxxxxxxxxxxxxxxxxxxx


htcondor.Collector.directQuery *should* work just condor_status -direct, but clearly it doesn't at this point. We may look to open a ticket about this.

In the meantime, if you want to get info on more than just slot1, use the "fake" Collector object constructed with the Startd address.

Jason Patton

On Fri, Oct 20, 2017 at 2:25 PM, Todd Tannenbaum <tannenba@xxxxxxxxxxx> wrote:
On 10/20/2017 2:14 AM, Antonio Delgado Peris wrote:
> Dear all,
>
> A (hopefully) quick question: does anybody know if there is a way to
> directly query a Startd (or other) daemon to get its classads, like
> 'condor_status -direct' does?
>

Yes, use method directQuery() in the Collector class. This will not communicate with the Collector, but will go directly to the startd (or schedd), just like condor_status -direct.

For example to directly query the startd on the local machine:

 import htcondor
 col = htcondor.Collector()
 ad = coll.directQuery(htcondor.AdTypes.Startd)
 print(ad)

And help details from the Python shell:

>>> help("htcondor.Collector.directQuery")
Help on method directQuery in htcondor.Collector:

htcondor.Collector.directQuery = directQuery(...) unbound htcondor.Collector method
  directQuery( (Collector)arg1, (DaemonTypes)daemon_type [, (str)name='' [, (list)projection=[] [, (str)statistics='']]]) -> object :
    Query a given daemon directly instead of returning a collector ad.
    This may return more up-to-date or detailed information than what is in the collector.
    :param daemon_type: Type of daemon; must be from the DaemonTypes enum.
    :param name: Name of daemon to locate. If not specified, it searches for the local daemon.
    :param projection: A list of attributes; if specified, the returned ads will be projected along these attributes.
    :param statistics: A list of additional statistics to return, if the remote daemon has any.
    :return: The ad of the matching daemon, from the daemon itself.

For gory details, here is the development ticket that added this functionality:
 https://htcondor-wiki.cs.wisc.edu/index.cgi/tktview?tn=4843

Hope this helps,
Todd

_______________________________________________
HTCondor-users mailing list
To unsubscribe, send a message to htcondor-users-request@cs.wisc.edu with a
subject: Unsubscribe
You can also unsubscribe by visiting
https://lists.cs.wisc.edu/mailman/listinfo/htcondor-users

The archives can be found at:
https://lists.cs.wisc.edu/archive/htcondor-users/



_______________________________________________
HTCondor-users mailing list
To unsubscribe, send a message to htcondor-users-request@xxxxxxxxxxx with a
subject: Unsubscribe
You can also unsubscribe by visiting
https://lists.cs.wisc.edu/mailman/listinfo/htcondor-users

The archives can be found at:
https://lists.cs.wisc.edu/archive/htcondor-users/