Revert "Add missing node tracking for config-defined nodes"

This reverts commit 9ec193ef1d.
This commit is contained in:
Ian Gulliver
2026-01-28 08:42:12 -08:00
parent 9ec193ef1d
commit 85cfa6a9f4
7 changed files with 104 additions and 254 deletions

View File

@@ -2,7 +2,6 @@ package tendrils
import (
"encoding/json"
"net"
"os"
"gopkg.in/yaml.v3"
@@ -13,54 +12,10 @@ type Config struct {
}
type Location struct {
Name string `yaml:"name" json:"name"`
Direction string `yaml:"direction,omitempty" json:"direction,omitempty"`
Nodes []*NodeRef `yaml:"nodes,omitempty" json:"nodes,omitempty"`
Children []*Location `yaml:"children,omitempty" json:"children,omitempty"`
}
type NodeRef struct {
Name string `yaml:"name,omitempty" json:"name,omitempty"`
MAC string `yaml:"mac,omitempty" json:"mac,omitempty"`
IP string `yaml:"ip,omitempty" json:"ip,omitempty"`
}
func (r *NodeRef) DisplayName() string {
if r.Name != "" {
return r.Name
}
if r.MAC != "" {
return r.MAC
}
return r.IP
}
func (r *NodeRef) ParseMAC() net.HardwareAddr {
if r.MAC == "" {
return nil
}
mac, _ := net.ParseMAC(r.MAC)
return mac
}
func (r *NodeRef) ParseIP() net.IP {
if r.IP == "" {
return nil
}
return net.ParseIP(r.IP)
}
func (c *Config) AllNodeRefs() []*NodeRef {
var refs []*NodeRef
var collect func([]*Location)
collect = func(locs []*Location) {
for _, loc := range locs {
refs = append(refs, loc.Nodes...)
collect(loc.Children)
}
}
collect(c.Locations)
return refs
Name string `yaml:"name" json:"name"`
Direction string `yaml:"direction,omitempty" json:"direction,omitempty"`
Nodes []string `yaml:"nodes,omitempty" json:"nodes,omitempty"`
Children []*Location `yaml:"children,omitempty" json:"children,omitempty"`
}
func LoadConfig(path string) (*Config, error) {