Add IpCIDR6 and IPv6 DHCP range
Signed-off-by: Timothy Middelkoop <tmiddelkoop@internet2.edu>
This commit is contained in:
@@ -11,6 +11,8 @@ type DHCPConf struct {
|
||||
Template string `yaml:"template,omitempty" default:"default"`
|
||||
RangeStart string `yaml:"range start,omitempty"`
|
||||
RangeEnd string `yaml:"range end,omitempty"`
|
||||
Range6Start string `yaml:"range6 start,omitempty"`
|
||||
Range6End string `yaml:"range6 end,omitempty"`
|
||||
SystemdName string `yaml:"systemd name,omitempty" default:"dhcpd"`
|
||||
}
|
||||
|
||||
|
||||
@@ -29,6 +29,7 @@ type WarewulfYaml struct {
|
||||
Ipaddr6 string `yaml:"ipaddr6,omitempty"`
|
||||
Netmask string `yaml:"netmask,omitempty"`
|
||||
Network string `yaml:"network,omitempty"`
|
||||
IpCIDR6 string `yaml:"-"`
|
||||
Fqdn string `yaml:"fqdn,omitempty"`
|
||||
Warewulf *WarewulfConf `yaml:"warewulf,omitempty"`
|
||||
API *APIConf `yaml:"api,omitempty"`
|
||||
@@ -140,7 +141,13 @@ func (conf *WarewulfYaml) Parse(data []byte, autodetect bool) error {
|
||||
}
|
||||
|
||||
if conf.Ipaddr6 != "" {
|
||||
if _, _, err := net.ParseCIDR(conf.Ipaddr6); err != nil {
|
||||
if ip, _, err := net.ParseCIDR(conf.Ipaddr6); err == nil {
|
||||
if ip.To4() != nil {
|
||||
return fmt.Errorf("invalid ipv6 address: ip address is ipv4: %s", conf.Ipaddr6)
|
||||
}
|
||||
conf.IpCIDR6 = conf.Ipaddr6
|
||||
conf.Ipaddr6 = ip.String()
|
||||
} else {
|
||||
return fmt.Errorf("invalid ipv6 address: must use CIDR notation: %s", conf.Ipaddr6)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -152,7 +152,7 @@ api:
|
||||
ipaddr6: "2001:db8::1/64"
|
||||
`,
|
||||
result: `
|
||||
ipaddr6: "2001:db8::1/64"
|
||||
ipaddr6: "2001:db8::1"
|
||||
warewulf:
|
||||
autobuild overlays: true
|
||||
grubboot: false
|
||||
|
||||
@@ -26,6 +26,7 @@ type TemplateStruct struct {
|
||||
Ipaddr string
|
||||
IpCIDR string
|
||||
Ipaddr6 string
|
||||
IpCIDR6 string
|
||||
Netmask string
|
||||
Network string
|
||||
NetworkCIDR string
|
||||
@@ -70,6 +71,10 @@ func InitStruct(overlayName string, nodeData node.Node, allNodes []node.Node) (T
|
||||
tstruct.Ipaddr = controller.Ipaddr
|
||||
tstruct.IpCIDR = controller.IpCIDR()
|
||||
tstruct.Ipaddr6 = controller.Ipaddr6
|
||||
tstruct.IpCIDR6 = controller.IpCIDR6
|
||||
if controller.Ipaddr6 != "" && controller.IpCIDR6 != "" {
|
||||
tstruct.Ipv6 = true
|
||||
}
|
||||
tstruct.Netmask = controller.Netmask
|
||||
tstruct.Network = controller.Network
|
||||
tstruct.NetworkCIDR = controller.NetworkCIDR()
|
||||
|
||||
Reference in New Issue
Block a user