Quantcast
Channel: Togotutor.com » soa
Viewing all articles
Browse latest Browse all 5

SOA Audit Level Setting WLST

$
0
0
soa

soa

Audit Level: Audit level let’s you set the amount of the information you want to be collected by the messaging infrastructure.

To configure the Audit Level Settings:

Login to EM –> Expand Farm –> Click SOA –> Right Click SOA_Infra –> SOA Administration –> Common Properties and here you can change the audit level to Off, Production or Development.

Another way is to use the WLST script to do so: Here is one ready for you.

PROPERTIES FILE

#*****************************************************
# Security Info
#*****************************************************
ADMIN_USERNAME=weblogic
ADMIN_PASSWORD=welcome01
ADMIN_URL=t3://togotutor.com:7001
#****************************************************
# SERVER Info
#****************************************************
MANAGED_SERVER_INFO=soaserver1
#****************************************************
# Application Name
#****************************************************
APP_NAME=soa-infra
#****************************************************
# Mbean Information
#****************************************************
SOA_CONFIG=oracle.as.soainfra.config
#****************************************************
# Attribute Information
#****************************************************
AUDITLEVEL=AuditLevel
### Possible Values=Audit level. The possible values are Off, Production and Development ###
AUDITLEVEL_VALUE=Development

WLST Script

#################################################
#
# Name : Create User WLST Script
# Author : Togotutor
# Copyright ©2012 www.togotutor.com
#
################################################
"""
Connection To Admin Server
"""
 
def __connectToAdmin(properties):
    adminusername = getKeyValue('ADMIN_USERNAME', properties)
    print adminusername
    adminpassword = getKeyValue('ADMIN_PASSWORD', properties)
    adminurl = getKeyValue('ADMIN_URL', properties)
    domainname = getKeyValue('DOMAIN_NAME', properties)
    print '[INFO]: Connecting to the domain'+' '+domainname
    try:
        connect(adminusername, adminpassword, adminurl)
    except WLSTException:
        print '[ERROR]: Trying to connect to the domain:' + domainname
        exit()
"""
DisConnect To Admin Server
"""
def __disconnectToAdmin():
    disconnect()
"""
Create a User in Weblogic
"""
def __changeAuditLevel(properties):
    domainRuntime()
    soaconfigmbean=getKeyValue('SOA_CONFIG', properties)
    locationinfo=getKeyValue('MANAGED_SERVER_INFO', properties)
    appname=getKeyValue('APP_NAME', properties)
    auditlevel=getKeyValue('AUDITLEVEL', properties)
    auditlevelvalue=getKeyValue('AUDITLEVEL_VALUE', properties)
    SOAInfraConfigobj = ObjectName(soaconfigmbean+':Location='+locationinfo+',name='+appname+',type=SoaInfraConfig,Application='+appname)
    print ('Current Audit Level Value is set to —-> ' + mbs.getAttribute(SOAInfraConfigobj, auditlevel))
    mbs.setAttribute(SOAInfraConfigobj, Attribute(auditlevel,auditlevelvalue))
    print ('Post Audit Level Value is set to —-> ' + mbs.getAttribute(SOAInfraConfigobj, auditlevel))
#****************************************************************************
# MAIN
#****************************************************************************
#
# Calling all the Methods here
print(' -------------------------- ')
print('[INFO] Printing the output')
print('')
execfile('utils.py')
propFilename = 'domain.soa.auditlog.setting.properties'
properties = {}
properties = loadProperties(propFilename)
__connectToAdmin(properties)
__changeAuditLevel(properties)
__disconnectToAdmin()
print ''
print '[INFO]: Quitting the WLST script'
print(' -------------------------- ')
print '[INFO] Completed.'

Utils – To read the properties file

#! /usr/bin/python
#****************************************************************************
# File: utils.py
#****************************************************************************
from java.lang import System
#****************************************************************************
# def notNullOrEmpty()
#****************************************************************************
def notNullOrEmpty(val):
    return val != None and len(val) != 0
#****************************************************************************
# def substitute()
#****************************************************************************
def substitute(orig, subs):
    startIndex = orig.find('${')
    #print 'startIndex =', startIndex
    if startIndex == -1:
        return orig
        endIndex = orig.find('}', startIndex)
        #print 'endIndex =', endIndex
        if endIndex == -1:
            return orig
            substitutionKey = orig[startIndex + 2:endIndex]
            value = System.getProperty(substitutionKey)
            if subs.has_key(substitutionKey):
                value = subs[substitutionKey]
                if value != None:
                    return orig[0:startIndex] + value + substitute(orig[endIndex + 1:], subs)
                    if len(orig) == endIndex + 1:
                        print 'WARNING: No substitution found for key:', orig
                        return orig
                    else:
                        return orig[0:endIndex + 1] + substitute(orig[endIndex + 1], subs)
#****************************************************************************
# def loadOrderedProps
#****************************************************************************
def loadOrderedProps(filename):
    def split(line):
        index = line.find('=')
        if index == -1:
            return None
        else:
            return (line[:index], line[index + 1:])
    propLines = open(filename, 'r').readlines()
    propLines = [line.strip() for line in propLines]
    propLines = [line for line in propLines if len(line) > 0 and not line.startswith('#')]
    propLines = [split(line) for line in propLines]
    propLines = [line for line in propLines if line]
    return propLines
#****************************************************************************
# def loadProperties()
#****************************************************************************
def loadProperties(propFile):
    props = {}
    originalProps = loadOrderedProps(propFile)
    for key, value in originalProps:
        #print ' KEY: [' + key + ']'
        value = substitute(value, props)
        #print ' VALUE: [' + value + ']'
        props[key] = value
    return props
#****************************************************************************
# def getValue
#****************************************************************************
def getValue(propKey, defaultKey, properties):
    if properties.get(propKey) != None:
        val = properties[propKey]
    else:
        if properties.get(defaultKey) != None:
            val = properties[defaultKey]
        else:
            val = ''
    return val
#****************************************************************************
# def getKeyValue
#****************************************************************************
def getKeyValue(propkey, properties):
    if properties.get(propkey) != None:
        val = properties[propkey]
    else:
        val = ''
    return val

41 total views, 3 views today


Viewing all articles
Browse latest Browse all 5

Latest Images

Trending Articles





Latest Images