Compare commits

..

2 Commits

Author SHA1 Message Date
Gibheer 5e06ba6b61 add function to get subnets to schema
This also adds a view to get a list of all containers and their free
space in between.
This is needed for ippool_list to get a nice overview over everything.
2021-05-21 17:42:10 +02:00
Gibheer efecc60e9c add view to get container hierarchy 2021-05-18 15:04:57 +02:00
2 changed files with 1 additions and 21 deletions

View File

@ -68,11 +68,7 @@ func main() {
s.Register("layer3domain_list", layer3DomainList)
s.Register("layer3domain_get_attr", layer3DomainGetAttr)
s.Register("layer3domain_set_attr", layer3DomainSetAttr)
s.Register("ipblock_create", containerCreate)
s.Register("ipblock_remove", containerDelete)
s.Register("ipblock_list", containerList)
s.Register("ipblock_set_attr", containerSetAttr)
s.Register("ipblock_get_attr", containerGetAttr)
s.Register("ipblock_create", ipblockCreate)
s.Register("ippool_create", PoolCreate)
s.Register("ippool_delete", PoolDelete)
s.Register("ippool_list", PoolList)

View File

@ -5,7 +5,6 @@ import (
"database/sql/driver"
"fmt"
"net"
"strconv"
)
type (
@ -13,8 +12,6 @@ type (
Subnet net.IPNet
// IP is used to parse an IP parameter.
IP net.IP
// IPVersion represents the two IP versions currently in use.
IPVersion int
)
// UnmarshalJSON parses a value into a subnet.
@ -72,16 +69,3 @@ func (i *IP) UnmarshalJSON(in []byte) error {
*i = IP(ip)
return nil
}
// UnmarshalJSON parses the incoming version from json.
func (v *IPVersion) UnmarshalJSON(in []byte) error {
raw, err := strconv.Atoi(string(in))
if err != nil {
return fmt.Errorf("can't parse ip version: %#v", err)
}
if raw != 4 && raw != 6 {
return fmt.Errorf("only version 4 and 6 are supported")
}
*v = IPVersion(raw)
return nil
}