Added controllers, services, and lots of various optimizations and fixes
This commit is contained in:
@@ -30,78 +30,80 @@ func New() (nodeYaml, error) {
|
||||
func (self *nodeYaml) FindAllNodes() ([]NodeInfo, error) {
|
||||
var ret []NodeInfo
|
||||
|
||||
for groupname, group := range self.NodeGroups {
|
||||
for nodename, node := range group.Nodes {
|
||||
var n NodeInfo
|
||||
var allProfiles []string
|
||||
for controllername, controller := range self.Controllers {
|
||||
for groupname, group := range controller.NodeGroups {
|
||||
for nodename, node := range group.Nodes {
|
||||
var n NodeInfo
|
||||
var allProfiles []string
|
||||
|
||||
if node.Disabled == true || group.Disabled == true {
|
||||
wwlog.Printf(wwlog.VERBOSE, "Skipping disabled node: %s/%s\n", groupname, nodename)
|
||||
continue
|
||||
}
|
||||
|
||||
n.Id.Set(nodename)
|
||||
n.Gid.Set(groupname)
|
||||
n.GroupName.Set(groupname)
|
||||
n.HostName.Set(node.Hostname)
|
||||
n.IpmiIpaddr.Set(node.IpmiIpaddr)
|
||||
n.DomainName.Set(node.DomainName)
|
||||
n.Vnfs.Set(node.Vnfs)
|
||||
n.KernelVersion.Set(node.KernelVersion)
|
||||
n.KernelArgs.Set(node.KernelArgs)
|
||||
n.Ipxe.Set(node.Ipxe)
|
||||
n.IpmiUserName.Set(node.IpmiUserName)
|
||||
n.IpmiPassword.Set(node.IpmiPassword)
|
||||
n.SystemOverlay.Set(node.SystemOverlay)
|
||||
n.RuntimeOverlay.Set(node.RuntimeOverlay)
|
||||
|
||||
n.DomainName.SetGroup(group.DomainName)
|
||||
n.Vnfs.SetGroup(group.Vnfs)
|
||||
n.KernelVersion.SetGroup(group.KernelVersion)
|
||||
n.KernelArgs.SetGroup(group.KernelArgs)
|
||||
n.Ipxe.SetGroup(group.Ipxe)
|
||||
n.IpmiUserName.SetGroup(group.IpmiUserName)
|
||||
n.IpmiPassword.SetGroup(group.IpmiPassword)
|
||||
n.SystemOverlay.SetGroup(group.SystemOverlay)
|
||||
n.RuntimeOverlay.SetGroup(group.RuntimeOverlay)
|
||||
|
||||
n.RuntimeOverlay.SetDefault("default")
|
||||
n.SystemOverlay.SetDefault("default")
|
||||
n.Ipxe.SetDefault("default")
|
||||
n.KernelArgs.SetDefault("crashkernel=no quiet")
|
||||
|
||||
n.GroupProfiles = group.Profiles
|
||||
n.Profiles = node.Profiles
|
||||
|
||||
allProfiles = append(allProfiles, group.Profiles...)
|
||||
allProfiles = append(allProfiles, node.Profiles...)
|
||||
|
||||
for _, p := range allProfiles {
|
||||
if _, ok := self.NodeProfiles[p]; !ok {
|
||||
wwlog.Printf(wwlog.WARN, "Profile not found for node '%s': %s\n", nodename, p)
|
||||
if node.Disabled == true || group.Disabled == true {
|
||||
wwlog.Printf(wwlog.VERBOSE, "Skipping disabled node: %s/%s\n", groupname, nodename)
|
||||
continue
|
||||
}
|
||||
|
||||
n.DomainName.SetProfile(self.NodeProfiles[p].DomainName)
|
||||
n.Vnfs.SetProfile(self.NodeProfiles[p].Vnfs)
|
||||
n.KernelVersion.SetProfile(self.NodeProfiles[p].KernelVersion)
|
||||
n.KernelArgs.SetProfile(self.NodeProfiles[p].KernelArgs)
|
||||
n.Ipxe.SetProfile(self.NodeProfiles[p].Ipxe)
|
||||
n.IpmiUserName.SetProfile(self.NodeProfiles[p].IpmiUserName)
|
||||
n.IpmiPassword.SetProfile(self.NodeProfiles[p].IpmiPassword)
|
||||
n.SystemOverlay.SetProfile(self.NodeProfiles[p].SystemOverlay)
|
||||
n.RuntimeOverlay.SetProfile(self.NodeProfiles[p].RuntimeOverlay)
|
||||
n.Id.Set(nodename)
|
||||
n.Gid.Set(groupname)
|
||||
n.Cid.Set(controllername)
|
||||
n.HostName.Set(node.Hostname)
|
||||
n.IpmiIpaddr.Set(node.IpmiIpaddr)
|
||||
n.DomainName.Set(node.DomainName)
|
||||
n.Vnfs.Set(node.Vnfs)
|
||||
n.KernelVersion.Set(node.KernelVersion)
|
||||
n.KernelArgs.Set(node.KernelArgs)
|
||||
n.Ipxe.Set(node.Ipxe)
|
||||
n.IpmiUserName.Set(node.IpmiUserName)
|
||||
n.IpmiPassword.Set(node.IpmiPassword)
|
||||
n.SystemOverlay.Set(node.SystemOverlay)
|
||||
n.RuntimeOverlay.Set(node.RuntimeOverlay)
|
||||
|
||||
n.DomainName.SetGroup(group.DomainName)
|
||||
n.Vnfs.SetGroup(group.Vnfs)
|
||||
n.KernelVersion.SetGroup(group.KernelVersion)
|
||||
n.KernelArgs.SetGroup(group.KernelArgs)
|
||||
n.Ipxe.SetGroup(group.Ipxe)
|
||||
n.IpmiUserName.SetGroup(group.IpmiUserName)
|
||||
n.IpmiPassword.SetGroup(group.IpmiPassword)
|
||||
n.SystemOverlay.SetGroup(group.SystemOverlay)
|
||||
n.RuntimeOverlay.SetGroup(group.RuntimeOverlay)
|
||||
|
||||
n.RuntimeOverlay.SetDefault("default")
|
||||
n.SystemOverlay.SetDefault("default")
|
||||
n.Ipxe.SetDefault("default")
|
||||
n.KernelArgs.SetDefault("crashkernel=no quiet")
|
||||
|
||||
n.GroupProfiles = group.Profiles
|
||||
n.Profiles = node.Profiles
|
||||
|
||||
allProfiles = append(allProfiles, group.Profiles...)
|
||||
allProfiles = append(allProfiles, node.Profiles...)
|
||||
|
||||
for _, p := range allProfiles {
|
||||
if _, ok := self.NodeProfiles[p]; !ok {
|
||||
wwlog.Printf(wwlog.WARN, "Profile not found for node '%s': %s\n", nodename, p)
|
||||
continue
|
||||
}
|
||||
|
||||
n.DomainName.SetProfile(self.NodeProfiles[p].DomainName)
|
||||
n.Vnfs.SetProfile(self.NodeProfiles[p].Vnfs)
|
||||
n.KernelVersion.SetProfile(self.NodeProfiles[p].KernelVersion)
|
||||
n.KernelArgs.SetProfile(self.NodeProfiles[p].KernelArgs)
|
||||
n.Ipxe.SetProfile(self.NodeProfiles[p].Ipxe)
|
||||
n.IpmiUserName.SetProfile(self.NodeProfiles[p].IpmiUserName)
|
||||
n.IpmiPassword.SetProfile(self.NodeProfiles[p].IpmiPassword)
|
||||
n.SystemOverlay.SetProfile(self.NodeProfiles[p].SystemOverlay)
|
||||
n.RuntimeOverlay.SetProfile(self.NodeProfiles[p].RuntimeOverlay)
|
||||
}
|
||||
|
||||
if n.DomainName.Defined() == true {
|
||||
n.Fqdn.Set(node.Hostname + "." + n.DomainName.Get())
|
||||
} else {
|
||||
n.Fqdn.Set(node.Hostname)
|
||||
}
|
||||
|
||||
n.NetDevs = node.NetDevs
|
||||
|
||||
ret = append(ret, n)
|
||||
}
|
||||
|
||||
if n.DomainName.Defined() == true {
|
||||
n.Fqdn.Set(node.Hostname +"."+ n.DomainName.Get())
|
||||
} else {
|
||||
n.Fqdn.Set(node.Hostname)
|
||||
}
|
||||
|
||||
n.NetDevs = node.NetDevs
|
||||
|
||||
ret = append(ret, n)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -111,25 +113,76 @@ func (self *nodeYaml) FindAllNodes() ([]NodeInfo, error) {
|
||||
func (self *nodeYaml) FindAllGroups() ([]GroupInfo, error) {
|
||||
var ret []GroupInfo
|
||||
|
||||
for groupname, group := range self.NodeGroups {
|
||||
var g GroupInfo
|
||||
for controllername, controller := range self.Controllers {
|
||||
for groupname, group := range controller.NodeGroups {
|
||||
var g GroupInfo
|
||||
|
||||
g.Id = groupname
|
||||
g.DomainName = group.DomainName
|
||||
g.Comment = group.Comment
|
||||
g.Vnfs = group.Vnfs
|
||||
g.KernelVersion = group.KernelVersion
|
||||
g.KernelArgs = group.KernelArgs
|
||||
g.IpmiPassword = group.IpmiPassword
|
||||
g.IpmiUserName = group.IpmiUserName
|
||||
g.SystemOverlay = group.SystemOverlay
|
||||
g.RuntimeOverlay = group.RuntimeOverlay
|
||||
g.Id = groupname
|
||||
g.Cid = controllername
|
||||
g.DomainName = group.DomainName
|
||||
g.Comment = group.Comment
|
||||
g.Vnfs = group.Vnfs
|
||||
g.KernelVersion = group.KernelVersion
|
||||
g.KernelArgs = group.KernelArgs
|
||||
g.IpmiPassword = group.IpmiPassword
|
||||
g.IpmiUserName = group.IpmiUserName
|
||||
g.SystemOverlay = group.SystemOverlay
|
||||
g.RuntimeOverlay = group.RuntimeOverlay
|
||||
|
||||
g.Profiles = group.Profiles
|
||||
g.Profiles = group.Profiles
|
||||
|
||||
// TODO: Validate or die on all inputs
|
||||
|
||||
ret = append(ret, g)
|
||||
}
|
||||
}
|
||||
return ret, nil
|
||||
}
|
||||
|
||||
func (self *nodeYaml) FindAllControllers() ([]ControllerInfo, error) {
|
||||
var ret []ControllerInfo
|
||||
|
||||
for controllername, controller := range self.Controllers {
|
||||
var c ControllerInfo
|
||||
|
||||
c.Id = controllername
|
||||
c.Ipaddr = controller.Ipaddr
|
||||
c.Services = struct {
|
||||
Warewulfd struct {
|
||||
Port string
|
||||
Secure string
|
||||
StartCmd string
|
||||
RestartCmd string
|
||||
EnableCmd string
|
||||
}
|
||||
Dhcp struct {
|
||||
Enabled bool
|
||||
RangeStart string
|
||||
RangeEnd string
|
||||
ConfigFile string
|
||||
StartCmd string
|
||||
RestartCmd string
|
||||
EnableCmd string
|
||||
}
|
||||
Tftp struct {
|
||||
Enabled bool
|
||||
TftpRoot string
|
||||
StartCmd string
|
||||
RestartCmd string
|
||||
EnableCmd string
|
||||
}
|
||||
Nfs struct {
|
||||
Enabled bool
|
||||
Exports []string
|
||||
StartCmd string
|
||||
RestartCmd string
|
||||
EnableCmd string
|
||||
}
|
||||
}(controller.Services)
|
||||
|
||||
// TODO: Validate or die on all inputs
|
||||
|
||||
ret = append(ret, g)
|
||||
ret = append(ret, c)
|
||||
}
|
||||
return ret, nil
|
||||
}
|
||||
@@ -159,8 +212,6 @@ func (self *nodeYaml) FindAllProfiles() ([]ProfileInfo, error) {
|
||||
return ret, nil
|
||||
}
|
||||
|
||||
|
||||
|
||||
func (self *nodeYaml) FindByHwaddr(hwa string) (NodeInfo, error) {
|
||||
var ret NodeInfo
|
||||
|
||||
@@ -193,13 +244,6 @@ func (self *nodeYaml) FindByIpaddr(ipaddr string) (NodeInfo, error) {
|
||||
return ret, errors.New("No nodes found with IP Addr: " + ipaddr)
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
func (nodes *nodeYaml) SearchByName(search string) ([]NodeInfo, error) {
|
||||
var ret []NodeInfo
|
||||
|
||||
|
||||
@@ -6,127 +6,212 @@ import (
|
||||
"os"
|
||||
)
|
||||
|
||||
/******
|
||||
* YAML data representations
|
||||
******/
|
||||
|
||||
type nodeYaml struct {
|
||||
NodeProfiles map[string]*ProfileConf
|
||||
NodeGroups map[string]*GroupConf
|
||||
NodeProfiles map[string]*ProfileConf
|
||||
Controllers map[string]*ControllerConf `yaml:"control"`
|
||||
}
|
||||
|
||||
type ProfileConf struct {
|
||||
Comment string `yaml:"comment"`
|
||||
Vnfs string `yaml:"vnfs,omitempty"`
|
||||
Ipxe string `yaml:"ipxe template,omitempty"`
|
||||
KernelVersion string `yaml:"kernel version,omitempty"`
|
||||
KernelArgs string `yaml:"kernel args,omitempty"`
|
||||
IpmiUserName string `yaml:"ipmi username,omitempty"`
|
||||
IpmiPassword string `yaml:"ipmi password,omitempty"`
|
||||
DomainName string `yaml:"domain name,omitempty"`
|
||||
RuntimeOverlay string `yaml:"runtime overlay files,omitempty"`
|
||||
SystemOverlay string `yaml:"system overlay files,omitempty"`
|
||||
Comment string `yaml:"comment"`
|
||||
Vnfs string `yaml:"vnfs,omitempty"`
|
||||
Ipxe string `yaml:"ipxe template,omitempty"`
|
||||
KernelVersion string `yaml:"kernel version,omitempty"`
|
||||
KernelArgs string `yaml:"kernel args,omitempty"`
|
||||
IpmiUserName string `yaml:"ipmi username,omitempty"`
|
||||
IpmiPassword string `yaml:"ipmi password,omitempty"`
|
||||
DomainName string `yaml:"domain name,omitempty"`
|
||||
RuntimeOverlay string `yaml:"runtime overlay files,omitempty"`
|
||||
SystemOverlay string `yaml:"system overlay files,omitempty"`
|
||||
}
|
||||
|
||||
type ControllerConf struct {
|
||||
Comment string `yaml:"comment"`
|
||||
Ipaddr string `yaml:"ipaddr"`
|
||||
Services struct {
|
||||
Warewulfd struct {
|
||||
Port string `yaml:"port"`
|
||||
Secure string `yaml:"secure,omitempty"`
|
||||
StartCmd string `yaml:"start command,omitempty"`
|
||||
RestartCmd string `yaml:"restart command,omitempty"`
|
||||
EnableCmd string `yaml:"enable command,omitempty"`
|
||||
} `yaml:"warewulf"`
|
||||
Dhcp struct {
|
||||
Enabled bool `yaml:"enabled,omitempty"`
|
||||
RangeStart string `yaml:"range start,omitempty"`
|
||||
RangeEnd string `yaml:"range end,omitempty"`
|
||||
ConfigFile string `yaml:"config file,omitempty"`
|
||||
StartCmd string `yaml:"start command,omitempty"`
|
||||
RestartCmd string `yaml:"restart command,omitempty"`
|
||||
EnableCmd string `yaml:"enable command,omitempty"`
|
||||
} `yaml:"dhcp,omitempty"`
|
||||
Tftp struct {
|
||||
Enabled bool `yaml:"enabled,omitempty"`
|
||||
TftpRoot string `yaml:"tftp root,omitempty"`
|
||||
StartCmd string `yaml:"start command,omitempty"`
|
||||
RestartCmd string `yaml:"restart command,omitempty"`
|
||||
EnableCmd string `yaml:"enable command,omitempty"`
|
||||
} `yaml:"tftp,omitempty"`
|
||||
Nfs struct {
|
||||
Enabled bool `yaml:"enabled,omitempty"`
|
||||
Exports []string `yaml:"exports,omitempty"`
|
||||
StartCmd string `yaml:"start command,omitempty"`
|
||||
RestartCmd string `yaml:"restart command,omitempty"`
|
||||
EnableCmd string `yaml:"enable command,omitempty"`
|
||||
} `yaml:"nfs,omitempty"`
|
||||
} `yaml:"services"`
|
||||
NodeGroups map[string]*GroupConf
|
||||
}
|
||||
|
||||
type GroupConf struct {
|
||||
Comment string `yaml:"comment"`
|
||||
Disabled bool `yaml:"disabled,omitempty"`
|
||||
DomainName string `yaml:"domain name"`
|
||||
Vnfs string `yaml:"vnfs,omitempty"`
|
||||
Ipxe string `yaml:"ipxe template,omitempty"`
|
||||
KernelVersion string `yaml:"kernel version,omitempty"`
|
||||
KernelArgs string `yaml:"kernel args,omitempty"`
|
||||
IpmiUserName string `yaml:"ipmi username,omitempty"`
|
||||
IpmiPassword string `yaml:"ipmi password,omitempty"`
|
||||
RuntimeOverlay string `yaml:"runtime overlay files,omitempty"`
|
||||
SystemOverlay string `yaml:"system overlay files,omitempty"`
|
||||
Profiles []string `yaml:"profiles,omitempty"`
|
||||
Nodes map[string]*NodeConf
|
||||
Comment string `yaml:"comment"`
|
||||
Disabled bool `yaml:"disabled,omitempty"`
|
||||
DomainName string `yaml:"domain name"`
|
||||
Vnfs string `yaml:"vnfs,omitempty"`
|
||||
Ipxe string `yaml:"ipxe template,omitempty"`
|
||||
KernelVersion string `yaml:"kernel version,omitempty"`
|
||||
KernelArgs string `yaml:"kernel args,omitempty"`
|
||||
IpmiUserName string `yaml:"ipmi username,omitempty"`
|
||||
IpmiPassword string `yaml:"ipmi password,omitempty"`
|
||||
RuntimeOverlay string `yaml:"runtime overlay files,omitempty"`
|
||||
SystemOverlay string `yaml:"system overlay files,omitempty"`
|
||||
Profiles []string `yaml:"profiles,omitempty"`
|
||||
Nodes map[string]*NodeConf
|
||||
}
|
||||
|
||||
type NodeConf struct {
|
||||
Comment string `yaml:"comment,omitempty"`
|
||||
Disabled bool `yaml:"disabled,omitempty"`
|
||||
Hostname string `yaml:"hostname,omitempty"`
|
||||
DomainName string `yaml:"domain name,omitempty"`
|
||||
Vnfs string `yaml:"vnfs,omitempty"`
|
||||
Ipxe string `yaml:"ipxe template,omitempty"`
|
||||
KernelVersion string `yaml:"kernel version,omitempty"`
|
||||
KernelArgs string `yaml:"kernel args,omitempty"`
|
||||
IpmiUserName string `yaml:"ipmi username,omitempty"`
|
||||
IpmiPassword string `yaml:"ipmi password,omitempty"`
|
||||
IpmiIpaddr string `yaml:"ipmi ipaddr,omitempty"`
|
||||
RuntimeOverlay string `yaml:"runtime overlay files,omitempty"`
|
||||
SystemOverlay string `yaml:"system overlay files,omitempty"`
|
||||
Profiles []string `yaml:"profiles,omitempty"`
|
||||
NetDevs map[string]*NetDevs
|
||||
Comment string `yaml:"comment,omitempty"`
|
||||
Disabled bool `yaml:"disabled,omitempty"`
|
||||
Hostname string `yaml:"hostname,omitempty"`
|
||||
DomainName string `yaml:"domain name,omitempty"`
|
||||
Vnfs string `yaml:"vnfs,omitempty"`
|
||||
Ipxe string `yaml:"ipxe template,omitempty"`
|
||||
KernelVersion string `yaml:"kernel version,omitempty"`
|
||||
KernelArgs string `yaml:"kernel args,omitempty"`
|
||||
IpmiUserName string `yaml:"ipmi username,omitempty"`
|
||||
IpmiPassword string `yaml:"ipmi password,omitempty"`
|
||||
IpmiIpaddr string `yaml:"ipmi ipaddr,omitempty"`
|
||||
RuntimeOverlay string `yaml:"runtime overlay files,omitempty"`
|
||||
SystemOverlay string `yaml:"system overlay files,omitempty"`
|
||||
Profiles []string `yaml:"profiles,omitempty"`
|
||||
NetDevs map[string]*NetDevs
|
||||
}
|
||||
|
||||
type NetDevs struct {
|
||||
Type string `yaml:"type,omitempty"`
|
||||
Hwaddr string
|
||||
Ipaddr string
|
||||
Netmask string
|
||||
Gateway string `yaml:"gateway,omitempty"`
|
||||
Type string `yaml:"type,omitempty"`
|
||||
Hwaddr string
|
||||
Ipaddr string
|
||||
Netmask string
|
||||
Gateway string `yaml:"gateway,omitempty"`
|
||||
}
|
||||
|
||||
/******
|
||||
* Code internal data representations
|
||||
******/
|
||||
|
||||
type NodeInfoEntry struct {
|
||||
value string
|
||||
profile string
|
||||
group string
|
||||
def string
|
||||
value string
|
||||
profile string
|
||||
group string
|
||||
controller string
|
||||
def string
|
||||
}
|
||||
|
||||
type NodeInfo struct {
|
||||
Id NodeInfoEntry
|
||||
Gid NodeInfoEntry
|
||||
Uid NodeInfoEntry
|
||||
Comment NodeInfoEntry
|
||||
GroupName NodeInfoEntry
|
||||
HostName NodeInfoEntry
|
||||
Fqdn NodeInfoEntry
|
||||
DomainName NodeInfoEntry
|
||||
Vnfs NodeInfoEntry
|
||||
Ipxe NodeInfoEntry
|
||||
KernelVersion NodeInfoEntry
|
||||
KernelArgs NodeInfoEntry
|
||||
IpmiIpaddr NodeInfoEntry
|
||||
IpmiUserName NodeInfoEntry
|
||||
IpmiPassword NodeInfoEntry
|
||||
RuntimeOverlay NodeInfoEntry
|
||||
SystemOverlay NodeInfoEntry
|
||||
Profiles []string
|
||||
GroupProfiles []string
|
||||
NetDevs map[string]*NetDevs
|
||||
Id NodeInfoEntry
|
||||
Gid NodeInfoEntry
|
||||
Cid NodeInfoEntry
|
||||
Comment NodeInfoEntry
|
||||
HostName NodeInfoEntry
|
||||
Fqdn NodeInfoEntry
|
||||
DomainName NodeInfoEntry
|
||||
Vnfs NodeInfoEntry
|
||||
Ipxe NodeInfoEntry
|
||||
KernelVersion NodeInfoEntry
|
||||
KernelArgs NodeInfoEntry
|
||||
IpmiIpaddr NodeInfoEntry
|
||||
IpmiUserName NodeInfoEntry
|
||||
IpmiPassword NodeInfoEntry
|
||||
RuntimeOverlay NodeInfoEntry
|
||||
SystemOverlay NodeInfoEntry
|
||||
Profiles []string
|
||||
GroupProfiles []string
|
||||
NetDevs map[string]*NetDevs
|
||||
}
|
||||
|
||||
type ControllerInfo struct {
|
||||
Id string
|
||||
Comment string
|
||||
Ipaddr string
|
||||
Fqdn string
|
||||
DomainName string
|
||||
Services struct {
|
||||
Warewulfd struct {
|
||||
Port string
|
||||
Secure string
|
||||
StartCmd string
|
||||
RestartCmd string
|
||||
EnableCmd string
|
||||
}
|
||||
Dhcp struct {
|
||||
Enabled bool
|
||||
RangeStart string
|
||||
RangeEnd string
|
||||
ConfigFile string
|
||||
StartCmd string
|
||||
RestartCmd string
|
||||
EnableCmd string
|
||||
}
|
||||
Tftp struct {
|
||||
Enabled bool
|
||||
TftpRoot string
|
||||
StartCmd string
|
||||
RestartCmd string
|
||||
EnableCmd string
|
||||
}
|
||||
Nfs struct {
|
||||
Enabled bool
|
||||
Exports []string
|
||||
StartCmd string
|
||||
RestartCmd string
|
||||
EnableCmd string
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
type GroupInfo struct {
|
||||
Id string
|
||||
Comment string
|
||||
Vnfs string
|
||||
Ipxe string
|
||||
KernelVersion string
|
||||
KernelArgs string
|
||||
IpmiUserName string
|
||||
IpmiPassword string
|
||||
DomainName string
|
||||
RuntimeOverlay string
|
||||
SystemOverlay string
|
||||
Profiles []string
|
||||
Id string
|
||||
Cid string
|
||||
Comment string
|
||||
Vnfs string
|
||||
Ipxe string
|
||||
KernelVersion string
|
||||
KernelArgs string
|
||||
IpmiUserName string
|
||||
IpmiPassword string
|
||||
DomainName string
|
||||
RuntimeOverlay string
|
||||
SystemOverlay string
|
||||
Profiles []string
|
||||
}
|
||||
|
||||
type ProfileInfo struct {
|
||||
Id string
|
||||
Comment string
|
||||
Vnfs string
|
||||
Ipxe string
|
||||
KernelVersion string
|
||||
KernelArgs string
|
||||
IpmiUserName string
|
||||
IpmiPassword string
|
||||
DomainName string
|
||||
RuntimeOverlay string
|
||||
SystemOverlay string
|
||||
Id string
|
||||
Comment string
|
||||
Vnfs string
|
||||
Ipxe string
|
||||
KernelVersion string
|
||||
KernelArgs string
|
||||
IpmiUserName string
|
||||
IpmiPassword string
|
||||
DomainName string
|
||||
RuntimeOverlay string
|
||||
SystemOverlay string
|
||||
}
|
||||
|
||||
|
||||
|
||||
const ConfigFile = "/etc/warewulf/nodes.conf"
|
||||
|
||||
func init() {
|
||||
|
||||
@@ -14,6 +14,9 @@ func (self *NodeInfoEntry) String() string {
|
||||
if self.profile != "" {
|
||||
return self.profile
|
||||
}
|
||||
if self.controller != "" {
|
||||
return self.controller
|
||||
}
|
||||
if self.def != "" {
|
||||
return self.def
|
||||
}
|
||||
@@ -30,6 +33,9 @@ func (self *NodeInfoEntry) Source() string {
|
||||
if self.profile != "" {
|
||||
return "profile"
|
||||
}
|
||||
if self.controller != "" {
|
||||
return "controller"
|
||||
}
|
||||
if self.def != "" {
|
||||
return "default"
|
||||
}
|
||||
@@ -46,6 +52,9 @@ func (self *NodeInfoEntry) Get() string {
|
||||
if self.profile != "" {
|
||||
return self.profile
|
||||
}
|
||||
if self.controller != "" {
|
||||
return self.controller
|
||||
}
|
||||
if self.def != "" {
|
||||
return self.def
|
||||
}
|
||||
@@ -81,6 +90,13 @@ func (self *NodeInfoEntry) SetProfile(value string) {
|
||||
self.profile = value
|
||||
}
|
||||
|
||||
func (self *NodeInfoEntry) SetController(value string) {
|
||||
if value == "" {
|
||||
return
|
||||
}
|
||||
self.controller = value
|
||||
}
|
||||
|
||||
func (self *NodeInfoEntry) Set(value string) {
|
||||
if value == "" {
|
||||
return
|
||||
|
||||
@@ -14,64 +14,79 @@ import (
|
||||
*
|
||||
****/
|
||||
|
||||
func (self *nodeYaml) AddNode(groupID string, nodeID string) error {
|
||||
func (self *nodeYaml) AddNode(controllerID string, groupID string, nodeID string) error {
|
||||
var node NodeConf
|
||||
|
||||
wwlog.Printf(wwlog.VERBOSE, "Adding new node: %s/%s\n", groupID, nodeID)
|
||||
|
||||
if _, ok := self.NodeGroups[groupID]; !ok {
|
||||
if _, ok := self.Controllers[controllerID]; ! ok {
|
||||
return errors.New("Controller does not exist: " + controllerID)
|
||||
}
|
||||
|
||||
if _, ok := self.Controllers[controllerID].NodeGroups[groupID]; ! ok {
|
||||
return errors.New("Group does not exist: " + groupID)
|
||||
}
|
||||
|
||||
if _, ok := self.NodeGroups[groupID].Nodes[groupID]; ok {
|
||||
if _, ok := self.Controllers[controllerID].NodeGroups[groupID].Nodes[groupID]; ok {
|
||||
return errors.New("Nodename already exists in group: " + nodeID)
|
||||
}
|
||||
|
||||
self.NodeGroups[groupID].Nodes[nodeID] = &node
|
||||
self.NodeGroups[groupID].Nodes[nodeID].Hostname = nodeID
|
||||
self.Controllers[controllerID].NodeGroups[groupID].Nodes[nodeID] = &node
|
||||
self.Controllers[controllerID].NodeGroups[groupID].Nodes[nodeID].Hostname = nodeID
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (self *nodeYaml) DelNode(groupID string, nodeID string) error {
|
||||
func (self *nodeYaml) DelNode(controllerID string, groupID string, nodeID string) error {
|
||||
|
||||
if _, ok := self.NodeGroups[groupID]; !ok {
|
||||
return errors.New("Group '" + groupID + "' was not found")
|
||||
if _, ok := self.Controllers[controllerID]; ! ok {
|
||||
return errors.New("Controller does not exist: " + controllerID)
|
||||
}
|
||||
if _, ok := self.NodeGroups[groupID].Nodes[nodeID]; !ok {
|
||||
return errors.New("Node '" + nodeID + "' was not found in group '" + groupID + "'")
|
||||
|
||||
if _, ok := self.Controllers[controllerID].NodeGroups[groupID]; ! ok {
|
||||
return errors.New("Group does not exist: " + groupID)
|
||||
}
|
||||
|
||||
if _, ok := self.Controllers[controllerID].NodeGroups[groupID].Nodes[groupID]; ok {
|
||||
return errors.New("Nodename does not exist in group: " + nodeID)
|
||||
}
|
||||
|
||||
wwlog.Printf(wwlog.VERBOSE, "Deleting node network device: %s/%s\n", groupID, nodeID)
|
||||
delete(self.NodeGroups[groupID].Nodes, nodeID)
|
||||
delete(self.Controllers[controllerID].NodeGroups[groupID].Nodes, nodeID)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func(self *nodeYaml) NodeUpdate(node NodeInfo) error {
|
||||
controllerID := node.Cid.Get()
|
||||
groupID := node.Gid.Get()
|
||||
nodeID := node.Id.Get()
|
||||
|
||||
if _, ok := self.NodeGroups[groupID]; !ok {
|
||||
return errors.New("Group '" + groupID + "' was not found")
|
||||
}
|
||||
if _, ok := self.NodeGroups[groupID].Nodes[nodeID]; !ok {
|
||||
return errors.New("Node '" + nodeID + "' was not found in group '" + groupID + "'")
|
||||
if _, ok := self.Controllers[controllerID]; ! ok {
|
||||
return errors.New("Controller does not exist: " + controllerID)
|
||||
}
|
||||
|
||||
self.NodeGroups[groupID].Nodes[nodeID].Hostname = node.HostName.GetReal()
|
||||
self.NodeGroups[groupID].Nodes[nodeID].Vnfs = node.Vnfs.GetReal()
|
||||
self.NodeGroups[groupID].Nodes[nodeID].DomainName = node.DomainName.GetReal()
|
||||
self.NodeGroups[groupID].Nodes[nodeID].Ipxe = node.Ipxe.GetReal()
|
||||
self.NodeGroups[groupID].Nodes[nodeID].KernelVersion = node.KernelVersion.GetReal()
|
||||
self.NodeGroups[groupID].Nodes[nodeID].KernelArgs = node.KernelArgs.GetReal()
|
||||
self.NodeGroups[groupID].Nodes[nodeID].IpmiIpaddr = node.IpmiIpaddr.GetReal()
|
||||
self.NodeGroups[groupID].Nodes[nodeID].IpmiUserName = node.IpmiUserName.GetReal()
|
||||
self.NodeGroups[groupID].Nodes[nodeID].IpmiPassword = node.IpmiPassword.GetReal()
|
||||
self.NodeGroups[groupID].Nodes[nodeID].RuntimeOverlay = node.RuntimeOverlay.GetReal()
|
||||
self.NodeGroups[groupID].Nodes[nodeID].SystemOverlay = node.SystemOverlay.GetReal()
|
||||
self.NodeGroups[groupID].Nodes[nodeID].Profiles = node.Profiles
|
||||
self.NodeGroups[groupID].Nodes[nodeID].NetDevs = node.NetDevs
|
||||
if _, ok := self.Controllers[controllerID].NodeGroups[groupID]; ! ok {
|
||||
return errors.New("Group does not exist: " + groupID)
|
||||
}
|
||||
|
||||
if _, ok := self.Controllers[controllerID].NodeGroups[groupID].Nodes[groupID]; ! ok {
|
||||
return errors.New("Nodename does not exist in group: " + nodeID)
|
||||
}
|
||||
|
||||
self.Controllers[controllerID].NodeGroups[groupID].Nodes[nodeID].Hostname = node.HostName.GetReal()
|
||||
self.Controllers[controllerID].NodeGroups[groupID].Nodes[nodeID].Vnfs = node.Vnfs.GetReal()
|
||||
self.Controllers[controllerID].NodeGroups[groupID].Nodes[nodeID].DomainName = node.DomainName.GetReal()
|
||||
self.Controllers[controllerID].NodeGroups[groupID].Nodes[nodeID].Ipxe = node.Ipxe.GetReal()
|
||||
self.Controllers[controllerID].NodeGroups[groupID].Nodes[nodeID].KernelVersion = node.KernelVersion.GetReal()
|
||||
self.Controllers[controllerID].NodeGroups[groupID].Nodes[nodeID].KernelArgs = node.KernelArgs.GetReal()
|
||||
self.Controllers[controllerID].NodeGroups[groupID].Nodes[nodeID].IpmiIpaddr = node.IpmiIpaddr.GetReal()
|
||||
self.Controllers[controllerID].NodeGroups[groupID].Nodes[nodeID].IpmiUserName = node.IpmiUserName.GetReal()
|
||||
self.Controllers[controllerID].NodeGroups[groupID].Nodes[nodeID].IpmiPassword = node.IpmiPassword.GetReal()
|
||||
self.Controllers[controllerID].NodeGroups[groupID].Nodes[nodeID].RuntimeOverlay = node.RuntimeOverlay.GetReal()
|
||||
self.Controllers[controllerID].NodeGroups[groupID].Nodes[nodeID].SystemOverlay = node.SystemOverlay.GetReal()
|
||||
self.Controllers[controllerID].NodeGroups[groupID].Nodes[nodeID].Profiles = node.Profiles
|
||||
self.Controllers[controllerID].NodeGroups[groupID].Nodes[nodeID].NetDevs = node.NetDevs
|
||||
|
||||
return nil
|
||||
}
|
||||
@@ -84,51 +99,140 @@ func(self *nodeYaml) NodeUpdate(node NodeInfo) error {
|
||||
*
|
||||
****/
|
||||
|
||||
func (self *nodeYaml) AddGroup(groupID string) error {
|
||||
func (self *nodeYaml) AddGroup(controllerID string, groupID string) error {
|
||||
var group GroupConf
|
||||
|
||||
wwlog.Printf(wwlog.VERBOSE, "Adding new group: %s/%s\n", groupID)
|
||||
|
||||
if _, ok := self.NodeGroups[groupID]; ok {
|
||||
return errors.New("Group name already exists: " + groupID)
|
||||
if _, ok := self.Controllers[controllerID]; ! ok {
|
||||
return errors.New("Controller does not exist: " + controllerID)
|
||||
}
|
||||
|
||||
self.NodeGroups[groupID] = &group
|
||||
self.NodeGroups[groupID].DomainName = groupID
|
||||
self.NodeGroups[groupID].Profiles = []string{"default"}
|
||||
if _, ok := self.Controllers[controllerID].NodeGroups[groupID]; ok {
|
||||
return errors.New("Group already exists: " + groupID)
|
||||
}
|
||||
|
||||
self.Controllers[controllerID].NodeGroups[groupID] = &group
|
||||
self.Controllers[controllerID].NodeGroups[groupID].DomainName = groupID
|
||||
self.Controllers[controllerID].NodeGroups[groupID].Profiles = []string{"default"}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (self *nodeYaml) DelGroup(groupID string) error {
|
||||
if _, ok := self.NodeGroups[groupID]; !ok {
|
||||
func (self *nodeYaml) DelGroup(controllerID string, groupID string) error {
|
||||
|
||||
return errors.New("Group '" + groupID + "' was not found")
|
||||
if _, ok := self.Controllers[controllerID]; ! ok {
|
||||
return errors.New("Controller does not exist: " + controllerID)
|
||||
}
|
||||
|
||||
if _, ok := self.Controllers[controllerID].NodeGroups[groupID]; ! ok {
|
||||
return errors.New("Group does not exist: " + groupID)
|
||||
}
|
||||
|
||||
wwlog.Printf(wwlog.VERBOSE, "Deleting group: %s\n", groupID)
|
||||
delete(self.NodeGroups, groupID)
|
||||
delete(self.Controllers[controllerID].NodeGroups, groupID)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func(self *nodeYaml) GroupUpdate(group GroupInfo) error {
|
||||
controllerID := group.Cid
|
||||
groupID := group.Id
|
||||
|
||||
if _, ok := self.NodeGroups[groupID]; !ok {
|
||||
return errors.New("Group '" + groupID + "' was not found")
|
||||
if _, ok := self.Controllers[controllerID]; ! ok {
|
||||
return errors.New("Controller does not exist: " + controllerID)
|
||||
}
|
||||
|
||||
self.NodeGroups[groupID].DomainName = group.DomainName
|
||||
self.NodeGroups[groupID].Vnfs = group.Vnfs
|
||||
self.NodeGroups[groupID].KernelVersion = group.KernelVersion
|
||||
self.NodeGroups[groupID].KernelArgs = group.KernelArgs
|
||||
self.NodeGroups[groupID].Ipxe = group.Ipxe
|
||||
self.NodeGroups[groupID].IpmiUserName = group.IpmiUserName
|
||||
self.NodeGroups[groupID].IpmiPassword = group.IpmiPassword
|
||||
self.NodeGroups[groupID].RuntimeOverlay = group.RuntimeOverlay
|
||||
self.NodeGroups[groupID].SystemOverlay = group.SystemOverlay
|
||||
self.NodeGroups[groupID].Profiles = group.Profiles
|
||||
if _, ok := self.Controllers[controllerID].NodeGroups[groupID]; ! ok {
|
||||
return errors.New("Group does not exist: " + groupID)
|
||||
}
|
||||
|
||||
self.Controllers[controllerID].NodeGroups[groupID].DomainName = group.DomainName
|
||||
self.Controllers[controllerID].NodeGroups[groupID].Vnfs = group.Vnfs
|
||||
self.Controllers[controllerID].NodeGroups[groupID].KernelVersion = group.KernelVersion
|
||||
self.Controllers[controllerID].NodeGroups[groupID].KernelArgs = group.KernelArgs
|
||||
self.Controllers[controllerID].NodeGroups[groupID].Ipxe = group.Ipxe
|
||||
self.Controllers[controllerID].NodeGroups[groupID].IpmiUserName = group.IpmiUserName
|
||||
self.Controllers[controllerID].NodeGroups[groupID].IpmiPassword = group.IpmiPassword
|
||||
self.Controllers[controllerID].NodeGroups[groupID].RuntimeOverlay = group.RuntimeOverlay
|
||||
self.Controllers[controllerID].NodeGroups[groupID].SystemOverlay = group.SystemOverlay
|
||||
self.Controllers[controllerID].NodeGroups[groupID].Profiles = group.Profiles
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
|
||||
/****
|
||||
*
|
||||
* CONTROLLER MODIFIERS
|
||||
*
|
||||
****/
|
||||
|
||||
func (self *nodeYaml) AddController(controllerID string) error {
|
||||
var controller ControllerConf
|
||||
var group GroupConf
|
||||
|
||||
wwlog.Printf(wwlog.VERBOSE, "Adding new controller: %s/%s\n", controllerID)
|
||||
|
||||
if _, ok := self.Controllers[controllerID]; ok {
|
||||
return errors.New("Controller already exists: " + controllerID)
|
||||
}
|
||||
|
||||
self.Controllers[controllerID] = &controller
|
||||
self.Controllers[controllerID].NodeGroups = make(map[string]*GroupConf)
|
||||
self.Controllers[controllerID].NodeGroups["default"] = &group
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (self *nodeYaml) DelController(controllerID string) error {
|
||||
|
||||
if _, ok := self.Controllers[controllerID]; ! ok {
|
||||
return errors.New("Controller does not exist: " + controllerID)
|
||||
}
|
||||
|
||||
wwlog.Printf(wwlog.VERBOSE, "Deleting controller: %s\n", controllerID)
|
||||
delete(self.Controllers, controllerID)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func(self *nodeYaml) ControllerUpdate(controller ControllerInfo) error {
|
||||
controllerID := controller.Id
|
||||
|
||||
if _, ok := self.Controllers[controllerID]; ! ok {
|
||||
return errors.New("Controller does not exist: " + controllerID)
|
||||
}
|
||||
|
||||
self.Controllers[controllerID].Ipaddr = controller.Ipaddr
|
||||
self.Controllers[controllerID].Comment = controller.Comment
|
||||
|
||||
self.Controllers[controllerID].Services.Warewulfd.Port = controller.Services.Warewulfd.Port
|
||||
self.Controllers[controllerID].Services.Warewulfd.Secure = controller.Services.Warewulfd.Secure
|
||||
self.Controllers[controllerID].Services.Warewulfd.StartCmd = controller.Services.Warewulfd.StartCmd
|
||||
self.Controllers[controllerID].Services.Warewulfd.RestartCmd = controller.Services.Warewulfd.RestartCmd
|
||||
self.Controllers[controllerID].Services.Warewulfd.EnableCmd = controller.Services.Warewulfd.EnableCmd
|
||||
|
||||
self.Controllers[controllerID].Services.Dhcp.Enabled = controller.Services.Dhcp.Enabled
|
||||
self.Controllers[controllerID].Services.Dhcp.ConfigFile = controller.Services.Dhcp.ConfigFile
|
||||
self.Controllers[controllerID].Services.Dhcp.RangeStart = controller.Services.Dhcp.RangeStart
|
||||
self.Controllers[controllerID].Services.Dhcp.RangeEnd = controller.Services.Dhcp.RangeEnd
|
||||
self.Controllers[controllerID].Services.Dhcp.StartCmd = controller.Services.Dhcp.StartCmd
|
||||
self.Controllers[controllerID].Services.Dhcp.RestartCmd = controller.Services.Dhcp.RestartCmd
|
||||
self.Controllers[controllerID].Services.Dhcp.EnableCmd = controller.Services.Dhcp.EnableCmd
|
||||
|
||||
self.Controllers[controllerID].Services.Nfs.Enabled = controller.Services.Nfs.Enabled
|
||||
self.Controllers[controllerID].Services.Nfs.Exports = controller.Services.Nfs.Exports
|
||||
self.Controllers[controllerID].Services.Nfs.StartCmd = controller.Services.Nfs.StartCmd
|
||||
self.Controllers[controllerID].Services.Nfs.RestartCmd = controller.Services.Nfs.RestartCmd
|
||||
self.Controllers[controllerID].Services.Nfs.EnableCmd = controller.Services.Nfs.EnableCmd
|
||||
|
||||
self.Controllers[controllerID].Services.Tftp.Enabled = controller.Services.Tftp.Enabled
|
||||
self.Controllers[controllerID].Services.Tftp.TftpRoot = controller.Services.Tftp.TftpRoot
|
||||
self.Controllers[controllerID].Services.Tftp.StartCmd = controller.Services.Tftp.StartCmd
|
||||
self.Controllers[controllerID].Services.Tftp.RestartCmd = controller.Services.Tftp.RestartCmd
|
||||
self.Controllers[controllerID].Services.Tftp.EnableCmd = controller.Services.Tftp.EnableCmd
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user