Sunday, September 9, 2018

Oracle WebLogic Server 12c: Administration I - 1Z0-133 - Part - 1

Oracle WebLogic Server 12c: Administration I - 1Z0-133 


Oracle 1Z0-133 Certification Details:

Exam NameOracle WebLogic Server 12c Administration I
Exam Code1Z0-133
Exam Product VersionWebLogic Server
Exam PriceUSD $245 (Pricing may vary by country or by localized currency)
Duration120 minutes
Number of Questions77
Passing Score64%
Validated AgainstThis exam is validated against 12.1.2.
FormatMultiple Choice
Recommended TrainingOracle WebLogic Server 12c: Administration I
Schedule ExamPearson 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
Chapter 3 Creating Domains   





  • Domain Modes
  • Using the configuration wizard
  • Domain Planning
  • Domain Creation Tools
  • Multitenancy concepts.
  • Domain Templates
Chapter 4 Node Manager





Chapter 5 Starting Servers




  • Restarting Failed Servers.
  • Customizing Domain Scripts
  • Server Lifecycle
  • Starting and Stopping Servers
  • Domain Scripts.
Chapter 6 Configuration Management
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
































    Question -  Select the tools that enable domain configuration and customization



    1. The configuration wizard
    2. The administration console
    3. WLST
    4. The pack and unpack commands
    5. All of the above


    Answer - a, b and c.






    ==================================================================================


    WLST Script to  create a domain
    ==============================




    #

    # Import statements

    # -----------------

    # Java

    from java.util import Properties
    from java.io import FileInputStream
    from java.io import File
    from java.io import FileOutputStream
    from java import io
    from java.lang import Exception
    from java.lang import Throwable
    # Python
    from org.python.modules import re
    # Need to import time this way to avoid name clash with Java
    from time import strftime, gmtime
    import os.path 
    import 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
    #=======================================================================================
    #Boolean
    G_TRUE  = 1
    G_FALSE = 0

    class DomainWLST:
       "Maintain WebLogic Domain using WLST"
       
       # Dictionary for BT WLST Control properties file
       controlDict={}
       
       # Dictionary for MBeans
       mBeanDict={}
       
       # 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 = 2
       numMs = 0
       auditLog = "wlst_audit.log"
       numAuditedChanges = 0
       numVerifyDifferences = 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 called
       adminServerAlreadyRunning = G_TRUE
       
       
       
       def __init__( self, controlProp, mBeanProp ):
          "Populates bt wlst control properties file into controlProp"
          
          for entry in controlProp.entrySet():
             value = entry.value
             value = value.strip() 
             self.controlDict[entry.key] = value   
          password = self.controlDict["connect.password"]
          if password == "prompt":
             password = raw_input( 'Enter WebLogic Password: ' )
             password.strip()
          self.controlDict["connect.password"] = password     
          
          for entry in mBeanProp.entrySet(): 
             value = entry.value
             value = value.strip() 
             self.mBeanDict[entry.key] = value
             
          # Initialise class string variables
          if 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.adminServerName 

          self.domainHome = self.controlDict["domRoot"] + "/" + self.controlDict["domName"]
          
          if self.controlDict.has_key( "auditLog" ):   
             self.auditLog =  self.controlDict["auditLog"]
          else:
             self.auditLog = self.domainHome  + "/" +  self.auditLog 

          if 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] = value
          for 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] = value    
           
           
       def convertBoolean(self, expectedValue): 
            " Convert true and false to numeric equivalents"

            if (expectedValue == "true"):
                return G_TRUE
            elif (expectedValue == "false"):
                return G_FALSE
            else:
                return expectedValue
            
            
       def convertBackToBoolean(self, expectedValue): 
           """Convert booleran numeric equivalents back to boolean string literals
              Need 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 expectedValue       
            
             
       def 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.DriverName
                   if 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 backup
       def 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 + "." + now
             print "INFO: Backuping up config.xml to " + backupFile
             shutil.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+nostage 
                valueList = 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 running
          redirect('/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_TRUE
          try:
             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_FALSE 
          except:
             print "INFO: WebLogic Not running (python exception caught)"
             result = G_FALSE
          return result
          
             
       def 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 + " -> " + value
                    
                if ( key.find( "managed" ) != -1 ) :
                    for ms in range( self.numMs ):
                       managedServerName = "managed"+str( ms + 1 )+"_"+self.controlDict["domName"]
                       msvalue = value
                       msvalue = 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 verify
       def mBeanExist(self, mBeanName, mBeanType):
           "Returns G_TRUE if mBean exist in current directory, else G_FALSE"

           beanFound = G_TRUE       
           mycmd="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.1
           try:
               mybeanPath = eval(mycmd)
               if mybeanPath == None:
                   # WebLogic 9 behaviour (8.1 will have thown an exception by now)
                   return G_FALSE
           except:
               # WebLogic 8.1 behaviour
               return G_FALSE
               
           return G_TRUE  
           
           
       def checkMBean(self, parentDir, mBeanName, mBeanType):
           """ Returns G_TRUE if mBean exist under parentDir, else G_FALSE
               If parent dir exists, then this function will cd to it
           """
          
           try:
               cd(parentDir)
           except:
               print "ERROR: Parent Directory " + parentDir + " does NOT exist"
               return G_FALSE

           if 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 " + mBeanName
                create( 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 message
             log = open( self.auditLog, 'a' ) 
             log.write( now + ": " + message + "\n" ) 
             log.close() 
             self.numAuditedChanges = self.numAuditedChanges + 1
          
          
       def 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 mBean
          for key in attributeDict.keys():            
                
                value = attributeDict[key]
                if re.match( '^[0-9]+$', value ):
                    value = int( value )
                else:
                    value = value.replace( searchString, replaceString )
                     
                doUpdate = G_TRUE
                try:
                    mycmd = "cmo.get"+key+"()"
                    if self.debug > 0:
                        print "INFO: about to execute mycmd "+mycmd
                    oldValue = eval(mycmd)
                except:
                    # For some reason oldValue = get(key) fails in WL 9
                    if self.debug > 0:
                        print "INFO: about to get the oldValue "+key
                    oldValue = 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_FALSE           
                
                if doUpdate:
                    if (key != "Password"):
                        prtValue = str(value)
                    else:
                        prtValue = "********"
                    if self.debug > 0:
                        print "Setting attribute for " + key + " value " + prtValue
                    if ( 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 first     
          for 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 attributeDict        
                   
                    
       def 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 mBean
          for key in attributeDict.keys():            
                
                expectedValue = attributeDict[key]
                expectedValue = expectedValue.replace( searchString, replaceString )
                 
                if key == "Password":
                    print "INFO: do NOT verify password attibutes"
                    continue
                      
                actualValue = 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 0
            newValue = 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_TRUE
            else:      
                return G_FALSE                 


       def 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 set
                   targets = cmo.getTargets()
                   targetNotFound = G_TRUE
                   for target in targets:
                       if target.getName() == tgtbean.getName():
                           print "INFO: Target already set"
                           targetNotFound = G_FALSE
                           break
                   if 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 + 1
           print "VERIFY ERROR: " + message
           
           
       def 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 + " -> " + value   
                     
                if ( key.find( "managed" ) != -1 ) :
                    for ms in range( self.numMs ):
                       managedServerName = "managed"+str( ms + 1 )+"_"+self.controlDict["domName"]
                       msvalue = value
                       msvalue = 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

Hyderabad Trip - Best Places to visit

 Best Places to Visit  in Hyderabad 1.        1. Golconda Fort Maps Link :   https://www.google.com/maps/dir/Aparna+Serene+Park,+Masj...