Install application into appserver with multiple options.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 | ####################################################################
# Install App.
####################################################################
# Patrick Finnegan 15/02/2005. V1.
####################################################################
######################################
# Proc - check number of arguments
######################################
proc check_args {argc} {
if { $argc < 0 } {
error "\nArgument Count is Zero. No arguments supplied.\n"
} else {
puts "\nargument count = $argc\n"
}
}
######################################
# Proc - check if dir path exists. If not create the directory.
######################################
proc check_file { file_name } {
if { [ file exists $file_name ] == 1} {
puts "File location confirmed for: $file_name"
} else {
set errMsg "$file_name does not exist. Create $file_name before running this scipt"
return -code error \n$errMsg\n
}
}
########################################################
# Proc - get user roles from input file and process into list
# - note that there can be several users to a role so "list user"
########################################################
proc get_userroles {userrolesFileid node cell } {
puts "executing get_userroles"
global list_userroleslist
puts "User roles are ...................."
puts ""
while { [ gets $userrolesFileid line ] >=0 } {
puts "role mapping is: $line"
lappend roleslist $line
}
set list_userroleslist [list $roleslist]
}
########################################################
# Proc - get group roles from input file and process into list
# - note that there can be several groups to a role so we map multiple groups
# to the same role. This requires an embedded loop.
########################################################
proc get_grouproles {grouprolesFileid} {
puts "executing get_grouproles"
puts "Group roles are ....................\n"
gets $grouprolesFileid line
while { ![ eof $grouprolesFileid ] } {
set x [ lindex $line 0 ]
set appRole $x
while { $appRole == $x && \
![ eof $grouprolesFileid ]
} {
set ldapRole [ lindex $line 1 ]
puts [ format "%-5s %-20s" " " "###########################" ]
puts [ format "%-5s %-20s %-20s " " " "Application Role" $appRole ]
puts [ format "%-5s %-20s %-20s " " " "Ldap Role" $ldapRole ]
append groups $ldapRole|
gets $grouprolesFileid line
set x [ lindex $line 0 ]
}
lappend groupRoleList [ list $appRole no no "" $groups]
unset groups
}
close $grouprolesFileid
return $groupRoleList
}
########################################################
# Proc - get virtual host mappings
# - note vhosts can be spread across nodes
########################################################
proc get_vhosts {vhostsFileid} {
puts "\nexecuting get_vhosts\n"
while { [ gets $vhostsFileid line ] != -1 } {
set name [ lindex $line 0 ]
set module [ lindex $line 1 ]
set vhost [ lindex $line 2 ]
puts [ format "%-5s %-20s" " " "###########################" ]
puts [ format "%-5s %-20s %-20s " " " "Module Name" $name ]
puts [ format "%-5s %-20s %-20s " " " "Module" $module ]
puts [ format "%-5s %-20s %-20s " " " "Virtual Host" $vhost ]
lappend vhostList [ list $name $module $vhost ]
}
close $vhostsFileid
return $vhostList
}
########################################################
# Proc - get appserver mappings
# - note webmodules can be spread across appservers
########################################################
proc get_servers {serverFileid cellName nodeName } {
puts "\nexecuting get_servers\n"
while { [ gets $serverFileid line ] != -1 } {
set name [ lindex $line 0 ]
set module [ lindex $line 1 ]
set server [ lindex $line 2 ]
set serverName WebSphere:cell=$cellName,node=$nodeName,server=$server
puts [ format "%-5s %-20s %-20s " " " "Module Name" $name ]
puts [ format "%-5s %-20s %-20s " " " "Module" $module ]
puts [ format "%-5s %-20s %-20s " " " "Server" $server ]
puts [ format "%-5s %-20s" " " "###########################" ]
lappend serverList [ list $name $module $serverName ]
}
close $serverFileid
return $serverList
}
########################################################
# Proc - get ejb jndi names
########################################################
proc get_ejbs {ejbFileid} {
puts "\nexecuting get_ejbs\n"
while { [ gets $ejbFileid line ] != -1 } {
set name [ lindex $line 0 ]
set module [ lindex $line 1 ]
set ejb [ lindex $line 2 ]
puts [ format "%-5s %-20s %-20s %-20s" " " $name $module $ejb ]
lappend ejbList [ list $name $module $ejb ]
}
close $ejbFileid
return $ejbList
}
######################################################
# Proc - install enterprise app.
######################################################
proc installEnterpriseApp { nodeName earFile appName serverName vhostList groupRoleList serverList } {
global AdminApp
puts "\ninstallEnterpriseApp\n"
puts "########################################"
puts "Creating $appName Enterprise Application"
puts "########################################"
set optionList [ list -appname $appName \
-node $nodeName \
-server $serverName \
-MapWebModToVH $vhostList \
-MapRolesToUsers $groupRoleList \
-MapModulesToServers $serverList ]
if { [ catch { $AdminApp install $earFile $optionList } result_var] == 0 } {
puts $result_var
puts "\n$appName deployed sucessfully\n"
} else {
puts \n$result_var\n
puts "########################################"
puts "$appName failed to deploy"
puts "########################################"
return -code error $result_var
}
}
######################################################
# Proc - modify enterprise app.
######################################################
proc modifyEnterpriseApp { appName sessionTimeout } {
global AdminConfig
puts "\nmodifyEnterpriseApp"
puts "_____________________\n"
puts "########################################"
puts "Modify $appName Enterprise Application"
puts "########################################"
set appId [ $AdminConfig getid /Deployment:$appName ]
# get deployed object characteristics.
set depObject [ $AdminConfig showAttribute $appId deployedObject ]
# get current policies.
set warClassLoader [ $AdminConfig showAttribute $depObject warClassLoaderPolicy ]
set reloadEnabled [ $AdminConfig showAttribute $depObject reloadEnabled ]
set reloadInterval [ $AdminConfig showAttribute $depObject reloadInterval ]
puts "\n#######################################################"
puts "Current WAR Class Loader Policy is $warClassLoader"
puts "Current WAR Reload Enabled Policy is $reloadEnabled"
puts "Current WAR Reload Interval Policy is $reloadInterval"
puts "#########################################################\n"
set newWarClassLoaderPolicy [ list warClassLoaderPolicy SINGLE ]
set reloadEnabled [ list reloadEnabled true ]
set reloadInterval [ list reloadInterval 3 ]
set attributes [ list $newWarClassLoaderPolicy \
$reloadEnabled \
$reloadInterval \
]
if { [ catch { $AdminConfig modify $depObject $attributes } result_var] == 0 } {
set warClassLoader [ $AdminConfig showAttribute $depObject warClassLoaderPolicy ]
set reloadEnabled [ $AdminConfig showAttribute $depObject reloadEnabled ]
set reloadInterval [ $AdminConfig showAttribute $depObject reloadInterval ]
puts "#######################################################"
puts "New WAR Class Loader Policy is $warClassLoader"
puts "New WAR Reload Enabled Policy is $reloadEnabled"
puts "New WAR Reload Interval Policy is $reloadInterval"
puts "#########################################################\n"
} else {
puts \n$result_var\n
puts "########################################"
puts "$appName - Modification failed"
puts "########################################"
return -code error
}
# set session manager parameters
set newAllowSerializedSessionAccess [ list allowSerializedSessionAccess false]
set newAccessSessionOnTimeOut [ list accessSessionOnTimeout true ]
set newMaxWaitTime [ list maxWaitTime 90 ]
# set Tuning Parms
set allowOverflow [ list allowOverflow false ]
set invalidationTimeout [ list invalidationTimeout $sessionTimeout ]
set maxInMemorySessionCount [ list maxInMemorySessionCount 1000 ]
set tuningParamsList [ list $allowOverflow \
$invalidationTimeout \
$maxInMemorySessionCount \
]
set tuningParams [ list tuningParams $tuningParamsList ]
set sessionManagerAttr [ list $newAllowSerializedSessionAccess \
$newAccessSessionOnTimeOut \
$newMaxWaitTime \
$tuningParams \
]
set newSessionManagement [ list [ list sessionManagement $sessionManagerAttr ] ]
if { [ catch { $AdminConfig create ApplicationConfig $depObject $newSessionManagement } result_var] == 0 } {
puts "\nNew Session Manager Attributes for $appName are:\n"
foreach i $sessionManagerAttr {
foreach { a b } $i {
puts "$a $b"
}
}
puts "\n$appName modified sucessfully\n"
$AdminConfig save
} else {
puts \n$result_var\n
puts "########################################"
puts "$appName - Modification failed"
puts "########################################"
return -code error
}
}
######################################################
# Proc - display attributes.
######################################################
proc displayAttributes { appName } {
global AdminApp
puts "displayAttributes"
puts "_____________________"
set taskList [ $AdminApp view $appName {-tasknames} ]
foreach x $taskList {
puts [ format "%-15s %-s " " " "################################" ]
puts [ format "%-15s %-s " " " "Attributes - $x" ]
puts [ format "%-15s %-s " " " "################################" ]
puts [ $AdminApp view $appName -$x ]
}
}
######################################################
# Proc - nodeSync.
######################################################
proc nodeSync { nodeName } {
global AdminControl
puts "\nnodeSync"
puts "________\n"
puts "########################################"
puts "Sync server application details with node."
puts "########################################"
set nodeSync [ $AdminControl queryNames type=NodeSync,node=$nodeName,* ]
# if the node sync object is null then this is a WAS 5 base instalation.
if { $nodeSync != {} } {
puts "\n set enabled flag"
set enabledFlag [ $AdminControl getAttribute $nodeSync serverStartupSyncEnabled ]
if { [ string compare $enabledFlag false ] == 0 } {
puts "\n Syncing node with DM"
puts "______________________\n"
if { [ catch { $AdminControl invoke $nodeSync sync } r ] == 0 } {
puts "########################################"
puts "$nodeName synced sucessfully"
puts "########################################"
} else {
puts \n$r\n
puts "########################################"
puts "$nodeName failed to sync"
puts "########################################"
}
}
}
}
######################################
# Control block"
######################################
if { [ catch { check_args $argc } r ] != 0 } {
return -code error $r
}
set earFile [ lindex $argv 0 ]
set appName [ lindex $argv 1 ]
set serverName [ lindex $argv 2 ]
set userrolesFile [ lindex $argv 3 ]
set vhostsFile [ lindex $argv 4 ]
set serverFile [ lindex $argv 5 ]
set grouprolesFile [ lindex $argv 6 ]
set ejbFile [ lindex $argv 7 ]
set sessionTimeout [ lindex $argv 8 ]
# Assume one cell, one deployment manager node and one application node.
set cellId [ lindex [ $AdminConfig list Cell ] 0 ]
set nodes [ $AdminConfig list Node ]
# delete the manager node from the list.
set manIndex [ lsearch -glob $nodes *Manager* ]
set nodeId [ lindex [ lreplace $nodes $manIndex $manIndex ] 0 ]
# get name attribute for cell and application node
set cellName [ $AdminConfig showAttribute $cellId name ]
set nodeName [ $AdminConfig showAttribute $nodeId name ]
set formatSpec "%-20s %-1s %-1s %s"
puts [ format $formatSpec "Cell Name" " " "=" $cellId ]
puts [ format $formatSpec "Node Name" " " "=" $nodeId ]
puts [ format $formatSpec "Server Name" " " "=" $serverName ]
puts [ format $formatSpec "Application" " " "=" $appName ]
puts [ format $formatSpec "User Mapping File" " " "=" $userrolesFile ]
puts [ format $formatSpec "Ear Mapping File" " " "=" $earFile ]
puts [ format $formatSpec "Vhosts Mapping File" " " "=" $vhostsFile ]
puts [ format $formatSpec "Server Mapping File" " " "=" $serverFile ]
puts [ format $formatSpec "Group Mapping File" " " "=" $grouprolesFile ]
puts [ format $formatSpec "Ejb Mapping File" " " "=" $ejbFile ]
puts [ format $formatSpec "Session Timeout" " " "=" $sessionTimeout ]
puts ""
check_file $earFile
check_file $userrolesFile
check_file $grouprolesFile
check_file $vhostsFile
check_file $serverFile
check_file $ejbFile
puts ""
set userrolesFile_id [open $userrolesFile r ]
set grouprolesFile_id [open $grouprolesFile r ]
set vhostsFileid [open $vhostsFile r ]
set serverFileid [open $serverFile r ]
set ejbFileid [open $ejbFile r ]
if { [ catch { get_vhosts $vhostsFileid } r ] != 0 } {
return -code error \n$r\n
exit 1
} else {
set vhostList $r
}
if { [ catch { get_servers $serverFileid $cellName $nodeName } r ] != 0 } {
return -code error \n$r\n
exit 1
} else {
set serverList $r
}
if { [ catch { get_grouproles $grouprolesFile_id } r ] != 0 } {
return -code error \n$r\n
exit 1
} else {
set groupRoleList $r
}
######################################
# Install Application.
######################################
if { [ catch { installEnterpriseApp $nodeName \
$earFile \
$appName \
$serverName \
$vhostList \
$groupRoleList \
$serverList } r ] != 0 } {
return -code error \n$r\n
exit 1
} else {
$AdminConfig save
}
######################################
# Modify Application Attributes.
######################################
if { [ catch { modifyEnterpriseApp $appName $sessionTimeout } r ] != 0 } {
return -code error \n$r\n
exit 1
} else {
$AdminConfig save
}
######################################
# Display Application Attributes.
######################################
if { [ catch { displayAttributes $appName } r ] != 0 } {
return -code error \n$r\n
exit 1
}
######################################
# Sync Node if ND installation.
######################################
if { [ catch { nodeSync $nodeName } r ] != 0 } {
return -code error \n$r\n
exit 1
}
######################################
# END
######################################
|
The script takes a number of parameters specifying deployment options and mapping files. The mapping files specify one to one relationships for that particular mapping.
For example the group role mapping file would look like:
AppRole1 LdapRole1 AppRole2 LdapRole2 AppRole3 LdapRole3 .........
The server role mapping file would look like:
"YourApp" YourApp.war,WEB-INF/web.xml YourAppServer ........
The virtual host mapping file would look like:
YourAppl YourApp.war,WEB-INF/web.xml YourVirtualHost
Calling script.
@echo off
setlocal
set subject="%computername% - Create YourApp Report" set reportfile=D:\reports\websphere\createYourApp.txt
set earFile=D:\enterprise_apps\YourApp.ear set appName=YourApp set serverName=YourApp set userrolesFile=D:\WEBSPHERE_MAPPINGS\YourApp\websphere_userrole_mapping.txt set vhostsfile=D:\WEBSPHERE_MAPPINGS\YourApp\websphere_vhost_mapping.txt set serverfile=D:\WEBSPHERE_MAPPINGS\YourApp\websphere_server_mappings.txt set grouprolesFile=D:\WEBSPHERE_MAPPINGS\YourApp\websphere_grouprole_mapping.txt set ejbfile=D:\WEBSPHERE_MAPPINGS\YourApp\websphere_ejbmappings.txt set sessionTimeout=30
echo ################################################### echo # Install %appName% on %COMPUTERNAME% echo ###################################################
command.com /c
call D:\IBM\WebSphere\DeploymentManager\bin\wsadmin -username wsadminlogon^ -password wsadminlogon^ -f d:\scripts\websphere\JACL\installApp.tcl %earFile% %appName% %serverName% %userrolesFile% %vhostsfile% %serverfile% %grouprolesFile% %ejbfile% %sessionTimeout% 2>The script takes a number of parameters specifying deployment options and mapping files. The mapping files specify one to one relationships for that particular mapping.
For example the group role mapping file would look like:
AppRole1 LdapRole1 AppRole2 LdapRole2 AppRole3 LdapRole3 .........
The server role mapping file would look like:
"YourApp" YourApp.war,WEB-INF/web.xml YourAppServer ........
The virtual host mapping file would look like:
YourAppl YourApp.war,WEB-INF/web.xml YourVirtualHost
Calling script.
@echo off
setlocal
set subject="%computername% - Create YourApp Report" set reportfile=D:\reports\websphere\createYourApp.txt
set earFile=D:\enterprise_apps\YourApp.ear set appName=YourApp set serverName=YourApp set userrolesFile=D:\WEBSPHERE_MAPPINGS\YourApp\websphere_userrole_mapping.txt set vhostsfile=D:\WEBSPHERE_MAPPINGS\YourApp\websphere_vhost_mapping.txt set serverfile=D:\WEBSPHERE_MAPPINGS\YourApp\websphere_server_mappings.txt set grouprolesFile=D:\WEBSPHERE_MAPPINGS\YourApp\websphere_grouprole_mapping.txt set ejbfile=D:\WEBSPHERE_MAPPINGS\YourApp\websphere_ejbmappings.txt set sessionTimeout=30
echo ################################################### echo # Install %appName% on %COMPUTERNAME% echo ###################################################
command.com /c
call D:\IBM\WebSphere\DeploymentManager\bin\wsadmin -username wsadminlogon^ -password wsadminlogon^ -f d:\scripts\websphere\JACL\installApp.tcl %earFile% %appName% %serverName% %userrolesFile% %vhostsfile% %serverfile% %grouprolesFile% %ejbfile% %sessionTimeout% 2>