Tuesday, August 11, 2015

Automation of RPD Deployment in OBIEE


In post I will be explaining you How we can Automate the RPD Deployment in OBIEE.


Will provide you the script just you need to change the property file and provide the location of RPD in the script.
The concept is simple if you have the script just you need to schedule it via any scheduler making sure that latest RPD is available in mentioned folder.


Now reason why you are here is the beauty of this script is it is going to be CoreScript for your all the environment because suppose if you want to the deployment in another environment just you need to change location of properties file when batch or cmd file which you are going to invoke.


Below is the Command File which can be scheduled or can be invoked manually.

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
REM This script created by Vikram and it take 2 parameter i.e. properties file and RPD location. It is mandatory to have the properties file and OBI rpd in mentioned folder.

@echo off

REM Calling the Python script DeployCore.cmd to deploy the RPD even this scipt will do the recycle of OPMN services via mbean.

call wlst <deploy_script_location>\DeployCore.cmd <location_of_properties_file>\server.properties <location_of_latest_RPD>\OBI.rpd

REM Once the RPD is deployed it the latest RPD must get copied from 01 server to Cluster environment. Below line will accompolish that.

xcopy \\servername\D$\OBIEE\instances\instance2\bifoundation\OracleBIServerComponent\coreapplication_obis1\repository\OBI_BI*.rpd \\server\D$\OBIEE\Cluster_RPD /s /d /Y

pause

exit
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++


Below is the script of the Deploying RPD (DeployRPD.cmd).
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
# This script will deploy the RPD and will recycle the OPMN services via mbean in 01 and 02 server
#
# Script expects the following arguments but all the information are passed by server.properties file.
#

import sys
import os

import java.io
from java.io import FileInputStream

# Check the arguments to this script are as expected.
# argv[0] is script name.

argLen = len(sys.argv)
if argLen -1 != 2:
    print "ERROR: got ", argLen -2, " args."
    print "USAGE: It must contains the properties file and latest OBI RPD location"
    print "   eg: wlst server.properties OBI.rpd"
    exit()

properties = sys.argv[1]
rpdlocation = sys.argv[2]

propInputStream = FileInputStream(properties)
configProps = Properties()
configProps.load(propInputStream)

adminUrl = configProps.get("admin.url")
adminUser = configProps.get("admin.username")
adminPassword = configProps.get("admin.password")
rpdpassword = configProps.get("admin.rpdpassword")

#print 'Connecting to '+ WLS_HOST+ ':' + WLS_PORT + ' as user: ' + WLS_USER + ' ...'

print 'This script is creating by Vikram Kumar For any comments please reach at vikram.kumar@abc.com'

connect(userConfigFile=adminUser,userKeyFile=adminPassword,url=adminUrl,timeout=0)

print 'Connecting to Domain ...'
domainCustom()

cd ('oracle.biee.admin')

cd ('oracle.biee.admin:type=BIDomain,group=Service')

# define the MBean parameters and data types as arrays

objs = jarray.array([],java.lang.Object)
strs = jarray.array([],java.lang.String)

# Invoke the lock operation from the BIDomainMBean
# (equivalent to the Lock and Edit Configuration button in
# Enterprise Manager

print 'Locking the domain ...'

invoke('lock',objs,strs)

# Read the name of the first instance from first entry
# in the BIInstances property within the BIDomainMBean
# (initially returned as an array, first value selected)

biinstances = get('BIInstances')
biinstance = biinstances[0]

# Connect to the corresponding BIInstanceMBean

print ('Connecting to BIInstance MBean')

cd ('..')
cd (biinstance.toString())

# Retrieve the name of the MBean for managing the
# BI Server configuration

biserver = get('ServerConfiguration')

# Connect to the ServerConfigurationMBean for this BI Server

cd ('..')
cd (biserver.toString())

# Now prepare for the RPD upload
# Prepare arrays for parameters and datatypes
# Load the parameters with the RPD name and password
# Then invoke the uploadRepository within the ServerConfigurationMBean

print ('Uploading repository ...')

argtypes = jarray.array(['java.lang.String','java.lang.String'],java.lang.String)
argvalues = jarray.array([rpdlocation,rpdpassword],java.lang.Object)

invoke('uploadRepository',argvalues,argtypes)

# Now go back to the BIDomainMBean and commit the change
# (equivalent to the Activate Changes button in Enterprise Manager)

print ('Committing the update ...')

cd('..')
cd('oracle.biee.admin:type=BIDomain,group=Service')
objs = jarray.array([],java.lang.Object)
strs = jarray.array([],java.lang.String)

invoke('commit',objs,strs)

print ('Now restarting the instance, to pick up the new RPD file')

print 'Connecting to BIInstance MBean ...'
cd ('..')
cd (biinstance.toString())

# The BIInstanceMBean controls the overall status of
# the Oracle instance, and if directed to stop or start
# will stop/start all components together

print 'Getting instance status ...'

# ServiceStatus property in BIInstanceMBean returns
# the current status of the instance

servicestatus=get('ServiceStatus')
print 'BIInstance MBean; ServiceStatus: ' + servicestatus

# Stop action, if invoked, will stop entire instance

print 'Calling stop ...'
objs = jarray.array([], java.lang.Object)
strs = jarray.array([], java.lang.String)
invoke('stop', objs, strs)
servicestatus=get('ServiceStatus')

print 'BIInstance MBean; ServiceStatus: ' + servicestatus

# Start action will start the instance, and pick up
# the configuration change (the new RPD file path)

print 'Calling start ...'
objs = jarray.array([], java.lang.Object)
strs = jarray.array([], java.lang.String)
invoke('start', objs, strs)
servicestatus=get('ServiceStatus')

print 'BIInstance MBean; ServiceStatus: ' + servicestatus

print 'RPD Upload now complete!'

exit()
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Below script is for the server.properties file
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
admin.url=t3://servername:7001
admin.username=<location of username>/configfileqa.secure
admin.password=<location of password>/keyfileqa.secure
admin.rpdpassword=ABCDEFG
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Now here you can see that admin username and password has been supplied configfileqa.secure and keyfileqa.secure respectively. So this is encryped username and password, it can be generated using below link:

https://blogs.oracle.com/bala/entry/encrypt_the_credentials_when_r

Please do reply me back if you have some new finding or comments.

Thanks.