add user defined keys for networks/netdev

Every network in the profile and for the nodes can have induvidual keys values
pairs, called Tags, which are propergated to the templates. So they can be used
for things like MTU size like
  `wwct node set node01 --nettag mtu=9000`
and in in ifcfg.xml.ww
```
{{ if $netdev.Tags.mtu -}}
<mtu> {{ $netdev.Tags.mtu }} </mtu>
{{ end -}}
```
This commit is contained in:
Christian Goll
2022-03-31 11:00:48 +02:00
committed by Christian Goll
parent 16fa2518fa
commit 95050a44ce
10 changed files with 132 additions and 15 deletions

View File

@@ -15,6 +15,9 @@ type nodeYaml struct {
Nodes map[string]*NodeConf
}
/*
NodeConf is the datastructure which is stored on disk.
*/
type NodeConf struct {
Comment string `yaml:"comment,omitempty"`
ClusterName string `yaml:"cluster name,omitempty"`
@@ -51,24 +54,25 @@ type KernelConf struct {
}
type NetDevs struct {
Type string `yaml:"type,omitempty"`
OnBoot string `yaml:"onboot,omitempty"`
Device string `yaml:"device,omitempty"`
Hwaddr string `yaml:"hwaddr,omitempty"`
Ipaddr string `yaml:"ipaddr,omitempty"`
IpCIDR string `yaml:"ipcidr,omitempty"`
Ipaddr6 string `yaml:"ip6addr,omitempty"`
Prefix string `yaml:"prefix,omitempty"`
Netmask string `yaml:"netmask,omitempty"`
Gateway string `yaml:"gateway,omitempty"`
Default string `yaml:"default,omitempty"`
Type string `yaml:"type,omitempty"`
OnBoot string `yaml:"onboot,omitempty"`
Device string `yaml:"device,omitempty"`
Hwaddr string `yaml:"hwaddr,omitempty"`
Ipaddr string `yaml:"ipaddr,omitempty"`
IpCIDR string `yaml:"ipcidr,omitempty"`
Ipaddr6 string `yaml:"ip6addr,omitempty"`
Prefix string `yaml:"prefix,omitempty"`
Netmask string `yaml:"netmask,omitempty"`
Gateway string `yaml:"gateway,omitempty"`
Default string `yaml:"default,omitempty"`
Tags map[string]string `yaml:"tags,omitempty"`
}
/******
* Internal code data representations
******/
/*
Holds a strtng value, when accessed via Get, its value
Holds string values, when accessed via Get, its value
is returned which is the default or if set the value
from the profile or if set the value of the node itself
*/
@@ -79,6 +83,12 @@ type Entry struct {
def []string
}
/*
NodeInfo is the in memory datastructure, which can containe
a default value, which is overwritten by the overlay from the
overlay (altvalue) which is overwitten by the value of the
node itself, for all values of type Entry.
*/
type NodeInfo struct {
Id Entry
Cid Entry
@@ -129,6 +139,7 @@ type NetDevEntry struct {
Netmask Entry
Gateway Entry
Default Entry
Tags map[string]*Entry
}
func init() {