Oracle WebLogic Server 12c: Administration I - 1Z0-133
Oracle 1Z0-133 Certification Details:
Exam Name | Oracle WebLogic Server 12c Administration I |
Exam Code | 1Z0-133 |
Exam Product Version | WebLogic Server |
Exam Price | USD $245 (Pricing may vary by country or by localized currency) |
Duration | 120 minutes |
Number of Questions | 77 |
Passing Score | 64% |
Validated Against | This exam is validated against 12.1.2. |
Format | Multiple Choice |
Recommended Training | Oracle WebLogic Server 12c: Administration I |
Schedule Exam | Pearson VUE - Oracle |
How to take exam ?
- In order to register and schedule the exam, candidates must have active accounts with both Oracle and PearsonVue.
- The Oracle account can be created at www.oracle.com and the PearsonVue account can be created at www.pearsonvue.com/oracle.
- Creating a PearsonVue account will also create an Oracle Testing ID
- This ID must then be entered at Oracle University's certification website at certview.oracle.com, thus linking the Oracle and PearsonVue accounts.
- There is a one-hour delay between the time that the Oracle Testing ID has been created by PearsonVue and the time that it will be recognized by the CertView website.
- Once the candidate profile has been completed, the exam can be purchased and scheduled directly from PearsonVue.
- The Oracle account can then be used to access exam history, scores, and other details regarding the certification efforts at the CertView website.
- The exam experience is simple and standardized across test centers. Candidates are required to present a photo ID at the selected test center and are not allowed to introduce any objects into the test room.The exam terminal presents a simple user interface displaying one question and its possible answers per each screen. The questions can be marked for later review.
- Once all questions have been answered, the exam may be submitted to Oracle for grading. After a short period of time, usually under 30 minutes, a notification of the exam result will be emailed to the candidate. There is a delay of around 24 hours between the time that the notification of exam results is received and the time that the results will also appear in the CertView website.
- The two possible exam results are pass or fail. Regardless of the exam results, feedback will be provided to help identify any questions that were answered incorrectly. Users with a failing score should return to this feedback in preparing for future attempts.
- Once Oracle has notified a candidate of a passing score, he or she has officially become a certified Oracle WebLogic Server 12c Administrator. PearsonVue and Oracle also offer badges for certain certifications. These badges are useful to publish certification credentials to third parties and on social networks such as LinkedIn.
- A candidate who fails must wait 14 days before attempting the same exam again, with a maximum of 4 attempts in a 12-month period. Candidates should consult the Oracle certification website though, in order to ensure that the requirements have not changed.
Chapter 1 Overview of Weblogic Server
- Java Cloud Service
- Application Services
- Weblogic Server Architecture
- Administration Tools
Chapter 2 Installation, Patching and Updates
- Zero Downtime Patching.
- Patching WebLogic Server
- Installing WebLogic Server
- Domain Modes
- Using the configuration wizard
- Domain Planning
- Domain Creation Tools
- Multitenancy concepts.
- Domain Templates
- Restarting Failed Servers.
- Customizing Domain Scripts
- Server Lifecycle
- Starting and Stopping Servers
- Domain Scripts.
Chapter 12 JDBC
Chapter 13 Transactions
Chapter 14 Application Deployment
Chapter 15 Security
Chapter 16 Backup and Upgrade
Certification Topics in very detail
Introduction
Chapter 1 Overview of Weblogic Server
- Explain the WebLogic Server terms: domain, server, machine and cluster
Explain the difference between the administration server and the managed servers.
- Describe the administrative tools: Administration Console, WLST, WLDF, Monitoring Dashboard
Chapter 2 Installation, Patching and Updates
- Determine supported configurations for WebLogic Server
- Install WebLogic Server in graphical mode
- Install WebLogic Server silently
- Describe the installation directory structure
- Apply a patch to WebLogic Server by using OPatch
Chapter 3 Creating Domains
- Describe a domain's file system
- Create a domain by using the Configuration Wizard
- Configure machines, servers, and clusters by using the Configuration Wizard
- Copy a domain to another computer with the pack and unpack utilities
Monitoring Domain
- Configure WebLogic Server logs
- Interpret a server log file entry
- Create and apply a log filter
- Enable WebLogic Server debugging output
- Monitor WebLogic Server health and performance
- Monitor JDBC data sources, JMX Mbeans
- Access diagnostic charts in the Monitoring Dashboard
Chapter 4 Node Manager
- Describe the architecture and capabilities of the Node Manager
- Create a Node Manager with the Configuration Wizard
- Configure properties for the Java Node Manager
- Describe the Java Node Manager directory structure
- Enroll a Node Manager with a domain
- Start and stop a Node Manager
- Start and stop managed servers by using the Administration Console
Chapter 5 Starting Servers
- Start and stop servers with standard scripts
- Identify and resolve problems with server startup
- Customize start and stop scripts, including the CLASSPATH
- Restart a failed server on a different machine
Using Administration Console
- Access the WebLogic Server Administration Console
- Identify the components of the Administration Console
- Update Administration Console preferences
- Use the Administration Console change center
- Create and configure servers by using the Administration Console
Chapter 6 Configuration Management
Chapter 7 Logging and Monitoring
Chapter 8 Networking
Chapter 9 Clusters - Basics
Chapter 10 Clusters - Advanced
Chapter 11 Clusters - Proxies
Creating and configuring clusters.
- Describe basic and multi-tier cluster architectures
- Create a cluster by using the Configuration Wizard
- Create and configure a cluster by using the Administration Console
- Create and configure a dynamic cluster
- Create and configure a server template
- Describe how a dynamic cluster calculates listen ports and machines for generated servers
Cluster proxies and sessions
- Install Oracle HTTP Server with the Web Tier installer
- Configure Oracle HTTP Server as a WebLogic Server cluster proxy
- List the options for HTTP session failover
- Configure in-memory session replication
- Configure replication groups
Cluster communication, planning and troubleshooting
- Explain the difference between unicast and multicast cluster communication
- Configure replication channels by using the Administration Console
- Describe planning for a cluster
- Monitor a cluster
Chapter 12 JDBC
- Describe WebLogic Server's JDBC architecture
- Describe WebLogic Server's JNDI architecture
- Compare the different types of data sources
- Compare the different data source transaction options
- Create and configure a generic data source
- Tune a data source's connection pool
-Create and configure a GridLink data source
Chapter 13 Transactions
- Explain WebLogic Server's role in managing transactions
- Configure WebLogic Server transactions (JTA)
- Configure the WebLogic Server default store used for transaction logs
- Configure a database persistent store for WebLogic Server transaction logs
- Monitor WebLogic Server transactions
Chapter 14 Application Deployment
Deploying applications
- Deploy an application
- Start a deployed application
- Stop a deployed application
- Undeploy an application
- Redeploy an application
- Use the test links for an application supplied by the Administration Console
- Monitor a deployed application
- Use the Monitoring Dashboard's built-in application view
- Load test an application with The Grinder console given a script
Network Channels and virtual hosts
- Configure a WebLogic Server network channel
- Monitor a network channel
- Configure WebLogic Server to use an administration port
- Configure a virtual host for WebLogic Server
Chapter 15 Security
- List some of the WebLogic Server security providers and what they do
- Describe basic LDAP architecture
- Configure an external LDAP authentication provider for WebLogic Server
- Describe how multiple authentication providers can be used with WebLogic Server
Chapter 16 Backup and Upgrade
- Back up a WebLogic Server domain
- Restore a WebLogic Server domain
- Define Managed Service Independence mode
- Describe the process to upgrade WebLogic Server 11g to 12c
- Run the WebLogic Server Reconfiguration Wizard as part of the upgrade process
- 1.
Enterprise applications may run directly on top of the Java SE platform.
- True
- False
Answer - No
3.
What fundamental component of the Java EE architecture is provided by an application server?- The virtual machine
- The runtime environment
- The database drivers
- The management console
- None of the above
Answer : The runtime environment
Provides support for creating Web Service clients and endpoints using a REST architectural style:
- JAXP
- JAX-WS
- JMX
- All of the above
- None of the above
Answer : None of the above
5.
What edition of WebLogic Server should I license if I intend to use the Oracle JVM profiling tools?
- WebLogic Server Standard Edition
- WebLogic Server Enterprise Edition
- WebLogic Server Suite
- All of the above
- None of the above
Answer : b and cInstallation MethodsThe WebLogic Server 12c release series has two installation methods available.1) Graphic - Below is flow diagram which represents Graphic installation.2) Silent- The silent installation method is a convenient method to perform an installation on aremote system in which X11 forwarding is not enabled or when manually running the
-- console method that was available in previous versions is not available in 12c.
-- The silent installation method is best for automating the installation process when
managing a large number of systems.
Running the installer tool in silent method requires a response file from which this information will be read.In addition to the response file, running the installer in silent mode requires a file that by convention is named oraInst.loc that, as the name implies, is a pointer to the inventory location. This file must contain the same two pieces of information that the first step of the graphic installer requires in the following format:
inventory_loc=/path/to/inventory/location inst_group=group_name
The response file must contain all other pieces of information gathered by the installer tool in graphic mode. The most important of these are the location of the Oracle home and the install type. The rest of the lines require information regarding declining or accepting notification of security updates. For the sake of brevity, the contents of the response file are not shown. The following is the complete command to run the installer tool in silent mode:$JAVA_HOME/bin/java -jar fmw_12.1.3.0.0_wls.jar -silent -invPtrLoc /path/ to/oraInst.loc -responseFile /path/to/env.rsp
Installation Structure
Either installation method results in the exact same installed structure in the target file system. The following directories and files will be created by the installer after a successful run:- coherence (core Coherence product files)
- install (files related to installation run)
- inventory (product inventory that is local to this Oracle home)
- OPatch (patch and update tool)
- oracle_common (libraries required by WebLogic Server)
- oraInst.loc (pointer to local inventory)
- oui (installer tool product files)
- wlserver (core WebLogic Server product files)
At this point, the WebLogic Server installation has been successful and the system is ready for product configuration.
Recommended Exercises
- Perform an installation of WebLogic Server 12c version 12.1.2 using the Complete with Examples installation type and save the corresponding response file.
- Edit the response file to define a different Oracle home and a different installation type.
- Perform a silent installation of WebLogic Server 12c version 12.1.2 using a response file.
- Review the two Oracle homes just installed by contrasting the resulting file system structures.
Question :
Select the operating systems certified to run Weblogic Server 12c in production environments ?
- Red Hat Linux 7
- Ubuntu Linux 14.04
- Microsoft Windows 7
- Mac OS 10.5
- Oracle Solaris 11
Answer - a and d - Red Hat Linux 7 and Mac OS 10.5Question -Select the product distribution types supported to run WebLogic Server in production environments :a. Physical mediab. WebLogic Server JAR file.c. Middleware Infrastructure JAR file.d. ZIP distributions.e. All of the above.Answer - b and c - Weblogic Server JAR file and Middleware Infrastructure JAR file.Q - Select the option that lists the correct components of the standard installation topology :
- One administration server, one managed server, one machine, one domain
- Two administration servers, two managed servers, two machines, one domain
- One administration server, one cluster, two managed servers, one machine, one domain
- None of the above
- All of the above
Answer - None of the above. - d
Q - Select all of the supported installation methods.- Graphicb
- Consolec
- Silent
- Remotee
- Local
Anser - a and c - ( Graphicb and Silent)Q - Select the required command to apply a security patch :- bsu -install
- bsu -apply
- opatch install
- opatch apply
- opatch secure
Answer - d - opatch secure.Domains :Oracle WebLogic Server domains and its components:the domain structure in file system and the methods available to create and configure a domain.The domain configuration flow and the steps required to configure a domain spanning multiple hosts, one of several required actions to configure WebLogic server in high availability.WebLogic Scripting Tool or WLST, which is an administration tool highly useful in automating WebLogic Server administrative tasks.and how WLST works, such as connectivity and run modes, enough to understand how to use WLST to accomplish the task of configuring a domain.Domain Structure
As mentioned before, it is an Oracle recommended practice to maintain the directory where the product installation is stored, separate from the product configuration. Despite this recommendation, the configuration wizard will by default suggest to create the domain in a path such as ORACLE_HOME/user_projects/domains/domain_name.Most WebLogic Server administrators will instead define a directory that contains separate directories for product installation and product configuration. In this latter directory the domains/domain_name directory can be created. It is a convention also to suffix the name of the domain directory with the string: _domain. Unless there is a need to use a different name for the domain directory, it is not a bad idea to stick to this convention but it is by no means a requirement.Whatever the location and names defined, the following directories will be created in the target directory:- autodeploy – Depending on the domain configuration, at regular intervals WebLogic can scan this directory for files of type EAR, WAR, or JAR and automatically deploy them.
- bin – Contains server life-cycle control scripts. Other scripts may be added to this directory, for example, as hooks to modify the behavior of the JVM using command-line arguments.
- config – Main domain configuration directory, includes information about the deployment state of all servers in the domain.
- config/jdbc – Contains system modules configuration for JDBC.
- config/jms – Contains system modules configuration for JMS.
- console-ext – Contains files that represent customization of the administration console.
- init-info – Contains files used when creating the domain.
- lib – JAR files found by WebLogic in this directory are added to the CLASSPATH of each server instance.
- pending – Contains files representing domain configuration changes requested but not yet activated.
- security – Contains critical files of the security configuration of the domain, including those used in processes such as file encryption and decryption.
- servers – Contains a directory for each server instance that has been started in the host.
- servers/server-name/data – Contains files representing the persistent state of this particular server instance.
- servers/server-name/security – Contains security files required to run this particular server instance, such as the one containing the credentials to query the administration server for configuration information.
- servers/server-name/logs – Contains log files of this particular server instance.
- servers/server-name/tmp – Contains temporary data of this particular server instance.
- servers/server-name/cache – Contains processed data used in this particular server instance.
The content of the logs, tmp, and cache directories of each managed server should be left alone at runtime. However, it is possible to discard their contents once the corresponding server instances have been shut down.
Pack Command
The pack.sh script is used as an efficient, one-step command to create domain templates from existing domains. This tool cannot be used to customize domains. The pack.sh command creates a template by taking a snapshot of a fully functional domain. The pack command can produce either domain templates or managed server templates.Domain templates can be used to create full copies of the source domain, or can be used as a starting point for further customization using other tools, such as the configuration wizard or WLST.Managed server templates include only a subset of the domain resources, just enough to create the managed server structure on the file system of a host participating in a domain. This is precisely the type of template required to propagate the configuration of a domain to other hosts whose responsibility as domain members will only be to run managed servers. The pack command can be used to create a domain template as follows:./pack.sh -domain=/path/to/source_domain -template=/path/to/domain_ template.jar -template_name=MyDomain -log=/path/to/pack.log
The pack command receives as arguments the path to the domain that will be packed, the path to the domain template that will be created, name inclusive, a template name, and optionally a log file.Creating a managed server template requires adding the argument: -managed=true to the command above.
Unpack Command
The unpack.sh script is the counter part of the pack.sh script. It is also executed as an efficient, one-step command but it is used to create domains from existing templates. The unpack command used with a domain template can create a domain and optionally customize the administration username and/or password, the JDK path, the domain mode, the node manager configuration, as well as specifying an applications directory when needed.If used with a managed server template, no customization is available because the template will use the configuration settings specified by the administration server in the source domain. The unpack command can be used to create a domain from a template as follows:./unpack.sh -template=/path/to/domain_template.jar -domain=/path/to/target_ domain -log=/path/to/unpack.log
The unpack command takes as arguments the path to the domain template and the path to the location where the domain will be created by expanding the contents of the domain template. Customization when using a domain template is optional. It is available through the following arguments:-user_name=USER -password=PASS -app_dir=/path/to/apps -nodemanager_ type=TYPE[6] -nodemanager_home=/path/to/nodemanager -java_home=/path/to/jdk -server_start_mode=MODE
The available customization options with the unpack command include setting the Node Manager type, either plan or SSL; the path to the Node Manager home location; and a server start mode, either development or production.
Recommended Exercises
- Using the configuration wizard, create a domain that defines a cluster with two managed servers and a machine definition for the host.
- Review the structure and contents of the main configuration file config.xml.
- Using the pack command create a domain template and a managed server template from the created domain.
- Using the configuration wizard, use the domain template just created with the pack command to create a new domain, adding the definition of a second cluster comprised of two additional managed servers.
- Use the readTemplate() function and explore the representation of the domain template in WLST.
Some questions on domains in certification point of viewQuestion - How many servers can be designated as administration servers in a domain ?
- One and only one
- More than one
- Two
- Any
Answer - a - one and only one.
Question - Each managed server in a domain requires its own product installation to run ?
a.True
b. FalseAnswer - b - False
Question - Is it possible to run more than one domain in
a.True
b. FalseAnswer - True.
Question - What format is used to persist the domain configuration ?
a. A database schema
b. A set of XML files.
c. In-memoryAnswer - b
Question - Select the tools that enable domain configuration and customization
- The configuration wizard
- The administration console
- WLST
- The pack and unpack commands
- All of the above
Answer - a, b and c.
==================================================================================
WLST Script to create a domain==============================
#
# Import statements
# -----------------
# Java
from java.util import Propertiesfrom java.io import FileInputStreamfrom java.io import Filefrom java.io import FileOutputStreamfrom java import iofrom java.lang import Exceptionfrom java.lang import Throwable# Pythonfrom org.python.modules import re# Need to import time this way to avoid name clash with Javafrom time import strftime, gmtimeimport os.pathimport shutil#=======================================================================================# File Constants# Python Note:# You can use the values of variables defined outside a Class or function# (assuming there is no variable with the same name within the function)# but you can NOT assign values to them)# This is a short list with variables in CAPITALS (starting with G_)# to indicate that they are constants#=======================================================================================#BooleanG_TRUE = 1G_FALSE = 0class DomainWLST:"Maintain WebLogic Domain using WLST"# Dictionary for BT WLST Control properties filecontrolDict={}# Dictionary for MBeansmBeanDict={}# Class String Variable# Use default name for admin server (allow usage on PC where developers might# not want to use the standard name)adminServerName = "myserver"domainHome = ""debug = 2numMs = 0auditLog = "wlst_audit.log"numAuditedChanges = 0numVerifyDifferences = 0# For WebLogic 9 (allow configure to be run without doing saves)updateSaveChanges = "true"# If admin server is already running, leave it running, otherwise stop it# when stopAdminServer is calledadminServerAlreadyRunning = G_TRUEdef __init__( self, controlProp, mBeanProp ):"Populates bt wlst control properties file into controlProp"for entry in controlProp.entrySet():value = entry.valuevalue = value.strip()self.controlDict[entry.key] = valuepassword = self.controlDict["connect.password"]if password == "prompt":password = raw_input( 'Enter WebLogic Password: ' )password.strip()self.controlDict["connect.password"] = passwordfor entry in mBeanProp.entrySet():value = entry.valuevalue = value.strip()self.mBeanDict[entry.key] = value# Initialise class string variablesif self.controlDict.has_key( "debug" ):self.debug = int( self.controlDict["debug"] )if self.controlDict.has_key( "numManagedServers" ):self.numMs = int( self.controlDict["numManagedServers"] )self.adminServerName = self.controlDict["adminServerName"]self.adminServerName = self.adminServerName.replace("@DOMAIN_NAME@", self.controlDict["domName"] )if self.debug > 1:print "Admin Server Name now " + self.adminServerNameself.domainHome = self.controlDict["domRoot"] + "/" + self.controlDict["domName"]if self.controlDict.has_key( "auditLog" ):self.auditLog = self.controlDict["auditLog"]else:self.auditLog = self.domainHome + "/" + self.auditLogif self.controlDict.has_key( "update.saveChanges" ):self.updateSaveChanges = self.controlDict["update.saveChanges"]# Do all general substitions in dictionaries# i.e. NOT @SERVER_NAME@, @MANAGED_SERVER@for key, value in self.controlDict.items():value = value.replace( "@DOMAIN_NAME@", self.controlDict["domName"] )value = value.replace( "@DOMAIN_ROOT@", self.controlDict["domRoot"] )value = value.replace( "@DOMAIN_HOME@", self.domainHome )value = value.replace( "@ADMIN_SERVER@", self.adminServerName )self.controlDict[key] = valuefor key, value in self.mBeanDict.items():value = value.replace( "@DOMAIN_NAME@", self.controlDict["domName"] )value = value.replace( "@DOMAIN_ROOT@", self.controlDict["domRoot"] )value = value.replace( "@DOMAIN_HOME@", self.domainHome )value = value.replace( "@ADMIN_SERVER@", self.adminServerName )self.mBeanDict[key] = valuedef convertBoolean(self, expectedValue):" Convert true and false to numeric equivalents"if (expectedValue == "true"):return G_TRUEelif (expectedValue == "false"):return G_FALSEelse:return expectedValuedef convertBackToBoolean(self, expectedValue):"""Convert booleran numeric equivalents back to boolean string literalsNeed to make sure this field is a boolean before calling it"""if (expectedValue == G_TRUE):return "true"elif (expectedValue == G_FALSE):return "false"else:return expectedValuedef promptPasswordAttributes( self ):"Prompts user for any password mBean attributes which have value set to prompt"for key, value in self.mBeanDict.items():keyitems = key.split(".")if keyitems[0] == "attribute" and keyitems[3] == "Password":#attribute.JDBCConnectionPool.1.DriverNameif value == "prompt":password = raw_input("Enter Password for " +keyitems[1] + "." +keyitems[2] + ": ")password.strip()self.mBeanDict[key] = password# Since config.xml lives in different locations in 81 and 9, get each function# call generic function with location of config.xml to backupdef backupConfigXml81( self ):self._backupConfigXml( self.domainHome )def _backupConfigXml( self, configDir ):confixXmlFullName = os.path.join( configDir, "config.xml" )if os.path.exists( confixXmlFullName ):now = strftime( "%y%m%d%H%M%S", gmtime() )backupFile = confixXmlFullName + "." + nowprint "INFO: Backuping up config.xml to " + backupFileshutil.copy( confixXmlFullName, backupFile )def deploy( self ):keyList = self.mBeanDict.keys()keyList.sort()for key in keyList:keyItems = key.split( "." )if keyItems[0] == "application":value = self.mBeanDict[key]#application.010.deploy=PingWar+D:/code/NetcVeritasPing/WebLogicWebAppPing.war+@DOMAIN_NAME@_cluster+nostagevalueList = value.split( ";" )action = keyItems[2]if ( action == "deploy" ):try:deploy( valueList[0], valueList[1], valueList[2], valueList[3] )except Throwable, th:# create a list of errors to give at end of program ?print 'Problem deploying ' + key + ' due to ' + th.toString()elif ( action == "undeploy" ):try:if len( valueList ) == 2:print "INFO: undeploy " + valueList[0] + " on targets " + valueList[1]undeploy( valueList[0], valueList[1] )else:print "INFO: undeploy " + valueList[0]undeploy( valueList[0] )except Throwable, th:# create a list of errors to give at end of program ?print 'Problem undeploying ' + key + ' due to ' + th.toString()elif ( action == "redeploy" ):try:redeploy( valueList[0] )except Throwable, th:# create a list of errors to give at end of program ?print 'Problem redeploying ' + key + ' due to ' + th.toString()def connectToWebLogic( self ):"Connect to WebLogic Server using properties in bt_wlst_control.properties"# Turn off message output so that user doesn't see exception thrown if# Admin server is not currently runningredirect('/dev/null', 'false')if not self._connectToWebLogic():stopRedirect()print "INFO: Starting Admin Server..."self.startAdminServer()if not self._connectToWebLogic():print "ERROR: Can not connect to WebLogic"exit()stopRedirect()def startAdminServer( self ):self.adminServerAlreadyRunning = G_FALSE# Refacting using eval command ?if self.controlDict.has_key("startServerBlockTimeout"):print "INFO: Using timeout msecs of " + self.controlDict["startServerBlockTimeout"]startServer( self.adminServerName,self.controlDict["domName"],self.controlDict["connect.url"],self.controlDict["connect.username"],self.controlDict["connect.password"],self.domainHome,block='true',timeout=int(self.controlDict["startServerBlockTimeout"]))else:startServer( self.adminServerName,self.controlDict["domName"],self.controlDict["connect.url"],self.controlDict["connect.username"],self.controlDict["connect.password"],self.domainHome,block='true' )def stopAdminServer( self, timeoutSeconds ):" Stops admin server if we started it in this run"if not self.adminServerAlreadyRunning:shutdown(self.adminServerName,"Server","true",timeoutSeconds )def _connectToWebLogic( self ):result = G_TRUEtry:print "INFO: Connecting to WebLogic at url " + self.controlDict["connect.url"]if self.controlDict.has_key( "connect.userConfigFile" ):print "Connecting using userConfigFile and connect.userKeyFile"connect( userConfigFile=self.controlDict["connect.userConfigFile"],userKeyFile=self.controlDict["connect.userKeyFile"],url=self.controlDict["connect.url"] )else:print "Connecting using username and password"password = self.controlDict["connect.password"]connect( self.controlDict["connect.username"], password, self.controlDict["connect.url"] )except Throwable, th:print "INFO: WebLogic Not running"result = G_FALSEexcept:print "INFO: WebLogic Not running (python exception caught)"result = G_FALSEreturn resultdef configureDomain( self ):"Mbean creation in domain (when creating or updating domain)"self.promptPasswordAttributes()mBeanKeys = self.mBeanDict.keys()mBeanKeys.sort()for key in mBeanKeys:keyItems = key.split( "." )if keyItems[0] == "mbean":value = self.mBeanDict[key]# Value is split into [parent dir] [mbean name] [mbean type]if self.debug > 1:print "Filter create is " + key + " -> " + valueif ( key.find( "managed" ) != -1 ) :for ms in range( self.numMs ):managedServerName = "managed"+str( ms + 1 )+"_"+self.controlDict["domName"]msvalue = valuemsvalue = msvalue.replace( "@MANAGED_SERVER@", managedServerName )valueList = msvalue.split( ";" )self.buildMBean(parentDir = valueList[0],mBeanName = valueList[1],mBeanType = keyItems[2] )self.setAttributeValues(mBeanName = valueList[1],mBeanType = keyItems[2],filterSet = ( keyItems[3], keyItems[3]+str( ms + 1 ) ),searchString = "@SERVER_NAME@",replaceString = managedServerName )else :valueList = value.split( ";" )self.buildMBean(parentDir = valueList[0],mBeanName = valueList[1],mBeanType = keyItems[2] )if (key.find( "admin" ) != -1 ):self.setAttributeValues(mBeanName = valueList[1],mBeanType = keyItems[2],filterSet = ( keyItems[3], ),searchString = "@SERVER_NAME@",replaceString = self.adminServerName )else:self.setAttributeValues(mBeanName = valueList[1],mBeanType = keyItems[2],filterSet = ( keyItems[3], ),searchString = "DUMMY",replaceString = "DUMMY")# WARNING: WebLogic 8.1 and 9 behave differently maybe due to differences# with the version of JMX used). For 8.1 an exception is thrown if getMBean# does NOT find an MBean. For 9.X this does NOT occur but the result is NONE# This function encapsulates this and is used in both configure and verifydef mBeanExist(self, mBeanName, mBeanType):"Returns G_TRUE if mBean exist in current directory, else G_FALSE"beanFound = G_TRUEmycmd="getMBean('"+mBeanType+"/"+mBeanName+"')"if self.debug > 1:print "about to run the command "+mycmd# Use exceptions since BEA have not provided a simple API call to# check if a mBean exists with WebLogic 8.1try:mybeanPath = eval(mycmd)if mybeanPath == None:# WebLogic 9 behaviour (8.1 will have thown an exception by now)return G_FALSEexcept:# WebLogic 8.1 behaviourreturn G_FALSEreturn G_TRUEdef checkMBean(self, parentDir, mBeanName, mBeanType):""" Returns G_TRUE if mBean exist under parentDir, else G_FALSEIf parent dir exists, then this function will cd to it"""try:cd(parentDir)except:print "ERROR: Parent Directory " + parentDir + " does NOT exist"return G_FALSEif self.debug > 1:print "Current Dir " + str(pwd())return self.mBeanExist(mBeanName, mBeanType)def buildMBean(self, parentDir, mBeanName, mBeanType):"Create MBean if it does not exist. Always cd to MBean directory"if self.debug > 0:print "Mbean " + mBeanName + " " + mBeanType + " (parent dir = " + parentDir + ")"cd(parentDir)if self.debug > 1:print "Current Dir " + str(pwd())if not self.mBeanExist(mBeanName, mBeanType):print "Create mbean " + mBeanType + " with name " + mBeanNamecreate( mBeanName, mBeanType )self.logAuditMsg( "Created mbean " + mBeanType + " with name " + mBeanName )cd( mBeanType+"/"+mBeanName )def logAuditMsg( self, message ):if self.updateSaveChanges != "false":now = strftime( "%y%m%d-%H:%M:%S", gmtime() )print messagelog = open( self.auditLog, 'a' )log.write( now + ": " + message + "\n" )log.close()self.numAuditedChanges = self.numAuditedChanges + 1def setAttributeValues( self, mBeanName ,mBeanType, filterSet,searchString, replaceString ):""" Set updated attributes for existing mBeans. Use mBeanName for log only"""attributeDict = self._createFilteredAttributeDict(mBeanType, filterSet)# These attributes need to be processed for the current mBeanfor key in attributeDict.keys():value = attributeDict[key]if re.match( '^[0-9]+$', value ):value = int( value )else:value = value.replace( searchString, replaceString )doUpdate = G_TRUEtry:mycmd = "cmo.get"+key+"()"if self.debug > 0:print "INFO: about to execute mycmd "+mycmdoldValue = eval(mycmd)except:# For some reason oldValue = get(key) fails in WL 9if self.debug > 0:print "INFO: about to get the oldValue "+keyoldValue = get(key)if self.debug > 1 and key != "Password":print "Old Value " + str(oldValue)if self.areAttributeValuesEqual(attributeName = key,oldValue = oldValue,newValue = value):doUpdate = G_FALSEif doUpdate:if (key != "Password"):prtValue = str(value)else:prtValue = "********"if self.debug > 0:print "Setting attribute for " + key + " value " + prtValueif ( key == "Properties" ):props = makePropertiesObject(value)set( key, props )elif ( key == "JNDINames" ):mypwd=str(pwd())mytestarray=mypwd.split("/")if re.match( 'JDBCDataSourceParams', mytestarray[5] ):cd('../..')dsp=cmo.getJDBCDataSourceParams()dsp.removeJNDIName(value)dsp.addJNDIName(value)else:set( key, value )if str(value) == "true" or value == "false":oldValue = self.convertBackToBoolean(oldValue)self.logAuditMsg("Update Attribute for " + key + " value " +prtValue + " from " + str(oldValue) +" (mBean " + mBeanName +", type " + mBeanType + ")")def _createFilteredAttributeDict(self, mBeanType, filterSet):attributeDict = {} # key = MBean attribute, Value = MBean Value# add all common attributes firstfor key in self.mBeanDict.keys():keyItems = key.split( "." )if keyItems[0] == "attribute" and keyItems[1] == mBeanType and \keyItems[2] == "common" :attributeDict[keyItems[3]] = self.mBeanDict[key]# add specific attributes (this will overwrite any common values already# set in this dictionary)for filter in filterSet:for key in self.mBeanDict.keys():keyItems = key.split( "." )if keyItems[0] == "attribute" and keyItems[1] == mBeanType and \keyItems[2] == filter :attributeDict[keyItems[3]] = self.mBeanDict[key]return attributeDictdef checkAttributeValues( self, mBeanName ,mBeanType, filterSet,searchString, replaceString ):""" Check if attibutes are same as expected. Log Verify differences"""attributeDict = self._createFilteredAttributeDict(mBeanType, filterSet)# These attributes need to be processed for the current mBeanfor key in attributeDict.keys():expectedValue = attributeDict[key]expectedValue = expectedValue.replace( searchString, replaceString )if key == "Password":print "INFO: do NOT verify password attibutes"continueactualValue = get(key)if not self.areAttributeValuesEqual(attributeName = key,oldValue = actualValue,newValue = expectedValue):self.handleVerifyError("Attribute for " + key + " expected " +expectedValue + " actual " + str(actualValue) +" (mBean " + mBeanName + ", type " + mBeanType + ")")def areAttributeValuesEqual(self, attributeName, oldValue, newValue):"return G_TRUE if attribute values are the same (else G_FALSE)"# While config.xml has true or false, get returns 1 or 0newValue = self.convertBoolean(newValue) # naff I know# On Windows, Windows and UNIX filenames are the same!if (attributeName == "FileName"):oldValue = oldValue.replace("\\","/")newValue = newValue.replace("\\","/")elif (attributeName == "Properties"):newValue = "{" + newValue + "}"if ( str(newValue) == str(oldValue) ):return G_TRUEelse:return G_FALSEdef targetConfigValues( self ):for key in self.mBeanDict.keys():keyItems = key.split( "." )if keyItems[0] == "target":value = self.mBeanDict[key]valueItems = value.split( ";" )tgtbean = getMBean( valueItems[1] )print "CMO for target " + keyItems[2] + tgtbean.getName()cd( valueItems[0] )if keyItems[2] == "setCluster":print "Running setCluster command for " + tgtbean.getName()cmo.setCluster( tgtbean )elif keyItems[2] == "addTarget":# check if target already settargets = cmo.getTargets()targetNotFound = G_TRUEfor target in targets:if target.getName() == tgtbean.getName():print "INFO: Target already set"targetNotFound = G_FALSEbreakif targetNotFound:print "Running addTarget command for " + tgtbean.getName()try:cmo.addTarget( tgtbean )#addLogRecord("AddTarget " + tgtbean.getName() + " for " + keyItems[2])except Throwable, th:print 'Problem in adding target ' + tgtbean.getName() + ' due to ' + th.toString()def handleVerifyError(self, message):"Printout error details in standard format and increment count"self.numVerifyDifferences = self.numVerifyDifferences + 1print "VERIFY ERROR: " + messagedef verifyDomain(self):"Verify Domain against expected file of mBean items"mBeanKeys = self.mBeanDict.keys()mBeanKeys.sort()for key in mBeanKeys:keyItems = key.split( "." )if keyItems[0] == "mbean":value = self.mBeanDict[key]# Value is split into [parent dir] [mbean name] [mbean type]if self.debug > 2:print "Verify " + key + " -> " + valueif ( key.find( "managed" ) != -1 ) :for ms in range( self.numMs ):managedServerName = "managed"+str( ms + 1 )+"_"+self.controlDict["domName"]msvalue = valuemsvalue = msvalue.replace( "@MANAGED_SERVER@", managedServerName )valueList = msvalue.split( ";" )if not self.checkMBean(parentDir = valueList[0],mBeanName = valueList[1],mBeanType = keyItems[2]):self.handleVerifyError("Expected mBean " + valueList[1] +" does NOT exist!")else:cd( keyItems[2]+"/"+valueList[1] )self.checkAttributeValues(mBeanName = valueList[1],mBeanType = keyItems[2],filterSet = ( keyItems[3], keyItems[3]+str( ms + 1 ) ),searchString = "@SERVER_NAME@",replaceString = managedServerName)else:valueList = value.split( ";" )if not self.checkMBean(parentDir = valueList[0],mBeanName = valueList[1],mBeanType = keyItems[2]):self.handleVerifyError("Expected mBean " + valueList[1] + " does NOT exist!")else:cd( keyItems[2]+"/"+valueList[1] )if (key.find( "admin" ) != -1 ):self.checkAttributeValues(mBeanName = valueList[1],mBeanType = keyItems[2],filterSet = ( keyItems[3], ),searchString = "@SERVER_NAME@",replaceString = self.adminServerName )else:self.checkAttributeValues(mBeanName = valueList[1],mBeanType = keyItems[2],filterSet = ( keyItems[3], ),searchString = "DUMMY",replaceString = "DUMMY")def copyFileToDomainHome(self, controlPropFile):baseFilename = os.path.basename(controlPropFile)domainFilename = os.path.join( self.domainHome, baseFilename)if not os.path.exists(domainFilename):print "INFO: Copy " + baseFilename + " to DOMAIN_HOME"shutil.copy(controlPropFile, domainFilename)# End of File===================================================================================
No comments:
Post a Comment