?
Solved

WAS7 automation scripts

Posted on 2012-03-16
7
Medium Priority
?
510 Views
Last Modified: 2012-03-19
like that i have 20 apps
so now i am running each application using below command at command prompt manually:
wsadmin.bat -lang jython -f C:/opt/WAS/xxxx/deployments/scripts/createJ2Cauth.py C:/opt/WAS/xxxx/deployments/scripts/apps/yyyy/app1/createj2cauth.properties
............
in my development environment it is working fine
Now my questions is:
1) i need a shell script or jython script to run and set all resources(like batch file) on UNIX and windows environment
2) i need a shell script or jython script to run particular .py and .properties to set resource by taking the user input.
Ex: i need to update only J2C authentications
i am not expert in shell or jython script could you please somebody help me on this ...

Thanks in advance
0
Comment
Question by:prathapjava
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
7 Comments
 
LVL 41

Expert Comment

by:HonorGod
ID: 37730908
You have lots of options.
For example:
- if all of the commands to be executed are in some directory, and they all use the same properties file, you could have a Jython script expect / require the "directory" containing the scripts to be executed.  It could then use operating systems command to identify all of the *.py (or *.jy) files in the specified directory, and use "execfile" command to execute each.
> The challenges:
  ? What should be done if & when an error is encountered?

- Another possibility: have a file contain the list of script to be executed.
  This has the advantage of specifying an order in which the scripts should be run.

What would you like to do?
0
 

Author Comment

by:prathapjava
ID: 37731078
we have 20 applications  folder structure like below:
each application i created below WAS scripts to configures resources in WAS7:
C:\opt\WAS\xxxxx\deployments\scripts\createdatasource.py
C:\opt\WAS\xxxxx\deployments\scripts\deployear.py
C:\opt\WAS\xxxxx\deployments\scripts\createtimermanager.py
C:\opt\WAS\xxxxx\deployments\scripts\createJ2CAuth.py
C:\opt\WAS\xxxxx\deployments\scripts\createworkmanager.py

each application properties we have separate properties file directories like below
app1:
C:\opt\WAS\xxxxx\deployments\scripts\apps\yyyy\app1\createdatasource.properties
C:\opt\WAS\xxxxx\deployments\scripts\apps\yyyy\app1\deployear.propetties
C:\opt\WAS\xxxxx\deployments\scripts\apps\yyyy\app1\createtimermanager.properties
C:\opt\WAS\xxxxx\deployments\scripts\apps\yyyys\app1\createJ2CAuth.properties
C:\opt\WAS\xxxxx\deployments\scripts\apps\yyyy\app1\createworkmanager.properties
app2:
................................................
............................................
..................................................
like that i have 20 apps
so now i am running each application using below command at command prompt manually:
wsadmin.bat -lang jython -f C:/opt/WAS/xxxx/deployments/scripts/createJ2Cauth.py C:/opt/WAS/xxxx/deployments/scripts/apps/yyyy/app1/createj2cauth.properties
............
in my development environment it is working fine
Now my questions is:
1) i need a shell script or jython script to run and set all resources(like batch file) on UNIX and windows environment
2) i need a shell script or jython script to run particular .py and .properties to set resource by taking the user input.
Ex: i need to update only J2C authentications
i am not expert in shell or jython script could you please somebody help me on this ...

Thanks in advance
0
 
LVL 41

Expert Comment

by:HonorGod
ID: 37732601
Much of which just said was stated when you opened the question.

Q: Do each of the scripts to configures resources, i.e., the ones in this folder:

     C:\opt\WAS\xxxxx\deployments\scripts

     each contain a single (or small number) of function definitions?
     or, do the each contain a bunch of code?

Can you attach one, or a small number, so that we can get an idea what they look like?
If you can, please include the corresponding properties file so that we can better understand how the scripts work.

Would you prefer 1 script that allows you to specify command line options identifying the operation to be performed?

For example, something like:

wsadmin -lang jython -f configure.py --application AppName --operation createJ2Cauth

