This is a work in progress API shift as the data structure has changed and I'm cleaning the interface.
This commit is contained in:
@@ -41,7 +41,7 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
|
||||
}
|
||||
|
||||
for _, node := range nodes {
|
||||
wwlog.Printf(wwlog.DEBUG, "evaluating node/kernel: %s/%s\n", node.Fqdn.Get(), node.KernelVersion.Get())
|
||||
wwlog.Printf(wwlog.DEBUG, "evaluating node/kernel: %s/%s\n", node.Id.Get(), node.KernelVersion.Get())
|
||||
if node.KernelVersion.Defined() == true {
|
||||
set[node.KernelVersion.Get()]++
|
||||
}
|
||||
|
||||
@@ -16,15 +16,95 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
|
||||
}
|
||||
|
||||
for _, a := range args {
|
||||
err = nodeDB.AddNode(SetController, SetGroup, a)
|
||||
n, err := nodeDB.AddNode(a)
|
||||
if err != nil {
|
||||
wwlog.Printf(wwlog.ERROR, "%s\n", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
fmt.Printf("Added node: %s\n", a)
|
||||
|
||||
if SetIpaddr != "" {
|
||||
if SetNetDev == "" {
|
||||
wwlog.Printf(wwlog.ERROR, "You must include the '--netdev' option\n")
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
if _, ok := n.NetDevs[SetNetDev]; !ok {
|
||||
var netdev node.NetDevEntry
|
||||
n.NetDevs[SetNetDev] = &netdev
|
||||
}
|
||||
|
||||
wwlog.Printf(wwlog.VERBOSE, "Node: %s:%s, Setting Ipaddr to: %s\n", n.Id, SetNetDev, SetIpaddr)
|
||||
|
||||
n.NetDevs[SetNetDev].Ipaddr.Set(SetIpaddr)
|
||||
n.NetDevs[SetNetDev].Default.SetB(true)
|
||||
err := nodeDB.NodeUpdate(n)
|
||||
if err != nil {
|
||||
wwlog.Printf(wwlog.ERROR, "%s\n", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
}
|
||||
if SetNetmask != "" {
|
||||
if SetNetDev == "" {
|
||||
wwlog.Printf(wwlog.ERROR, "You must include the '--netdev' option\n")
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
if _, ok := n.NetDevs[SetNetDev]; !ok {
|
||||
wwlog.Printf(wwlog.ERROR, "Network Device doesn't exist: %s\n", SetNetDev)
|
||||
os.Exit(1)
|
||||
}
|
||||
wwlog.Printf(wwlog.VERBOSE, "Node: %s:%s, Setting netmask to: %s\n", n.Id, SetNetDev, SetNetmask)
|
||||
|
||||
n.NetDevs[SetNetDev].Netmask.Set(SetNetmask)
|
||||
err := nodeDB.NodeUpdate(n)
|
||||
if err != nil {
|
||||
wwlog.Printf(wwlog.ERROR, "%s\n", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
}
|
||||
if SetGateway != "" {
|
||||
if SetNetDev == "" {
|
||||
wwlog.Printf(wwlog.ERROR, "You must include the '--netdev' option\n")
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
if _, ok := n.NetDevs[SetNetDev]; !ok {
|
||||
wwlog.Printf(wwlog.ERROR, "Network Device doesn't exist: %s\n", SetNetDev)
|
||||
os.Exit(1)
|
||||
}
|
||||
wwlog.Printf(wwlog.VERBOSE, "Node: %s:%s, Setting gateway to: %s\n", n.Id, SetNetDev, SetGateway)
|
||||
|
||||
n.NetDevs[SetNetDev].Gateway.Set(SetGateway)
|
||||
err := nodeDB.NodeUpdate(n)
|
||||
if err != nil {
|
||||
wwlog.Printf(wwlog.ERROR, "%s\n", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
}
|
||||
if SetHwaddr != "" {
|
||||
if SetNetDev == "" {
|
||||
wwlog.Printf(wwlog.ERROR, "You must include the '--netdev' option\n")
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
if _, ok := n.NetDevs[SetNetDev]; !ok {
|
||||
wwlog.Printf(wwlog.ERROR, "Network Device doesn't exist: %s\n", SetNetDev)
|
||||
os.Exit(1)
|
||||
}
|
||||
wwlog.Printf(wwlog.VERBOSE, "Node: %s:%s, Setting HW address to: %s\n", n.Id, SetNetDev, SetHwaddr)
|
||||
|
||||
n.NetDevs[SetNetDev].Hwaddr.Set(SetHwaddr)
|
||||
err := nodeDB.NodeUpdate(n)
|
||||
if err != nil {
|
||||
wwlog.Printf(wwlog.ERROR, "%s\n", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
nodeDB.Persist()
|
||||
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,11 +12,22 @@ var (
|
||||
}
|
||||
SetGroup string
|
||||
SetController string
|
||||
SetNetDev string
|
||||
SetIpaddr string
|
||||
SetNetmask string
|
||||
SetGateway string
|
||||
SetHwaddr string
|
||||
)
|
||||
|
||||
func init() {
|
||||
baseCmd.PersistentFlags().StringVarP(&SetGroup, "group", "g", "default", "Group to add nodes to")
|
||||
baseCmd.PersistentFlags().StringVarP(&SetController, "controller", "c", "localhost", "Controller to add nodes to")
|
||||
baseCmd.PersistentFlags().StringVarP(&SetNetDev, "netdev", "n", "eth0", "Define the network device to configure")
|
||||
baseCmd.PersistentFlags().StringVarP(&SetIpaddr, "ipaddr", "I", "", "Set the node's network device IP address")
|
||||
baseCmd.PersistentFlags().StringVarP(&SetNetmask, "netmask", "M", "", "Set the node's network device netmask")
|
||||
baseCmd.PersistentFlags().StringVarP(&SetGateway, "gateway", "G", "", "Set the node's network device gateway")
|
||||
baseCmd.PersistentFlags().StringVarP(&SetHwaddr, "hwaddr", "H", "", "Set the node's network device HW address")
|
||||
|
||||
}
|
||||
|
||||
// GetRootCommand returns the root cobra.Command for the application.
|
||||
|
||||
@@ -21,11 +21,7 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
|
||||
nodeList, err := nodeDB.SearchByNameList(args)
|
||||
|
||||
for _, n := range nodeList {
|
||||
if SetGroup != "" && SetGroup != n.Gid.Print() {
|
||||
wwlog.Printf(wwlog.DEBUG, "skipping node of different group: %s/%s\n", n.Gid, n.Id)
|
||||
continue
|
||||
}
|
||||
err := nodeDB.DelNode(n.Cid.Get(), n.Gid.Get(), n.Id.Get())
|
||||
err := nodeDB.DelNode(n.Id.Get())
|
||||
if err != nil {
|
||||
wwlog.Printf(wwlog.ERROR, "%s\n", err)
|
||||
} else {
|
||||
|
||||
@@ -31,9 +31,9 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
|
||||
}
|
||||
|
||||
sort.Slice(nodes, func(i, j int) bool {
|
||||
if nodes[i].Gid.Get() < nodes[j].Gid.Get() {
|
||||
if nodes[i].DomainName.Get() < nodes[j].DomainName.Get() {
|
||||
return true
|
||||
} else if nodes[i].Gid.Get() == nodes[j].Gid.Get() {
|
||||
} else if nodes[i].DomainName.Get() == nodes[j].DomainName.Get() {
|
||||
if nodes[i].Id.Get() < nodes[j].Id.Get() {
|
||||
return true
|
||||
}
|
||||
@@ -44,28 +44,29 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
|
||||
if ShowAll == true {
|
||||
for _, node := range nodes {
|
||||
fmt.Printf("################################################################################\n")
|
||||
fmt.Printf("%-20s %-18s %8s: %s\n", node.Fqdn.Get(), "Id", node.Id.Source(), node.Id.Print())
|
||||
fmt.Printf("%-20s %-18s %8s: %s\n", node.Fqdn.Get(), "Comment", node.Comment.Source(), node.Comment.Print())
|
||||
fmt.Printf("%-20s %-18s %8s: %s\n", node.Fqdn.Get(), "GroupName", node.Gid.Source(), node.Gid.Print())
|
||||
fmt.Printf("%-20s %-18s %8s: %s\n", node.Fqdn.Get(), "DomainName", node.DomainName.Source(), node.DomainName.Print())
|
||||
fmt.Printf("%-20s %-18s %8s: %s\n", node.Fqdn.Get(), "Profiles (Group)", "group", strings.Join(node.GroupProfiles, ","))
|
||||
fmt.Printf("%-20s %-18s %8s: %s\n", node.Fqdn.Get(), "Profiles (Node)", "node", strings.Join(node.Profiles, ","))
|
||||
fmt.Printf("%-20s %-18s %-12s %s\n", "NODE", "FIELD", "PROFILE", "VALUE")
|
||||
fmt.Printf("%-20s %-18s %-12s %s\n", node.Id.Get(), "Id", node.Id.Source(), node.Id.Print())
|
||||
fmt.Printf("%-20s %-18s %-12s %s\n", node.Id.Get(), "Comment", node.Comment.Source(), node.Comment.Print())
|
||||
fmt.Printf("%-20s %-18s %-12s %s\n", node.Id.Get(), "DomainName", node.DomainName.Source(), node.DomainName.Print())
|
||||
fmt.Printf("%-20s %-18s %-12s %s\n", node.Id.Get(), "Profiles", "--", strings.Join(node.Profiles, ","))
|
||||
|
||||
fmt.Printf("%-20s %-18s %8s: %s\n", node.Fqdn.Get(), "Vnfs", node.Vnfs.Source(), node.Vnfs.Print())
|
||||
fmt.Printf("%-20s %-18s %8s: %s\n", node.Fqdn.Get(), "KernelVersion", node.KernelVersion.Source(), node.KernelVersion.Print())
|
||||
fmt.Printf("%-20s %-18s %8s: %s\n", node.Fqdn.Get(), "KernelArgs", node.KernelArgs.Source(), node.KernelArgs.Print())
|
||||
fmt.Printf("%-20s %-18s %8s: %s\n", node.Fqdn.Get(), "RuntimeOverlay", node.RuntimeOverlay.Source(), node.RuntimeOverlay.Print())
|
||||
fmt.Printf("%-20s %-18s %8s: %s\n", node.Fqdn.Get(), "SystemOverlay", node.SystemOverlay.Source(), node.SystemOverlay.Print())
|
||||
fmt.Printf("%-20s %-18s %8s: %s\n", node.Fqdn.Get(), "Ipxe", node.Ipxe.Source(), node.Ipxe.Print())
|
||||
fmt.Printf("%-20s %-18s %8s: %s\n", node.Fqdn.Get(), "IpmiIpaddr", node.IpmiIpaddr.Source(), node.IpmiIpaddr.Print())
|
||||
fmt.Printf("%-20s %-18s %8s: %s\n", node.Fqdn.Get(), "IpmiNetmask", node.IpmiNetmask.Source(), node.IpmiNetmask.Print())
|
||||
fmt.Printf("%-20s %-18s %8s: %s\n", node.Fqdn.Get(), "IpmiUserName", node.IpmiUserName.Source(), node.IpmiUserName.Print())
|
||||
fmt.Printf("%-20s %-18s %-12s %s\n", node.Id.Get(), "Vnfs", node.Vnfs.Source(), node.Vnfs.Print())
|
||||
fmt.Printf("%-20s %-18s %-12s %s\n", node.Id.Get(), "KernelVersion", node.KernelVersion.Source(), node.KernelVersion.Print())
|
||||
fmt.Printf("%-20s %-18s %-12s %s\n", node.Id.Get(), "KernelArgs", node.KernelArgs.Source(), node.KernelArgs.Print())
|
||||
fmt.Printf("%-20s %-18s %-12s %s\n", node.Id.Get(), "RuntimeOverlay", node.RuntimeOverlay.Source(), node.RuntimeOverlay.Print())
|
||||
fmt.Printf("%-20s %-18s %-12s %s\n", node.Id.Get(), "SystemOverlay", node.SystemOverlay.Source(), node.SystemOverlay.Print())
|
||||
fmt.Printf("%-20s %-18s %-12s %s\n", node.Id.Get(), "Ipxe", node.Ipxe.Source(), node.Ipxe.Print())
|
||||
fmt.Printf("%-20s %-18s %-12s %s\n", node.Id.Get(), "IpmiIpaddr", node.IpmiIpaddr.Source(), node.IpmiIpaddr.Print())
|
||||
fmt.Printf("%-20s %-18s %-12s %s\n", node.Id.Get(), "IpmiNetmask", node.IpmiNetmask.Source(), node.IpmiNetmask.Print())
|
||||
fmt.Printf("%-20s %-18s %-12s %s\n", node.Id.Get(), "IpmiUserName", node.IpmiUserName.Source(), node.IpmiUserName.Print())
|
||||
|
||||
for name, netdev := range node.NetDevs {
|
||||
fmt.Printf("%-20s %-18s %8s: %s\n", node.Fqdn.Get(), name+":IPADDR", "node", netdev.Ipaddr)
|
||||
fmt.Printf("%-20s %-18s %8s: %s\n", node.Fqdn.Get(), name+":NETMASK", "node", netdev.Netmask)
|
||||
fmt.Printf("%-20s %-18s %8s: %s\n", node.Fqdn.Get(), name+":GATEWAY", "node", netdev.Gateway)
|
||||
fmt.Printf("%-20s %-18s %8s: %s\n", node.Fqdn.Get(), name+":HWADDR", "node", netdev.Hwaddr)
|
||||
fmt.Printf("%-20s %-18s %-12s %s\n", node.Id.Get(), name+":IPADDR", netdev.Ipaddr.Source(), netdev.Ipaddr.Get())
|
||||
fmt.Printf("%-20s %-18s %-12s %s\n", node.Id.Get(), name+":NETMASK", netdev.Netmask.Source(), netdev.Netmask.Get())
|
||||
fmt.Printf("%-20s %-18s %-12s %s\n", node.Id.Get(), name+":GATEWAY", netdev.Gateway.Source(), netdev.Gateway.Get())
|
||||
fmt.Printf("%-20s %-18s %-12s %s\n", node.Id.Get(), name+":HWADDR", netdev.Hwaddr.Source(), netdev.Hwaddr.Get())
|
||||
fmt.Printf("%-20s %-18s %-12s %s\n", node.Id.Get(), name+":TYPE", netdev.Type.Source(), netdev.Type.Get())
|
||||
|
||||
}
|
||||
|
||||
// v := reflect.ValueOf(node)
|
||||
@@ -83,10 +84,10 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
|
||||
for _, node := range nodes {
|
||||
if len(node.NetDevs) > 0 {
|
||||
for name, dev := range node.NetDevs {
|
||||
fmt.Printf("%-22s %-6s %-18s %-15s %-15s\n", node.Fqdn.Get(), name, dev.Hwaddr, dev.Ipaddr, dev.Gateway)
|
||||
fmt.Printf("%-22s %-6s %-18s %-15s %-15s\n", node.Id.Get(), name, dev.Hwaddr, dev.Ipaddr, dev.Gateway)
|
||||
}
|
||||
} else {
|
||||
fmt.Printf("%-22s %-6s %-18s %-15s %-15s\n", node.Fqdn.Get(), "--", "--", "--", "--")
|
||||
fmt.Printf("%-22s %-6s %-18s %-15s %-15s\n", node.Id.Get(), "--", "--", "--", "--")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -95,31 +96,30 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
|
||||
fmt.Println(strings.Repeat("=", 80))
|
||||
|
||||
for _, node := range nodes {
|
||||
fmt.Printf("%-22s %-16s %-20s %-20s\n", node.Fqdn.Get(), node.IpmiIpaddr.Print(), node.IpmiUserName.Print(), node.IpmiPassword.Print())
|
||||
fmt.Printf("%-22s %-16s %-20s %-20s\n", node.Id.Get(), node.IpmiIpaddr.Print(), node.IpmiUserName.Print(), node.IpmiPassword.Print())
|
||||
}
|
||||
|
||||
} else if ShowLong == true {
|
||||
fmt.Printf("%-22s %-12s %-26s %-35s %s\n", "NODE NAME", "GROUP NAME", "KERNEL VERSION", "VNFS IMAGE", "OVERLAYS (S/R)")
|
||||
fmt.Printf("%-22s %-26s %-35s %s\n", "NODE NAME", "KERNEL VERSION", "VNFS IMAGE", "OVERLAYS (S/R)")
|
||||
fmt.Println(strings.Repeat("=", 120))
|
||||
|
||||
for _, node := range nodes {
|
||||
fmt.Printf("%-22s %-12s %-26s %-35s %s\n", node.Fqdn.Get(), node.Gid.Print(), node.KernelVersion.Print(), node.Vnfs.Print(), node.SystemOverlay.Print()+"/"+node.RuntimeOverlay.Print())
|
||||
fmt.Printf("%-22s %-26s %-35s %s\n", node.Id.Get(), node.KernelVersion.Print(), node.Vnfs.Print(), node.SystemOverlay.Print()+"/"+node.RuntimeOverlay.Print())
|
||||
}
|
||||
|
||||
} else {
|
||||
fmt.Printf("%-22s: %-25s %s\n", "NODE NAME", "PROFILES", "NETDEVS")
|
||||
fmt.Printf("%-22s %-26s %s\n", "NODE NAME", "PROFILES", "NETWORK")
|
||||
|
||||
for _, node := range nodes {
|
||||
var netdevs []string
|
||||
if len(node.NetDevs) > 0 {
|
||||
for name, dev := range node.NetDevs {
|
||||
netdevs = append(netdevs, fmt.Sprintf("%s[%s/%s]", name, dev.Ipaddr, dev.Netmask))
|
||||
netdevs = append(netdevs, fmt.Sprintf("%s:%s", name, dev.Ipaddr.Get()))
|
||||
}
|
||||
}
|
||||
sort.Strings(netdevs)
|
||||
|
||||
allProfiles := append(node.GroupProfiles, node.Profiles...)
|
||||
fmt.Printf("%-22s: %-25s %s\n", node.Fqdn.Get(), strings.Join(allProfiles, ","), strings.Join(netdevs, ", "))
|
||||
fmt.Printf("%-22s %-26s %s\n", node.Id.Get(), strings.Join(node.Profiles, ","), strings.Join(netdevs, ", "))
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -35,7 +35,7 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
|
||||
for _, node := range nodeList {
|
||||
|
||||
if node.IpmiIpaddr.Get() == "" {
|
||||
wwlog.Printf(wwlog.ERROR, "%s: No IPMI IP address\n", node.HostName)
|
||||
wwlog.Printf(wwlog.ERROR, "%s: No IPMI IP address\n", node.Id.Get())
|
||||
continue
|
||||
}
|
||||
|
||||
@@ -49,12 +49,12 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
|
||||
out, err := ipmiCmd.PowerOff()
|
||||
|
||||
if err != nil {
|
||||
wwlog.Printf(wwlog.ERROR, "%s: %s\n", node.HostName, out)
|
||||
wwlog.Printf(wwlog.ERROR, "%s: %s\n", node.Id.Get(), out)
|
||||
returnErr = err
|
||||
continue
|
||||
}
|
||||
|
||||
wwlog.Printf(wwlog.INFO, "%s: %s\n", node.HostName, out)
|
||||
wwlog.Printf(wwlog.INFO, "%s: %s\n", node.Id.Get(), out)
|
||||
}
|
||||
|
||||
return returnErr
|
||||
|
||||
@@ -37,7 +37,7 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
|
||||
var powerCmd power.PowerOnInterface
|
||||
|
||||
if node.IpmiIpaddr.Get() == "" {
|
||||
wwlog.Printf(wwlog.ERROR, "%s: No IPMI IP address\n", node.HostName)
|
||||
wwlog.Printf(wwlog.ERROR, "%s: No IPMI IP address\n", node.Id.Get())
|
||||
continue
|
||||
}
|
||||
|
||||
@@ -53,12 +53,12 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
|
||||
out, err := powerCmd.PowerOn()
|
||||
|
||||
if err != nil {
|
||||
wwlog.Printf(wwlog.ERROR, "%s: %s\n", node.HostName, out)
|
||||
wwlog.Printf(wwlog.ERROR, "%s: %s\n", node.Id.Get(), out)
|
||||
returnErr = err
|
||||
continue
|
||||
}
|
||||
|
||||
wwlog.Printf(wwlog.INFO, "%s: %s\n", node.HostName, out)
|
||||
wwlog.Printf(wwlog.INFO, "%s: %s\n", node.Id.Get(), out)
|
||||
}
|
||||
|
||||
return returnErr
|
||||
|
||||
@@ -35,7 +35,7 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
|
||||
for _, node := range nodeList {
|
||||
|
||||
if node.IpmiIpaddr.Get() == "" {
|
||||
wwlog.Printf(wwlog.ERROR, "%s: No IPMI IP address\n", node.HostName)
|
||||
wwlog.Printf(wwlog.ERROR, "%s: No IPMI IP address\n", node.Id.Get())
|
||||
continue
|
||||
}
|
||||
|
||||
@@ -49,12 +49,12 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
|
||||
out, err := ipmiCmd.PowerStatus()
|
||||
|
||||
if err != nil {
|
||||
wwlog.Printf(wwlog.ERROR, "%s: %s\n", node.HostName, out)
|
||||
wwlog.Printf(wwlog.ERROR, "%s: %s\n", node.Id.Get(), out)
|
||||
returnErr = err
|
||||
continue
|
||||
}
|
||||
|
||||
wwlog.Printf(wwlog.INFO, "%s: %s\n", node.HostName, out)
|
||||
wwlog.Printf(wwlog.INFO, "%s: %s\n", node.Id.Get(), out)
|
||||
}
|
||||
|
||||
return returnErr
|
||||
|
||||
@@ -44,12 +44,22 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
|
||||
}
|
||||
|
||||
for _, n := range nodes {
|
||||
wwlog.Printf(wwlog.VERBOSE, "Evaluating node: %s\n", n.Fqdn.Get())
|
||||
wwlog.Printf(wwlog.VERBOSE, "Evaluating node: %s\n", n.Id.Get())
|
||||
|
||||
if SetComment != "" {
|
||||
wwlog.Printf(wwlog.VERBOSE, "Node: %s, Setting comment to: %s\n", n.Id.Get(), SetComment)
|
||||
|
||||
n.Comment.Set(SetComment)
|
||||
err := nodeDB.NodeUpdate(n)
|
||||
if err != nil {
|
||||
wwlog.Printf(wwlog.ERROR, "%s\n", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
}
|
||||
if SetVnfs != "" {
|
||||
wwlog.Printf(wwlog.VERBOSE, "Node: %s, Setting vnfs to: %s\n", n.Fqdn.Get(), SetVnfs)
|
||||
wwlog.Printf(wwlog.VERBOSE, "Node: %s, Setting vnfs to: %s\n", n.Id.Get(), SetVnfs)
|
||||
|
||||
n.Vnfs.SetNode(SetVnfs)
|
||||
n.Vnfs.Set(SetVnfs)
|
||||
err := nodeDB.NodeUpdate(n)
|
||||
if err != nil {
|
||||
wwlog.Printf(wwlog.ERROR, "%s\n", err)
|
||||
@@ -57,9 +67,9 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
|
||||
}
|
||||
}
|
||||
if SetKernel != "" {
|
||||
wwlog.Printf(wwlog.VERBOSE, "Node: %s, Setting kernel to: %s\n", n.Fqdn.Get(), SetKernel)
|
||||
wwlog.Printf(wwlog.VERBOSE, "Node: %s, Setting kernel to: %s\n", n.Id.Get(), SetKernel)
|
||||
|
||||
n.KernelVersion.SetNode(SetKernel)
|
||||
n.KernelVersion.Set(SetKernel)
|
||||
err := nodeDB.NodeUpdate(n)
|
||||
if err != nil {
|
||||
wwlog.Printf(wwlog.ERROR, "%s\n", err)
|
||||
@@ -67,9 +77,9 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
|
||||
}
|
||||
}
|
||||
if SetDomainName != "" {
|
||||
wwlog.Printf(wwlog.VERBOSE, "Node: %s, Setting domain name to: %s\n", n.Fqdn.Get(), SetDomainName)
|
||||
wwlog.Printf(wwlog.VERBOSE, "Node: %s, Setting domain name to: %s\n", n.Id.Get(), SetDomainName)
|
||||
|
||||
n.DomainName.SetNode(SetDomainName)
|
||||
n.DomainName.Set(SetDomainName)
|
||||
err := nodeDB.NodeUpdate(n)
|
||||
if err != nil {
|
||||
wwlog.Printf(wwlog.ERROR, "%s\n", err)
|
||||
@@ -77,9 +87,9 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
|
||||
}
|
||||
}
|
||||
if SetIpxe != "" {
|
||||
wwlog.Printf(wwlog.VERBOSE, "Node: %s, Setting iPXE template to: %s\n", n.Fqdn.Get(), SetIpxe)
|
||||
wwlog.Printf(wwlog.VERBOSE, "Node: %s, Setting iPXE template to: %s\n", n.Id.Get(), SetIpxe)
|
||||
|
||||
n.Ipxe.SetNode(SetIpxe)
|
||||
n.Ipxe.Set(SetIpxe)
|
||||
err := nodeDB.NodeUpdate(n)
|
||||
if err != nil {
|
||||
wwlog.Printf(wwlog.ERROR, "%s\n", err)
|
||||
@@ -87,9 +97,9 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
|
||||
}
|
||||
}
|
||||
if SetRuntimeOverlay != "" {
|
||||
wwlog.Printf(wwlog.VERBOSE, "Node: %s, Setting runtime overlay to: %s\n", n.Fqdn.Get(), SetRuntimeOverlay)
|
||||
wwlog.Printf(wwlog.VERBOSE, "Node: %s, Setting runtime overlay to: %s\n", n.Id.Get(), SetRuntimeOverlay)
|
||||
|
||||
n.RuntimeOverlay.SetNode(SetRuntimeOverlay)
|
||||
n.RuntimeOverlay.Set(SetRuntimeOverlay)
|
||||
err := nodeDB.NodeUpdate(n)
|
||||
if err != nil {
|
||||
wwlog.Printf(wwlog.ERROR, "%s\n", err)
|
||||
@@ -97,19 +107,9 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
|
||||
}
|
||||
}
|
||||
if SetSystemOverlay != "" {
|
||||
wwlog.Printf(wwlog.VERBOSE, "Node: %s, Setting system overlay to: %s\n", n.Fqdn.Get(), SetSystemOverlay)
|
||||
wwlog.Printf(wwlog.VERBOSE, "Node: %s, Setting system overlay to: %s\n", n.Id.Get(), SetSystemOverlay)
|
||||
|
||||
n.SystemOverlay.SetNode(SetSystemOverlay)
|
||||
err := nodeDB.NodeUpdate(n)
|
||||
if err != nil {
|
||||
wwlog.Printf(wwlog.ERROR, "%s\n", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
}
|
||||
if SetHostname != "" {
|
||||
wwlog.Printf(wwlog.VERBOSE, "Node: %s, Setting hostname to: %s\n", n.Fqdn.Get(), SetHostname)
|
||||
|
||||
n.HostName.SetNode(SetHostname)
|
||||
n.SystemOverlay.Set(SetSystemOverlay)
|
||||
err := nodeDB.NodeUpdate(n)
|
||||
if err != nil {
|
||||
wwlog.Printf(wwlog.ERROR, "%s\n", err)
|
||||
@@ -117,9 +117,9 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
|
||||
}
|
||||
}
|
||||
if SetIpmiIpaddr != "" {
|
||||
wwlog.Printf(wwlog.VERBOSE, "Node: %s, Setting IPMI IP address to: %s\n", n.Fqdn.Get(), SetIpmiIpaddr)
|
||||
wwlog.Printf(wwlog.VERBOSE, "Node: %s, Setting IPMI IP address to: %s\n", n.Id.Get(), SetIpmiIpaddr)
|
||||
|
||||
n.IpmiIpaddr.SetNode(SetIpmiIpaddr)
|
||||
n.IpmiIpaddr.Set(SetIpmiIpaddr)
|
||||
err := nodeDB.NodeUpdate(n)
|
||||
if err != nil {
|
||||
wwlog.Printf(wwlog.ERROR, "%s\n", err)
|
||||
@@ -127,9 +127,9 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
|
||||
}
|
||||
}
|
||||
if SetIpmiNetmask != "" {
|
||||
wwlog.Printf(wwlog.VERBOSE, "Node: %s, Setting IPMI netmask to: %s\n", n.Fqdn.Get(), SetIpmiNetmask)
|
||||
wwlog.Printf(wwlog.VERBOSE, "Node: %s, Setting IPMI netmask to: %s\n", n.Id.Get(), SetIpmiNetmask)
|
||||
|
||||
n.IpmiNetmask.SetNode(SetIpmiNetmask)
|
||||
n.IpmiNetmask.Set(SetIpmiNetmask)
|
||||
err := nodeDB.NodeUpdate(n)
|
||||
if err != nil {
|
||||
wwlog.Printf(wwlog.ERROR, "%s\n", err)
|
||||
@@ -137,9 +137,9 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
|
||||
}
|
||||
}
|
||||
if SetIpmiUsername != "" {
|
||||
wwlog.Printf(wwlog.VERBOSE, "Node: %s, Setting IPMI IP username to: %s\n", n.Fqdn.Get(), SetIpmiUsername)
|
||||
wwlog.Printf(wwlog.VERBOSE, "Node: %s, Setting IPMI IP username to: %s\n", n.Id.Get(), SetIpmiUsername)
|
||||
|
||||
n.IpmiUserName.SetNode(SetIpmiUsername)
|
||||
n.IpmiUserName.Set(SetIpmiUsername)
|
||||
err := nodeDB.NodeUpdate(n)
|
||||
if err != nil {
|
||||
wwlog.Printf(wwlog.ERROR, "%s\n", err)
|
||||
@@ -147,9 +147,9 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
|
||||
}
|
||||
}
|
||||
if SetIpmiPassword != "" {
|
||||
wwlog.Printf(wwlog.VERBOSE, "Node: %s, Setting IPMI IP password to: %s\n", n.Fqdn.Get(), SetIpmiPassword)
|
||||
wwlog.Printf(wwlog.VERBOSE, "Node: %s, Setting IPMI IP password to: %s\n", n.Id.Get(), SetIpmiPassword)
|
||||
|
||||
n.IpmiPassword.SetNode(SetIpmiPassword)
|
||||
n.IpmiPassword.Set(SetIpmiPassword)
|
||||
err := nodeDB.NodeUpdate(n)
|
||||
if err != nil {
|
||||
wwlog.Printf(wwlog.ERROR, "%s\n", err)
|
||||
@@ -159,7 +159,7 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
|
||||
|
||||
if len(SetAddProfile) > 0 {
|
||||
for _, p := range SetAddProfile {
|
||||
wwlog.Printf(wwlog.VERBOSE, "Node: %s, adding profile to '%s'\n", n.Fqdn, p)
|
||||
wwlog.Printf(wwlog.VERBOSE, "Node: %s, adding profile to '%s'\n", n.Id.Get(), p)
|
||||
n.Profiles = util.SliceAddUniqueElement(n.Profiles, p)
|
||||
}
|
||||
err := nodeDB.NodeUpdate(n)
|
||||
@@ -170,7 +170,7 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
|
||||
}
|
||||
if len(SetDelProfile) > 0 {
|
||||
for _, p := range SetDelProfile {
|
||||
wwlog.Printf(wwlog.VERBOSE, "Node: %s, deleting profile from '%s'\n", n.Fqdn, p)
|
||||
wwlog.Printf(wwlog.VERBOSE, "Node: %s, deleting profile from '%s'\n", n.Id.Get(), p)
|
||||
n.Profiles = util.SliceRemoveElement(n.Profiles, p)
|
||||
}
|
||||
err := nodeDB.NodeUpdate(n)
|
||||
@@ -185,7 +185,7 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
|
||||
wwlog.Printf(wwlog.ERROR, "You must include the '--netdev' option\n")
|
||||
os.Exit(1)
|
||||
}
|
||||
wwlog.Printf(wwlog.VERBOSE, "Node: %s, Deleting network device: %s\n", n.Fqdn, SetNetDev)
|
||||
wwlog.Printf(wwlog.VERBOSE, "Node: %s, Deleting network device: %s\n", n.Id.Get(), SetNetDev)
|
||||
|
||||
if _, ok := n.NetDevs[SetNetDev]; !ok {
|
||||
wwlog.Printf(wwlog.ERROR, "Network Device doesn't exist: %s\n", SetNetDev)
|
||||
@@ -209,9 +209,9 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
|
||||
wwlog.Printf(wwlog.ERROR, "Network Device doesn't exist: %s\n", SetNetDev)
|
||||
os.Exit(1)
|
||||
}
|
||||
wwlog.Printf(wwlog.VERBOSE, "Node: %s:%s, Setting Ipaddr to: %s\n", n.Fqdn, SetNetDev, SetIpaddr)
|
||||
wwlog.Printf(wwlog.VERBOSE, "Node: %s:%s, Setting Ipaddr to: %s\n", n.Id.Get(), SetNetDev, SetIpaddr)
|
||||
|
||||
n.NetDevs[SetNetDev].Ipaddr = SetIpaddr
|
||||
n.NetDevs[SetNetDev].Ipaddr.Set(SetIpaddr)
|
||||
err := nodeDB.NodeUpdate(n)
|
||||
if err != nil {
|
||||
wwlog.Printf(wwlog.ERROR, "%s\n", err)
|
||||
@@ -228,9 +228,9 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
|
||||
wwlog.Printf(wwlog.ERROR, "Network Device doesn't exist: %s\n", SetNetDev)
|
||||
os.Exit(1)
|
||||
}
|
||||
wwlog.Printf(wwlog.VERBOSE, "Node: %s:%s, Setting netmask to: %s\n", n.Fqdn, SetNetDev, SetNetmask)
|
||||
wwlog.Printf(wwlog.VERBOSE, "Node: %s:%s, Setting netmask to: %s\n", n.Id.Get(), SetNetDev, SetNetmask)
|
||||
|
||||
n.NetDevs[SetNetDev].Netmask = SetNetmask
|
||||
n.NetDevs[SetNetDev].Netmask.Set(SetNetmask)
|
||||
err := nodeDB.NodeUpdate(n)
|
||||
if err != nil {
|
||||
wwlog.Printf(wwlog.ERROR, "%s\n", err)
|
||||
@@ -247,9 +247,9 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
|
||||
wwlog.Printf(wwlog.ERROR, "Network Device doesn't exist: %s\n", SetNetDev)
|
||||
os.Exit(1)
|
||||
}
|
||||
wwlog.Printf(wwlog.VERBOSE, "Node: %s:%s, Setting gateway to: %s\n", n.Fqdn, SetNetDev, SetGateway)
|
||||
wwlog.Printf(wwlog.VERBOSE, "Node: %s:%s, Setting gateway to: %s\n", n.Id.Get(), SetNetDev, SetGateway)
|
||||
|
||||
n.NetDevs[SetNetDev].Gateway = SetGateway
|
||||
n.NetDevs[SetNetDev].Gateway.Set(SetGateway)
|
||||
err := nodeDB.NodeUpdate(n)
|
||||
if err != nil {
|
||||
wwlog.Printf(wwlog.ERROR, "%s\n", err)
|
||||
@@ -266,9 +266,9 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
|
||||
wwlog.Printf(wwlog.ERROR, "Network Device doesn't exist: %s\n", SetNetDev)
|
||||
os.Exit(1)
|
||||
}
|
||||
wwlog.Printf(wwlog.VERBOSE, "Node: %s:%s, Setting HW address to: %s\n", n.Fqdn, SetNetDev, SetHwaddr)
|
||||
wwlog.Printf(wwlog.VERBOSE, "Node: %s:%s, Setting HW address to: %s\n", n.Id.Get(), SetNetDev, SetHwaddr)
|
||||
|
||||
n.NetDevs[SetNetDev].Hwaddr = SetHwaddr
|
||||
n.NetDevs[SetNetDev].Hwaddr.Set(SetHwaddr)
|
||||
err := nodeDB.NodeUpdate(n)
|
||||
if err != nil {
|
||||
wwlog.Printf(wwlog.ERROR, "%s\n", err)
|
||||
|
||||
@@ -9,6 +9,7 @@ var (
|
||||
Long: "Set node configurations ",
|
||||
RunE: CobraRunE,
|
||||
}
|
||||
SetComment string
|
||||
SetVnfs string
|
||||
SetKernel string
|
||||
SetNetDev string
|
||||
@@ -21,7 +22,6 @@ var (
|
||||
SetIpxe string
|
||||
SetRuntimeOverlay string
|
||||
SetSystemOverlay string
|
||||
SetHostname string
|
||||
SetIpmiIpaddr string
|
||||
SetIpmiNetmask string
|
||||
SetIpmiUsername string
|
||||
@@ -33,13 +33,13 @@ var (
|
||||
)
|
||||
|
||||
func init() {
|
||||
baseCmd.PersistentFlags().StringVarP(&SetComment, "comment", "C", "", "Set a comment for this node")
|
||||
baseCmd.PersistentFlags().StringVarP(&SetVnfs, "vnfs", "V", "", "Set node Virtual Node File System (VNFS)")
|
||||
baseCmd.PersistentFlags().StringVarP(&SetKernel, "kernel", "K", "", "Set Kernel version for nodes")
|
||||
baseCmd.PersistentFlags().StringVarP(&SetDomainName, "domain", "D", "", "Set the node's domain name")
|
||||
baseCmd.PersistentFlags().StringVarP(&SetIpxe, "ipxe", "P", "", "Set the node's iPXE template name")
|
||||
baseCmd.PersistentFlags().StringVarP(&SetRuntimeOverlay, "runtime", "R", "", "Set the node's runtime overlay")
|
||||
baseCmd.PersistentFlags().StringVarP(&SetSystemOverlay, "system", "S", "", "Set the node's system overlay")
|
||||
baseCmd.PersistentFlags().StringVarP(&SetHostname, "hostname", "N", "", "Set the node's hostname")
|
||||
baseCmd.PersistentFlags().StringVar(&SetIpmiIpaddr, "ipmi", "", "Set the node's IPMI IP address")
|
||||
baseCmd.PersistentFlags().StringVar(&SetIpmiNetmask, "ipminetmask", "", "Set the node's IPMI netmask")
|
||||
baseCmd.PersistentFlags().StringVar(&SetIpmiUsername, "ipmiuser", "", "Set the node's IPMI username")
|
||||
@@ -48,12 +48,12 @@ func init() {
|
||||
baseCmd.PersistentFlags().StringSliceVarP(&SetAddProfile, "addprofile", "p", []string{}, "Add Profile(s) to node")
|
||||
baseCmd.PersistentFlags().StringSliceVarP(&SetDelProfile, "delprofile", "r", []string{}, "Remove Profile(s) to node")
|
||||
|
||||
baseCmd.PersistentFlags().StringVarP(&SetNetDev, "netdev", "n", "", "Define the network device to configure")
|
||||
baseCmd.PersistentFlags().StringVarP(&SetNetDev, "netdev", "n", "eth0", "Define the network device to configure")
|
||||
baseCmd.PersistentFlags().StringVarP(&SetIpaddr, "ipaddr", "I", "", "Set the node's network device IP address")
|
||||
baseCmd.PersistentFlags().StringVarP(&SetNetmask, "netmask", "M", "", "Set the node's network device netmask")
|
||||
baseCmd.PersistentFlags().StringVarP(&SetGateway, "gateway", "G", "", "Set the node's network device gateway")
|
||||
baseCmd.PersistentFlags().StringVarP(&SetHwaddr, "hwaddr", "H", "", "Set the node's network device HW address")
|
||||
baseCmd.PersistentFlags().BoolVar(&SetNetDevDel, "delete", false, "Delete the node's network device")
|
||||
baseCmd.PersistentFlags().BoolVar(&SetNetDevDel, "netdel", false, "Delete the node's network device")
|
||||
baseCmd.PersistentFlags().BoolVarP(&SetNodeAll, "all", "a", false, "Set all nodes")
|
||||
|
||||
baseCmd.PersistentFlags().BoolVarP(&SetYes, "yes", "y", false, "Set 'yes' to all questions asked")
|
||||
|
||||
@@ -15,7 +15,7 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
|
||||
}
|
||||
|
||||
for _, p := range args {
|
||||
err = nodeDB.AddProfile(p)
|
||||
_, err := nodeDB.AddProfile(p)
|
||||
if err != nil {
|
||||
wwlog.Printf(wwlog.ERROR, "%s\n", err)
|
||||
os.Exit(1)
|
||||
@@ -25,4 +25,4 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
|
||||
nodeDB.Persist()
|
||||
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,7 +15,6 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
|
||||
var numNodes int
|
||||
var numGroups int
|
||||
|
||||
|
||||
nodeDB, err := node.New()
|
||||
if err != nil {
|
||||
wwlog.Printf(wwlog.ERROR, "Failed to open node database: %s\n", err)
|
||||
@@ -27,12 +26,6 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
|
||||
wwlog.Printf(wwlog.ERROR, "Could not load all nodes: %s\n", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
groups, err := nodeDB.FindAllGroups()
|
||||
if err != nil {
|
||||
wwlog.Printf(wwlog.ERROR, "Could not load all groups: %s\n", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
|
||||
for _, p := range args {
|
||||
err := nodeDB.DelProfile(p)
|
||||
@@ -44,22 +37,12 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
|
||||
for _, np := range n.Profiles {
|
||||
if np == p {
|
||||
numNodes++
|
||||
wwlog.Printf(wwlog.VERBOSE, "Removing profile from node %s: %s\n", n.Fqdn.Get(), p)
|
||||
wwlog.Printf(wwlog.VERBOSE, "Removing profile from node %s: %s\n", n.Id.Get(), p)
|
||||
n.Profiles = util.SliceRemoveElement(n.Profiles, p)
|
||||
nodeDB.NodeUpdate(n)
|
||||
}
|
||||
}
|
||||
}
|
||||
for _, g := range groups {
|
||||
for _, np := range g.Profiles {
|
||||
if np == p {
|
||||
numGroups++
|
||||
wwlog.Printf(wwlog.VERBOSE, "Removing profile from group %s: %s\n", g.Id, p)
|
||||
g.Profiles = util.SliceRemoveElement(g.Profiles, p)
|
||||
nodeDB.GroupUpdate(g)
|
||||
}
|
||||
}
|
||||
}
|
||||
count++
|
||||
}
|
||||
|
||||
|
||||
@@ -6,7 +6,6 @@ import (
|
||||
"github.com/hpcng/warewulf/internal/pkg/wwlog"
|
||||
"github.com/spf13/cobra"
|
||||
"os"
|
||||
"reflect"
|
||||
)
|
||||
|
||||
func CobraRunE(cmd *cobra.Command, args []string) error {
|
||||
@@ -23,14 +22,30 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
for _, group := range profiles {
|
||||
v := reflect.ValueOf(group)
|
||||
typeOfS := v.Type()
|
||||
for _, node := range profiles {
|
||||
fmt.Printf("################################################################################\n")
|
||||
for i := 0; i< v.NumField(); i++ {
|
||||
fmt.Printf("%-25s %s = %v\n", group.Id, typeOfS.Field(i).Name, v.Field(i).Interface())
|
||||
fmt.Printf("%-20s %-18s: %s\n", node.Id.Get(), "Id", node.Id.Print())
|
||||
fmt.Printf("%-20s %-18s: %s\n", node.Id.Get(), "Comment", node.Comment.Print())
|
||||
|
||||
fmt.Printf("%-20s %-18s: %s\n", node.Id.Get(), "Vnfs", node.Vnfs.Print())
|
||||
fmt.Printf("%-20s %-18s: %s\n", node.Id.Get(), "KernelVersion", node.KernelVersion.Print())
|
||||
fmt.Printf("%-20s %-18s: %s\n", node.Id.Get(), "KernelArgs", node.KernelArgs.Print())
|
||||
fmt.Printf("%-20s %-18s: %s\n", node.Id.Get(), "RuntimeOverlay", node.RuntimeOverlay.Print())
|
||||
fmt.Printf("%-20s %-18s: %s\n", node.Id.Get(), "SystemOverlay", node.SystemOverlay.Print())
|
||||
fmt.Printf("%-20s %-18s: %s\n", node.Id.Get(), "Ipxe", node.Ipxe.Print())
|
||||
fmt.Printf("%-20s %-18s: %s\n", node.Id.Get(), "IpmiIpaddr", node.IpmiIpaddr.Print())
|
||||
fmt.Printf("%-20s %-18s: %s\n", node.Id.Get(), "IpmiNetmask", node.IpmiNetmask.Print())
|
||||
fmt.Printf("%-20s %-18s: %s\n", node.Id.Get(), "IpmiUserName", node.IpmiUserName.Print())
|
||||
|
||||
for name, netdev := range node.NetDevs {
|
||||
fmt.Printf("%-20s %-18s: %s\n", node.Id.Get(), name+":IPADDR", netdev.Ipaddr.Get())
|
||||
fmt.Printf("%-20s %-18s: %s\n", node.Id.Get(), name+":NETMASK", netdev.Netmask.Get())
|
||||
fmt.Printf("%-20s %-18s: %s\n", node.Id.Get(), name+":GATEWAY", netdev.Gateway.Get())
|
||||
fmt.Printf("%-20s %-18s: %s\n", node.Id.Get(), name+":HWADDR", netdev.Hwaddr.Get())
|
||||
fmt.Printf("%-20s %-18s: %s\n", node.Id.Get(), name+":TYPE", netdev.Hwaddr.Get())
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@ import (
|
||||
|
||||
func CobraRunE(cmd *cobra.Command, args []string) error {
|
||||
var err error
|
||||
var profiles []node.ProfileInfo
|
||||
var profiles []node.NodeInfo
|
||||
|
||||
nodeDB, err := node.New()
|
||||
if err != nil {
|
||||
@@ -19,29 +19,18 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
wwlog.Printf(wwlog.ERROR, "Cloud not get nodeList: %s\n", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
if len(args) == 0 {
|
||||
args = append(args, "default")
|
||||
}
|
||||
|
||||
if SetAll == true {
|
||||
var tmp []node.ProfileInfo
|
||||
tmp, err = nodeDB.FindAllProfiles()
|
||||
profiles, err = nodeDB.FindAllProfiles()
|
||||
if err != nil {
|
||||
wwlog.Printf(wwlog.ERROR, "%s\n", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
for _, p := range tmp {
|
||||
profiles = append(profiles, p)
|
||||
}
|
||||
|
||||
} else {
|
||||
var tmp []node.ProfileInfo
|
||||
var tmp []node.NodeInfo
|
||||
tmp, err = nodeDB.FindAllProfiles()
|
||||
if err != nil {
|
||||
wwlog.Printf(wwlog.ERROR, "%s\n", err)
|
||||
@@ -50,7 +39,7 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
|
||||
|
||||
for _, a := range args {
|
||||
for _, p := range tmp {
|
||||
if p.Id == a {
|
||||
if p.Id.Get() == a {
|
||||
profiles = append(profiles, p)
|
||||
}
|
||||
}
|
||||
@@ -59,10 +48,20 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
|
||||
|
||||
for _, p := range profiles {
|
||||
|
||||
if SetComment != "" {
|
||||
wwlog.Printf(wwlog.VERBOSE, "Profile: %s, Setting comment to: %s\n", p.Id, SetComment)
|
||||
|
||||
p.Comment.Set(SetComment)
|
||||
err := nodeDB.ProfileUpdate(p)
|
||||
if err != nil {
|
||||
wwlog.Printf(wwlog.ERROR, "%s\n", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
}
|
||||
if SetDomainName != "" {
|
||||
wwlog.Printf(wwlog.VERBOSE, "Profile: %s, Setting domain name to: %s\n", p.Id, SetDomainName)
|
||||
|
||||
p.DomainName = SetDomainName
|
||||
p.DomainName.Set(SetDomainName)
|
||||
err := nodeDB.ProfileUpdate(p)
|
||||
if err != nil {
|
||||
wwlog.Printf(wwlog.ERROR, "%s\n", err)
|
||||
@@ -72,7 +71,7 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
|
||||
if SetVnfs != "" {
|
||||
wwlog.Printf(wwlog.VERBOSE, "Profile: %s, Setting VNFS to: %s\n", p.Id, SetVnfs)
|
||||
|
||||
p.Vnfs = SetVnfs
|
||||
p.Vnfs.Set(SetVnfs)
|
||||
err := nodeDB.ProfileUpdate(p)
|
||||
if err != nil {
|
||||
wwlog.Printf(wwlog.ERROR, "%s\n", err)
|
||||
@@ -82,7 +81,7 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
|
||||
if SetKernel != "" {
|
||||
wwlog.Printf(wwlog.VERBOSE, "Profile: %s, Setting Kernel version to: %s\n", p.Id, SetKernel)
|
||||
|
||||
p.KernelVersion = SetKernel
|
||||
p.KernelVersion.Set(SetKernel)
|
||||
err := nodeDB.ProfileUpdate(p)
|
||||
if err != nil {
|
||||
wwlog.Printf(wwlog.ERROR, "%s\n", err)
|
||||
@@ -92,7 +91,7 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
|
||||
if SetIpxe != "" {
|
||||
wwlog.Printf(wwlog.VERBOSE, "Profile: %s, Setting iPXE template to: %s\n", p.Id, SetIpxe)
|
||||
|
||||
p.Ipxe = SetIpxe
|
||||
p.Ipxe.Set(SetIpxe)
|
||||
err := nodeDB.ProfileUpdate(p)
|
||||
if err != nil {
|
||||
wwlog.Printf(wwlog.ERROR, "%s\n", err)
|
||||
@@ -102,7 +101,7 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
|
||||
if SetRuntimeOverlay != "" {
|
||||
wwlog.Printf(wwlog.VERBOSE, "Profile: %s, Setting runtime overlay to: %s\n", p.Id, SetRuntimeOverlay)
|
||||
|
||||
p.RuntimeOverlay = SetRuntimeOverlay
|
||||
p.RuntimeOverlay.Set(SetRuntimeOverlay)
|
||||
err := nodeDB.ProfileUpdate(p)
|
||||
if err != nil {
|
||||
wwlog.Printf(wwlog.ERROR, "%s\n", err)
|
||||
@@ -112,7 +111,7 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
|
||||
if SetSystemOverlay != "" {
|
||||
wwlog.Printf(wwlog.VERBOSE, "Profile: %s, Setting system overlay to: %s\n", p.Id, SetSystemOverlay)
|
||||
|
||||
p.SystemOverlay = SetSystemOverlay
|
||||
p.SystemOverlay.Set(SetSystemOverlay)
|
||||
err := nodeDB.ProfileUpdate(p)
|
||||
if err != nil {
|
||||
wwlog.Printf(wwlog.ERROR, "%s\n", err)
|
||||
@@ -122,7 +121,7 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
|
||||
if SetIpmiNetmask != "" {
|
||||
wwlog.Printf(wwlog.VERBOSE, "Profile: %s, Setting IPMI username to: %s\n", p.Id, SetIpmiNetmask)
|
||||
|
||||
p.IpmiNetmask = SetIpmiNetmask
|
||||
p.IpmiNetmask.Set(SetIpmiNetmask)
|
||||
err := nodeDB.ProfileUpdate(p)
|
||||
if err != nil {
|
||||
wwlog.Printf(wwlog.ERROR, "%s\n", err)
|
||||
@@ -132,7 +131,7 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
|
||||
if SetIpmiUsername != "" {
|
||||
wwlog.Printf(wwlog.VERBOSE, "Profile: %s, Setting IPMI username to: %s\n", p.Id, SetIpmiUsername)
|
||||
|
||||
p.IpmiUserName = SetIpmiUsername
|
||||
p.IpmiUserName.Set(SetIpmiUsername)
|
||||
err := nodeDB.ProfileUpdate(p)
|
||||
if err != nil {
|
||||
wwlog.Printf(wwlog.ERROR, "%s\n", err)
|
||||
@@ -142,7 +141,7 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
|
||||
if SetIpmiPassword != "" {
|
||||
wwlog.Printf(wwlog.VERBOSE, "Profile: %s, Setting IPMI username to: %s\n", p.Id, SetIpmiPassword)
|
||||
|
||||
p.IpmiPassword = SetIpmiPassword
|
||||
p.IpmiPassword.Set(SetIpmiPassword)
|
||||
err := nodeDB.ProfileUpdate(p)
|
||||
if err != nil {
|
||||
wwlog.Printf(wwlog.ERROR, "%s\n", err)
|
||||
|
||||
@@ -10,6 +10,7 @@ var (
|
||||
RunE: CobraRunE,
|
||||
}
|
||||
SetAll bool
|
||||
SetComment string
|
||||
SetVnfs string
|
||||
SetKernel string
|
||||
SetDomainName string
|
||||
@@ -22,6 +23,7 @@ var (
|
||||
)
|
||||
|
||||
func init() {
|
||||
baseCmd.PersistentFlags().StringVarP(&SetComment, "comment", "C", "", "Set a comment for this node")
|
||||
baseCmd.PersistentFlags().StringVarP(&SetVnfs, "vnfs", "V", "", "Set node Virtual Node File System (VNFS)")
|
||||
baseCmd.PersistentFlags().StringVarP(&SetKernel, "kernel", "K", "", "Set Kernel version for nodes")
|
||||
baseCmd.PersistentFlags().StringVarP(&SetDomainName, "domain", "D", "", "Set the node's domain name")
|
||||
|
||||
@@ -42,11 +42,11 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
|
||||
vnfs_good = true
|
||||
} else {
|
||||
status = false
|
||||
wwlog.Printf(wwlog.VERBOSE, "VNFS not found: %s, %s\n", node.Fqdn.Get(), v.Source)
|
||||
wwlog.Printf(wwlog.VERBOSE, "VNFS not found: %s, %s\n", node.Id.Get(), v.Source)
|
||||
}
|
||||
} else {
|
||||
status = false
|
||||
wwlog.Printf(wwlog.VERBOSE, "Node Kernel not defined: %s\n", node.Fqdn.Get())
|
||||
wwlog.Printf(wwlog.VERBOSE, "Node Kernel not defined: %s\n", node.Id.Get())
|
||||
}
|
||||
|
||||
if node.KernelVersion.Get() != "" {
|
||||
@@ -54,44 +54,44 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
|
||||
kernel_good = true
|
||||
} else {
|
||||
status = false
|
||||
wwlog.Printf(wwlog.VERBOSE, "Node Kernel not found: %s, %s\n", node.Fqdn.Get(), node.KernelVersion.Get())
|
||||
wwlog.Printf(wwlog.VERBOSE, "Node Kernel not found: %s, %s\n", node.Id.Get(), node.KernelVersion.Get())
|
||||
}
|
||||
if util.IsFile(config.KmodsImage(node.KernelVersion.Get())) == true {
|
||||
kmods_good = true
|
||||
} else {
|
||||
status = false
|
||||
wwlog.Printf(wwlog.VERBOSE, "Node Kmods not found: %s, %s\n", node.Fqdn.Get(), node.KernelVersion.Get())
|
||||
wwlog.Printf(wwlog.VERBOSE, "Node Kmods not found: %s, %s\n", node.Id.Get(), node.KernelVersion.Get())
|
||||
}
|
||||
} else {
|
||||
status = false
|
||||
wwlog.Printf(wwlog.VERBOSE, "Node Kernel version not defined: %s\n", node.Fqdn.Get())
|
||||
wwlog.Printf(wwlog.VERBOSE, "Node Kernel version not defined: %s\n", node.Id.Get())
|
||||
}
|
||||
|
||||
if node.SystemOverlay.Get() != "" {
|
||||
if util.IsFile(config.SystemOverlayImage(node.Fqdn.Get())) == true {
|
||||
if util.IsFile(config.SystemOverlayImage(node.Id.Get())) == true {
|
||||
systemo_good = true
|
||||
} else {
|
||||
status = false
|
||||
wwlog.Printf(wwlog.VERBOSE, "System Overlay not found: %s\n", config.SystemOverlayImage(node.Fqdn.Get()))
|
||||
wwlog.Printf(wwlog.VERBOSE, "System Overlay not found: %s\n", config.SystemOverlayImage(node.Id.Get()))
|
||||
}
|
||||
} else {
|
||||
status = false
|
||||
wwlog.Printf(wwlog.VERBOSE, "System Overlay not defined: %s\n", node.Fqdn.Get())
|
||||
wwlog.Printf(wwlog.VERBOSE, "System Overlay not defined: %s\n", node.Id.Get())
|
||||
}
|
||||
|
||||
if node.RuntimeOverlay.Get() != "" {
|
||||
if util.IsFile(config.RuntimeOverlayImage(node.Fqdn.Get())) == true {
|
||||
if util.IsFile(config.RuntimeOverlayImage(node.Id.Get())) == true {
|
||||
runtimeo_good = true
|
||||
} else {
|
||||
status = false
|
||||
wwlog.Printf(wwlog.VERBOSE, "Runtime Overlay not found: %s\n", config.RuntimeOverlaySource(node.Fqdn.Get()))
|
||||
wwlog.Printf(wwlog.VERBOSE, "Runtime Overlay not found: %s\n", config.RuntimeOverlaySource(node.Id.Get()))
|
||||
}
|
||||
} else {
|
||||
status = false
|
||||
wwlog.Printf(wwlog.VERBOSE, "Runtime Overlay not defined: %s\n", node.Fqdn.Get())
|
||||
wwlog.Printf(wwlog.VERBOSE, "Runtime Overlay not defined: %s\n", node.Id.Get())
|
||||
}
|
||||
|
||||
fmt.Printf("%-25s %-10t %-6t %-6t %-6t %-6t %-6t\n", node.Fqdn.Get(), status, vnfs_good, kernel_good, kmods_good, systemo_good, runtimeo_good)
|
||||
fmt.Printf("%-25s %-10t %-6t %-6t %-6t %-6t %-6t\n", node.Id.Get(), status, vnfs_good, kernel_good, kmods_good, systemo_good, runtimeo_good)
|
||||
}
|
||||
|
||||
return nil
|
||||
|
||||
@@ -1,14 +1,11 @@
|
||||
package wwctl
|
||||
|
||||
import (
|
||||
"github.com/hpcng/warewulf/internal/app/wwctl/controller"
|
||||
"github.com/hpcng/warewulf/internal/app/wwctl/group"
|
||||
"github.com/hpcng/warewulf/internal/app/wwctl/kernel"
|
||||
"github.com/hpcng/warewulf/internal/app/wwctl/node"
|
||||
"github.com/hpcng/warewulf/internal/app/wwctl/overlay"
|
||||
"github.com/hpcng/warewulf/internal/app/wwctl/profile"
|
||||
"github.com/hpcng/warewulf/internal/app/wwctl/ready"
|
||||
"github.com/hpcng/warewulf/internal/app/wwctl/service"
|
||||
"github.com/hpcng/warewulf/internal/app/wwctl/vnfs"
|
||||
|
||||
"github.com/hpcng/warewulf/internal/pkg/wwlog"
|
||||
@@ -33,13 +30,13 @@ func init() {
|
||||
//rootCmd.AddCommand(build.GetCommand())
|
||||
|
||||
rootCmd.AddCommand(overlay.GetCommand())
|
||||
rootCmd.AddCommand(controller.GetCommand())
|
||||
// rootCmd.AddCommand(controller.GetCommand())
|
||||
rootCmd.AddCommand(vnfs.GetCommand())
|
||||
rootCmd.AddCommand(node.GetCommand())
|
||||
rootCmd.AddCommand(kernel.GetCommand())
|
||||
rootCmd.AddCommand(group.GetCommand())
|
||||
// rootCmd.AddCommand(group.GetCommand())
|
||||
rootCmd.AddCommand(profile.GetCommand())
|
||||
rootCmd.AddCommand(service.GetCommand())
|
||||
// rootCmd.AddCommand(service.GetCommand())
|
||||
rootCmd.AddCommand(ready.GetCommand())
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user