IBM / xmlservice

XML-based interface for accessing IBM i resources
https://xmlservice.readthedocs.io/
BSD 3-Clause "New" or "Revised" License
35 stars 18 forks source link

Itoolkit's iPgm - Library setup #45

Open deepakpenjarla opened 4 years ago

deepakpenjarla commented 4 years ago

iToolkit's iPgm is taking Library List from User's JOBD library list. Any way to give the library list in run time.?

I tried submitting the job with a JOBD which has a set of libraries but no use. When I console the result after run( ). I see below XML.

<?xml version='1.0'?>

\n \n XML Toolkit 1.9.9\n \n 1100016\n \n \n \n \n 10000 05\n \n \n \n \n 1100016\n \n \n \n \n *NA\n FFFFFFFF\n< jobname>QSQSRVR \n QUSER\n 266967\n *ACTIVE\n USER01\n 37\n 37\n 819\n ENU\n US\n QSYSWRK\n QSYS\n \n QSYS QSYS2 QHLPSYS QUSRSYS\n QTEMP LIBRARY1 LIBRARY2\n see log scan, not error list \n \n \nundefined
deepakpenjarla commented 4 years ago

@ThePrez Could you please help on this.?

abmusse commented 4 years ago

@deepakpenjarla

What if you ran CHGLIBL prior to calling your program?

What version of itoolkit are you using?

deepakpenjarla commented 4 years ago

@abmusse We are using itoolkit v0.1.6.

Library List of submitted Job (Node Jobs) is having the library list properly. Node Jobs :
QP0ZSPWT USER01 BATCHI ACTIVE PGM-sh
QP0ZSPWT USER01 BATCHI ACTIVE PGM-node
QZSHSH USER01 BATCHI ACTIVE PGM-QZSHSH

but it internally submitting another PRESTART job with QUSER

QSQSRVR QUSER 267369 PJ ACTIVE

This prestart job's library list is taken from Prestart JobD (QDFTSVR/QGPL ) which I can't change because the same prestart job might be using for different purpose. Is there a way to configure to use a particular prestart job instead of using QSQSRVR always.?

deepakpenjarla commented 4 years ago

One more question here,, If we do not specify library Name in iPGM options, from which library list it tries to find the program.? Is it from current library list.?

abmusse commented 4 years ago

@deepakpenjarla

One more question here,, If we do not specify library Name in iPGM options, from which library list it tries to find the program.? Is it from current library list.?

Yes it should try to use your library list first.

Below is an example changing your library list using v0.1.6:

const { iConn, iCmd, xmlToJson } = require('itoolkit');

const conn = new iConn('*LOCAL', process.env.USER, process.env.PASSWORD);

conn.add(iCmd("RTVJOBA USRLIBL(?) SYSLIBL(?)"));
conn.add(iCmd("CHGLIBL LIBL(QXMLSERV)"));
conn.add(iCmd("RTVJOBA USRLIBL(?) SYSLIBL(?)"));

conn.run((xmlOut) => {
  const output = xmlToJson(xmlOut);
  for (let command of output) {
   console.log(command);
  }
});

Output:

{
  type: 'cmd',
  success: true,
  cmd: 'RTVJOBA USRLIBL(?) SYSLIBL(?)',
  data: [
    {
      name: 'USRLIBL',
      value: 'QGPL       QTEMP      QDEVELOP   QBLDSYS    QBLDSYSR'
    },
    {
      name: 'SYSLIBL',
      value: 'QSYS       QSYS2      QHLPSYS    QUSRSYS'
    }
  ]
}
{ type: 'cmd', success: true, cmd: 'CHGLIBL LIBL(QXMLSERV)' }
{
  type: 'cmd',
  success: true,
  cmd: 'RTVJOBA USRLIBL(?) SYSLIBL(?)',
  data: [
    { name: 'USRLIBL', value: 'QXMLSERV' },
    {
      name: 'SYSLIBL',
      value: 'QSYS       QSYS2      QHLPSYS    QUSRSYS'
    }
  ]
}
deepakpenjarla commented 4 years ago

@abmusse Thanks for your answer. Yes, I agree we can use Retrieve and Change but if partiular JOBD is having 15-20 libraries then I need to retrieve and set the library list before every call of program. And, if I use the calling of a program in a POST request then I might be doing the same for every POST request. Is there a way to set the Node to always refer to a particular JOBD libraries.? may be in the current versions of itoolkit (I might be using older version).?

kadler commented 4 years ago

Why do you need to retrieve it? Just set it exactly how you want it.

deepakpenjarla commented 4 years ago

@kadler I would like to use Library list from a JOBD, so to get the library list, I need to retrieve the library list from a particular JOBD and set it.

kadler commented 4 years ago

