We recently looked at how we deploy a RPD via Enterprise Manager, here I am doing the same through a WLST script.

Files Included…

1. setEnv.sh


export CLASSPATH=/<fmw_home>/wlserver_10.3/server/lib/weblogic.jar
export JAVA_HOME=<java_home>
export PATH=$PATH:$JAVA_HOME/bin

2. biRPDDeployer.py

3. artifact-deployment.properties


#########################################################################################################################
## Properties
#########################################################################################################################
admin.server.host=<host>
admin.server.port=<port>
domain.name=<bi_domain_name>
rpd.directory.location=/<whatever>

deploy.only=1
rpdPassword=<whatever>
artifact.1=OBIEE11g_TEST_RPD.rpd

Pre execution steps –

Create env properties file (For example above :- artifact-deployment.properties)
Create – utils directory in the directory where you have copied 1,2 & 3.
Copy the .rpd file in a required location (See above in properties file  –      rpd.directory.location)

How to execute –

Step -1

Set the environment,

$source setEnv.sh

Step -2

Execute script (Type folliwng for usage instructions, follow the instructions)

java weblogic.WLST biRPDDeployer.py

Script – biRPDDeployer.py

#!/usr/bin/python 

# Copyright 2017-2020 by Vijay Jadhav. All Rights Reserved.
#
# Permission to use, copy, modify, and distribute this software and its
# documentation for any purpose and without fee is hereby granted,
# provided that the above copyright notice appear in all copies and that
# both that copyright notice and this permission notice appear in
# supporting documentation, and that the name of Vijay Jadhav
# not be used in advertising or publicity pertaining to distribution
# of the software without specific, written prior permission.
# Vijay Jadhav DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
# ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
# Vijay Jadhav BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
# ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER
# IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
# OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.


import os
import sys
import getopt
from java.io import FileInputStream


if len(sys.argv) > 1:
   print ("")
else:
        print ("\033[91m##############################################################################################")
        print ("##########  USAGE  ##########")
        print ("##############################################################################################\033[0m")
        print ("\t$ java weblogic.WLST biRPDdeployer.py -o <deploy>  -f  artifact-deployment.properties")
        print ("\tExample DEPLOY")
        print ("\t$ java weblogic.WLST  biRPDdeployer.py -o deploy  -f artifact-deployment.properties")
        print ("\033[91m##############################################################################################\033[0m")
        sys.exit()

def usage():
        print ("\033[91m##############################################################################################")
        print ("##########  USAGE  ##########")
        print ("##############################################################################################\033[0m")
        print ("\t$ java weblogic.WLST biRPDdeployer.py -o <deploy>  -f  artifact-deployment.properties")
        print ("\tExample DEPLOY")
        print ("\t$ java weblogic.WLST  biRPDdeployer.py -o deploy  -f artifact-deployment.properties")
        print ("\033[91m##############################################################################################\033[0m")

def loadProps(propsFileName):
    print('LOADING ENVIRONMENT PROPERTIES FILE...')
    propInputStream = FileInputStream(propsFileName)
    envProps = Properties()
    envProps.load(propInputStream)
    print('LOADING ENVIRONMENT PROPERTIES FILE...DONE')
    return envProps
        
def connectAdmin(props):
     try:
      domainName=props.get("domain.name")
      connect(userConfigFile=os.getcwd() + "/utils/"+ "WLConfig_"+ domainName+".properties", userKeyFile=os.getcwd() + "/utils/"+ "WLKey_"+ domainName+".properties", url="t3://" + props.get('admin.server.host') + ":" + props.get('admin.server.port'))
     except:
      print('\033[91m UNABLE TO FIND ADMIN SERVER...')
      exit()
      
def generateLginConfig(props,domainName,domain_user,domain_password):
    try:
      connect(domain_user, domain_password, "t3://" + props.get('admin.server.host') + ":" + props.get('admin.server.port'))
    except:
      print('\033[91m UNABLE TO CONNECT TO OR FIND ADMIN SERVER...')
      exit()
    storeUserConfig(os.getcwd() + "/utils/"+ "WLConfig_"+ domainName+".properties", os.getcwd() + "/utils/"+ "WLKey_" +  domainName+".properties")
    print("CONFIG FILES HAVE BEEN GENERATED SUCCESSFULLY..\n")
    testGeneratedConfigKey(props,domainName)
    disconnect()

