Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to access objects that are in Auxiliary Storage Pool (ASP) ? #47

Closed
ranga543 opened this issue Feb 17, 2020 · 15 comments
Closed

How to access objects that are in Auxiliary Storage Pool (ASP) ? #47

ranga543 opened this issue Feb 17, 2020 · 15 comments

Comments

@ranga543
Copy link

I'm not a RPG developer but we are trying automate some using ansible on IBM I and we came across an issue to related Auxiliary Storage Pool. We have our libraries or programs in ASP and we are trying to access them via itoolkit. Is it possible to access via itoolkit ?

If it's not right place to ask this question, please close the issue.

@kadler
Copy link
Member

kadler commented Feb 17, 2020

If you call the SETASPGRP command as the first action, does that work?

@ranga543
Copy link
Author

@kadler I didn't try that but If you want I can give it a try.
Is it like itool.add(iCmd('command', 'SETASPGRP(TEST)'))

@kadler
Copy link
Member

kadler commented Feb 17, 2020

Yep, exactly. You'll have to do that at the same time you call your programs as every time you make a call, you'll get a new job.

@ranga543
Copy link
Author

ranga543 commented Feb 17, 2020

@kadler I tried below snippet didn't work it's throwing following error Library X not found for data area

asp_group='TEST'
conn = dbi.connect()
itransport = iDB2Call(conn)
itool = iToolKit()
if not asp_group:
  itool.add(iCmd('command', "SETASPGRP({})".format(asp_group), {'error': 'on'}))
itool.add(iCmd('command', command, {'error': 'on'}))
itool.call(itransport)

@kadler
Copy link
Member

kadler commented Feb 17, 2020

Looks like the code as written will not call SETASPGRP unless none is set. I think you mean:

if asp_group:
  itool.add(iCmd('command', "SETASPGRP({})".format(asp_group), {'error': 'on'}))

@ranga543
Copy link
Author

ranga543 commented Feb 17, 2020

@kadler sorry we fixed that and we are getting following message

ASP group TEST not set for thread X'0000000000000001'.                                     
Cause . . . . . :   An attempt to set the auxiliary storage pool (ASP) group                                       
for the current thread failed. The reason code is 1. The reason codes are: 1                                       
- Set is not allowed by an active operating system function. For a list of                                       
these functions, see the help for the SETASPGRP command. 2 - Commitment                                       
control with uncommitted resources is active. 3 - The thread has an SQL                                      
connection with pending work or the thread is running an SQL stored                                    
procedure, user defined function or trigger. Recovery  . . . :   For reason                                      
code 1, use the set ASP group operation in some other job. For example, do                                      
this through use the Submit Job (SBMJOB) command. 

@ranga543 ranga543 reopened this Feb 17, 2020
@ranga543
Copy link
Author

@kadler any ideas ?

@kadler
Copy link
Member

kadler commented Feb 17, 2020

My guess is that because it's coming in through a stored procedure and the default is to run in that job instead of using a spawned job, it won't let you run SETASPGRP. You could try using the SSH, HTTP, or direct transports which don't have that problem.

@kadler
Copy link
Member

kadler commented Feb 17, 2020

Though truthfully, I'm not an ASP expert, so I'm not sure if that will work either.

@kadler
Copy link
Member

kadler commented Feb 17, 2020

Or instead of connecting to *LOCAL database, you could use the RDB name for the IASP you want to use.

@ranga543
Copy link
Author

@kadler It worked when I used DirectTransport. Thank you

@ranga543
Copy link
Author

@kadler Noticed when we use DirectTransport it's not returning actual command stand output instead it just shows success but when it's fails it's showing up actual stand error output.

{u'success': u'+++ success SETASPGRP ASPGRP(TEST)'}

we don't need stand output for this particular command but we have other commands that requires stand output to do some operation based on that.

Is there way to get around the problem ?

@kadler
Copy link
Member

kadler commented Feb 20, 2020

Do you want the display output? Not sure what you mean by "stand output", but for display output you can use iCmd5250.

@ranga543
Copy link
Author

ranga543 commented Feb 20, 2020

@kadler I tried with iCmd5250 but it seems to be throwing some kind of error
test.py

from itoolkit import *
from itoolkit.transport import DirectTransport

itransport = DirectTransport()
itool = iToolKit()
itool.add(iCmd5250('aspgroup_cmd', 'SETASPGRP ASPGRP(TEST)'))
itool.call(itransport)
cmd_out = itool.dict_out('aspgroup_cmd')

if 'error' in cmd_out:
  print ('test')
  print (cmd_out['error'])
  exit()
{'aspgroup_cmd': {'error': {...}}, u'error1': u" ?xml version='1.0'? xmlservice /sh /xmlservice ", u'error': u'*BADPARSE'}

@kadler
Copy link
Member

kadler commented Feb 20, 2020

Please open a new issue for this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants