Welcome, guest | Sign In | My Account | Store | Cart

Installs application server with multiple custom options.

Tcl, 601 lines
  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
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
# 
# Install Application Server.
#
####################################################################
# Patrick Finnegan 19/10/2005.  V1. 
####################################################################

####################################################################
# List installed application servers.
####################################################################
proc showList { a } {

    puts "\nList installed servers"
    puts "**********************\n"

    foreach e $a {
	regexp {(.*)(\(cells.*)} $e 1 2 3
	puts [ format "%-5s %-50s"  " "  $2 ]
	lappend returnList                 $2
    }

    puts "\n**********************\n"

    return $returnList   
}
####################################################################
# Install Server then create properties for server.
####################################################################
proc installServer { serverName nodeId nonsslPort sslPort rmiPort sessionTimeout tranTimeout } {

   global AdminConfig 

   set nameList [ list name $serverName ]
   set attrList [ list $nameList        ] 

   if { [ catch {$AdminConfig create Server $nodeId $attrList} r ] == 0 } {
        puts "************************************"
        puts "$serverName server created successfully."
        puts "************************************\n"
   } else {
           puts "\nfailed to create $serverName server\n"
           puts $r 
           puts "************************************\n"
	   return -code error $r
   }

   set serverId [ $AdminConfig getid /Server:$serverName/ ]

   regexp {(.*)(\(cells.*)} $serverId 1 2 3
   set serverName $2

#  set Transaction Service Properties. 

   if { [ catch { setTransProps $serverId $serverName $tranTimeout } r ] != 0 } {
	   return -code error $r
   }

#  set Web Container Properties. 

   if { [ catch { setWebProps $serverId $serverName $nonsslPort $sslPort $sessionTimeout } r ] != 0 } { 
	   return -code error $r
   }

#  set Log File Properties. 

   if { [ catch { setLogProps $serverId $serverName } r ] != 0 } {
	   return -code error $r
   }

#  set JVM Properties. 

   if { [ catch { setJVMProps $serverId $serverName } r ] != 0 } {
	   return -code error $r
   }

#  set Process Definition Properties. 

   if { [ catch { setProcessDefProps $serverId $serverName } r ] != 0 } {
	   return -code error $r
   }

#  set EndPoints Properties. 

   if { [ catch { setEndPointsProps $serverId $serverName $rmiPort } r ] != 0 } {
	   puts "\nfailed - result is $r"
	   return -code error $r
   }
}
####################################################################
# Set transaction service properties.
####################################################################
proc setTransProps { serverId serverName tranTimeout } {

   global alias 
   global AdminConfig 

   # get Transaction Service id 

   set TransactionServiceId [ $AdminConfig list TransactionService $serverId ]

   set drive [lindex [file split [info script]] 0 ] 

   set clientInactivityTimeout  [ list clientInactivityTimeout  60  ]
   set totalTranLifetimeTimeout [ list totalTranLifetimeTimeout $tranTimeout ]
   set transactionLogDirectory  [ list transactionLogDirectory  " " ]

   set attrList  [ list $clientInactivityTimeout  \
                        $totalTranLifetimeTimeout \
                        $transactionLogDirectory  \
                 ]

   if { [ catch { $AdminConfig modify $TransactionServiceId $attrList } r ] == 0 } {
        puts "************************************"
        puts "$serverName transaction properties created successfully."
        puts "************************************\n"
   } else {
           puts "\nfailed to create transaction properties for $serverName\n"
           puts $r 
           puts "************************************\n"
	   return -code error $r
   }
}
####################################################################
# Set web container properties.
####################################################################
proc setWebProps {serverId serverName nonsslPort sslPort sessionTimeout } {

   global AdminConfig 

   # get Web Container id 

   set WebContainerId [ $AdminConfig list WebContainer $serverId ]

   set defaultVirtualHostName [ list defaultVirtualHostName intg_$serverName ] 
   set enableServletCaching   [ list enableServletCaching   true ] 

   set attrList [ list $defaultVirtualHostName \
                       $enableServletCaching   \
                ]

   if { [ catch { $AdminConfig modify $WebContainerId $attrList } r ] == 0 } {
        puts "************************************"
        puts "$serverName - WebContainer properties created successfully."
        puts "************************************\n"
   } else {
           puts "\nfailed to create WebContainer properties for $serverName\n"
           puts $r 
           puts "************************************\n"
	   return -code error $r
   }

   # get ThreadPool id 

   set threadPoolId [ lindex [ $AdminConfig list ThreadPool $WebContainerId ] 0 ]

   set inactivityTimeout  [ list inactivityTimeout 3500  ]
   set isGrowable         [ list isGrowable        true  ]
   set maximumSize        [ list maximumSize       50 ]
   set minimumSize        [ list minimumSize       10 ]

   set threadPoolList  [ list $inactivityTimeout   \
                              $isGrowable          \
                              $maximumSize         \
                              $minimumSize         \
                       ]

   if { [ catch { $AdminConfig modify $threadPoolId $threadPoolList } r ] == 0 } {
        puts "************************************"
        puts "$serverName - Threadpool properties created successfully."
        puts "************************************\n"
   } else {
           puts "\nfailed to create Threadpool properties for $serverName\n"
           puts $r 
           puts "************************************\n"
	   return -code error $r
   }

   # get Session Manager id 

   set sessionManagerId [ $AdminConfig list SessionManager $WebContainerId]

   set accessSessionOnTimeout        [ list accessSessionOnTimeout        true   ]
   set allowSerializedSessionAccess  [ list allowSerializedSessionAccess  false  ] 
   set enable                        [ list enable                        true   ]
   set enableCookies                 [ list enableCookies                 true   ]
   set enableProtocolSwitchRewriting [ list enableProtocolSwitchRewriting false  ]
   set enableSSLTracking             [ list enableSSLTracking             false  ]
   set enableSecurityIntegration     [ list enableSecurityIntegration     false  ]
   set enableUrlRewriting            [ list enableUrlRewriting            false  ]
   set maxWaitTime                   [ list maxWaitTime                   5      ]

   set sessionManagerList [ list $accessSessionOnTimeout        \
                                 $allowSerializedSessionAccess  \
                                 $enable                        \
                                 $enableCookies                 \
                                 $enableProtocolSwitchRewriting \
                                 $enableSSLTracking             \
                                 $enableSecurityIntegration     \
                                 $enableUrlRewriting            \
                                 $maxWaitTime                   \
                          ]

   if { [ catch { $AdminConfig modify $sessionManagerId $sessionManagerList } r ] == 0 } {
        puts "************************************"
        puts "$serverName - Session Manager properties created successfully."
        puts "************************************\n"
   } else {
           puts "\nfailed to create Session Manager properties for $serverName\n"
           puts $r 
           puts "************************************\n"
	   return -code error $r
   }

   # get Tuning Parms 

   set tuningParamsId [ $AdminConfig list TuningParams $WebContainerId ]

   set allowOverflow                 [ list allowOverflow           false ]
   set invalidationTimeout           [ list invalidationTimeout     $sessionTimeout ] 
   set maxInMemorySessionCount       [ list maxInMemorySessionCount 1000  ]

   set tuningParamsList [ list $allowOverflow           \
                               $invalidationTimeout     \
                               $maxInMemorySessionCount \
                       ]

   if { [ catch { $AdminConfig modify $tuningParamsId $tuningParamsList } r ] == 0 } {
        puts "************************************"
        puts "$serverName - Tuning properties created successfully."
        puts "************************************\n"
   } else {
           puts "\nfailed to create Tuning properties for $serverName\n"
           puts $r 
           puts "************************************\n"
	   return -code error $r
   }

   # get http transports id. 

   set httpTransportIdList [ $AdminConfig list HTTPTransport $WebContainerId ]

   # assume two default host entries.  
   # modify host entries with new values.

   # Transport 1.
   set transport1     [ lindex $httpTransportIdList 0 ]
   set addressId [ $AdminConfig showAttribute $transport1 address ] 
   set oldHost   [ $AdminConfig showAttribute $addressId host ]
   set oldPort   [ $AdminConfig showAttribute $addressId port ]

   puts "Old Host is $oldHost " 
   puts "Old Port is $oldPort " 

   set newHost     [ list host *           ]
   set newPort     [ list port $nonsslPort ]
   set addressList [ list $newHost $newPort  ]

   puts "New Host is $oldHost" 
   puts "New Port is $newPort" 

   if { [ catch { $AdminConfig modify $addressId $addressList } r ] == 0 } {
        puts "************************************"
        puts "$serverName - HTTP Transport properties modified successfully."
        puts "************************************\n"
   } else {
           puts "************************************"
           puts "\nfailed to create modify HTTP Transport properties for $serverName\n"
           puts $r 
           puts "************************************\n"
	   return -code error $r
   }

   # Transport2.
   set transport2 [ lindex $httpTransportIdList 1 ]
   set addressId  [ $AdminConfig showAttribute $transport2 address ] 
   set oldHost    [ $AdminConfig showAttribute $addressId host ]
   set oldPort    [ $AdminConfig showAttribute $addressId port ]

   puts "Old Host is $oldHost " 
   puts "Old Port is $oldPort " 

   set newHost     [ list host *            ]
   set newPort     [ list port $sslPort     ]
   set addressList [ list $newHost $newPort ]

   puts "New Host is $oldHost" 
   puts "New Port is $newPort" 

   if { [ catch { $AdminConfig modify $addressId $addressList } r ] == 0 } {
        puts "************************************"
        puts "$serverName - HTTP Transport properties modified successfully."
        puts "************************************\n"
   } else {
           puts "************************************"
           puts "\nfailed to create modify HTTP Transport properties for $serverName\n"
           puts $r 
           puts "************************************\n"
	   return -code error $r
   }
   
}
####################################################################
# Set logging properties.
####################################################################
proc setLogProps {serverId serverName } {

   global AdminConfig 

   # get websphere install directory from node variable map. 

   set nodeVarMapId [ $AdminConfig getid /Node:[exec hostname]/VariableMap:/ ]
   set listVar1     [ eval join  [ $AdminConfig showall $nodeVarMapId ] ]
   set x            [ lindex [ lindex $listVar1 [lsearch $listVar1 *WAS_INSTALL_ROOT*] ] 2 ]
   set WAS_INSTALL_ROOT [ lindex [ split $x ] 1 ]

   # get output log id 

   set outputLogId [ $AdminConfig showAttribute $serverId outputStreamRedirect ]

   set baseHour               [ list baseHour 24 ]
   set fileName               [ list fileName $WAS_INSTALL_ROOT\\logs\\$serverName\\$serverName\_SystemOut.log ]
   set formatWrites           [ list formatWrites           true   ]
   set maxNumberOfBackupFiles [ list maxNumberOfBackupFiles 5      ]
   set messageFormatKind      [ list messageFormatKind      BASIC  ]
   set rolloverPeriod         [ list rolloverPeriod         24     ]
   set rolloverSize           [ list rolloverSize           5      ]
   set rolloverType           [ list rolloverType           TIME   ]
   set suppressStackTrace     [ list suppressStackTrace     false  ]
   set suppressWrites         [ list suppressWrites         false  ]

   set attrList [ list $baseHour               \
                       $fileName               \
                       $formatWrites           \
                       $maxNumberOfBackupFiles \
                       $messageFormatKind      \
                       $rolloverPeriod         \
                       $rolloverSize           \
                       $rolloverType           \
                       $suppressStackTrace     \
                       $suppressWrites         \
                ]
   
   if { [ catch { $AdminConfig modify $outputLogId $attrList } r ] == 0 } {
        puts "************************************"
        puts "$serverName - Server output log properties created successfully."
        puts "************************************\n"
   } else {
           puts "\nfailed to create Server output log properties for $serverName\n"
           puts $r 
           puts "************************************\n"
	   return -code error $r
   }

   # get error log id 

   set errorLogId [ $AdminConfig showAttribute $serverId errorStreamRedirect ]

   set baseHour               [ list baseHour 24 ]
   set fileName               [ list fileName $WAS_INSTALL_ROOT\\logs\\$serverName\\$serverName\_SystemErr.log ]
   set formatWrites           [ list formatWrites           true   ]
   set maxNumberOfBackupFiles [ list maxNumberOfBackupFiles 5      ]
   set messageFormatKind      [ list messageFormatKind      BASIC  ]
   set rolloverPeriod         [ list rolloverPeriod         24     ]
   set rolloverSize           [ list rolloverSize           5      ]
   set rolloverType           [ list rolloverType           TIME   ]
   set suppressStackTrace     [ list suppressStackTrace     false  ]
   set suppressWrites         [ list suppressWrites         false  ]

   set attrList [ list $baseHour               \
                       $fileName               \
                       $formatWrites           \
                       $maxNumberOfBackupFiles \
                       $messageFormatKind      \
                       $rolloverPeriod         \
                       $rolloverSize           \
                       $rolloverType           \
                       $suppressStackTrace     \
                       $suppressWrites         \
                ]

   if { [ catch { $AdminConfig modify $errorLogId $attrList } r ] == 0 } {
        puts "************************************"
        puts "$serverName - Server error log properties created successfully."
        puts "************************************\n"
   } else {
           puts "\nfailed to create Server error log properties for $serverName\n"
           puts $r 
           puts "************************************\n"
	   return -code error $r
   }

}
####################################################################
# Set JVM Properties.
####################################################################
proc setJVMProps {serverId serverName } {

   global AdminConfig 

   # get JVM id 

   set jvmId [ $AdminConfig list JavaVirtualMachine $serverId ]


   set initialHeapSize        [ list initialHeapSize 128 ]
   set maximumHeapSize        [ list maximumHeapSize 256 ]

   # set custom properties.
   ## ws.ext.dirs
  
   set name                   [ list name        ws.ext.dirs                  ]
   set value                  [ list value       {d:\HBFWeb\properties}  ]
   set description            [ list description {Application Property Files} ]

   set wsExtDirs              [ list $name $value $description ]

   set systemPropertiesList   [ list systemProperties [ list $wsExtDirs]]

   set attrList [ list $initialHeapSize        \
                       $maximumHeapSize        \
                       $systemPropertiesList   \
                ]

   if { [ catch { $AdminConfig modify $jvmId $attrList } r ] == 0 } {
        puts "************************************"
        puts "$serverName - JVM properties created successfully."
        puts "************************************\n"
   } else {
           puts "\nfailed to create Server JVM properties for $serverName\n"
           puts "************************************\n"
	   return -code error $r
   }

}
####################################################################
# Set Process Definition Properties.
####################################################################
proc setProcessDefProps {serverId serverName } {

   global AdminConfig 

   set processDefId [ $AdminConfig showAttribute $serverId processDefinition ]

   set monPolicyId  [$AdminConfig showAttribute $processDefId monitoringPolicy ]

   set monPolicy    [ list nodeRestartState PREVIOUS ] 

   set attrList     [ list $monPolicy ]

   if { [ catch { $AdminConfig modify $monPolicyId $attrList } r ] == 0 } {
        puts "************************************"
        puts "$serverName - Process Definition properties created successfully."
        puts "************************************\n"
   } else {
           puts "\nfailed to create Process Definition properties for $serverName\n"
           puts "************************************\n"
	   return -code error $r
   }

}
####################################################################
# Set Endpoints - RMI. 
####################################################################
proc setEndPointsProps {serverId serverName rmiPort } {

   global AdminConfig 

   set endPointsId      [ $AdminConfig getid /ServerEntry:$serverName/ ]

   set specialEndPoints [ $AdminConfig showAttribute $endPointsId specialEndpoints ]

   # specialEndPoints is a one element list containing an embedded list. 
  
   set listlength [ llength [ lindex $specialEndPoints 0 ] ]

   set listElements [ expr { $listlength - 1 } ] 

   # iterate through the sublist and find the bootstrap address.

   set i 0

   while { $i <= $listElements } {

       set endPoint [ lindex [ lindex $specialEndPoints 0 ] $i ]

       set endPointName [ $AdminConfig showAttribute $endPoint endPointName ] 

       if { $endPointName == "BOOTSTRAP_ADDRESS" } {

          set endPointId [ $AdminConfig showAttribute $endPoint endPoint ] 
          set port       [ $AdminConfig showAttribute $endPointId port ]

	  puts "End Point Name = $endPointName"
	  puts "Old port       = $port"

	  set newPort  [ list port $rmiPort ] 
	  set attrList [ list $newPort ] 

	  if { [ catch { $AdminConfig modify $endPointId $attrList } r ] == 0 } {

	       puts "************************************"
	       puts "End Point Name = $endPointName"
	       puts "New port       = $rmiPort"
	       puts "$serverName - End Points modified successfully."
	       puts "************************************\n"

	  } else {
	          puts "************************************"
	          puts "\nfailed to modify End Points for $serverName\n"
	          puts "************************************\n"
	          return -code error $r
	  }

       }

       incr i

    }

}
####################################################################
# Main Control.
####################################################################

puts "\n argc = $argc \n"

if {$argc < 1} {
        return -code error "error - no arguments supplied.  Supply server name"
        puts "no arguments"
}

# 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 serverName     [ lindex $argv 0 ]
set nonsslPort     [ lindex $argv 1 ]
set sslPort        [ lindex $argv 2 ]
set rmiPort        [ lindex $argv 3 ]
set sessionTimeout [ lindex $argv 4 ]
set tranTimeout    [ lindex $argv 5 ]

puts "server name    = $serverName"
puts "nonsslPort     = $nonsslPort"  
puts "sslPort        = $sslPort"  
puts "rmiPort        = $rmiPort"   
puts "sessionTimeout = $sessionTimeout"   
puts "tranTimeout    = $tranTimeout"   

#######################################################################
# List servers and check if target server already exists.
# If so delete it and recreate
#######################################################################

set servers [ $AdminConfig list Server ]

catch { showList $servers } r

catch {lsearch $r $serverName } r 

if { $r == -1 } {
    set continue true 
} else { 
        set serverId [ $AdminConfig getid /Server:$serverName/ ]
        catch { $AdminConfig remove $serverId } r
	puts $r
}
####################################################################
# Install Server 
####################################################################

if { [ catch { installServer $serverName $nodeId $nonsslPort $sslPort $rmiPort $sessionTimeout $tranTimeout } r ] == 0 } {
    puts "************************************"
    puts "$serverName installed successfully"
    puts "************************************\n"
    puts "\n###### Admin Config Save ######\n"
    $AdminConfig save
} else {
        puts "\n$serverName failed to install\n"
        puts $r 
        puts "************************************\n"
}

####################################################################
# List servers to verify install 
####################################################################

set servers [ $AdminConfig list Server ]

catch { showList $servers } r
Created by Patrick Finnegan on Tue, 18 Oct 2005 (MIT)
Tcl recipes (162)
Patrick Finnegan's recipes (56)

Required Modules

  • (none specified)

Other Information and Tasks