def testGeneratedConfigKey(props,domainName):
    print("TESTING GENERATED CONFIG/KEY FILES..\n")
    print("CONNECTING TO ADMIN WITH CONFIG/KEY FILES..\n")
    try:
        connect(userConfigFile=os.getcwd() + "/utils/"+ "WLConfig_"+ domainName+".properties", userKeyFile=os.getcwd() + "/utils/"+ "WLKey_"+ domainName+".properties", url="t3://" + props.get('admin.server.host') + ":" + props.get('admin.server.port'))
    except e:
            print("PROBLEM CONNECTING TO ADMIN WITH CONFIG/KEYS..\n" + e)
            exit()
    print("CONFIG FILES HAVE BEEN TESTED SUCCESSFULLY.... CONTINUING WITH DEPLOYMENT..\n")
    disconnect()
        
def deployRPD(props,rpd_file_name):
        connectAdmin(props)
        print("cd TO ROOT" )
        cd('..\..')
        print('CONNECTING TO DOMAIN ...')
        try:
            domainCustom()
        except:
            print('ALREADY IN domainCustom()')
        print('GO TO BIEE ADMIN DOMAIN')
        cd('oracle.biee.admin')
        print('GO TO BIDOMAIN.BIINSTANCE.SERVERCONFIGURATION MBEAN')
        cd('oracle.biee.admin:type=BIDomain.BIInstance.ServerConfiguration,biInstance=coreapplication,group=Service')
        print('OBTAIN EDIT LOCK ...')
        cd('..')
        cd('oracle.biee.admin:type=BIDomain,group=Service')
        objs = jarray.array([], java.lang.Object)
        strs = jarray.array([], java.lang.String)
        try:
            invoke('lock', objs, strs)
        except:
            print('EDIT LOCK IS ALREADY IN PLACE')
        cd('..')
        cd('oracle.biee.admin:type=BIDomain.BIInstance.ServerConfiguration,biInstance=coreapplication,group=Service')
        print('UPLOADING RPD...')
        rpdPassword=props.get('rpdPassword')
        rpdFile=props.get('rpd.directory.location')+'/'+rpd_file_name
        params =  jarray.array([rpdFile,rpdPassword],java.lang.Object)
        sign =  jarray.array(['java.lang.String', 'java.lang.String'],java.lang.String)
        invoke( 'uploadRepository', params, sign)
        print('RPD UPLOADED...')
        print('COMMITING CHANGES')
        cd('..')
        cd('oracle.biee.admin:type=BIDomain,group=Service')
        objs = jarray.array([], java.lang.Object)
        strs = jarray.array([], java.lang.String)
        try:
            invoke('commit', objs, strs)
            print("#######################################################################################################")
            print ("RPD DEPLOYED SUCCESSFULLY...ABOUT TO RESTART BI SERVERS..")
            print("#######################################################################################################")
        except:
            print('PROBLEM COMMITING RPD CHANGES')
        
def restartBIServers(props):
        connectAdmin(props) 
        print('RESTARTING ALL OBIEE PROCESSES...')
        print('CONNECTING TO DOMAIN ...')
        domainCustom()
        cd('oracle.biee.admin')
        print('CONNECTING TO BIDOMAIN MBEAN ...')
        cd('oracle.biee.admin:type=BIDomain.BIInstance,biInstance=coreapplication,group=Service')
  
        ''' FOR BI SERVER ONLY, YOU COULD TRY
        cd('oracle.biee.admin:oracleInstance=instance2,type=BIDomain.BIInstanceDeployment.BIComponent,biInstance=coreapplication,process=coreapplication_obis1,group=Service')
        '''      
        print("STOPPING coreapplication's  ALL OBIEE PROCESSES")
        params = jarray.array([], java.lang.Object)
        signs = jarray.array([], java.lang.String)
        invoke('stop', params, signs)
        
        print('CHECKING OBIEE SERVICE STATUS...')
        OBIEEProcessStatus = get('ServiceStatus')
        print('OBIEE SERVICE STATUS ' + OBIEEProcessStatus)
       
        print("STARTING coreapplication's  ALL OBIEE PROCESSES")
        params = jarray.array([], java.lang.Object)
        signs = jarray.array([], java.lang.String)
        invoke('start', params, signs)
       
        print('CHECKING OBIEE SERVICE STATUS...')
        BIServerStatus = get('ServiceStatus')
        print('OBIEE SERVERSTATUS ' + BIServerStatus)
        print("#######################################################################################################")
        print ("OBIEE RESTARTED SUCCESSFULLY....")
        print ("ENVIRONMENT IS READY FOR TESTING BARRING ANY CATALOGUE SECURITY CHANGES....")
        print("#######################################################################################################")
        disconnect()
        
