BDD Scenarios: Automating Application Deployment

Scenario 2: Using Default Gateway Values to Query a Database

Published: March 8, 2005

Again, it may not be desirable to maintain lists of packages for each default gateway (or site) in the CustomSettings.ini file directly. It would be better to use a database table. The following table can be created in the BDDAdminDB database to hold the location-specific package list.

use [BDDAdminDB]
go

if exists  (select * from dbo.sysobjects where id = 
 object_id(N'[dbo].[LocationPackages]') 
 and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[LocationPackages]
go

CREATE TABLE [dbo].[LocationPackages] (
	[DefaultGateway] [nvarchar] (50),
	[Packages] [nvarchar] (50)
)
go

Now, you can populate that table with rows for each location.

use [BDDAdminDB]
go

insert into LocationPackages 
 (DefaultGateway, Packages) values('11.1.1.11', 'XXX00004-Program name 4')
go 
insert into LocationPackages 
 (DefaultGateway, Packages) values('11.1.1.11', 'XXX00005-Program name 5')
go
insert into LocationPackages 
 (DefaultGateway, Packages) values('172.28.20.1', 'XXX00004-Program name 4')
go 
insert into LocationPackages 
 (DefaultGateway, Packages) values('172.28.20.1', 'XXX00005-Program name 5')
go
insert into LocationPackages 
 (DefaultGateway, Packages) values('192.168.0.1', 'XXX00006-Program name 6')
go
insert into LocationPackages 
 (DefaultGateway, Packages) values('192.168.0.1', 'XXX00007-Program name 7')
go
insert into LocationPackages 
 (DefaultGateway, Packages) values('192.168.0.1', 'XXX00008-Program name 8')
go

Now, the CustomSettings.ini file must be configured to query this database table by specifying the name of a section (in the "Priority" list) that points to the database information.

[Settings]
…
Priority=MacAddress, DefaultGateway, LocationQuery, Default
CustomKeysUserData=UDShare, UDDir, UDProfiles, SLShare, OSInstall, 
Packages(*), Administrators(*), PowerUsers(*), DriverPath(*)
…

This new LocationQuery section must then specify the name of a database section.

[LocationQuery]
SQLDefault= DB_LocationQuery

Then that section specifies the database connection information and query details.

[DB_LocationQuery]
SQLServer=SERVER1
Database=BDDAdminDB
Table=LocationPackages
Parameters=DefaultGateway
SQLShare=Logs

In this case, the BDDAdminDB database on the computer running SQL Server named SERVER1 will be queried. This database contains a table named LocationPackages (created above) and the default gateway values will be used to automatically create a query.

SELECT * FROM LocationPackages WHERE DefaultGateway = ?

The actual default gateway will be substituted for the "?" above. (If there are multiple default gateways, an "IN" clause will be built instead.) This query would return a recordset with zero or more rows; each row returned specifies one package to be added to the list of packages to be installed during the state restore phase.


Top of pageTop of pagePrevious10 of 20Next
**
In This Article
**