ESP dSeries Workload Automation

 View Only
  • 1.  Using variables when defining jobs

    Posted Sep 29, 2020 12:46 PM

    Is there a way to change the default job name from unjx_1 to %(jp)%var1.%var2.%var3._00010  (increment the step# by 10 for each job) ?

    I am trying to code an application once, for use in each environment by using the event prefix to set the jp (job prefix) to P or Q or T, and use javascript in the appl to set var1, var2 etc.

    If anyone is doing something like this, can you show me how you coded everything?



  • 2.  RE: Using variables when defining jobs

    Posted Sep 29, 2020 02:28 PM
    Edited by David Lock Sep 29, 2020 02:35 PM
    Hi John,

    When we create an application, we name it with a generic name say APPLICATION_X
    For different environments like DEV, QA, PROD etc we use the event prefix to drive it.
    So you could use Strings like DEV, QA, PROD or numbers that represent each environment like 300 = DEV, 200 = QA, 100=PROD etc
    The %(APPL._eventprefix) variable.



    When you define your event, down in the left corner where you add event etc, you can define the event prefix.
    Event details
    Normally the event is given the users name as the event prefix, so override it and set it to something else.
    If you have saved it prior to changing, you will need to delete that event and add a new event.

    Then at run time you can define your APPL to be named say %(APPL._eventprefix)_APPLICATION_X



    This could translate into DEV_APPLICATION_ or QA_APPLICATION_X or PROD_APPLICATION_X
    or
    300_APPLICATION or 200_APPLICATION or 100_APPLICATION

    Numbers corresponding to envs allows for greater number of envs.

    This can also tie into your global variables where you can define connection strings for each environment etc.
    user names & passwords etc etc.  Use %APPL.<GLOBAL_VARIABLE>  loaded based on context.

    You can define a global variable say called EnvType for each, named say "DEV", "QA" or "PROD"
    You can reference this in email notifications etc by %APPL.EnvType 


    Just ensure you set load javascript at runtime within the APPL.


    Or you can write some Javascript like this to leverage.

    loadContext(APPL,'%APPL._eventprefix');   <-- HERE you specifically load the EVENT PREFIX VARIABLES ONLY

    switch (parseInt(APPL._eventprefix)) {
    case 100:
    APPL.envType='PROD';
    break;
    case 201:
    APPL.envType='STAGING';
    break;
    case 200:
    APPL.envType='QA';
    break;
    case 300:
    APPL.envType='DEV';
    break;
    case 400:
    APPL.envType='STG';
    break;
    case 500:
    APPL.envType='XYZ';
    break;
    default:
    APPL.envType='UNKNOWN';

    Jobs

    As for the jobs, I leave those named the generically, no event prefix in those.
    You could set with event prefix too I guess, I just don't as I track by Application
    In the CA WA DB you will can select Applications by name i.e. DEV_APPLICATION_X and then linked to the ESP_GENERIC_JOB table by APPLICATION_ID

    I hope this is useful.

    Thanks





  • 3.  RE: Using variables when defining jobs

    Posted Sep 30, 2020 11:40 AM

    Thanks you Dave and Ken for your reply. I was trying pretty much the same thing.  It's reassuring to know that I was on the right track!
    I am also using a JS in the application properties that uses the event prefix + switch/case construct to set multiple variables that I would use in the job definitions.

    for example - event PROD.MYAPPL would trigger in appl MYAPPL along with it's JS SetApplDefaults, which would set variables...

    jobPrefix = 'P'
    agent = 'PRODAGENT'  (or maybe APPL._defaultAgent ? )
    jobNode1 = 'AAAA' 
    jobNode2 = 'BBBB'
    jobName = jp + jobnode + jobnode2
    So now I'd like to set the default jobname for a unix job type from unix_1  to %(jobname)_00010 which would  resolve to 'PAAAABBBB_00010'.
    subsequent jobs, regardless of type would be called 'PAAAABBBB_00020' 'PAAAABBBB_00030'  and so on.

    If I go to the Palette and select one of the job types, Right click then select Job Defaults, but unfortunately job name is not one of the fields.




  • 4.  RE: Using variables when defining jobs

    Posted Oct 02, 2020 09:53 AM
    Thanks again to both of you for your examples.  I finally have my process working. We are still hashing out job/appl naming standards so this process will evolve for a while.  On a related question... How do you promote code from one environment to another?


  • 5.  RE: Using variables when defining jobs

    Posted Sep 30, 2020 07:38 AM
    We have a DEV and PROD espresso where we use a IF statement and javascripts EVENT and Application to automate populating variables in either environment. Maybe there is something you can adjust to your needs. 

    In the EVENT we have multiple "setvar" javascripts to created variables for Servers, ENV, DB, INSTANCE etc. based on the environment (Dev, Test, QA or PROD).

    In the Properties of the Application we have the javascript with the IF PROD statement.


    If you want the Application named based on Environment you can just add the APPL.ESPENV to the runtime name in the Application