an improved approach to generating configuration files from a database jon finke rensselaer...
TRANSCRIPT
![Page 1: An Improved Approach to Generating Configuration Files from a Database Jon Finke Rensselaer Polytechnic Institute](https://reader035.vdocuments.us/reader035/viewer/2022062321/56649e4e5503460f94b450a9/html5/thumbnails/1.jpg)
An Improved Approach to Generating Configuration Files from
a DatabaseJon Finke
Rensselaer Polytechnic Institute
![Page 2: An Improved Approach to Generating Configuration Files from a Database Jon Finke Rensselaer Polytechnic Institute](https://reader035.vdocuments.us/reader035/viewer/2022062321/56649e4e5503460f94b450a9/html5/thumbnails/2.jpg)
Conclusions
• Cuts development time– Standard development environment– Host interface written once– Code sharing with web routines– All work done centrally– PL/SQL well integrated to Database
• Platform independence
![Page 3: An Improved Approach to Generating Configuration Files from a Database Jon Finke Rensselaer Polytechnic Institute](https://reader035.vdocuments.us/reader035/viewer/2022062321/56649e4e5503460f94b450a9/html5/thumbnails/3.jpg)
The Old Way
• Custom program for each file type.– Common file system– Small number of platforms– Standard development environment– Lots of cut and paste C coding– Direct access to tables and views
![Page 4: An Improved Approach to Generating Configuration Files from a Database Jon Finke Rensselaer Polytechnic Institute](https://reader035.vdocuments.us/reader035/viewer/2022062321/56649e4e5503460f94b450a9/html5/thumbnails/4.jpg)
Old Model
Relational Database
SQL*NET
File Format Logic
Version Control
SQL*NET
File Format Logic
Version Control
![Page 5: An Improved Approach to Generating Configuration Files from a Database Jon Finke Rensselaer Polytechnic Institute](https://reader035.vdocuments.us/reader035/viewer/2022062321/56649e4e5503460f94b450a9/html5/thumbnails/5.jpg)
The Problems
• Loss of common file system– Harder to distribute custom programs
• Multiple development environments
• Program logic unavailable to web applications.
• Minor file format changes require too much work.
![Page 6: An Improved Approach to Generating Configuration Files from a Database Jon Finke Rensselaer Polytechnic Institute](https://reader035.vdocuments.us/reader035/viewer/2022062321/56649e4e5503460f94b450a9/html5/thumbnails/6.jpg)
New Model
SQL*NET
Version Control
SQL*NET
Version Control
File Format Logic
Relational Database
Switcher
File Format Logic File Format Logic
![Page 7: An Improved Approach to Generating Configuration Files from a Database Jon Finke Rensselaer Polytechnic Institute](https://reader035.vdocuments.us/reader035/viewer/2022062321/56649e4e5503460f94b450a9/html5/thumbnails/7.jpg)
New Way
• File format logic stored in DB– Changes made centrally
• Generic file extraction program– No changes after installation– Platform independence
• Code sharing with web applications• PL/SQL programs are shorter
– Faster to write
![Page 8: An Improved Approach to Generating Configuration Files from a Database Jon Finke Rensselaer Polytechnic Institute](https://reader035.vdocuments.us/reader035/viewer/2022062321/56649e4e5503460f94b450a9/html5/thumbnails/8.jpg)
Stored Procedures and Packages
• PL/SQL– Procedural extension to SQL
• Simple Procedure or Function• Package
– Set of procedures and functions– maintains state
• Stored and executed by database server
![Page 9: An Improved Approach to Generating Configuration Files from a Database Jon Finke Rensselaer Polytechnic Institute](https://reader035.vdocuments.us/reader035/viewer/2022062321/56649e4e5503460f94b450a9/html5/thumbnails/9.jpg)
PL/SQL
• Variables and Constants
• SQL built in functions– String, Numeric, Date
• Conditionals
• Looping Constructs
• Exception Handling
• Records
![Page 10: An Improved Approach to Generating Configuration Files from a Database Jon Finke Rensselaer Polytechnic Institute](https://reader035.vdocuments.us/reader035/viewer/2022062321/56649e4e5503460f94b450a9/html5/thumbnails/10.jpg)
Generic ProgramGet Filename
Null?Done
Start
Open File
Get Line
Null? Write Line
Version?
![Page 11: An Improved Approach to Generating Configuration Files from a Database Jon Finke Rensselaer Polytechnic Institute](https://reader035.vdocuments.us/reader035/viewer/2022062321/56649e4e5503460f94b450a9/html5/thumbnails/11.jpg)
“Switcher” functions
• Standard API for generic program
• Provides access control
• Provide filename for simple cases– Also direction, and other attributes
• Grouping of multiple simple files
• Environment info for specific file generator routines.
![Page 12: An Improved Approach to Generating Configuration Files from a Database Jon Finke Rensselaer Polytechnic Institute](https://reader035.vdocuments.us/reader035/viewer/2022062321/56649e4e5503460f94b450a9/html5/thumbnails/12.jpg)
SwitcherGet_Filename
Record?
Return Null
AccessOK?
Return Error
Get NextTarget Rec
Simple?
Open?
OpenTarget Rec
Files>0?
Return Rec.GetFname()
ReturnRec.Filename
![Page 13: An Improved Approach to Generating Configuration Files from a Database Jon Finke Rensselaer Polytechnic Institute](https://reader035.vdocuments.us/reader035/viewer/2022062321/56649e4e5503460f94b450a9/html5/thumbnails/13.jpg)
Target Record
• Target Name, Sequence Number
• Access List
• Get Data Routine Name
• Get FileName Routine Name (C)
• FileName (S)
• Direction, DBMS_OUT Flag (S)
• Version Info (S)
![Page 14: An Improved Approach to Generating Configuration Files from a Database Jon Finke Rensselaer Polytechnic Institute](https://reader035.vdocuments.us/reader035/viewer/2022062321/56649e4e5503460f94b450a9/html5/thumbnails/14.jpg)
Get_Data (1)Cursor Get_Records is
Select Username, Uid Gid, Gecos, Shell, Path from Logins;
. . .
Procedure Get_Data(Result out varchar2) is
R Get_Records%RowType
begin
if not Get_Records%IsOpen
then
Open Get_Records;
end if;
![Page 15: An Improved Approach to Generating Configuration Files from a Database Jon Finke Rensselaer Polytechnic Institute](https://reader035.vdocuments.us/reader035/viewer/2022062321/56649e4e5503460f94b450a9/html5/thumbnails/15.jpg)
Get_Data (2)Fetch Get_Records into R;
if Get_Records%NotFound
then
Close Get_Records;
Result := Null;
else
Result := R.Username || ‘:*:’ || R.Uid || ‘:’
|| R.Gid || ‘:’ || R.Gecos || ‘:’ || R.Path
|| ‘:’ || R.shell;
end if;
return;
![Page 16: An Improved Approach to Generating Configuration Files from a Database Jon Finke Rensselaer Polytechnic Institute](https://reader035.vdocuments.us/reader035/viewer/2022062321/56649e4e5503460f94b450a9/html5/thumbnails/16.jpg)
Complex Targets
• Get_FileName– Like Get_Data– Stashes context info for Get_Data– Provides version info (optionally)
• Keep calling until no more files.
• For each file, call Get_Data until no more data.
![Page 17: An Improved Approach to Generating Configuration Files from a Database Jon Finke Rensselaer Polytechnic Institute](https://reader035.vdocuments.us/reader035/viewer/2022062321/56649e4e5503460f94b450a9/html5/thumbnails/17.jpg)
More Conclusions
• Replacing existing custom programs
• Loading data as well as extraction
• Handler for back end processing– File “STDOUT”
• Wish I had done this long ago
![Page 18: An Improved Approach to Generating Configuration Files from a Database Jon Finke Rensselaer Polytechnic Institute](https://reader035.vdocuments.us/reader035/viewer/2022062321/56649e4e5503460f94b450a9/html5/thumbnails/18.jpg)
Package Design
Relational Database Tables
WP Table Routines
WP Web
WP File
Web ServerFile Gen
![Page 19: An Improved Approach to Generating Configuration Files from a Database Jon Finke Rensselaer Polytechnic Institute](https://reader035.vdocuments.us/reader035/viewer/2022062321/56649e4e5503460f94b450a9/html5/thumbnails/19.jpg)
Files Currently Generated
• White Pages – LaTeX, HTML, LDIF, ph, CSV
• Hostmaster– Resource Record (bind)– Hostfile– DHCP Config
• TSM Billing– Error Reports
![Page 20: An Improved Approach to Generating Configuration Files from a Database Jon Finke Rensselaer Polytechnic Institute](https://reader035.vdocuments.us/reader035/viewer/2022062321/56649e4e5503460f94b450a9/html5/thumbnails/20.jpg)
Files Currently Loaded
• TSM (Backup/archive)– Accounting Records
• White Pages– CSV staff list (remote campus)
• Terminal Server– Accounting logs
• lpd (printing) – Accounting logs
![Page 21: An Improved Approach to Generating Configuration Files from a Database Jon Finke Rensselaer Polytechnic Institute](https://reader035.vdocuments.us/reader035/viewer/2022062321/56649e4e5503460f94b450a9/html5/thumbnails/21.jpg)
Futures
• GET from program
• PUT to program
• Boilerplate management
• Call file generation from Web– Faster development for web pages– Alternate Boilerplate testing
• More platforms
![Page 22: An Improved Approach to Generating Configuration Files from a Database Jon Finke Rensselaer Polytechnic Institute](https://reader035.vdocuments.us/reader035/viewer/2022062321/56649e4e5503460f94b450a9/html5/thumbnails/22.jpg)
An Improved Approach to Generating Configuration Files from
a Database
Jon Finke
Rensselaer Polytechnic Institute
http://www.rpi.edu/~finkej