wip
This commit is contained in:
parent
6acf004eab
commit
68c87509f2
@ -11,18 +11,20 @@ type Host struct {
|
||||
MACs []string
|
||||
IPs []string
|
||||
|
||||
IPXE string
|
||||
|
||||
Kernel string
|
||||
Initrd string
|
||||
Layers map[string]string
|
||||
Versions map[string]string
|
||||
|
||||
Config []byte
|
||||
Config string
|
||||
}
|
||||
|
||||
func (h *Host) WriteHashDataTo(w io.Writer) error {
|
||||
return yaml.NewEncoder(w).Encode(Host{
|
||||
Kernel: h.Kernel,
|
||||
Initrd: h.Initrd,
|
||||
Layers: h.Layers,
|
||||
Versions: h.Versions,
|
||||
Config: h.Config,
|
||||
})
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
package localconfig
|
||||
|
||||
import (
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"strings"
|
||||
|
||||
@ -10,11 +11,12 @@ import (
|
||||
type Config struct {
|
||||
Clusters []*Cluster
|
||||
Hosts []*Host
|
||||
SSLConfig string
|
||||
}
|
||||
|
||||
type Cluster struct {
|
||||
Name string
|
||||
Addons []byte
|
||||
Addons string
|
||||
}
|
||||
|
||||
func FromBytes(data []byte) (*Config, error) {
|
||||
@ -34,6 +36,19 @@ func FromFile(path string) (*Config, error) {
|
||||
return FromBytes(ba)
|
||||
}
|
||||
|
||||
func (c *Config) WriteTo(w io.Writer) error {
|
||||
return yaml.NewEncoder(w).Encode(c)
|
||||
}
|
||||
|
||||
func (c *Config) Cluster(name string) *Cluster {
|
||||
for _, cluster := range c.Clusters {
|
||||
if cluster.Name == name {
|
||||
return cluster
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (c *Config) ClusterByName(name string) *Cluster {
|
||||
for _, cluster := range c.Clusters {
|
||||
if cluster.Name == name {
|
||||
@ -43,6 +58,15 @@ func (c *Config) ClusterByName(name string) *Cluster {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (c *Config) Host(name string) *Host {
|
||||
for _, host := range c.Hosts {
|
||||
if host.Name == name {
|
||||
return host
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (c *Config) HostByIP(ip string) *Host {
|
||||
for _, host := range c.Hosts {
|
||||
for _, hostIP := range host.IPs {
|
||||
|
Loading…
Reference in New Issue
Block a user