Link to home
Start Free TrialLog in
Avatar of k_satish22
k_satish22

asked on

Jython Script

Hello HonorGod,

As per your comment in other question. I have opend new Question. Jython Script to export and import Namespace Bindings from one environment other. The please find the attached for the output you have asked for below code.

for ns in AdminConfig.list( 'NameSpaceBinding' ).splitlines() :
  print ns
  print '-' * 50
  print AdminConfig.show( ns )
  print '-' * 50
  print



ns-out.txt
Avatar of Gary Patterson, CISSP
Gary Patterson, CISSP
Flag of United States of America image

So what's the problem or question?

- Gary Patterson
Avatar of k_satish22
k_satish22

ASKER

Hi Gary,

I need a script to export and import Namespace Bindings from one environment other.
That is of no help for me because hu8mypho is developing his own script and never posted the script.
Old (related) question - which was the instigation for this one:
https://www.experts-exchange.com/questions/26928348/Jython-Script.html?anchorAnswerId=35318694#a35318694

What's the output of:


for ns in AdminConfig.list( 'NameSpaceBinding' ).splitlines() :
  name = AdminConfig.showAttribute( ns, 'name' )
  ot   = AdminConfig.getObjectType( ns )
  print '%20s %s' % ( ot, name )

Open in new window

It looks like you only have String, and EJB NameSpaceBindings
One of the challenges that I'm having is trying to determine if they are all bound to the Cell, or if some other scope is involved...
There are some other scops also involved.
Will the new bindings be imported to a configuration containing the same Cell, Node, Cluster, and Server names?
Yes.
I have attached the output.

Can I  change the questio to -
Script to create NameSpaceBinding by taking input from Properties files. That properties file will contain Scop, Values.

The Properties file will contain –
Scope=
                            Name: nameInNameSpace, stringToBind
Property:Value= CACHE_SWITCH, CACHE_SWITCH,ON



ns-out.txt
Thanks!

Q: Can I  change the question?
A: Sure, it's your question.  ;-)

The Properties file will contain –
Scope=


                            Name: nameInNameSpace, stringToBind
Property:Value= CACHE_SWITCH, CACHE_SWITCH,ON

My questions for you are:

Q: Is the Scope going to be like what was eventually used here?
     https://www.experts-exchange.com/questions/26928348/Jython-Script.html?anchorAnswerId=35316498#a35316498

Q: Can we change the Property:Value to include a "Type" indicator?
     e.g., Something like

     String
     EJB
     Corba
     Indirect

  I wanted to provide a link to the online documentation about the different
namespace bindings, but I'm having trouble with my machine at the moment. ;-(

  Does this make sense?
I am sorry for the Confusion I am creating here. I would like to stick to earlier question only. Because I need create a properties file with 1300 entries. These namespace bindings already configured in one of our environments. I just want to export form that environment and import to my new environment. I will open a new question of creation of namespace bindings.
ok.  I'm trying to figure out how to determine scope of a given NameSpace Binding.
I will get back to you.
Thank you very much.
Please execute the following script and let me know:

- if you encounter any errors
  Please include all messages written to the screen
- if no errors are encountered, please attach the output file

Thanks!

If you invoke it without any extra parameters, it should display appropriate Usage information.
e.g.,

./wsadmin.sh -conntype none -f exportNS.py

exportNS.py
Here is the error...

$ ./wsadmin.sh -conntype none -f exportNS.py
WASX7357I: By request, this scripting client is not connected to any server process. Certain configuration and application operations will be available in local mode.
WASX7017E: Exception received while running file "exportNS.py"; exception information: com.ibm.bsf.BSFException: exception from Jython:
Traceback (innermost last):
  (no code object) at line 0
  File "<string>", line 27
                  cp, depth = '', len( hierarchy ) // 2
                                                    ^
SyntaxError: invalid syntax

$
drat...

typo, and a mistake...

Please use this one.
exportNS.py
sorry.  ;-(
Unfortunately, I can't test it very thoroughly be cause I don't have any NameSpaceBindings defined.

Thanks for your help!
I fixed a trivial typo that messed up the Usage information slightly
exportNS.py
Please find the attached for the output...
exportNS.txt
That looks sweet! (as well as looking right).

Now, I have to write the reverse ... i.e., importNS  ;-)

Did you take a look at the output?
ok, this might work, I've tested it some, but I'm not certain if my environment is "good enough"

./wsadmin.sh -conntype none -f importNS.py

Shows usage information

Note: The "save" feature is currently disabled, so actual changes will not occur!
importNS.py
Hello HonorGod

I am very sorry for the delayed response on this question. The import script is not working Please find the attachement for error details.
importNS-Out.txt
Ah ha.  Your output helped me find a mistake.

Please try this, and let me know how it goes.
importNS.py
Now I am gettting below error ....

WASX7209I: Connected to process "dmgr" on node dmgr1ProcNode01 using SOAP connector;  The type of process is: DeploymentManager
WASX7303I: The following options are passed to the scripting environment and are available as arguments that are stored in the argv variable: "[/home/wasadmin/satish_scripts/exportNS_out.txt]"

