WSADMIN basics. ○ Scripting with WSADMIN. ○ JACL. ○ Jython. ○ Script WSADMIN is a scripting interface used at the command line. WSADMIN is a scripting interface used at the command line. You can use the The possible languages include: Jacl and Jython. you can run. Basics to write your own jython scripts to get reliable and consistent Jython • Version included in wsadmin – Functions of Python or.

Author: Baktilar Akile
Country: Syria
Language: English (Spanish)
Genre: History
Published (Last): 21 January 2008
Pages: 286
PDF File Size: 1.14 Mb
ePub File Size: 19.96 Mb
ISBN: 225-3-63669-153-5
Downloads: 42645
Price: Free* [*Free Regsitration Required]
Uploader: Kar

Even before writing a book about WebSphere Application Server Administration Wsxdmin JythonI was aware of how few examples exist that describe how you might go about creating a complete script. Therefore, I thought it might be helpful for aspiring wsadmin script writers if I described the process that I have used many times to create such scripts.

WPS and WAS Jython Scripting – Knowledge Wiki

In general, these are the high level steps you need to perform to create a wsadmin script from scratch:. For demonstration purposes, this article describes the steps you would perform to build a script that enables you to create cluster members. For example, should the script be able to create just a single cluster member, or would you also want the ability to use it to create more than one member at a time?

As you begin, the idea is to first find information about the task you are interested in so you can understand the process and the parameters that are involved. This will enable you to can create a script that performs the task in a proper and efficient manner. The result is encouraging because items titled Creating cluster members using scripting display at the top of the search results.

Select the first such link to display the related documentation:. Searching for AdminConfig produces several results, including one at the top of the results list called Commands for the AdminConfig object using wsadmin scripting. Reviewing this item reveals that a createClusterMember method exists on the AdminConfig scripting object.

Take a quick look at the examples farther down that page to better understand how they are used. How is it that the templateID parameter can be left off the sample code if it is really required?

The templateID parameter is actually only permitted for the first member of the cluster. The creation of subsequent cluster members uses the first member as a template.

WSADMIN Tutorial – Part1 – WebSphere Application Server Notes

About the sample scripts provided Using the scripts provided enables you to maintain focus on the process of creating wsad,in desired script rather than the mechanics of creating the required cluster containing a single member. This article acknowledges that a cluster Cluster1 and its first member Member1 were created previously.

Also, since these scripts were created using the processes described in this article, you can also use them as additional examples for study wsdmin.

To help you do that, you can use these scripts, which are included in the download materials accompanying this article and which were created using the techniques described here:. Listing 1 shows this interactive session, and Table 2 explains the session in detail. Here is what a script would need to do to create a single cluster member using this technique:. Of course, this is just a rough approximation of the process, but it gives you an idea ttuorial the kind of coding that is required to use this particular technique.

Search the Information Center again, this time for the term AdminTask. With more than results, you have to scroll down a bit to find an item called ClusterConfigCommands command group for the AdminTask object. Selecting this item provides a link to the createClusterMember method, which is described further down the page.

This section helps you better understand how to use this method:. This means tutorlal can ignore the template-related parameters and focus on just those parameters related to the creation of subsequent cluster members. If you are going to have your script use scripting object methods to create cluster members, then you need understand the parameters that are available.


Because the documentation on this can be confusing, try using interactive wsadmin sessions to get a better understanding. One of the really powerful wswdmin useful things about the AdminTask scripting object is that almost every method includes a way to “step through” the parameter definitions. You do this by calling the method and specifying -interactive as the only parameter. Use this technique now to learn the difference between using the cluster configuration ID and the cluster name, as they relate to the createClusterMember method.

Start by calling the method, similar to what you see on Line 1 of Listing 2a. Because of the number of lines generated during this wsadmin session, it has been divided here into Listings 2a through 2e. The result of the interactive call is assigned to a variable Listing 2a, Line 1 because when you are done with your interactive parameter specification, the resulting call to AdminTask. The result of the call will be the configuration ID of the newly created cluster member.

Line 6 is where the AdminTask scripting object prompts you for information, telling you that it is looking for the value of Cluster Object ID that is, the configuration ID of the cluster to which a new member is being added.

Because you want to find out what this command looks like when you specify a configuration ID, copy and paste the complete configuration ID of the cluster in response to this prompt. Continuing with this interactive session in Listing 2b, you are prompted for the name of the cluster in which the member is to be created. Therefore, you can simply press Enter Listing 2b, Line 1. This results in the display of the available steps as a submenu Lines 6 through 9the available input options Lines 11 through 14and the command prompt requesting your input Line 17, with the default selection shown in square brackets.

