aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid M. Syzdek <syzdek@bindlebinaries.com>2019-05-07 12:04:16 -0800
committerDavid M. Syzdek <syzdek@bindlebinaries.com>2019-05-07 12:04:16 -0800
commit886e6b18f3298ba4eefbb50a55bf36309692655f (patch)
treebee908967d180c220f700e6ee99a36e038597655
parent854a5f847fc3f1804174d5f6087f0a18fad6df24 (diff)
downloadscratchpad-886e6b18f3298ba4eefbb50a55bf36309692655f.tar.gz
scratchpad-886e6b18f3298ba4eefbb50a55bf36309692655f.tar.bz2
scratchpad-886e6b18f3298ba4eefbb50a55bf36309692655f.tar.xz
scratchpad-886e6b18f3298ba4eefbb50a55bf36309692655f.zip
Updating ippool schema.
-rw-r--r--notes/projects/radius/sql/ippool-database.sql27
-rw-r--r--notes/projects/radius/sql/ippool-demo.sql15
-rw-r--r--notes/projects/radius/sql/ippool-schema.sql25
-rw-r--r--notes/projects/radius/sql/ippool.md20
4 files changed, 76 insertions, 11 deletions
diff --git a/notes/projects/radius/sql/ippool-database.sql b/notes/projects/radius/sql/ippool-database.sql
new file mode 100644
index 0000000..ed188cd
--- /dev/null
+++ b/notes/projects/radius/sql/ippool-database.sql
@@ -0,0 +1,27 @@
1/*
2 * IP Engineering RADIUS Servers
3 *
4 * ippool-database.sql - builds roles and database for RADIUS IP Pools
5 *
6 */
7
8
9CREATE ROLE radius_ippool WITH
10 NOSUPERUSER
11 NOCREATEDB
12 NOCREATEROLE
13 NOINHERIT
14 NOLOGIN
15 NOREPLICATION
16 NOBYPASSRLS
17 ADMIN admin;
18
19
20CREATE DATABASE radius_ippool WITH
21 OWNER = radius_ippool
22 ENCODING = "UTF8"
23 LC_COLLATE = "en_US.UTF-8"
24 LC_CTYPE = "en_US.UTF-8";
25
26
27/* end of sql */
diff --git a/notes/projects/radius/sql/ippool-demo.sql b/notes/projects/radius/sql/ippool-demo.sql
index e6f0d9f..9bf7edc 100644
--- a/notes/projects/radius/sql/ippool-demo.sql
+++ b/notes/projects/radius/sql/ippool-demo.sql
@@ -1,17 +1,30 @@
1/*
2 * IP Engineering RADIUS Servers
3 *
4 * ippool-demo.sql - inserts demo data into RADIUS IP Pools database
5 *
6 */
7
8
9SET ROLE radius_ippool;
10
1 11
2INSERT INTO pool ( name ) VALUES 12INSERT INTO pool ( name ) VALUES
3 ( 'dhcp' ), 13 ( 'dhcp' ),
4 ( 'pppoe' ); 14 ( 'pppoe' );
5 15
16
6INSERT INTO region ( name ) VALUES 17INSERT INTO region ( name ) VALUES
7 ( 'anchorage' ), 18 ( 'anchorage' ),
8 ( 'soldotna' ), 19 ( 'soldotna' ),
9 ( 'fairbanks' ); 20 ( 'fairbanks' );
10 21
22
11INSERT INTO nas ( name, regionid ) VALUES 23INSERT INTO nas ( name, regionid ) VALUES
12 ( 'br1.cwc', (SELECT id FROM region WHERE name LIKE 'anchorage') ), 24 ( 'br1.cwc', (SELECT id FROM region WHERE name LIKE 'anchorage') ),
13 ( 'br1.sol', (SELECT id FROM region WHERE name LIKE 'soldotna') ); 25 ( 'br1.sol', (SELECT id FROM region WHERE name LIKE 'soldotna') );
14 26
27
15INSERT INTO block ( poolId, regionId, net, description ) VALUES 28INSERT INTO block ( poolId, regionId, net, description ) VALUES
16 ( ( SELECT id FROM pool WHERE name LIKE 'dhcp' ), 29 ( ( SELECT id FROM pool WHERE name LIKE 'dhcp' ),
17 ( SELECT id FROM region WHERE name LIKE 'anchorage' ), 30 ( SELECT id FROM region WHERE name LIKE 'anchorage' ),
@@ -22,3 +35,5 @@ INSERT INTO block ( poolId, regionId, net, description ) VALUES
22 '209.112.128.0/24', 35 '209.112.128.0/24',
23 'User Blocks' ); 36 'User Blocks' );
24 37
38
39/* end of sql */
diff --git a/notes/projects/radius/sql/ippool-schema.sql b/notes/projects/radius/sql/ippool-schema.sql
index 9b57676..485a5cc 100644
--- a/notes/projects/radius/sql/ippool-schema.sql
+++ b/notes/projects/radius/sql/ippool-schema.sql
@@ -1,3 +1,13 @@
1/*
2 * IP Engineering RADIUS Servers
3 *
4 * ippool-schema.sql - builds database schema for RADIUS IP Pools
5 *
6 */
7
8
9SET ROLE radius_ippool;
10
1 11
2CREATE TABLE IF NOT EXISTS pool 12CREATE TABLE IF NOT EXISTS pool
3( 13(
@@ -28,7 +38,7 @@ CREATE TABLE IF NOT EXISTS block
28 net INET NOT NULL UNIQUE, 38 net INET NOT NULL UNIQUE,
29 active BOOLEAN NOT NULL DEFAULT TRUE, 39 active BOOLEAN NOT NULL DEFAULT TRUE,
30 description VARCHAR(32), 40 description VARCHAR(32),
31 FOREIGN KEY (poolId) REFERENCES pool (id), 41 FOREIGN KEY (poolId) REFERENCES pool (id),
32 FOREIGN KEY (regionId) REFERENCES region (id) 42 FOREIGN KEY (regionId) REFERENCES region (id)
33); 43);
34 44
@@ -38,24 +48,17 @@ CREATE TABLE IF NOT EXISTS address
38 poolId INTEGER NOT NULL, 48 poolId INTEGER NOT NULL,
39 assigned BOOLEAN NOT NULL DEFAULT FALSE, 49 assigned BOOLEAN NOT NULL DEFAULT FALSE,
40 lastChanged timestamp WITH TIME ZONE NOT NULL DEFAULT TIMESTAMP 'epoch', 50 lastChanged timestamp WITH TIME ZONE NOT NULL DEFAULT TIMESTAMP 'epoch',
41 currentUser VARCHAR(32), 51 username VARCHAR(64),
42 currentCircuit VARCHAR(64),
43 FOREIGN KEY (poolId) REFERENCES pool (id) 52 FOREIGN KEY (poolId) REFERENCES pool (id)
44); 53);
45 54
46 55
47ALTER TABLE pool OWNER TO postgres;
48ALTER TABLE region OWNER TO postgres;
49ALTER TABLE nas OWNER TO postgres;
50ALTER TABLE block OWNER TO postgres;
51ALTER TABLE address OWNER TO postgres;
52
53
54CREATE INDEX IF NOT EXISTS pool_index ON pool ( id ); 56CREATE INDEX IF NOT EXISTS pool_index ON pool ( id );
55CREATE INDEX IF NOT EXISTS region_index ON region ( id ); 57CREATE INDEX IF NOT EXISTS region_index ON region ( id );
56CREATE INDEX IF NOT EXISTS nas_index ON nas ( id, regionId ); 58CREATE INDEX IF NOT EXISTS nas_index ON nas ( id, regionId );
57CREATE INDEX IF NOT EXISTS block_index ON block ( id, poolId, net, active ); 59CREATE INDEX IF NOT EXISTS block_index ON block ( id, poolId, net, active );
58CREATE INDEX IF NOT EXISTS address_index ON address ( address, poolId, 60CREATE INDEX IF NOT EXISTS address_index ON address ( address, poolId,
59 assigned, lastChanged, currentUser, currentCircuit ); 61 assigned, lastChanged, lastuser );
60 62
61 63
64/* end of sql */
diff --git a/notes/projects/radius/sql/ippool.md b/notes/projects/radius/sql/ippool.md
new file mode 100644
index 0000000..ad8328c
--- /dev/null
+++ b/notes/projects/radius/sql/ippool.md
@@ -0,0 +1,20 @@
1
2IP Engineering RADIUS IP Pool Database
3======================================
4
5Objectives
6----------
7
8 * Psuedo static IP addresses
9 * Per NAS Preference for geographic regions
10 * Ability to deavtivate/busy out specific netblocks
11
12Files
13----
14
15 * ippool.md - This file
16 * ippool-database.sql - Creates database
17 * ippool-schema.sql - Creates database schema (tables, indexes, etc)
18 * ippool-demo.sql - Loads demo data
19
20