Error: WASX7480E: "'" found instead of expected [.
Attribute= had invalid value= for input parameter='[ [ "name", "ClaimInquiry_Bloodhound_REALM" ], [ "nameInNameSpace", "ClaimInquiry_Bloodhound_REALM" ], [ "stringToBind", "bh0009" ] ]'

, line ignored
----------------------------------------------------------------------
'StringNameSpaceBinding' '/Cell:ProcCell01/Node:wps01Node01/Server:NonClaims1/' '[ [ "name", "ClaimInquiry_Bloodhound_REALM" ], [ "nameInNameSpace", "ClaimInquiry_Bloodhound_REALM" ], [ "stringToBin
d", "bh0009" ] ]'
----------------------------------------------------------------------

Error: WASX7480E: "'" found instead of expected [.
Attribute= had invalid value= for input parameter='[ [ "name", "ClaimInquiry_Bloodhound_REALM" ], [ "nameInNameSpace", "ClaimInquiry_Bloodhound_REALM" ], [ "stringToBind", "bh0009" ] ]'
^
, line ignored
----------------------------------------------------------------------
'StringNameSpaceBinding' '/Cell:ProcCell01/Node:wps02Node01/Server:NonClaims2/' '[ [ "name", "ClaimInquiry_Bloodhound_REALM" ], [ "nameInNameSpace", "ClaimInquiry_Bloodhound_REALM" ], [ "stringToBin
d", "bh0009" ] ]'
----------------------------------------------------------------------

Error: WASX7480E: "'" found instead of expected [.
Attribute= had invalid value= for input parameter='[ [ "name", "ClaimInquiry_Bloodhound_REALM" ], [ "nameInNameSpace", "ClaimInquiry_Bloodhound_REALM" ], [ "stringToBind", "bh0009" ] ]'
^
, line ignored
----------------------------------------------------------------------
'StringNameSpaceBinding' '/Cell:ProcCell01/Node:wps01Node01/Server:NonClaims1/' '[ [ "name", "ClaimInquiry_Bloodhound_URL" ], [ "nameInNameSpace", "ClaimInquiry_Bloodhound_URL" ], [ "stringToBind",
"https://ATLENTVAWSL01/bhi/web-portlet/sso/sso.seam" ] ]'
----------------------------------------------------------------------

Error: WASX7480E: "'" found instead of expected [.
Attribute= had invalid value= for input parameter='[ [ "name", "ClaimInquiry_Bloodhound_REALM" ], [ "nameInNameSpace", "ClaimInquiry_Bloodhound_REALM" ], [ "stringToBind", "bh0009" ] ]'
^
, line ignored
----------------------------------------------------------------------
'StringNameSpaceBinding' '/Cell:ProcCell01/Node:wps02Node01/Server:NonClaims2/' '[ [ "name", "ClaimInquiry_Bloodhound_URL" ], [ "nameInNameSpace", "ClaimInquiry_Bloodhound_URL" ], [ "stringToBind",
"https://ATLENTVAWSL01/bhi/web-portlet/sso/sso.seam" ] ]'
----------------------------------------------------------------------

Yikes.  Please provide the input file.  Thanks!
Ah.  I bet I made the same kind of mistake for the 3rd parameter that I did for the 1st!
importNS.py
Now I am getting below error.

Error: WASX7122E: Expected "]"  not found.
Attribute=name had invalid value=, for input parameter= [ "name", "ClaimInquiry_Bloodhound_REALM" ], [ "nameInNameSpace", "ClaimInquiry_Bloodhound_REALM" ], [ "stringToBind", "bh0009" ]
          ^
, line ignored
----------------------------------------------------------------------
'StringNameSpaceBinding' '/Cell:ProcCell01/Node:wps02Node01/Server:NonClaims2/' '[ [ "name", "xPressionServerURL" ], [ "nameInNameSpace", "xPressionServerURL" ], [ "stringToBind", "10.220.31.54:9081" ] ]'
----------------------------------------------------------------------

Error: WASX7122E: Expected "]"  not found.
Attribute=name had invalid value=, for input parameter= [ "name", "ClaimInquiry_Bloodhound_REALM" ], [ "nameInNameSpace", "ClaimInquiry_Bloodhound_REALM" ], [ "stringToBind", "bh0009" ]
          ^
, line ignored
----------------------------------------------------------------------
'StringNameSpaceBinding' '/Cell:ProcCell01/Node:wps01Node01/Server:Cots1/' '[ [ "name", "xPressionWaterMarkProfileName" ], [ "nameInNameSpace", "xPressionWaterMarkProfileName" ], [ "stringToBind", "ENV05__NH_Realtime_Watermark_View" ] ]'
----------------------------------------------------------------------

Error: WASX7122E: Expected "]"  not found.
Attribute=name had invalid value=, for input parameter= [ "name", "ClaimInquiry_Bloodhound_REALM" ], [ "nameInNameSpace", "ClaimInquiry_Bloodhound_REALM" ], [ "stringToBind", "bh0009" ]
          ^
, line ignored
----------------------------------------------------------------------
'StringNameSpaceBinding' '/Cell:ProcCell01/Node:wps02Node01/Server:Cots2/' '[ [ "name", "xPressionWaterMarkProfileName" ], [ "nameInNameSpace", "xPressionWaterMarkProfileName" ], [ "stringToBind", "ENV05__NH_Realtime_Watermark_View" ] ]'
----------------------------------------------------------------------
0 objects created.
ASKER CERTIFIED SOLUTION
Avatar of HonorGod
HonorGod
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
You Rock!!!!
Thanks for the compliments, grade and points.

Good luck & have a great day.