Posts

Jython Multi Threading in wsadmin

What is the Multi threading? Multi threading is similar to how multiple programs runs on your computer system, moreover which run at same time. When you are running multiple tasks in parallel on same CPU[machine]. More cores parallel processing allowed by your VM. The simple mapping let me tell you that if you have 1 core CPU that links to Multiple threads. Do's and Don'ts in threading Let us talk about does first here: You defined tasks which are independent of each other Physics/collision calculations in on thread, graphics in another All the threads should communicate back with the main thread which actually starts them Don'ts If you don't have clarity on multi threading then whole program would mess up! so be-careful Simple Threading examples on wsadmin The following sample is from tutorial point python examples. import threading import time exitFlag = 0 class LearnThread (threading.Thread): def __init__(self, threadID, name, counter): ...

Jython Date and time formats experiment

Basic date and time formats in Jython This is common requirement in most of our WAS administration tasks. You need the date or time formats in the following tasks: Back of the deployment units such as .war or .ear or .jar files Log file rotations Monitoring report logs with time stamps Update the Logger with time stamp Jython allow us to use time object only from Python module. other two date, datetime objects are not available in Jython. Lets experiments with the time object and its different functions in a simple script: import time timetuple=time.localtime() print "Time tuple:", timetuple print "Time tuple with loop" for t in timetuple: print t # Week of the day print "Today Weekday in short:",time.strftime('%a') print "Today Weekday in full:", time.strftime('%A') # Month of the date print "This month in short:", time.strftime('%b') print "This month in full:", time.strftime('%...

Creating cluster using Jython wsadmin

Pre requisites  As per todays experiment what I understood is we need the following are the pre-requisites for the Cluster configuration in WebSphere Environment: 1) Cell created with a DMGR Profile 2) Nodeagents created and added to the cell. 3) Dmgr, Nodeagent must be running. Jython Script for Cluster import sys import os import socket #Get the operating system line separator from the linesep method of the os object nl = os.linesep # Store the Cell identifier for the specified Cell cellID = AdminConfig.list('Cell') cellName = AdminConfig.showAttribute(cellID, 'name') #derives the environment type from the cellName sName = cellName.replace("Cell","") sName = sName.replace("Demo","") # Store the Node identifier for the specified Node nodeIDs = AdminConfig.list('Node').split(nl) nodeNames = AdminTask.listNodes().split(nl) nodeNames.sort() # Identify each node and it's purpose so we can start creating s...

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...