def main(): 
        print("PYTHON VERSION: " + str(sys.version_info))
        try:
                opts, args = getopt.getopt(sys.argv[1:], "o:f:", ["option", "inputFileName"])
                if opts.__len__() < 2:
                    usage()
                    sys.exit(2)
        except getopt.GetoptError, e:
                print (str(e))
                usage()
                sys.exit(2)
        for opt, arg in opts:
                if opt == "-o":
                         inputOption = arg
                         
                         if  inputOption !="deploy":
                             print("-o OPTION IS NOT VALID, VALID OPTION IS -> deploy: \033[92m " + "\033[91m"+ inputOption + "\033[00m" + " HENCE EXITING THE SCRIPT EXECUTION")
                             sys.exit(2)

                elif opt == "-f":
                         propsFile = arg
                         if not os.path.exists(os.getcwd() + "/"+propsFile):
                            print("PROPERTIES FILE DOES NOT EXIST, PLEASE CHECK THE NAME: \033[92m " + "\033[91m"+ propsFile + "\033[00m" + " HENCE EXITING THE SCRIPT EXECUTION")
                            sys.exit(2)
        props = loadProps(propsFile)
        
        print("###############################################################################")
        print("###############################################################################\n")
        deployOnlyList = props.get('deploy.only').split(',')
        print("\033[91mDEPLOYING ONLY  "+ str(deployOnlyList ) +" IN A SEQUENCE \033[00m")
        print("\n###############################################################################\n")
        print("\033[91mDEPLOYING FOLLOWING ARTIFACTS TO:\033[00m \033[92m " + props.get('admin.server.host') + ":" + props.get('admin.server.port') +"\033[00m")
        print("\n###############################################################################\n")
        for artifactId in deployOnlyList:
            aryifact_details= props.get("artifact." + artifactId).split('|')
            artifact_file_name = aryifact_details[0]
            if not os.path.exists(os.getcwd() + "/"+ props.get('rpd.directory.location') + "/"+artifact_file_name):
                            print("ARTIFACT  DOES NOT EXIST IN ARTIFACTS DIRECTORY, PLEASE CHECK THE NAME: \033[92m " + "\033[91m"+ artifact_file_name + "\033[00m" + " HENCE EXITING THE SCRIPT EXECUTION")
                            sys.exit(2)
            print("\033[91m    (" + artifactId +") \033[00m")
            print("\033[91m    RPD FILE NAME : " +  artifact_file_name + " \033[00m")
            print("###############################################################################\n")
                
        ''' Check if the User/Password config exists '''
        print("###############################################################################\n")
        print("CHECKING IF AUTENTICATION CONFIG EXISTS..\n")
        print("###############################################################################\n")
        domainName= props.get("domain.name")   
        if not os.path.exists(os.getcwd() + "/utils/WLKey_" + domainName+".properties" ):
                if not os.path.exists(os.getcwd() + "/utils"):
                    os.makedirs(os.getcwd() + "/utils")
                print ("AUTENTICATION CONFIG DOES NOT EXIST, PLEASE ENTER THE DETAILS BELOW \n")
                domain_user=raw_input("\033[91mPLEASE ENTER DOMAIN USER NAME E.G. weblogic : \033[00m")
                domain_password=raw_input("\033[91mPLEASE ENTER DOMAIN PASSWORD : \033[00m")
                print("\033[91m    YOU ENETERED : USERNAME: " + domain_user + " \033[00m")
                print("\033[91m    YOU ENETERED : PASSWORD: " + domain_password + " \033[00m")
                generateLginConfig(props,domainName,domain_user,domain_password)
        else:
            print("YES - AUTENTICATION CONFIG EXISTS.....\n")        
        choice=raw_input("\033[91mWOULD YOU LIKE TO PROCEED - y/n  : \033[00m").lower()
        if choice != 'y':
           print("THANK YOU - EXITING SCRIPT... YOU ENTERED : \033[91m " + choice+"\033[00m")          
           sys.exit(2)
        
        deployRPD(props,artifact_file_name)
        restartBIServers(props)        
        
