#################################################################### # Modify Server. # Modify the attributes of an existing server. #################################################################### namespace eval modifyServer { proc modifyServer { propertiesFile } { global AdminConfig set procName [ lindex [ info level 0 ] 0 ] putsLog "## proc - $procName" foreach i [ info args $procName ] { upvar 0 $i ilocal set propertiesArray($i) $ilocal } putsLog "properties are.................." foreach { a b } [ array get propertiesArray ] { putsLog [ format "%-35s %s" "$a" "$b" ] } # call the hashMap proc which returns a Property object populated with property file values. if { [ catch { hashMap $propertiesFile } r ] == 0 } { set PropertyI $r } else { return -code error $r } # call the hashMapList proc which extracts the java hashmap into a tcl list. putsLog "new server properties are:............" if { [ catch { hashMapList $propertiesFile } r ] == 0 } { set propertiesList $r foreach a $propertiesList { putsLog [ format "%-50s %-s" "[ lindex $a 0 ]" "[ lindex $a 1 ]" ] } } else { return -code error $r } # get the server id. Check for a null return. variable serverName [ $PropertyI getProperty serverName ] if { [ catch { $AdminConfig getid /Server:$serverName/ } r ] == 0 } { if { $r == {} } { putsLog "ERROR: Server $serverName does not exist" return -code error $r } else { set serverId $r } } else { return -code error $r } # set Transaction Service Properties. # name value pair is attribute name and value. foreach a $propertiesList { # the first list element contains the property name. # the first segment of the property name is the type. # the second segment of the property name is the attribute. set propertyName [ lindex $a 0 ] #puts "property name is $propertyName" set lengthFirstName [ string first "." $propertyName ] set firstName [ string range $propertyName 0 [ expr { $lengthFirstName - 1 } ] ] set secondName [ string range $propertyName [ expr { $lengthFirstName + 1 } ] end ] # Build the attribute lists switch -exact -- $firstName { errorstreamredirect { lappend errorstreamredirectList [ list $secondName [ lindex $a 1 ] ] } HTTPTransport { lappend HTTPTransportList [ list $secondName [ lindex $a 1 ] ] } JavaVirtualMachine { lappend JavaVirtualMachineList [ list $secondName [ lindex $a 1 ] ] } MonitoringPolicy { lappend MonitoringPolicyList [ list $secondName [ lindex $a 1 ] ] } outputStreamRedirect { lappend outputStreamRedirectlist [ list $secondName [ lindex $a 1 ] ] } SessionManager { lappend SessionManagerList [ list $secondName [ lindex $a 1 ] ] } ThreadPool { lappend ThreadPoolList [ list $secondName [ lindex $a 1 ] ] } TransactionService { lappend TransactionList [ list $secondName [ lindex $a 1 ] ] } TuningParams { lappend TuningParamsList [ list $secondName [ lindex $a 1 ] ] } WebContainer { lappend WebContainerList [ list $secondName [ lindex $a 1 ] ] } } } # 17/04/2007 # make the proc more flexible by only setting attributes that exist in the properties file. # check if each list variable exists. ## set transaction properties. if { [ info exist TransactionList ] == 1 } { if { [ catch { setTransProps $serverId $TransactionList } r ] != 0 } { return -code error $r } } ## set Web Container Properties. if { [ info exist WebContainerList ] == 1 } { if { [ catch { setWebProps $serverId $WebContainerList } r ] != 0 } { return -code error $r } } ## set Log File Properties. if { [ info exist outputStreamRedirectlist ] == 1 } { if { [ catch { setLogProps $serverId $outputStreamRedirectlist $errorstreamredirectList } r ] != 0 } { return -code error $r } } # set JVM Properties. if { [ info exist JavaVirtualMachineList ] == 1 } { if { [ catch { setJVMProps $serverId $JavaVirtualMachineList } r ] != 0 } { return -code error $r } } # set ThreadPool Properties. if { [ info exist ThreadPoolList ] == 1 } { if { [ catch { setThreadpoolProps $serverId $ThreadPoolList } r ] != 0 } { return -code error $r } } # set Session Manager Properties. if { [ info exist SessionManagerList ] == 1 } { if { [ catch { setSessionManagerProps $serverId $SessionManagerList } r ] != 0 } { return -code error $r } } # set TuningParams list. if { [ info exist TuningParamsList ] == 1 } { if { [ catch { setTuningParamsProps $serverId $TuningParamsList } r ] != 0 } { return -code error $r } } # set MonitoringPolicy Properties. if { [ info exist MonitoringPolicyList ] == 1 } { if { [ catch { setMonitoringPolicyProps $serverId $MonitoringPolicyList } r ] != 0 } { return -code error $r } } } #################################################################### # Set transaction service properties. #################################################################### proc setTransProps {serverId TransactionAttr } { variable serverName global AdminConfig set procName [ lindex [ info level 0 ] 0 ] putsLog "## proc - $procName" foreach i [ info args $procName ] { upvar 0 $i ilocal set propertiesArray($i) $ilocal } putsLog "properties are.................." foreach { a b } [ array get propertiesArray ] { putsLog [ format "%-35s %s" "$a" "$b" ] } # get Transaction Service id set TransactionServiceId [ $AdminConfig list TransactionService $serverId ] if { [ catch { $AdminConfig modify $TransactionServiceId $TransactionAttr } r ] == 0 } { putsLog "************************************" putsLog "$serverName transaction properties created successfully." putsLog "************************************" } else { putsLog "\nfailed to create transaction properties for $serverName\n" putsLog $r putsLog "************************************" return -code error $r } } #################################################################### # Set web container properties. #################################################################### proc setWebProps {serverId WebContainerList } { variable serverName global AdminConfig set procName [ lindex [ info level 0 ] 0 ] putsLog "## proc - $procName" foreach i [ info args $procName ] { upvar 0 $i ilocal set propertiesArray($i) $ilocal } putsLog "properties are.................." foreach { a b } [ array get propertiesArray ] { putsLog [ format "%-35s %s" "$a" "$b" ] } # get Web Container id set WebContainerId [ $AdminConfig list WebContainer $serverId ] if { [ catch { $AdminConfig modify $WebContainerId $WebContainerList } r ] == 0 } { putsLog "************************************" putsLog "$serverName - WebContainer properties created successfully." putsLog "************************************" } else { putsLog "\nfailed to create WebContainer properties for $serverName\n" putsLog $r putsLog "************************************" return -code error $r } } #################################################################### # Set logging properties. #################################################################### proc setLogProps { serverId outputStreamRedirectlist errorstreamredirectList } { global AdminConfig variable serverName set procName [ lindex [ info level 0 ] 0 ] putsLog "## proc - $procName" foreach i [ info args $procName ] { upvar 0 $i ilocal set propertiesArray($i) $ilocal } putsLog "properties are.................." foreach { a b } [ array get propertiesArray ] { putsLog [ format "%-35s %s" "$a" "$b" ] } # get output log id set outputLogId [ $AdminConfig showAttribute $serverId outputStreamRedirect ] if { [ catch { $AdminConfig modify $outputLogId $outputStreamRedirectlist } r ] == 0 } { putsLog "************************************" putsLog "$serverName - Server output log properties created successfully." putsLog "************************************" } else { putsLog "\nfailed to create Server output log properties for $serverName\n" putsLog $r putsLog "************************************" return -code error $r } # get error log id set errorLogId [ $AdminConfig showAttribute $serverId errorStreamRedirect ] if { [ catch { $AdminConfig modify $errorLogId $errorstreamredirectList } r ] == 0 } { putsLog "************************************" putsLog "$serverName - Server error log properties created successfully." putsLog "************************************" } else { putsLog "\nfailed to create Server error log properties for $serverName\n" putsLog $r putsLog "************************************" return -code error $r } } #################################################################### # Set JVM Properties. #################################################################### proc setJVMProps { serverId JavaVirtualMachineList } { global AdminConfig variable serverName set procName [ lindex [ info level 0 ] 0 ] putsLog "## proc - $procName" foreach i [ info args $procName ] { upvar 0 $i ilocal set propertiesArray($i) $ilocal } putsLog "properties are.................." foreach { a b } [ array get propertiesArray ] { putsLog [ format "%-35s %s" "$a" "$b" ] } # get JVM id set jvmId [ $AdminConfig list JavaVirtualMachine $serverId ] foreach i $JavaVirtualMachineList { if { [ lsearch $i "*systemProperties*" ] != -1 } { set fullName [ lindex $i 0 ] set stubIndex [ string first "." $fullName ] set name [ string range $fullName [ incr stubIndex ] end ] set value [ lindex $i 1 ] lappend systemPropertiesList [ list $name $value ] } } # extract the remaining systemProperties from the JVM properties list create attributes list. foreach i $JavaVirtualMachineList { if { [ lsearch $i "*systemProperties*" ] == -1 } { lappend otherAttributes [ list [ lindex $i 0 ] [ lindex $i 1 ] ] } } lappend $otherAttributes [ list systemProperties $systemPropertiesList ] set attrList $otherAttributes if { [ catch { $AdminConfig modify $jvmId $attrList } r ] == 0 } { putsLog "************************************" putsLog "$serverName - JVM properties created successfully." putsLog "************************************" } else { putsLog "\nfailed to create Server JVM properties for $serverName\n" putsLog "************************************" return -code error $r } } #################################################################### # Set Threadpool Properties. #################################################################### proc setThreadpoolProps { serverId ThreadPoolList } { global AdminConfig variable serverName set procName [ lindex [ info level 0 ] 0 ] putsLog "## proc - $procName" foreach i [ info args $procName ] { upvar 0 $i ilocal set propertiesArray($i) $ilocal } putsLog "procedure arguments are .................." foreach { a b } [ array get propertiesArray ] { putsLog [ format "%-35s %s" "$a" "$b" ] } # get ThreadPool id set threadPoolList [ $AdminConfig list ThreadPool $serverId ] foreach i $threadPoolList { if { [ $AdminConfig showAttribute $i name ] == "WebContainer" } { set threadPoolId $i } } # modify the ThreadPool id if { [ catch { $AdminConfig modify $threadPoolId $ThreadPoolList } r ] == 0 } { putsLog "************************************" putsLog "$serverName - Threadpool properties created successfully." putsLog "************************************" } else { putsLog "\nfailed to create Threadpool properties for $serverName\n" putsLog $r putsLog "************************************" return -code error $r } } #################################################################### # Set Session Manager Properties. #################################################################### proc setSessionManagerProps { serverId SessionManagerList } { global AdminConfig variable serverName set procName [ lindex [ info level 0 ] 0 ] putsLog "## proc - $procName" foreach i [ info args $procName ] { upvar 0 $i ilocal set propertiesArray($i) $ilocal } putsLog "procedure arguments are .................." foreach { a b } [ array get propertiesArray ] { putsLog [ format "%-35s %s" "$a" "$b" ] } # get the Webcontainer id set WebContainerId [ $AdminConfig list WebContainer $serverId ] # get the Session Manager id set sessionManagerId [ $AdminConfig list SessionManager $WebContainerId] if { [ catch { $AdminConfig modify $sessionManagerId $SessionManagerList } r ] == 0 } { putsLog "************************************" putsLog "$serverName - Session Manager properties created successfully." putsLog "************************************" } else { putsLog "failed to create Session Manager properties for $serverName" putsLog $r putsLog "************************************" return -code error $r } } #################################################################### # Set Tuning Parameters. #################################################################### proc setTuningParamsProps { serverId TuningParamsList } { global AdminConfig variable serverName set procName [ lindex [ info level 0 ] 0 ] putsLog "## proc - $procName" foreach i [ info args $procName ] { upvar 0 $i ilocal set propertiesArray($i) $ilocal } putsLog "procedure arguments are .................." foreach { a b } [ array get propertiesArray ] { putsLog [ format "%-35s %s" "$a" "$b" ] } # get the Webcontainer id set WebContainerId [ $AdminConfig list WebContainer $serverId ] # get the Session Manager id set sessionManagerId [ $AdminConfig list SessionManager $WebContainerId] # get the Tuning Params id. set tuningParamsId [ $AdminConfig showAttribute $sessionManagerId tuningParams ] if { [ catch { $AdminConfig modify $tuningParamsId $TuningParamsList } r ] == 0 } { putsLog "************************************" putsLog "$serverName - Tuning Params properties created successfully." putsLog "************************************" } else { putsLog "failed to create Tuning Params properties for $serverName" putsLog $r putsLog "************************************" return -code error $r } } ##################################################################### # Set Monitoring Policy Properties. ##################################################################### proc setMonitoringPolicyProps { serverId MonitoringPolicyList } { global AdminConfig variable serverName set procName [ lindex [ info level 0 ] 0 ] putsLog "## proc - $procName" foreach i [ info args $procName ] { upvar 0 $i ilocal set propertiesArray($i) $ilocal } putsLog "procedure arguments are .................." foreach { a b } [ array get propertiesArray ] { putsLog [ format "%-35s %s" "$a" "$b" ] } #set processDefId [ lindex [ $AdminConfig showAttribute $serverId processDefinitions ] 0 ] set processDefId [ lindex [ $AdminConfig showAttribute $serverId processDefinition ] 0 ] set monPolicyId [$AdminConfig showAttribute $processDefId monitoringPolicy ] if { [ catch { $AdminConfig modify $monPolicyId $MonitoringPolicyList } r ] == 0 } { putsLog "************************************" putsLog "$serverName - MonitoringPolicy properties created successfully." putsLog "************************************" } else { putsLog "failed to create MonitoringPolicy properties for $serverName" putsLog $r putsLog "************************************" return -code error $r } } }