First commit of backwards-compatible config datastructures
Signed-off-by: Jonathon Anderson <janderson@ciq.com>
This commit is contained in:
91
internal/pkg/upgrade/conf.go
Normal file
91
internal/pkg/upgrade/conf.go
Normal file
@@ -0,0 +1,91 @@
|
||||
package upgrade
|
||||
|
||||
type RootConf struct {
|
||||
WWInternal int `yaml:"WW_INTERNAL"`
|
||||
Comment string `yaml:"comment,omitempty"`
|
||||
Ipaddr string `yaml:"ipaddr"`
|
||||
Ipaddr6 string `yaml:"ipaddr6,omitempty"`
|
||||
Netmask string `yaml:"netmask"`
|
||||
Network string `yaml:"network,omitempty"`
|
||||
Ipv6net string `yaml:"ipv6net,omitempty"`
|
||||
Fqdn string `yaml:"fqdn,omitempty"`
|
||||
Warewulf *WarewulfConf `yaml:"warewulf"`
|
||||
DHCP *DHCPConf `yaml:"dhcp"`
|
||||
TFTP *TFTPConf `yaml:"tftp"`
|
||||
NFS *NFSConf `yaml:"nfs"`
|
||||
SSH *SSHConf `yaml:"ssh,omitempty"`
|
||||
MountsContainer []*MountEntry `yaml:"container mounts"`
|
||||
Paths *BuildConfig `yaml:"paths"`
|
||||
WWClient *WWClientConf `yaml:"wwclient"`
|
||||
}
|
||||
|
||||
type WarewulfConf struct {
|
||||
Port int `yaml:"port"`
|
||||
Secure bool `yaml:"secure"`
|
||||
UpdateInterval int `yaml:"update interval"`
|
||||
AutobuildOverlays bool `yaml:"autobuild overlays"`
|
||||
EnableHostOverlay bool `yaml:"host overlay"`
|
||||
Syslog bool `yaml:"syslog"`
|
||||
DataStore string `yaml:"datastore"`
|
||||
GrubBoot bool `yaml:"grubboot"`
|
||||
}
|
||||
|
||||
type DHCPConf struct {
|
||||
Enabled bool `yaml:"enabled"`
|
||||
Template string `yaml:"template"`
|
||||
RangeStart string `yaml:"range start,omitempty"`
|
||||
RangeEnd string `yaml:"range end,omitempty"`
|
||||
SystemdName string `yaml:"systemd name"`
|
||||
}
|
||||
|
||||
type TFTPConf struct {
|
||||
Enabled bool `yaml:"enabled"`
|
||||
TftpRoot string `yaml:"tftproot"`
|
||||
SystemdName string `yaml:"systemd name"`
|
||||
|
||||
IpxeBinaries map[string]string `yaml:"ipxe"`
|
||||
}
|
||||
|
||||
type NFSConf struct {
|
||||
Enabled bool `yaml:"enabled"`
|
||||
ExportsExtended []*NFSExportConf `yaml:"export paths"`
|
||||
SystemdName string `yaml:"systemd name"`
|
||||
}
|
||||
|
||||
type NFSExportConf struct {
|
||||
Path string `yaml:"path"`
|
||||
ExportOptions string `yaml:"export options"`
|
||||
MountOptions string `yaml:"mount options"`
|
||||
Mount bool `yaml:"mount"`
|
||||
}
|
||||
|
||||
type SSHConf struct {
|
||||
KeyTypes []string `yaml:"key types"`
|
||||
}
|
||||
|
||||
type MountEntry struct {
|
||||
Source string `yaml:"source"`
|
||||
Dest string `yaml:"dest,omitempty"`
|
||||
ReadOnly bool `yaml:"readonly,omitempty"`
|
||||
Options string `yaml:"options,omitempty"`
|
||||
Copy bool `yaml:"copy,omitempty"`
|
||||
}
|
||||
|
||||
type BuildConfig struct {
|
||||
Bindir string
|
||||
Sysconfdir string
|
||||
Localstatedir string
|
||||
Cachedir string
|
||||
Ipxesource string
|
||||
Srvdir string
|
||||
Firewallddir string
|
||||
Systemddir string
|
||||
WWOverlaydir string
|
||||
WWChrootdir string
|
||||
WWProvisiondir string
|
||||
WWClientdir string
|
||||
}
|
||||
|
||||
type WWClientConf struct {
|
||||
Port uint16 `yaml:"port"`
|
||||
}
|
||||
128
internal/pkg/upgrade/node.go
Normal file
128
internal/pkg/upgrade/node.go
Normal file
@@ -0,0 +1,128 @@
|
||||
package upgrade
|
||||
|
||||
import (
|
||||
"gopkg.in/yaml.v3"
|
||||
)
|
||||
|
||||
func Parse(data []byte) (nodeYaml NodeYaml, err error) {
|
||||
if err = yaml.Unmarshal(data, &nodeYaml); err != nil {
|
||||
return nodeYaml, err
|
||||
}
|
||||
if nodeYaml.Nodes == nil {
|
||||
nodeYaml.Nodes = map[string]*Node{}
|
||||
}
|
||||
if nodeYaml.NodeProfiles == nil {
|
||||
nodeYaml.NodeProfiles = map[string]*Profile{}
|
||||
}
|
||||
return nodeYaml, nil
|
||||
}
|
||||
|
||||
type NodeYaml struct {
|
||||
NodeProfiles map[string]*Profile
|
||||
Nodes map[string]*Node
|
||||
}
|
||||
|
||||
type Node struct {
|
||||
Profile `yaml:"-,inline"`
|
||||
}
|
||||
|
||||
type Profile struct {
|
||||
AssetKey string `yaml:"asset key,omitempty"`
|
||||
ClusterName string `yaml:"cluster name,omitempty"`
|
||||
Comment string `yaml:"comment,omitempty"`
|
||||
ContainerName string `yaml:"container name,omitempty"`
|
||||
Disabled string `yaml:"disabled,omitempty"`
|
||||
Discoverable string `yaml:"discoverable,omitempty"`
|
||||
Disks map[string]*Disk `yaml:"disks,omitempty"`
|
||||
FileSystems map[string]*FileSystem `yaml:"filesystems,omitempty"`
|
||||
Init string `yaml:"init,omitempty"`
|
||||
Ipmi *IpmiConf `yaml:"ipmi,omitempty"`
|
||||
IpmiEscapeChar string `yaml:"ipmi escapechar,omitempty"`
|
||||
IpmiGateway string `yaml:"ipmi gateway,omitempty"`
|
||||
IpmiInterface string `yaml:"ipmi interface,omitempty"`
|
||||
IpmiIpaddr string `yaml:"ipmi ipaddr,omitempty"`
|
||||
IpmiNetmask string `yaml:"ipmi netmask,omitempty"`
|
||||
IpmiPassword string `yaml:"ipmi password,omitempty"`
|
||||
IpmiPort string `yaml:"ipmi port,omitempty"`
|
||||
IpmiUserName string `yaml:"ipmi username,omitempty"`
|
||||
IpmiWrite string `yaml:"ipmi write,omitempty"`
|
||||
Ipxe string `yaml:"ipxe template,omitempty"`
|
||||
Kernel *KernelConf `yaml:"kernel,omitempty"`
|
||||
KernelArgs string `yaml:"kernel args,omitempty"`
|
||||
KernelOverride string `yaml:"kernel override,omitempty"`
|
||||
KernelVersion string `yaml:"kernel version,omitempty"`
|
||||
Keys map[string]string `yaml:"keys,omitempty"`
|
||||
NetDevs map[string]*NetDev `yaml:"network devices,omitempty"`
|
||||
PrimaryNetDev string `yaml:"primary network,omitempty"`
|
||||
Profiles []string `yaml:"profiles,omitempty"`
|
||||
Root string `yaml:"root,omitempty"`
|
||||
RuntimeOverlay []string `yaml:"runtime overlay,omitempty"`
|
||||
SystemOverlay []string `yaml:"system overlay,omitempty"`
|
||||
Tags map[string]string `yaml:"tags,omitempty"`
|
||||
TagsDel []string `yaml:"tagsdel,omitempty"`
|
||||
}
|
||||
|
||||
type IpmiConf struct {
|
||||
EscapeChar string `yaml:"escapechar,omitempty"`
|
||||
Gateway string `yaml:"gateway,omitempty"`
|
||||
Interface string `yaml:"interface,omitempty"`
|
||||
Ipaddr string `yaml:"ipaddr,omitempty"`
|
||||
Netmask string `yaml:"netmask,omitempty"`
|
||||
Password string `yaml:"password,omitempty"`
|
||||
Port string `yaml:"port,omitempty"`
|
||||
Tags map[string]string `yaml:"tags,omitempty"`
|
||||
TagsDel []string `yaml:"tagsdel,omitempty"`
|
||||
UserName string `yaml:"username,omitempty"`
|
||||
Write string `yaml:"write,omitempty"`
|
||||
}
|
||||
|
||||
type KernelConf struct {
|
||||
Args string `yaml:"args,omitempty"`
|
||||
Override string `yaml:"override,omitempty"`
|
||||
Version string `yaml:"version,omitempty"`
|
||||
}
|
||||
|
||||
type NetDev struct {
|
||||
Default string `yaml:"default"`
|
||||
Device string `yaml:"device,omitempty"`
|
||||
Gateway string `yaml:"gateway,omitempty"`
|
||||
Hwaddr string `yaml:"hwaddr,omitempty"`
|
||||
IpCIDR string `yaml:"ipcidr,omitempty"`
|
||||
Ipaddr string `yaml:"ipaddr,omitempty"`
|
||||
Ipaddr6 string `yaml:"ip6addr,omitempty"`
|
||||
MTU string `yaml:"mtu,omitempty"`
|
||||
Netmask string `yaml:"netmask,omitempty"`
|
||||
OnBoot string `yaml:"onboot,omitempty"`
|
||||
Prefix string `yaml:"prefix,omitempty"`
|
||||
Primary string `yaml:"primary,omitempty"`
|
||||
Tags map[string]string `yaml:"tags,omitempty"`
|
||||
TagsDel []string `yaml:"tagsdel,omitempty"`
|
||||
Type string `yaml:"type,omitempty"`
|
||||
}
|
||||
|
||||
type Disk struct {
|
||||
Partitions map[string]*Partition `yaml:"partitions,omitempty"`
|
||||
WipeTable string `yaml:"wipe_table,omitempty"`
|
||||
}
|
||||
|
||||
type Partition struct {
|
||||
Guid string `yaml:"guid,omitempty"`
|
||||
Number string `yaml:"number,omitempty"`
|
||||
Resize string `yaml:"resize,omitempty"`
|
||||
ShouldExist string `yaml:"should_exist,omitempty"`
|
||||
SizeMiB string `yaml:"size_mib,omitempty"`
|
||||
StartMiB string `yaml:"start_mib,omitempty"`
|
||||
TypeGuid string `yaml:"type_guid,omitempty"`
|
||||
WipePartitionEntry string `yaml:"wipe_partition_entry,omitempty"`
|
||||
}
|
||||
|
||||
type FileSystem struct {
|
||||
Format string `yaml:"format,omitempty"`
|
||||
Label string `yaml:"label,omitempty"`
|
||||
MountOptions string `yaml:"mount_options,omitempty"`
|
||||
//MountOptions []string `yaml:"mount_options,omitempty"`
|
||||
Options []string `yaml:"options,omitempty"`
|
||||
Path string `yaml:"path,omitempty"`
|
||||
Uuid string `yaml:"uuid,omitempty"`
|
||||
WipeFileSystem string `yaml:"wipe_filesystem,omitempty"`
|
||||
}
|
||||
Reference in New Issue
Block a user