Search This Blog

Saturday, June 18, 2016

Multitenancy in WebLogic 12c Part -7 Deploy and Undeploy Application to a Domain Partition

After almost four months took me to write this, due to busy in work this blog post on WebLogic 12.2.1 MT feature exploration took some time. To workout multiple deployment scenarios on MT environment we need real-time implementation environments. As of now I've limiting my scope to web application deployment on to a partition. You could do much more wider automation using WLST based on this script.

Pre-requisites set-up for Multitenancy:

You can also visit the following post so that you can have connectivity what we are discussing here.

  1. Configure Security Realm for MT
  2. Create Users & Groups for Partition domain
  3. Configure Virtual Target
  4. Creating Partition Domain
  5. Configure IDD for Partition
  6. Partition Control (start/stop using WLST)
  7. Deploy and Undeploy Application on Partition [This post]

Download sample application

You can download sample web application for WebLogic environment :
Here I am using benefits.war which available in Oracle examples.
Download Shopping Cart Sample Link

Deploying an application to a WebLogic server fine it was upto 11g and regular WebLogic environment. In WebLogic 12.2.1 MT introduced with the great feature that is maintaining small domain partitions where you can feel the required resources all that need to run the application you will get in the partition. This MT deployment might more frequent when your application moved to WebLogic 12.2.1.

The deploy() and undeploy() command variation with the number of arguments you pass that are related to partition or resource group template. Here I've used first option targeting to a RUNNING State partition. As Oracle recommends to use ResourceGroupTemplate as target in the MT environment.

undeploy with WLST on Partition Domain
WebLogic web application deployment with WLST to a partition


The best benefit you can provide it to the partition deployment do one time deployment same partition you can package using export you will get final outcome as zip file. That you can reuse in other test environments as well.using import.

def deploy2partition(a,ap, p,rg,o):
        progress=deploy(appName=a, path=ap, partition=p, resourceGroup=rg, deploymentOrder=o, securityModel='DDOnly')
        while not (progress.isCompleted() or progress.isFailed()) :
                os.time.sleep(2)
        print progress.getState()

def undeploy4mPartition(a, p):
        progress=undeploy(appName=a,  partition=p)
        while not (progress.isCompleted() or progress.isFailed()) :
                java.lang.Thread.sleep(2000)
        print progress.getState()

def main():
        # The following are the properties which can be changed according to your needs.
        APP_PATH='/u01/app/software/benefits.war'
        APPNAME='BENEFITS'
        USER='weblogic'
        PASSWD='welcome1'
        ADMURL='t3://192.168.33.100:6100'

        connect(USER, PASSWD, ADMURL)
        partitionName="Corporate_partition"
        rgName="Corporate_rg"
        DOrder=10

        if len(sys.argv) >1:
                choice  = sys.argv[1]
        else:
                usage()

        if choice == 'deploy':
                deploy2partition(APPNAME, APP_PATH, partitionName, rgName, DOrder)
        elif choice == 'undeploy':
                undeploy4mPartition(APPNAME, partitionName)

        disconnect()
        print "Deployment process on partition completed successful !!!"

def usage():
        print """Usage:
        wlst """+sys.argv[0] +""" deploy | undeploy"""
        exit()

main()

The deploy option:
 wlst partitionDeploy1.py deploy
WLST deploy on Partition Domain
Administration Console deployment update:
The undeploy option:
 wlst partitionDeploy1.py undeploy
WLST Undeploy on Partion

Popular Posts