if __name__ == "__main__":
                    print("###############################################################################")
                    print("SCRIPT BEING RUN DIRECTLY")
                    print("###############################################################################")
                    main()
else:
                    print("###############################################################################")
                    print("SCRIPT IS BEING IMPORTED IN ANOTHER MODULE LIKE > java weblogic.WLST jython module AND THEN EXECUTED")
                    print("###############################################################################")
                    main()

 

 

Deploy Logs will show something like this –

 

You will need to be connected to a running server to execute this command

WOULD YOU LIKE TO PROCEED - y/n  : y
Connecting to t3://<host>:<port> with userid weblogic ...
Successfully connected to Admin Server 'AdminServer' that belongs to domain 'bi_test_domain'.

Warning: An insecure protocol was used to connect to the
server. To ensure on-the-wire security, the SSL port or
Admin port should be used instead.

2017/03/15 15:22:50 | biRPDdeployer.py |  INFO: cd TO ROOT
2017/03/15 15:22:50 | biRPDdeployer.py |  INFO: CONNECTING TO DOMAIN ...
Location changed to domain custom tree. This is a writable tree with No root.
For more help, use help(domainCustom)

2017/03/15 15:23:22 | biRPDdeployer.py |  INFO: GO TO BIEE ADMIN DOMAIN
2017/03/15 15:23:22 | biRPDdeployer.py |  INFO: GO TO BIDOMAIN.BIINSTANCE.SERVERCONFIGURATION MBEAN
2017/03/15 15:23:22 | biRPDdeployer.py |  INFO: OBTAIN EDIT LOCK ...
2017/03/15 15:23:22 | biRPDdeployer.py |  INFO: UPLOADING RPD...
2017/03/15 15:23:22 | biRPDdeployer.py |  INFO: RPD UPLOADED...
2017/03/15 15:23:22 | biRPDdeployer.py |  INFO: COMMITING CHANGES
2017/03/15 15:23:25 | biRPDdeployer.py |  INFO: #######################################################################################################
2017/03/15 15:23:25 | biRPDdeployer.py |  INFO: RPD DEPLOYED SUCCESSFULLY...ABOUT TO RESTART BI SERVERS..
2017/03/15 15:23:25 | biRPDdeployer.py |  INFO: #######################################################################################################
Connecting to t3://<host>:<port> with userid weblogic ...
Successfully connected to Admin Server 'AdminServer' that belongs to domain 'bi_test_domain'.

Warning: An insecure protocol was used to connect to the
server. To ensure on-the-wire security, the SSL port or
Admin port should be used instead.

2017/03/15 15:23:26 | biRPDdeployer.py |  INFO: RESTARTING ALL OBIEE PROCESSES...
2017/03/15 15:23:26 | biRPDdeployer.py |  INFO: CONNECTING TO DOMAIN ...
Location changed to domain custom tree. This is a writable tree with No root.
For more help, use help(domainCustom)

2017/03/15 15:23:53 | biRPDdeployer.py |  INFO: CONNECTING TO BIDOMAIN MBEAN ...
2017/03/15 15:23:53 | biRPDdeployer.py |  INFO: STOPPING coreapplication's  ALL OBIEE PROCESSES
2017/03/15 15:24:52 | biRPDdeployer.py |  INFO: CHECKING OBIEE SERVICE STATUS...
2017/03/15 15:24:53 | biRPDdeployer.py |  INFO: OBIEE SERVICE STATUS STOPPED
2017/03/15 15:24:53 | biRPDdeployer.py |  INFO: STARTING coreapplication's  ALL OBIEE PROCESSES
2017/03/15 15:25:41 | biRPDdeployer.py |  INFO: CHECKING OBIEE SERVICE STATUS...
2017/03/15 15:25:41 | biRPDdeployer.py |  INFO: OBIEE SERVERSTATUS FULLY_STARTED
2017/03/15 15:25:41 | biRPDdeployer.py |  INFO: #######################################################################################################
2017/03/15 15:25:41 | biRPDdeployer.py |  INFO: OBIEE RESTARTED SUCCESSFULLY....
2017/03/15 15:25:41 | biRPDdeployer.py |  INFO: ENVIRONMENT IS READY FOR TESTING BARRING ANY CATALOGUE SECURITY CHANGES....
2017/03/15 15:25:41 | biRPDdeployer.py |  INFO: #######################################################################################################
Disconnected from weblogic server: AdminServer