Wednesday, August 24, 2011

WLST OBIEE Bounce BI server

Script to bounce the BI server using the WLST:


# Bounce BI server using WLST
# Be sure we are in the 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 coreapplication_obips1 Mbean'
cd('oracle.biee.admin:oracleInstance=instance1,type=BIDomain.BIInstanceDeployment.BIComponent,biInstance=coreapplication,process=coreapplication_obis1,group=Service')

print 'Stopping the BI server'
params = jarray.array([], java.lang.Object)
signs = jarray.array([], java.lang.String)
invoke('stop', params, signs)

BIServerStatus = get('Status')
print 'BI ServerStatus ' +BIServerStatus

print 'Starting the BI server'
params = jarray.array([], java.lang.Object)
signs = jarray.array([], java.lang.String)
invoke('start', params, signs)

BIServerStatus = get('Status')
print 'BI ServerStatus ' +BIServerStatus


Till Next Time

WLST OBIEE Bounce Presentation Server

Script to bounce the presentation server using the WLST:


# Bounce Presentationserver using WLST
# Be sure we are in the 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 coreapplication_obips1 Mbean'
cd('oracle.biee.admin:oracleInstance=instance1,type=BIDomain.BIInstanceDeployment.BIComponent,biInstance=coreapplication,process=coreapplication_obips1,group=Service')

print 'Stopping the presentation server'
params = jarray.array([], java.lang.Object)
signs = jarray.array([], java.lang.String)
invoke('stop', params, signs)

print 'Starting the presentation server'
params = jarray.array([], java.lang.Object)
signs = jarray.array([], java.lang.String)
invoke('start', params, signs)

PresentationServerStatus = get('Status')
print 'PresentationServerStatus± ' +PresentationServerStatus


Till Next Time

WLST OBIEE Change WebCat Location

Small script I use to changer the WebCat Location on a OBIEE11g BI system:


# Be sure we are in the root
cd('..\..')

print 'Connecting to Domain ...'
try:
domainCustom()
except:
print 'Already in domainCustom'

print 'Go to biee admin domain'
cd('oracle.biee.admin')

# Go to the presentation server catalog location
cd('oracle.biee.admin:type=BIDomain.BIInstance.PresentationServerConfiguration,biInstance=coreapplication,group=Service')

# Lock the System
execfile("F:\WLST\Lock System.py")

# Go to the presentation server catalog location
cd('..')
cd('oracle.biee.admin:type=BIDomain.BIInstance.PresentationServerConfiguration,biInstance=coreapplication,group=Service')

# Get the old WebCatalogSharedLocation
WebCatalogSharedLocation = get('WebCatalogSharedLocation')
print 'old WebCatalogSharedLocation = ' + WebCatalogSharedLocation

# set the old WebCatalogSharedLocation
newWebCatalogSharedLocation = '$ORACLE_INSTANCE/SampleAppWebcatNew'
set('WebCatalogSharedLocation',newWebCatalogSharedLocation)
WebCatalogSharedLocation = get('WebCatalogSharedLocation')
print 'new WebCatalogSharedLocation = ' + WebCatalogSharedLocation

# Commit the system
execfile("F:\WLST\Commit System.py")

print 'please restart Presentation-server using opmnctl'



Till Next Time

WLST OBIEE Upload RPD

Small script I use to upload RPD on the OBIEE11g BI system:

# Be sure we are in the root
cd('..\..')

print 'Connecting to Domain ...'
try:
domainCustom()
except:
print 'Already in domainCustom'

print 'Go to biee admin domain'
cd('oracle.biee.admin')

# go to the server configuration
print 'Go to BIDomain.BIInstance.ServerConfiguration MBean'
cd('oracle.biee.admin:type=BIDomain.BIInstance.ServerConfiguration,biInstance=coreapplication,group=Service')

# Lock the System
execfile("F:\WLST\Lock System.py")

cd('..')
# go to the server configuration
cd('oracle.biee.admin:type=BIDomain.BIInstance.ServerConfiguration,biInstance=coreapplication,group=Service')
print 'Uploading RPD'
# Set the parameters
params = jarray.array(['/home/oracle/Desktop/FolderShortcuts/OBIEEInstallHome/instances/instance1/bifoundation/OracleBIServerComponent/coreapplication_obis1/repository/10719.rpd','Admin123'],java.lang.Object)
# Set the parameters Signs
sign = jarray.array(['java.lang.String', 'java.lang.String'],java.lang.String)
# Invoke the procedure
invoke( 'uploadRepository', params, sign)

# Commit the system
execfile("F:\WLST\Commit System.py")

print 'please restart BI-server using opmnctl'


! DON’T FORGET to BOUNCE the BI-SERVER!



Till Next Time

WLST OBIEE Commit system

Small script I use to commit on the OBIEE11g BI system:

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)
except:
    print('System not locked')

I have put it in a separate file which I call from my main script:

execfile("F:\WLST\Commit System.py")

Till Next Time

WLST OBIEE Place Lock on system


Small script I use to set a lock on the OBIEE11g BI system:

print 'Calling 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 'System already locked'
I have put it in a separate file which I call from my main script:
execfile("F:\WLST\Lock System.py")
Till Next Time

Friday, July 15, 2011

WLST (un)deploying an application directory

#
# Deploy and start an application directory
# using WLST (online)
# John Minkjan Ciber Netherlands
#

print 'deploying....'
deploy('OBIEE_META2', 'D:/OBIEE_META2', targets='AdminServer,bi_server1')

print 'starting.....'
startApplication('OBIEE_META2')