Notice how the default command is S for Select. If you press Enteror the letter S followed by Enterthen the specified step will be preformed, and you will see the information shown in Listing 2c. In Listing 2c, the selected step description and step name are displayed in Line 1. The current values for the current step attributes are shown in Lines 3 through 9. Again, required values are prefixed with an asterisk. Because the values of some required attributes have qsadmin to be defined, the default command is E for Edit Line When you press Enter at this point, you will be prompted for the missing values that are required.

Listing 2d shows these prompts and the responses that were provided Lines 1 through 8. In this case, the only values that were entered were for the tutoorial attributes Lines 1 and 2. jytthon

The important thing to note is that since all required attribute values have been provided, a new command, F Finish is now available Line 20 and is also the default command Line Selecting the Finish command initiates the last phase of the interactive method and ultimately displays the generated command. The result is shown jthon Listing 2e. The basic form of the command is:.

The TargetObject, as you can readily see, is the configuration ID of the target cluster to which the new member will be added. The Parameters value is a little more complicated, but is a string in the form:. You might remember seeing memberConfig before; it appeared in Listing 2b Line 6Listing 2c Line 1and in the Steps subsection of the Information Center documentation. You can now correlate the documentation to the interactive createClusterMember interactive session, and see how the pieces jythpn the puzzle fall into place.

You can also see that the generated command includes some of the default values for example, genUniquePorts and replicatorEntry.

Getting started with wsadmin scripting

Since they are default, you can decide later whether or not tutoroal script needs to provide these values. At this point, you have used the interactive form of the createClusterMember method to determine exactly how the command would look should you decide to use the cluster configuration ID.

You can do the same thing to see how the command would look if you used the clusterName parameter instead. All you have to do is use the AdminConfig. The result of doing this is shown in Listing 3. In fact, the -memberConfig values are identical to what you saw earlier. This might help you better understand the on-line documentation where the -clusterName parameter was identified as required.


The scritping for the —clusterName parameter indicates that either the TargetObject or the —clusterName value should be specified. If both are actually provided, an exception is thrown, and the command is not executed. Hopefully, this exercise has helped iython to understand the createClusterMember method, its -interactive execution, and the documentation that supports it. Having done this, you now know that the parameters your script would need to handle to use the AdminTask.

For the purpose of this article, and for simplicity, the default values will be accepted for all other values. You should now have a fairly good understanding of what it would take to use this approach to create a script.

The third approach you might consider for accomplishing the task of creating cluster members is using the createClusterMember method in the AdminClusterManagement scripting library.

Because the scriptLibraries already exist in WebSphere Application Server V7, this approach might enable you to meet your requirement with a minimum of effort.

Cluster configuration scripts using wsadmin scriptingwhich describes some of the methods in that library module, including the createClusterMember method — which appears to be exactly the scriptiny of information for which you might be looking. To test this, you need to have a deployment manager configuration that has at least one cluster with at least one member. Listing 4 shows a sample interactive wsadmin session used to test this situation, and Table 3 describes these steps in detail.

Finding the source code for a specific method is relatively easy. Listing 5 shows an example of how you can use this attribute. Make a copy of any library file that you want to view, and then edit only your copy.

Looking closely at the AdminClusterManagement. For example, you might notice that no default value is provided for any of the first three parameters clusterName, nodeName, or newMember.

Therefore, you must specify a value for each when the function is called. This is apparent when you review the code because, except for the method banner that displays information about the method and how it was called, the values of these parameters are checked to see if they contain an empty string.

Listing 6 shows some of this code. The specific details of the parameters provided to the AdminUtilities. Are these checks necessary — or sufficient — for your environment? That will depend on your requirements and how thorough you need to be; for example, do you need to check for:. The scripting library modules raise a ScriptLibraryException when a parameter error occurs.

The code then determines whether the specified values are valid. You could, however, make some improvements to the code shown in Listing 6. For example, Line 2 shows a check that determines if jyython empty string has been provided. If not, Lines 12 and wsadmni check to see if the specified cluster exists.

Creating a Jython administrative script for IBM WebSphere Application Server

A problem with this code occurs when a clusterName containing a single blank is specified; the empty string check in Line 2 returns false, and the result of the call to the AdminConfig. Also, the test in Scrkpting 13 will fail to detect an error because the result of the call will not be an empty string.

When the parameter checking is complete, all that remains is the actual call to the AdminTask. Having recently investigated this call, it should be easy to understand the statement itself:. As you might know, the Jython wsadmin scripting object methods can pass either tutoorial list of strings as you see here or a string of lists which you saw earlier.

The difference is in the syntax.