One of my online buddy requested me for a Side by Side(SBS) deployment using WLST
Description : A Python Script for SBS deployment.
The project is in developing stage, the client need deploying the same applications with different versions must be available for development and testing teams,
an automated handy script is requested to prepare buddy WLA. To do this interesting task, the plan for execution is prepared as following while doing the deployment criteria:
1. If the application is New and the version is new i.e no other version is in the ACTIVE state with the given appName, the script will deploy the application
2. If one of the version of given application is in ACTIVE state visible in the console, then the developer is try to deploy the next version, the script should do DeActivate the old version and deploy the new version.
3. so now already have two versions deployed on the domain one is : ACTIVE state and other is in RETIERED State then undeploy the REITRED versioned application with a timeout or deploy the new version so that it will make current ACTIVE application to RETIERED and new deployment to ACTIVE.
For implementing the above logic in cronological way. Issue was with iterations. it was controlled by 'break' statement usually any C programmer knows it. And I have used here a flag variable 'appFlags'.
like that we are maintained 2 version max in the console of the same app.
import sys
#===========================================================
# Function for fresh plain deployment
#===========================================================
def newDeploy(appName,ver):
print 'Deploying .........'
deploy(appName,'/path/applications/'+appName+'/'+ver , targets='AdminServer')
startApplication(appName)
#===========================================================
# Function for finding the Application Status
#===========================================================
def appstatus(appName, serverName):
cd('domainRuntime:/AppRuntimeStateRuntime/AppRuntimeStateRuntime')
#get current real state for app in specific server
currentState = cmo.getCurrentState(appName, serverName)
return currentState
#===========================================================
# Undeploying the given applicaiton
# Target we can change according to domain and applicaiton deployed on
#===========================================================
def unDeploy(appName):
print 'stopping and undeploying ....'
stopApplication(appName, targets='AdminServer')
undeploy(appName, targets='AdminServer')
#===========================================================
# Main program here...
# Target you can change as per the need
#===========================================================
appName=sys.argv[1]
ver=sys.argv[2]
connect(user, passwd, adminurl)
cd('AppDeployments')
appflag=0
y=ls(returnMap='true')
for i in y :
if i.startswith(appName ) ==1:
#Checking for the application existence)
print i
print appstatus(i,'AdminServer')
if appstatus(i,'AdminServer')=='STATE_RETIRED' :
appflag=1
break
elif appstatus(i,'AdminServer')=='STATE_ACTIVE':
appflag=2
else:
print ' other Applications are Running '
pass
if appflag == 1 :
print 'application having RETIERED STATE ..'
unDeploy(i)
print appstatus(i,'AdminServer')
newDeploy(appName,ver)
print appstatus(i,'AdminServer')
elif appflag== 2:
print 'Application exists in ACTIVE state...'
newDeploy(appName,ver)
print appstatus(i,'AdminServer')
else:
print 'new application'
How to execute this?
Dear novice WLA, you can execute this script by re-defining your connection parameters at line 36. One more thing is the application targeted to AdminServer this may vary for your environment.
Dear novice WLA, you can execute this script by re-defining your connection parameters at line 36. One more thing is the application targeted to AdminServer this may vary for your environment.
prompt$ java weblogic.WLST SBSDeploy.py
2 comments:
Hi, your blogs are really helpful....But while doing deployment using WLST it is working fine but creating a difectory structure in the location from where i am running my script...the directory structure is
my_dir(from where i ran the script)..
my_dir/config/deployments/my_warfile/
my_war_file is also a directory but empty
can you help me in this issue i am bit new to wlst
Thunderboy,
Can you share your script so that it will be clear to understand your concern.
What deployment mode you are using?
What is the error you are getting?
Post a Comment