#
# stop and undeploy an application directory
# using WLST (online)
# John Minkjan Ciber Netherlands
#

print 'stoping.....'
stopApplication('OBIEE_META2')

print 'undeploying....'
undeploy('OBIEE_META2')

Till Next Time

WLST List User, Groups and Users in Groups

#
# listing Users and Groups (online)
# John Minkjan Ciber Netherlands
#


from weblogic.management.security.authentication import UserReaderMBean
from weblogic.management.security.authentication import GroupReaderMBean

realm=cmo.getSecurityConfiguration().getDefaultRealm()
atns = realm.getAuthenticationProviders()

print 'All Users'
for i in atns:
  if isinstance(i,UserReaderMBean):
    userReader = i
    cursor = i.listUsers("*",0)
    print 'Users in realm '+realm.getName()+' are: '
    while userReader.haveCurrent(cursor):
      print userReader.getCurrentName(cursor)
      userReader.advance(cursor)
    userReader.close(cursor)

print 'All Groups'
for i in atns:
  if isinstance(i,GroupReaderMBean):
    groupReader = i
    cursor = i.listGroups("*",0)
    print 'Groups in realm are: '
    while groupReader.haveCurrent(cursor):
      print groupReader.getCurrentName(cursor)
      groupReader.advance(cursor)
    groupReader.close(cursor)

print 'users in group'   
for i in atns:
  if isinstance(i,GroupReaderMBean):
    groupReader = i
    cursor =  i.listGroups("*",0)
    while groupReader.haveCurrent(cursor):
        group = groupReader.getCurrentName(cursor)   
        usergroup = i.listAllUsersInGroup(group,"*",0)
        print realm.getName()
        print '-', group
        for user in usergroup:
            print '--',user       
        groupReader.advance(cursor)
    groupReader.close(cursor)
   
   
print ' unique users in group'   
for i in atns:
  if isinstance(i,GroupReaderMBean):
    groupReader = i
    cursor =  i.listGroups("*",0)
    while groupReader.haveCurrent(cursor):
        group = groupReader.getCurrentName(cursor)   
        usergroup = i.listAllUsersInGroup(group,"*",0)
        print realm.getName()
        print '-', group
        uniqueUser = []
        for user in usergroup:
            if user not in uniqueUser:
                uniqueUser.append(user)
        for user in uniqueUser:
            print '--',user       
        groupReader.advance(cursor)
    groupReader.close(cursor)

WLST Removing user from group.

#
# Removing Users to a Group using WLST (online)
# John Minkjan Ciber Netherlands
#
print 'lookup DefaultAuthenticator'
atnr=cmo.getSecurityConfiguration().getDefaultRealm().lookupAuthenticationProvider('DefaultAuthenticator')

groups = ['companya']
for group in groups:
    users = ['user1','user2']
    for user in users:       
        print 'removing user: ',user, ' from group:', group
        try:
            atnr.removeMemberFromGroup(group,user)
        except:
            print 'user: ', user , ' can not be removed from group: ', group

 

Till Next Time

WLST executing a script file

execfile( filePath .py)

execfile('D:\WLST_PY\DELETEUSERSFROMGROUP.py')

Till Next Time

Thursday, July 14, 2011

WLST Adding Users to a Group

#
# Adding Users to a Group using WLST (online)
# John Minkjan Ciber Netherlands
#
print 'lookup DefaultAuthenticator'
atnr=cmo.getSecurityConfiguration().getDefaultRealm().lookupAuthenticationProvider('DefaultAuthenticator')

groups = ['companya','BIConsumers','BIAuthors']
for group in groups:
    users = ['user1','user2']
    for user in users:       
        print 'working user: ',user, ' group:', group
        try:
            atnr.addMemberToGroup(group,user)
        except:
            print 'user: ', user , ' can not be placed in group: ', group

Till Next Time

WLST Removing and Adding Users

#
# Removing and Adding Users using WLST (online)
# John Minkjan Ciber Netherlands
#
print 'lookup DefaultAuthenticator'
atnr=cmo.getSecurityConfiguration().getDefaultRealm().lookupAuthenticationProvider('DefaultAuthenticator')

group = 'companya'
password = 'Welcome1'
users = ['user1','user2']
# delete the "old" users
for user in users:   
    try:
        print 'working user: ',user
        atnr.removeUser (user)
    except:
        pass

# Create the "new" users
users = ['user1','user2']
for user in users:           
    try:       
        print 'create user: ',user
        atnr.createUser(user,password,user)
    except:
        pass

Till Next Time

WLST Removing and Adding Groups

#
# Removing and Adding groups using WLST (online)
# John Minkjan Ciber Netherlands
#
print 'lookup DefaultAuthenticator'
atnr=cmo.getSecurityConfiguration().getDefaultRealm().lookupAuthenticationProvider('DefaultAuthenticator')

groups = ['companya', 'companyb']
groupcomment = 'If you work for this company you need this group'

for group in groups:
    print 'delete the old one if exists'
    try:
        atnr.removeGroup(group)
    except:
        print '*************** CANNOT DELETE !!! Check If The Group With the Name : ' , group ,' Exists or NOT...'

for group in groups:
    print 'create group:' , group
    atnr.createGroup(group,groupcomment)

 

Till Next Time

Monday, July 11, 2011

WLST Connect

connect('weblogic','Ciber2011','t3://localhost:7001',adminServerName='AdminServer')

Till Next Time

Welcome to wlst101

An other 101 blog John Minkjan dedicated to the Weblogic Scripting Tool.


Till Next Time