Open in new window


If the directories containing the function to be executed, and the properties files are fixed, then this could be "hard coded" in the "configure.py" script.

Does that make sense?

Of course this is just one, of many possible, options.
0
How to Create Failover DNS Record Sets in Route 53

Route 53 has the ability to easily configure DNS record sets specifically for failover scenarios. These failover record sets can be configured to failover to full-blown deployments in other regions or to a static HTML page that informs your customers of the issue.

 

Author Comment

by:prathapjava
ID: 37733398
As you mentioned please find the attached createJ2C.py and create j2c.properties files

now i am running particular .py file using the command below in windows command prompt its working fine:
wsadmin.bat -lang jython -f C:/opt/WAS/xxxxx/deployments/scripts/createJ2Cauth.py C:\opt\WAS\xxxxx\deployments\scripts\apps\yyyys\app1\createJ2CAuth.properties

here j2c for one application app1 is working fine but i have app1,app2,app3...........app20 like 20applicatication i need shell or jython script to run all apps at a time and also i need another script in that user can input app name command line  arguments like
app3 j2c update/create then the script should able to call particular .py and respective .properties file this is my requirement

sorry for the confusion i think now you got my question

thanks in advance
createJ2CAuth.py
createj2cauth.txt
0
 
LVL 41

Accepted Solution

by:
HonorGod earned 2000 total points
ID: 37737372
- One interesting technique that is used by the script (createJ2CAuth.py), is the way that information is stored, and loaded from the properties file.  The code requires the properties file to be formatted in a specific way.

Q: Is this something that you came up with, or was it from someone / somewhere else?

- The reason I ask is that using "eval" to interpret the information from the properties file can be problematic. There are many examples of just how bad this technique can be, consider a properties file containing something like this:

  os.system( 'echo some nasty command' )

  As long as the os module has been imported, the result of using eval() to to "interpret" this would result in the execution of the command by the operating system.

- Ignoring that, for the moment, we can do what you want by adding a little something to the bottom of each of your *.py files.

- Currently, the script ends with code like this:
# Read command line arguments
# Please pass the updatedatasource.properties as command line argument
# /opt/WAS/stage/AppServer/bin/wsadmin.sh -lang jython -f createJ2CAuth.py createj2cauth.properties
if len(sys.argv) == 0:
    print "This script requires properties file as command line argument"
    exit(0)
else:
    infileName = sys.argv[0]
    exemain()

Open in new window


It we were to change the script just a little, it would prove very helpful, and beneficial to the task.

What should we do?

- Allow the script to be executed, or imported

While I was at it, I cleaned up the code a little.
1. I replaced all tab characters with spaces - mixing tabs and spaces to indent is a very bad practice
2. I passed parameters instead of depending upon global variable, e.g., exemain()
3. Changed readFile() to require a fileName, instead of fileHandle & dictionary

How does that help us solve the original problem?

Well, now this script can either be used stand-alone, just like is currently being used, and, it can also be imported by another script so that the createJ2CAlias() routine can be used elsewhere.  For example:

from createJ2CAuth_01 import createJ2CAlias

Open in new window


Does this make sense?

Then, you can have one script that allows you to decide what operation(s) you need to perform, and call the appropriate routine.
createJ2CAuth-01.py
0
 

Author Closing Comment

by:prathapjava
ID: 37738398
Thanks sir its working fine
0
 
LVL 41

Expert Comment

by:HonorGod
ID: 37738514
Thanks for the grade & points.

Good luck & have a great day.
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this tutorial I will show you how to provide a dynamic RTF document on your website generated with data from your database. For this tutorial you will need Microsoft Word or WordPad, WhizBase and Microsoft Access. In this tutorial I will show …
The Windows functions GetTickCount and timeGetTime retrieve the number of milliseconds since the system was started. However, the value is stored in a DWORD, which means that it wraps around to zero every 49.7 days. This article shows how to solve t…
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.
Suggested Courses

718 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question