File an rfe for this because I agree that we should have this in the blcli.
That script is pretty good.
Since you like jython, and if you want another challenge, can you write something that lets you set the run-time notification options for a job (email/snmp for a job run, not via a schedule).
The only compensation I can offer is my respect ☺
Is there any way to deal with
with the blcli? For functions that require it (e.g. JobRun findAllByJobRunStatusByServerByJobType) how do you generate it? Is that something that can only be done with jython or is there some weird syntax in the blcli to generate such an object?
Also, where do you get all the function names for jython?
have a look at:
do they fit your needs?
Not ideally. I would like to find the most recent job run of a certain job for a server (nb - not the same as the latest job run as that may not be the one that targetted the given server). I'm trying to export the most recent patch analysis job (for a given patch analysis job) run against a target server (a job which can be assumed to only run against a single server at a time). So if i have a patch analysis job named foo, i want to find the most recent JobRun of foo that targetted server X without having to iterate through every jobRun given that this number will become quite large.
I've had this problem in many other places but usually there is a way to work around the problem (for instance, to find the most recent deploy job run against a server you can use 'Server jobActiivityByJobType' and restrict the date range). However, despite the indications this cli function does not properly report patching or patch analysis jobs. If I have to, I could embed the analysis job and the export job in a batch and search for the last run of the batch against the target server, but I'd prefer to have a standalone export job instead of one that only works when run as part of the batch.
And also, I'm really just curious if there's any way to do this with the CLI. I constantly end up hitting a dead end of a function that looks like it would work for me but requires some object I can't find a way to generate. I'd be fine in most cases if I could just pass in a null to use a default (e.g. in this case I don't really care about the status of the jobrun, but there is no other function I can find that allows me to search for a JobRun based on the target server). I don't know if I'm missing something, or if it isn't possible without using jython.
Yes, sorry, I should have read more carefully, what your intention was.
Now - to respond to your last thoughts: there are quite a few "dead ends". So it's very likely that you have to use jython in this case
It just seems like there must be one missing step for creating these objects. I'm not entirely sure why Utility createModelObject doesn't work.
With jython, where do you see the function names? For instance, in the above script where did:
come from? Is there a way to get a list of functions from the class definition (i.e. a location to see all functions available from importing com.bladelogic.model.job.executor.ProgressStatusEnum)?
btw - 8.1 has some new commands for this - there's a 'executeAgainstFailedTarget', 'executeAgainstServerGroups' and 'executeAgainstServers'
We are using this script with BAO to do exactly this, "executeAgainst" many different targets. If we use this script, is there a way to send the values of the properties that each job uses as part of the execution command?
Thanks in advance.
In 8.1 I believe there is.
Isn't it possible to do it in version 8.0? (we are using the same script that Andreas Schessner posted).
There is no blcli command to do executeAgainst in 8.0 – there is the jython someone posted on this site. in 8.1 it’s a blcli command.
A little late to this, but I needed an "execute against" functionality for a script job via blcli (nsh) on 7.6. This is what I came up with. This only works for a single server, and doesn't seem to return useful things like job run key, run id, etc.
It takes three arguments: job path, job name, and server to execute against.
blcli_execute NSHScriptJob findByGroupAndName "$job_path" "$job_name"
blcli_execute Job getJobId
blcli_execute Server findByName "$server"
blcli_execute Server getDeviceId
blcli_execute Utility setTargetObject
blcli_execute Utility objectToList
blcli_execute Utility setTargetObject
blcli_execute Utility storeTargetObject device_list
blcli_execute Job execute $jobid NAMED_OBJECT=device_list
So you didn’t save the job before you run it?
Correct: I pass the job id and device list to "Job execute", and that is it. This is like the "Job execute*AndWait*" set of commands.