Automic Workload Automation

Expand all | Collapse all

How to make an Object inactive via Script call

  • 1.  How to make an Object inactive via Script call

    Posted Oct 26, 2017 10:14 AM
    Hi,
    How can I make an object inactive by using a script command?
     I though MODIFY_TASK might do this but I have doubts.
    Thanks,
    John.



  • 2.  How to make an Object inactive via Script call

    Posted Oct 26, 2017 10:19 AM
    Hey,

    By "make inactive" you mean deactivate?

    Unless I'm missing something, there is a script command DEACTIVATE_UC_OBJECT. That'll do.

    Best,
    Carsten


  • 3.  How to make an Object inactive via Script call

    Posted Oct 26, 2017 10:20 AM
    Carsten_Schmitz_7883

    Thanks I just thought of that too, but it doesn't seem to work.
    Let me test again.

    :SET &RUNID# = GET_UC_OBJECT_NR("DBA.DB_REFRESH_TESTER")
    :SET &DEAC# = DEACTIVATE_UC_OBJECT(&RUNID#)



  • 4.  How to make an Object inactive via Script call

    Posted Oct 26, 2017 10:23 AM
    I tested again, but it doesn't seem to make my Job inactive for some reason.

    mz50jynls2sx.pnghttps://us.v-cdn.net/5019921/uploads/editor/hp/mz50jynls2sx.png" width="635">



  • 5.  How to make an Object inactive via Script call

    Posted Oct 26, 2017 10:40 AM
    Ah, I missunderstood. I meant you wanted to deactivate an already activated job instance from Activity Window, but your screenshot clarified it.

    I just searched the docs because I had the nagging feeling it could be done, but I can't find any way to do it. MODIFY_TASK is definetly only for already active (i.e. running) workflows, and so is PUT_ATT and friends, and MODIFY_UC_OBJECT is, too. So those are out, as far as I see.

    Thus, sorry, so far I don't seem to know a way to do this with script. Could be done with SQL easily, but writing to the DB would be unsupported territory.




  • 6.  How to make an Object inactive via Script call

    Posted Oct 26, 2017 10:48 AM
    Colleague just reminded me that when we had to edit properties of a bunch of objects in the past, we also couldn't find ways to do it with script.

    When he had to do it, he exported his objects to XML, changed the part, and re-imported them. Technically, messing with the "intermediate" XML is probably unsupported by Automic. And when I had to change an attribute of a few thousand jobs, I modified the database directly (with at least some level of case-by-case approval by Automic).

    The best bet for a fully supported way, in my current estimate, would probably be the Java API.

    For the sake of completeness and for future readers: there is also MODIFY_OBJECT, that function DOES modify properties of objects, as oposed to running instances, but it only modifies specific stuff about calendars, logins and variables, and not the "Active" flag.




  • 7.  How to make an Object inactive via Script call

    Posted Oct 26, 2017 10:50 AM

    In Automic Workload Automation, the terms active, inactive, activate, and deactivate can mean three or four different things, depending on context. I opened an enhancement request a few years ago, asking that Automic make the terminology more consistent. Automic denied this request on the grounds that it would be too costly to implement. Automic does expend some effort on using terms consistently.



  • 8.  How to make an Object inactive via Script call

    Posted Oct 26, 2017 10:57 AM
    Michael_Lowry

    Nicely said and with a positive spin. Cheers, I might not have been able to phrase it quite as such  ;)


  • 9.  How to make an Object inactive via Script call

    Posted Oct 26, 2017 11:01 AM
    If you’re comfortable using the Java APIs, the XHeader class provides methods for working with the Header tab of AE objects, including reading & setting the Active flag:
    • isActive()— return the current value of theActiveflag
    • setActive()— set the value of the Activeflag


  • 10.  How to make an Object inactive via Script call

    Posted Oct 26, 2017 11:18 AM
    I hadn't thought of doing this through the DB but it's probably the easiest option.
    worked fine in a dev env.

    p0oazxffamz6.pnghttps://us.v-cdn.net/5019921/uploads/editor/ox/p0oazxffamz6.png" width="398">






  • 11.  How to make an Object inactive via Script call

    Posted Oct 26, 2017 11:21 AM
    Carsten Schmitz said:
    MODIFY_TASK is definitely only for already active (i.e. running) workflows, and so is PUT_ATT and friends, and MODIFY_UC_OBJECT is, too
    The MODIFY_UC_OBJECT command (and several others, such as DEACTIVATE_UC_OBJECT) were obviously created before anyone had made a serious attempt to impose some semblance of consistency to the terminology used in the app. These commands include the term object despite the fact that the entities they work with are more correctly called tasks.
    Nicely said and with a positive spin. Cheers, I might not have been able to phrase it quite as such  ;)
    I could rant about this topic for long enough to drink two or three beers. Cheers back at you! :)


  • 12.  How to make an Object inactive via Script call

    Posted Oct 26, 2017 11:23 AM
    Yeah, that works.

    Be aware though: When you do that, best make sure to increase oh_modcnt for the modified objects as well, because your server's WP have cached the data from the database. By incrementing oh_modcnt by one, the WP knows to re-read all the other fields into it's memory. Otherwise, your UI might show the object as "active" even though it's not in the DB, or the other way round.

    (Oracle syntax):

    update oh set oh_modcnt = oh_modcnt + 1 where oh_idnr = whatever;
    commit;



  • 13.  How to make an Object inactive via Script call

    Posted Oct 26, 2017 11:33 AM
    I could rant about this topic for long enough to drink two or three beers. Cheers back at you! :)
    We'll be at FOKUS in Braunschweig and probably some future Automic Worlds also. Should join us then ... there's usually beer after the events, and I can easily provide additional ranting to cover time for at least another two ...

    (I'm not saying Automic script is turning me into an alcoholic. Unless that's exactly what I'm saying ...  ;) ).


  • 14.  How to make an Object inactive via Script call

    Posted Oct 26, 2017 02:12 PM
    I am shocked....

    WHY for gods sake are you raping your poor Automic system ??????
    the script command you are looking for is STOP NOMSG

    example:
    : STOP NOMSG, 50, "Message"
    with that your job will be skipped with Status: ENDED_EMPTY - task is empty (STOP NOMSG).




  • 15.  How to make an Object inactive via Script call

    Posted Oct 27, 2017 02:45 AM
    Firstly, did you really have to use that word  >:) 

    Secondly, I need to be able to make an object inactive from somewhere else i.e. a totally separate script.
    This STOP commands looks like it can't take a parameter of RUNID.

    Thirdly, why is there always such a negative reaction to using the database to perform this type of activity. I thought those days were over. I've been on an Automic Database training course so I do understand the risks and would not proceed without thoroughly testing.

    I would be happy to use an alternative, if there was one. I haven't used Java API's before but will look into it.



  • 16.  How to make an Object inactive via Script call

    Posted Oct 27, 2017 04:22 AM
    What I'm actually trying to do here is find a way to stop and Job A from running while Job B is running.
    There must be another way of doing this without making Job A inactive.
    I was hoping to use a Scripting command at the beginning and end of Job B but I cant find one.


  • 17.  How to make an Object inactive via Script call

    Posted Oct 27, 2017 04:27 AM
    John O'Mullane said:
    What I'm actually trying to do here is find a way to stop and Job A from running while Job B is running.
    Isn't that the classic domain of syncs in Automic? I admit to having avoided them myself, but you may want to look into those for this matter. A rather "simple" sync might probably suffice to avoid job A starting whenever job B is active.


  • 18.  How to make an Object inactive via Script call

    Posted Oct 27, 2017 04:37 AM
    Yes, I have thought of using the SYNC and actually tested it but I have 100's of Job A's that I want to "Pause" and I don't want to have to edit each one and add a Sync Object.

    I'm actually dynamically working out the name of Job B in my Pre Process of Job B and I was hoping to issue a command there to "Pause" job A. 

    Job B is being called 100's of times, passing in a value that allow's me to work the name of Job B.




  • 19.  How to make an Object inactive via Script call

    Posted Oct 27, 2017 05:12 AM
    Firstly, did you really have to use that word  >:)
    Hi John,
    in this case yes, because it exacly describes, what is being done to the system.
    As myself and most others state: noone, absolutely noone from Automic does changes to his system per update script (yes there is one exclusion - the Activities delete statement) - even development & consulting use java api...
    I did the DB training myself but I would never dare running an update script ....

    Apart from that - which kind of objects do you want to set inactive? WHEN do you want them to become inactive - whilst they are running?
    - There could be some difficulties because of the object type - thats why I am asking.

    what about TOGGLE_OBJECT_STATUS - would this fulfill your needs?



  • 20.  How to make an Object inactive via Script call

    Posted Oct 27, 2017 05:35 AM
    update script (yes there is one exclusion - the Activities delete statement) - even development & consulting use java api...

    Fwiw, the update statement on oh_modcnt I posted above came to me straight from Automic development, as part of an incident where it was concluded that in this special case, an SQL update was in fact agreeable.

    I do agree that the Java API is safer. Hm, maybe if Automic University had a course on "Using the UC4 Java API (for Java Dummies)", I'd even book that course. Alas ... ;)


  • 21.  How to make an Object inactive via Script call

    Posted Oct 27, 2017 06:01 AM
    Hi Carsten,
    sorry it seems that I did not make my self clear enough...

    I meant during normal operation....

    that excepts special cases and emergencies...


  • 22.  How to make an Object inactive via Script call

    Posted Oct 27, 2017 06:01 AM
    That might work.

    For TOGGLE_OBJECT_STATUS, if I use this and set my Object to 'STOP, does this prevent the Object in question from executing in the future if kicked off from a Schedule until I then set it to GO or does it just stop an Object which is running at the time this command is executed?




  • 23.  How to make an Object inactive via Script call

    Posted Oct 27, 2017 06:13 AM
    TOGGLE_OBJECT_STATUS works for one (already activated) object.
    I do not fully get what you want to archieve...

    You want - if a special object gets started:

    * Stop many other objects, currently running
    * prevent those objects from being started again

    right?



  • 24.  How to make an Object inactive via Script call

    Posted Oct 27, 2017 06:53 AM
    JohnO'Mullane

    What object type is this deactivation goal ultimately about? SCRI? JOBS?

    TOGGLE_OBJECT_STATUS stops or starts the processing of an already activated (i.e. running) object. It won't, at least in my understanding, prohibit starting new instances of those objects (unless of course there is an additional concurrency limit, e.g. "only one instance of Job A at any one time.")

    The documentation also says that it only works for several object types, but does not say which ones. Based on the example, the utility of TOGGLE_OBJECT_STATUS seems to be to start/stop already activated events and probably also schedulers. I strongly doubt it works for JOBS, for example (disclaimer: haven't tried though).

    Just my $0.02


  • 25.  How to make an Object inactive via Script call

    Posted Oct 27, 2017 07:07 AM
    If running jobs should be stopped there is a basic problem caused by design:

    AE generates a job (= batch file with JCL)
    transfers it to the agent
    agent executes it
    sends RC and report back to AE

    between stage transfer JCL to agent and send RC back you have no control over the job, as its running on the agent....
    if its just a couple of minutes it sould be not a big issue but if the OS part of the job runs for a couple of hours there might be one....
    in this case there is just one possibility: killing the job with OS means...



  • 26.  How to make an Object inactive via Script call

    Posted Oct 27, 2017 07:14 AM

    between stage transfer JCL to agent and send RC back you have no control over the job, as its running on the agent....
    Yes, that exactly was the rationale for my hunch. I strongly suspect TOGGLE_OBJECT_STATUS can  only "suspend" things that it has under direct control, i.e. that linger in code 1550 ("Active") and such. Once a job has been passed to the agent, it's somewhat out of the engine's control. *) So that'll probably limit TOGGLE_OBJECT_STATUS to events and schedulers, and possibly scripts, though I doubt it for scripts, too.

    *) well, they COULD suspend JOBS on UNIX with process control (control-z), but that's not implemented in the agent afaik, and would not be cross-platform either.


  • 27.  How to make an Object inactive via Script call

    Posted Oct 27, 2017 07:15 AM
    So, I've got a script that is kicking off many workflows (Database Refreshes).
    I'm passing in the database name to each workflow via a SQL VARA.

    I also have a seperate Database Backup Job for each one getting refreshed. This Backup Job runs daily while my refresh once once per month.

    My requirement is that when my Refresh Workflows are spawned, I then want to somehow disable my Backup Job from starting for that database. The refresh can take multiple hours so there is a good chance that the Backup Job will kick off during this time. This is why I thought inactivating the Backup Job Object was the best approach.

    I had considered stopping the entire Backup schedule but some of my refreshes are quick and others can take hours, so I don't want to stop all my backups, only those where the refresh for that database is active.

    Hope this helps explain why I'm trying to achieve here.
     


  • 28.  How to make an Object inactive via Script call

    Posted Oct 27, 2017 07:23 AM
    Not sure if helping, but this comes to mind:

    Any chance of telling your backup job not to run when it detects the running database refresh on OS level? This is what I'm thinking:

    • your refresh is probably an OS utility being run on a server?
      Let's call it "refresh" for this example.

    • your backup is probably also an OS utility on a server?
      Let's call it "backup".

    • at least if those happen on the same server, you could check for the process "refresh" and only start "backup" if there is no "refresh"?

      On Linux, your backup JOBS would then have a command (or shell script) such as this:

      pgrep refresh || backup


      (or something similar with Powershell for Windows)?

      Edit: you could of course make that more elaborate, so it'll write out a message when it's not running, so you can review those messages in the UC4 report. Or you could exit with an error code if "backup" didn't run, so you can react in UC4 to that, too. The gist is, maybe a check for the refresh process in the OS is the way to go?


  • 29.  How to make an Object inactive via Script call

    Posted Oct 27, 2017 07:35 AM
    Thx for your explanation, John.

    In my opinion the easiest (Script) solution would be checking in the prep_Process of your Database Backup Job, if one of the refresh Jobs is running e.g. with SYS_STATE_ACTIVE.
    If No - just proceed, if Yes wait for a couple of minutes...

    Another Idea would be using one Queue as limiter.

    Or if its a workflow you could use preconditions.


  • 30.  How to make an Object inactive via Script call

    Posted Oct 27, 2017 09:45 AM
    ok, thanks FrankMuffke  and Carsten_Schmitz_7883
    I like the idea of handling this at OS script level. I don't really want to add a bit of code to each pre-process of my Backup jobs.


  • 31.  How to make an Object inactive via Script call

    Posted Oct 27, 2017 02:44 PM
    John, something else that you could do is not schedule your backup jobs for the day that the refresh will run. Then, you can add a backup job to the end of your refresh workflows that accepts the same database parameter that you're passing into the refresh workflow. You could also add a job, or code, that activates the appropriate backup job when the refresh is done. 


  • 32.  How to make an Object inactive via Script call

    Posted Oct 30, 2017 03:17 AM

    Hi all

    For all non-java-people out there looking for a nifty automated solution for the above, see my below GIST for doing the inactivation using my Powershell based WorkflowCommander solution.

     

    https://gist.github.com/JoelWiesmann/16cbb8c3fdf71570ddf6056ab559bbd5

    JohnO'Mullane if you want to see more - we'll have a Webex anyway for the SYNC question so just let me know and I make sure the test system will be online.

    Regards & sorry for the advertising :-)
    Joel



  • 33.  How to make an Object inactive via Script call

    Posted Oct 30, 2017 04:05 AM
    Hi Joel, I will definitely take you up on that webex call. I'm current on a couple of days vacation and back into the office on Wednesday. What location at you working from? John. Sent from my iPhone On 30 Oct 2017, at 07:17, Joel Wiesmann


  • 34.  How to make an Object inactive via Script call

    Posted Dec 01, 2017 04:30 PM
    I may have missed if this has already been offered. I use a precondition in the task properties that says if job A is running wait until it ends before proceeding. 

    ujllobndvoz3.pnghttps://us.v-cdn.net/5019921/uploads/editor/xk/ujllobndvoz3.png" width="698">


  • 35.  How to make an Object inactive via Script call

    Posted Dec 04, 2017 04:23 AM
    Thanks Curtis_Schouweiler_7107
    This is very useful and something I will look at. 


  • 36.  How to make an Object inactive via Script call

    Posted Dec 04, 2017 05:26 AM
    All this is interesting as it is something coming back for years now. If I may suggest a basic solutions available for decades in the product and used by many customers.

    1 - The use of XML files for modifying definitions is the simplest and perfectly supported process for doing a mass update. Just don't addany tag and use proper values for the tags you ar modifying. If it says uses "YES" or "NO" don't put "MAYBE" or "0" !!

    2 - The use of SYNC object when you have such case One vs Many is the easiest way :
         - One is checking if SYNC value is 0 and status is FREE
           ->  if ok, set status to BUSY, runs and set status to FREE at end.
           -> if not ok, waits until it is ok
         - Many is checking if SYNC status is FREE
           -> if ok, add 1 to value and runs, substract 1 to value at end
           -> if not ok waits

    If the activity doesn't allow a time when no objects runs, then split the check for One in a two step operation.
    A - run a Script object that will set SYNC status to BUSY (less than a second to perform the action !)
    B - At end of the Script object, activat One that will test only if SYNC value is 0 (no more Many process running). At end of One, set SYNC status back to FREE and Many processes that are in a waiting state will start.

    For me basic settings and proofed solution as it is used in many sites for such fonction. This is also the base for the SYNC object creation originally.

    Hope this can help you to find a solution to you problem and it shows the reason why you job are waiting ... if you use a significant name for the SYNC object  !  :)