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
namespace eval db::networks {}
proc db::networks::ls {db} {
set ret {}
$db eval {SELECT rowid as id, * FROM networks;} network {
set ndict {}
foreach k $network(*) {
dict set ndict $k [set network($k)]
}
lappend ret $ndict
}
return $ret
}
proc db::networks::add {db name servers} {
$db eval {INSERT INTO networks VALUES ($name $servers);}
}
proc db::networks::exists {db name} {
$db exists {SELECT * FROM networks WHERE name = :name}
}
sproc db::networks::creds {
add {db network name type args} {
if ![exists $db $network] { return -code error "Unknown network \"$network\" in \"$db\"." }
}
ls {db network} {
if ![exists $db $network] { return -code error "Unknown network \"$network\" in \"$db\"." }
}
remove {db network name} {
if ![exists $db $network] { return -code error "Unknown network \"$network\" in \"$db\"." }
}
}