Question : How do you set the scope of a datasource in a jython script?

We have a generic jython script (WAS 7)  that we use to create datasources.  It creates them scoped at the cell level and we would like to start creating Datasources scoped at the cluster level.  I need help understanding where that would happen in the attached script...  Is it as simple as an additional attribute, or is there more to it than that?
 
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:
#"WAS 6.1 Script Generator,  2.15"
#<2.1>

xa = "DB2 Universal JDBC Driver Provider"
node = AdminControl.getNode()
cell = AdminControl.getCell()
newjdbc = AdminConfig.getid('/Cell:' + cell + '/JDBCProvider:' + "DB2 Universal JDBC Driver Provider" +'/')


#print newjdbc
jdbcProviderDb2 = AdminConfig.getid('/JDBCProvider:DB2 Universal JDBC Driver Provider/')
jdbcProviderDb2XA = AdminConfig.getid('/JDBCProvider:DB2 Universal JDBC Driver Provider (XA)/')

if xa == "DB2 Universal JDBC Driver Provider":
	dataSourceType = "DB2 Universal JDBC Driver DataSource"
else: 
	dataSourceType = "DB2 Universal JDBC Driver XA DataSource"

if (len(sys.argv) == 4):
	UserID = sys.argv[0]
	dbname = sys.argv[1]
	DB_ServerName = sys.argv[2]
	PortNumber = sys.argv[3]
	print "  Using Parameters supplied" 
	
	
else:
	print " "
	print "   Using defaults. To customize this script pass in parameters in this order UserID    DatabaseName    DatabaseServerName   PortNumber"
	print " "
	UserID = "myAppUserID"
	dbname = "appsDatabase"
	DB_ServerName = "db_server"
	PortNumber = "50000"
	
sqlString = "select 1 from sysibm.sysdummy1"

authDataAlias = node +"/"+ UserID
userAttr = ['authDataAlias', 'authDataAlias']
attrs = []
attrs.append(["name", "myDS"])
attrs.append(["description", "WAS 6.1 Script Generator,  2.15"])
attrs.append(["jndiName", "jdbc/myDS"])
attrs.append(["statementCacheSize", "30"])
attrs.append(["authMechanismPreference", "BASIC_PASSWORD"])
attrs.append(["authDataAlias", authDataAlias])


template = AdminConfig.listTemplates("DataSource", dataSourceType )
        
dataSource = AdminConfig.createUsingTemplate("DataSource", newjdbc, attrs, template )


AdminConfig.save()

#--------------------------------------------------------------
# Clean up unused properties of the DataSource.
#--------------------------------------------------------------
psAttr = ["propertySet", []]
attrs = []
attrs.append(psAttr)
AdminConfig.modify(dataSource, attrs)
 
#--------------------------------------------------------------
# Add desired custom properties to the DataSource.
#--------------------------------------------------------------
 
dbnameAttr = [["name", "databaseName"], ["value", dbname], ["type", "java.lang.String"]]
svrnameAttr = [["name", "serverName"], ["value", DB_ServerName], ["type", "java.lang.String"]] 
portAttr = [["name", "portNumber"], ["value", PortNumber], ["type", "java.lang.String"]]
drivertypeAttr = [["name", "driverType"], ["value", "4"], ["type", "java.lang.Integer"]]
pretestsqlAttr = [["name", "preTestSQLString"], ["value", sqlString], ["type", "java.lang.String"]]

newsprops = []
newsprops.append(dbnameAttr)
newsprops.append(svrnameAttr)
newsprops.append(portAttr)
newsprops.append(drivertypeAttr)
newsprops.append(pretestsqlAttr)

psAttr = ["propertySet", [["resourceProperties", newsprops]]]
attrs = [psAttr]
AdminConfig.modify(dataSource, attrs)
# print AdminConfig.showall(dataSource)

#--------------------------------------------------------------
# Save the new datasource
#-------------------------------------------------------------- 

print "Success! DataSource Created! Saving the configuration"
AdminConfig.save( )

Answer : How do you set the scope of a datasource in a jython script?

In line 51, the 2nd parameter (i.e., "newjdbc" - which, by the way, really isn't accurately named), identifies the "parent" JDBC provider.

If you look at the output of this command, it identifies the possible scopes for which a JDBCProvider may be defined:


So, when a JDBCProvider is created, the "parent" of the JDBCProvider to be created identifies the associated scope.

Does this help?
1:
2:
3:
4:
5:
6:
wsadmin>print AdminConfig.parents( 'JDBCProvider' )
Cell
Deployment
Node
Server
ServerCluster
Random Solutions  
 
programming4us programming4us