Posts

Showing posts from August, 2014

Creating New Server using Jython

Image
In this learning and sharing today created a server using Jython script. The basic needs to create a App Server in WebSphere environemnt is to have Node and it should be added to the Cell. The script would perormed with the help of the NodeID to create the server. create is the simple command method on the AdminConfig object. CreateServer.py import sys # import system libraries #interactive method, type server & node name servername=raw_input("Enter server name:") nodename=raw_input("Enter Node name:") # get the config id of the node print "getting config id of node .." nodeid=AdminConfig.getid('/Node:'+nodename+'/') # verify whether the entered node exist or not try : if nodeid=='': print "entered correct node", nodename except: print " the node does not exist, please enter a valid node" # get the config id of the node #print "getting config id of node .." #nodeid=AdminConfig.getid...

Getting Node id, Cell ID, Server ID of Mbean in wsadmin

Image
Hey automation expert welcome to another interesting exploration on wsadmin basic commands that could build your Jython script much effectively. Let's jump into it. Basic understanding of wsadmin objects Here I've listed out what we need to consider as wsadmin objects which could help as build blocks for your Jython based automation scripts. Node – an individual system, either physical or virtual Node Manager – the process controlling the individual node and all servers in all cells, it executes the commands of the Deployment Manager Profile – a WebSphere entity similar to a node concept wise Application Server – a Java Virtual Machine (JVM) process Application – a Java enterprise application it could be .ear file with some modules Cluster – a group of Servers, all running the same applications Cell – an administrative domain of one or more servers Deployment Manager (DM) – the administration application for a cell How do all these pieces work togeth...

Administration objects and their help in wsadmin

Image
Welcome to Jython exclusive blog developed for the WebSphere Admins only. Here in this post we can explore more about the real-time wsadmin Objects. Which are most critical to develop the automate WebSphere server side.  wsadmin>print AdminConfig.help() WASX7053I: The AdminConfig object communicates with the Config Service in a WebSphere server to manipulate configuration data for a WebSphere installation. AdminConfig has commands to list, create, remove, display, and modify configuration data, as well as commands to display information about configuration data types. Most of the commands supported by AdminConfig operate in two modes: the default mode is one in which AdminConfig communicates with the WebSphere server to accomplish its tasks. A local mode is also possible, in which no server communication takes place. The local mode of operation is invoked by bringing up the scripting client with ...

Functions and Procedures in Jython wsadmin

Image
Modular programming is the need in the every scripting language it will tear down the bigger problem statement into small pieces and easy to resolve. We can get the strategy in building the Jython Functions and Procedures for different tasks. The are different ways to create the function body structure. A function is a sub program, which takes inputs as arguments, you can pass multiple arguments, same kind of data as agreements. A Function can return a value then that function call can be called in assignment statement, output statement, it can be in the expression. Functions can be created to reduce the complexity in the scripts  It  is easy to read and reuse them Function definition became a procedure when there are no return statement in it   The function definition in Jython The defining a new function starts with 'def' keyword. the function block begins with a name of the function and colon and followed by the Jython program control statement or J...

Errors and Exceptions in Jython

Image
Welcome to Jython4wsadmin blog!! This post is intended to collect all Errors and Exceptions that can occur when you work on WebSphere administration using wsadmin scripting. As you are aware that Jython is inherited from Python. We can categories the Errors and Exceptions as per their inheriting languages. Errors defined in Python Exception from Java Script based Exceptions depends on WASXShell When you start woking on the WebSphere Admin scripts you might encounter many types of Errors and Exceptions. Here you must focus on Python based Errors to make syntatic correct code. wsadmin>execfile('/home/krish/jython/while.py') WASX7015E: Exception running command: "execfile('/home/krish/jython/while.py')"; exception information: com.ibm.bsf.BSFException: exception from Jython: Traceback (innermost last):   File "<input>", line 1, in ?   File "/home/krish/jython/while.py", line 11         while x>=0         ...

Dictionary Accessing

Image
Dictionary Accessing  Jython provides many sequqnces and datastructures. Here is a map type where it is a combination of key and value pair or elements in a list. Diectonary in Jython script Lets do the experiment with Dictonary objects in Jython. Example of Dicttionary objects in Jython #This script is for adding, deleting, modifying,itrating. D={'dmgr':'10.12.13.14:80','app1':'10.0.0.12:90','app2':'10.0.0.15:100'} #Adding a element to dictionary D. D['app3']='10.1.1.12:85' #Update with New dictionary D2={'app4':'10.0.0.0:95'} D.update(D2) for k,v in D.items(): print k,'->',v #modifying dictionary element print 'modifying the dictionary app2' D['app2']='10.0.0.15:98' for k,v in D.items(): print k,'->',v keylist=D.keys() k=keylist.sort() print keylist for k in keylist: print k,'->',D[k] O/P wsadmin>exec...

Dictionary Data type in Jython wsadmin

Image
Dictionary Data type Now I have to evaluate dictionaries in the sequences types.  It is the combination of (Key, Value) pairs forms as elements in the dictionary type. We can extract each one as separate list that is keys list, values list. See my examples given in the below: Diectionary type in Jython # items is list of tuples and list variables, list variables in#This script will be sample for the dictionary type D1={} print D1 D2={'app1':'192.168.11.129:80', 'app2':'192.168.11.130:81$ print D2 print D2['app2'] print D2.keys() print D2.values() print D2.items() $variables in square brackets and tuples in round bracket$ square brackets and tuples in round brackets. O/P {} {'app2': '192.168.11.130:81', 'app1': '192.168.11.129:80'} 192.168.11.130:81 ['app2', 'app1'] ['192.168.11.130:81', '192.168.11.129:80'] [('app2', '192.168.11.130:81...

Jython variables in wsadmin

Image
A warm Welcome to my jython4wsadmin blog!! Variables in programming languages we need to declare on the top of the function or program. When we declare it we need to tell about what type of data we would like to store in the variable. Where as in Scripting languages you don't need to do so. Jython is a scripting language so you don't need to declare the variable. Like any programming language Jython also support variables but these variables looks like scripting variables, they are dynamic. The value that assigned to a variable is going to have an id and label internally it is one of the Python Object type as well. Let me experiment with my simple Jython script to understand more how the variables can be created and used in multi variants. Here the values can be integer, float, long types in numeric data types. Jython Variable inside wsadmin # This program will illustrate the variables of jython. # Integer variable x=5 print 'x=', x, type(x), id(x)...