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

Extract DataSource properties on WebSphere 5 server instance.

Windows platform.

Script called from top level Windows cmd file.

call wsadmin -f C:\scripts\websphere\JACL\extractDataSource.tcl

Tcl, 170 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
# 
# Extract DataSource Properties 
#


####################################################################
# List installed DataSources. 
####################################################################
proc showList { a } {

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

    return $returnList   
}
####################################################################
# List JAAS authentication entries. 
####################################################################
proc listJAAS { a } {

   global AdminConfig 

   foreach e $a {

      set subList [ $AdminConfig show $e ]

      foreach e $subList {
         puts [ format "%-5s %-30s %-20s" " " [ lindex $e 0 ] [ lindex $e 1 ] ]
      }

      puts "\n" 
   }

}

####################################################################
# Show properties of Installed DataSources.
####################################################################
proc showProperties {dataSourceId} {

   set dataSource [ string range $dataSourceId 0 [ expr [string first "(cells" $dataSourceId] -1 ] ]

   puts "\n *** - showProperties - dataSource is $dataSource - *** \n" 

   global AdminConfig 

   puts [ format "\n%-5s %-30s" " " "Display General Properties\n"]

   lappend propList authDataAlias 
   lappend propList authMechanismPreference 
   lappend propList description
   lappend propList name
   lappend propList jndiName
   lappend propList provider
   lappend propList relationalResourceAdapter
   lappend propList statementCacheSize
   lappend propList datasourceHelperClassname

   foreach e $propList {
        set attrValue [ $AdminConfig showAttribute $dataSourceId $e ]

	if { $e == "provider" || $e == "relationalResourceAdapter" } {
	    regexp {(.*)(\(cells.*)} $attrValue 1 2 3
	    set attrValue $2
        }
	puts [ format "%-5s %-30s %-20s" " " $e $attrValue ]
   }

#  Extract mapping properties from mapping list 
#  may not exist for all datasource types.
#  wsadmin returns variables even when they do not exist so cannot use info exist.

   puts [ format "\n%-5s %-30s" " " "Display mapping properties\n"]
   
   set mappingId [$AdminConfig show $dataSourceId mapping]

   if {[string length $mappingId] != 0 } {

       set mappingId [lindex [split [$AdminConfig show $dataSourceId mapping]] 1]

       regsub -all "\}" $mappingId "" mappingId
       
       foreach e [$AdminConfig showall $mappingId] {
	  puts [ format "%-5s %-30s %-20s" " " [lindex $e 0] [lindex $e 1] ]
       }
   }

#  Extract propertySet properties from propertySet list 

   set propertySetId [lindex [split [$AdminConfig show $dataSourceId propertySet]] 1]

   puts [ format "\n%-5s %-30s" " " "Display Custom Properties\n"]

   regsub -all "\}" $propertySetId "" propertySetId
   
   set propertySetList [ $AdminConfig showall $propertySetId ] 

   set i 0
   
   while { $i <= 7 } {

      set sublist [ lindex [ lindex [ lindex $propertySetList 0 ] 1 ] $i ]

      foreach e $sublist {
 
	 if {[lindex $e 0] == "description"} {
	     set continue true
         } else {
                 puts [ format "%-5s %-30s %-20s" " " [ lindex $e 0]  [ lindex $e 1 ] ]
         }
      }

      incr i
      puts \n 
   }
	
#  Extract connectionPool properties from connectionPool list 

   puts [ format "\n%-5s %-30s" " " "Display Connection Pool properties\n"]

   set connectionPoolId [lindex [split [$AdminConfig show $dataSourceId connectionPool]] 1]
   regsub -all "\}" $connectionPoolId "" connectionPoolId
   
   foreach e [$AdminConfig showall $connectionPoolId] {
      puts [ format "%-5s %-30s %-20s" " " [lindex $e 0] [lindex $e 1] ]
   }

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

####################################################################
# List Installed DataSources.
####################################################################
set datasources [ $AdminConfig list DataSource ]

puts "\nList installed DataSources\n"

catch { showList $datasources } r

####################################################################
# List JAASAuthData authentication entries.
####################################################################

set JAASentries [ $AdminConfig list JAASAuthData ] 

puts "\nList installed JAASAuthData authentication entries\n"

listJAAS $JAASentries

####################################################################
# Show properties for each datasource.
####################################################################

foreach e $datasources {

   showProperties $e 

}

####################################################################
# The end.
####################################################################

puts [ format "\n %-30s %-30s" " " "*** THE END ***\n" ]

Extract datasource properties into a flat file for backup or use as template for installation of new dataSource.

Created by Patrick Finnegan on Wed, 17 Dec 2003 (MIT)
Tcl recipes (162)
Patrick Finnegan's recipes (56)

Required Modules

  • (none specified)

Other Information and Tasks