Ok, gotcha.

ThePrez commented 4 years ago

You may also be able to specify the ctl transport option like so: *sbmjob(LIBNAME/JOBD/JOBNAME)

I believe this will result in the XMLService jobs being submitted to batch under the given *JOBD. https://www.ibm.com/developerworks/community/wikis/home?lang=en#!/wiki/IBM%20i%20Technology%20Updates/page/Toolkit%20for%20i%20APIs

Of course, there will be more overhead associated with submitting those batch jobs, but you can mitigate some of that with prestarted jobs and/or using the ipc parameter. http://yips.idevcloud.com/wiki/index.php/XMLService/XMLSERVICEQuick

deepakpenjarla commented 4 years ago

Hi @ThePrez I tried to use the iConn option as below

var conn = new xt.iConn("LOCAL","USER01","XXXXX",ctl:'sbmjob(QGPL/NEWUIJOBD/NODE_JB)',ipc:'/tmp/pdeepak/'});

I see it is submitting a job with NODE_JB with specified JOBD (NEWUIJOBD) but still library list for the job is User's JOBD library list. Am I missing something here.? or is it because of XMLSERVICE version or itoolkit version we are using.?

kadler commented 4 years ago

I found this old doc on library list in XMLSERVICE: http://yips.idevcloud.com/wiki/index.php/XMLService/XMLSERVICELibl

It generates the SBMJOB command like this: https://github.com/IBM/xmlservice/blob/491b0d3ccf246c278564b510f7c21dfa83f04837/src/plugipc.rpgle#L1410-L1445

There is a way to alter it, but it's a compile-time option: https://github.com/IBM/xmlservice/blob/9b9fa7dfe90a8490cfa984bf6676984d569311c3/src/plugconf_h.rpgle#L139-L148 and its hard-coded to use the current job's library list.

ThePrez commented 4 years ago

This sounds like a reasonable enhancement request to be routed to XMLService team for consideration.

According to this comment: https://github.com/IBM/xmlservice/blob/9b9fa7dfe90a8490cfa984bf6676984d569311c3/src/plugconf_h.rpgle#L137 Version 1.7.3 predates git control, so tracing history with certainty is impossible. However, I strongly suspect the "Alan" is @alanseiden. I will reach out to him to see if he remembers the reasoning behind that change (besides some obvious ones).

alanseiden commented 4 years ago

@ThePrez With the PHP toolkit, most users did not hand-craft a *SBMJOB string. To do so was rare, perhaps not even possible at first, and definitely more obscure than with the Node toolkit instantiation code I see discussed here. Users typically accepted the defaults (the Zend JOBD) and expected their user profile's library list to hold sway. They complained when their user profile's library list seemed to have no effect.

deepakpenjarla commented 4 years ago

@alanseiden I understand, usually we do not do SBMJOB with a JOBD name but I believe setting up library list from User JOBD should happen when we do not use SBMJOB (default way). If we specify a particular JOBD, it should use that JOBDs library list.

jimoibm commented 3 years ago

Listed some examples below.. if none is the case, can I get detailed explanation on the usage to get clear about what xmlservice expected to do?

  1. Use setting from *sbmjob() call program(by default it's XMLSERVICE pgm) with IPC key.. SBMJOB is only called when IPC "server" is not up. If this is the case, plugconf_h is designed to be customized by user in compile phase. I don't think the default values should be changed for minorities.
call qxmlserv.iPlug32k('/tmp/mykey',
'*sbmjob(JIMO/XSTESTJOBD/XSTEST)',
'<?xml version=''1.0''?>',
'?');
  1. Use from user input. Your SBMJOB will be called. describe your libl in the command
call qxmlserv.iPlug32k('/tmp/mykey',
'*sbmjob',
'<?xml version=''1.0''?>
  <sbmjob>SBMJOB CMD(CHGDTAARA DTAARA(JIMO/ADTAARA *ALL) VALUE(''2'')) JOB(XSSBMJOB) JOBD(JIMO/XSSBMJOBD) INLLIBL(*JOBD)</sbmjob>
',
'?');

Just a command to write as you wish.. describe your libl in the command

call qxmlserv.iPlug32k('*NA',
'*here',
'<?xml version=''1.0''?>
    <cmd>SBMJOB CMD(CHGDTAARA DTAARA(JIMO/ADTAARA *ALL) VALUE(''2'')) JOB(XSSBMJOB) JOBD(JIMO/XSSBMJOBD) INLLIBL(*JOBD)</cmd>
',
'?');
brandonp42 commented 1 year ago

FWIW I always control my library list with the ODBC connection string DBQ parameter and don't try to have a JOBD manage it. It appears that the *SBMJOB inherits it in my quick and dirty testing.