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.

Thursday, July 16, 2015

Creating VPN Connection from Home Machine and Connecting via SmartPhone.


As we all know that more than system we used to stick with SmartPhone so what if you want to connect to your home system and pull out from information.


Here you can achieve it, follow the below guidelines:

Creating a VPN Server

First, you’ll need to open the Network Connections window.

Press the Alt key, click the File menu that appears, and select New Incoming Connection.
windows-new-incoming-connection
You can now select the user accounts that can connect remotely. To increase security, you may want to create a new, limited user account rather than allow VPN logins from your primary user account. (Click Add someone to create a new user account.) Ensure the user you allow has a very strong password, as a weak password could be cracked by a dictionary attack.

Select the Through the Internet option to allow VPN connections over the Internet. You can also allow incoming connections over a dial-up modem, if you have the dial-up hardware.
allow-vpn-connections-through-the-internet
You can then select the networking protocols that should be enabled for incoming connections. For example, if you don’t want people connected to the VPN to have access to shared files and printers on your local network, you can uncheck the File and Printer Sharing option.
select-vpn-networking-protocols
Click the Allow access button and Windows will set up a VPN server.
allow-vpn-access-in-windows

Router Setup

You will now need to log into your router’s setup page and forward port 1723 to the IP address of the computer where you set up the VPN server
As I have BELKIN Router so I went to Virtual Server and did this settings. If you have it from some other (TPLINK, NETGEAR, etc) it can be done easily.
Make sure that it is allowed to the use the VPN Connection:
Now one setup you can do to avoid the IP Conflict from the connecting users:

Connecting to VPN Server


Via SmartPhone


Goto Setting -- Under Network (more) -- VPN --> Then Enable the VPN settings:

Note: When enable VPN Setting SmartPhone must have lock screen as PIN no. or Pattern.

Enable VPN should be appear like this:




Tap on the Add VPN




Upon tapping on the Add VPN now you can name it VPN (could be any name), type must be PPTP because the VPN server which you have create it uses PPT Protocol for communicate.

In the Server Address you need to type the IP address of the system for where you have created the VPN Server. Make sure you should what is the IP address is provided from your ISP (You may have to call up your service provider i.e Airtel, Verizon, etc). It is always recommended you should get static IP from your service provider so that connection will be persistent.


Once done then Tap on OK. Now you see that VPN connection is been created in your phone.



So, I have created a VKVPN is available Tap on it connect, then supply the credentials:

Bingo!! That's it You are connected


Now you can do Remote Desktop to your Home system or you can browse the file by using File Explorer in the SmartPhone Device.

As of now I have provided details for Andriod SmartPhones, Stay tuned will be sharing for iOS soon!

Thanks.

Sunday, July 12, 2015

Unix Shell Script for Viewing Size of Specific Files as well as with Addition of Similar Files



echo "This script is to show the size of files as well as collectively addition of similar file for the today and yesterday timestamp."

#Goto the folder where files are located
cd <destinated_folder_structure>

#Below command will list the files with the matching pattern then it will grep for the yesterday date file and size of file is storing in the temp file. Later in second line it doing the addition which will be overrite the temp file.
ls -ltrh <FileMatchingPattern>*txt* | grep "$(date --date="yesterday" '+%b %e')" | awk '{print $6, $7, $9, $5}' > y1.txt
ls -ltrh <FileMatchingPattern>*txt* | grep "$(date --date="yesterday" '+%b %e')" | awk '{total += $5}; END {print total}' >> y1.txt

#Similar activity as first command is doing but it will do for the Today's date
ls -ltrh <FileMatchingPattern>*txt* | grep "$(date '+%b %e')" | awk '{print $6, $7, $9, $5}' > t1.txt
ls -ltrh <FileMatchingPattern>*txt* | grep "$(date '+%b %e')" | awk '{total += $5}; END {print total}'>> t1.txt

#If you have more than one file pattern then you show them collectively. Let's assume below is another pattern and want to show it.

ls -ltrh <FileMatchingPattern>*txt* | grep "$(date --date="yesterday" '+%b %e')" | awk '{print $6, $7, $9, $5}' > y2.txt
ls -ltrh <FileMatchingPattern>*txt* | grep "$(date --date="yesterday" '+%b %e')" | awk '{total += $5}; END {print total}'>> y2.txt

ls -ltrh <FileMatchingPattern>*txt* | grep "$(date '+%b %e')" | awk '{print $6, $7, $9, $5}' > t2.txt
ls -ltrh <FileMatchingPattern>*txt* | grep "$(date '+%b %e')" | awk '{total += $5}; END {print total}'>> t2.txt


cat y1.txt > final.txt
cat t1.txt >> final.txt
cat y2.txt >> final.txt
cat t2.txt >> final.txt

#So if you want to see on the screen

cat final.txt

#If you want to mail the results

mail -s "Today and Yesterday File Size" abc@mail.com -c xyz@mail.com < final.txt

#If you wish you can delete the temporary generated file

rm -f y1.txt t1.txt y2.txt t2.txt final.txt


Save this file with .sh or .ksh extension and make it shell script and be run by ./<filename>.sh

After saving this file you may have to give permission to run so execute the below command
chmod 755 <filename>.sh

That's it.

Please leave your comments.

Thanks.