Fixup for node command
This commit is contained in:
@@ -40,7 +40,7 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
|
|||||||
fmt.Printf("################################################################################\n")
|
fmt.Printf("################################################################################\n")
|
||||||
for i := 0; i< v.NumField(); i++ {
|
for i := 0; i< v.NumField(); i++ {
|
||||||
//TODO: Fix for NetDevs and Interface should print Fprint() method
|
//TODO: Fix for NetDevs and Interface should print Fprint() method
|
||||||
fmt.Printf("%-25s %s = %v\n", node.Fqdn.String(), typeOfS.Field(i).Name, v.Field(i).Interface())
|
fmt.Printf("%-25s %s = %#v\n", node.Fqdn.Get(), typeOfS.Field(i).Name, v.Field(i).Interface())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -51,10 +51,10 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
|
|||||||
for _, node := range nodes {
|
for _, node := range nodes {
|
||||||
if len(node.NetDevs) > 0 {
|
if len(node.NetDevs) > 0 {
|
||||||
for name, dev := range node.NetDevs {
|
for name, dev := range node.NetDevs {
|
||||||
fmt.Printf("%-22s %-6s %-18s %-15s %-15s\n", node.Fqdn.String(), name, dev.Hwaddr, dev.Ipaddr, dev.Gateway)
|
fmt.Printf("%-22s %-6s %-18s %-15s %-15s\n", node.Fqdn.Get(), name, dev.Hwaddr, dev.Ipaddr, dev.Gateway)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
fmt.Printf("%-22s %-6s %-18s %-15s %-15s\n", node.Fqdn.String(), "--", "--", "--", "--")
|
fmt.Printf("%-22s %-6s %-18s %-15s %-15s\n", node.Fqdn.Get(), "--", "--", "--", "--")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -63,7 +63,7 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
|
|||||||
fmt.Println(strings.Repeat("=", 80))
|
fmt.Println(strings.Repeat("=", 80))
|
||||||
|
|
||||||
for _, node := range nodes {
|
for _, node := range nodes {
|
||||||
fmt.Printf("%-22s %-16s %-20s %-20s\n", node.Fqdn.String(), node.IpmiIpaddr.Fprint(), node.IpmiUserName.Fprint(), node.IpmiPassword.Fprint())
|
fmt.Printf("%-22s %-16s %-20s %-20s\n", node.Fqdn.Get(), node.IpmiIpaddr.Get(), node.IpmiUserName.Get(), node.IpmiPassword.Get())
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if ShowLong == true {
|
} else if ShowLong == true {
|
||||||
@@ -71,15 +71,15 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
|
|||||||
fmt.Println(strings.Repeat("=", 120))
|
fmt.Println(strings.Repeat("=", 120))
|
||||||
|
|
||||||
for _, node := range nodes {
|
for _, node := range nodes {
|
||||||
fmt.Printf("%-22s %-12s %-26s %-35s %s\n", node.Fqdn.String(), node.GroupName.Fprint(), node.KernelVersion.Fprint(), node.Vnfs.Fprint(), node.SystemOverlay.Fprint() +"/"+ node.RuntimeOverlay.Fprint())
|
fmt.Printf("%-22s %-12s %-26s %-35s %s\n", node.Fqdn.Get(), node.GroupName.Get(), node.KernelVersion.Get(), node.Vnfs.Get(), node.SystemOverlay.Get() +"/"+ node.RuntimeOverlay.Get())
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
fmt.Printf("%-22s %-26s %-30s\n", "NODE NAME", "KERNEL VERSION", "VNFS IMAGE")
|
fmt.Printf("%-22s %s\n", "NODE NAME", "PROFILES")
|
||||||
fmt.Println(strings.Repeat("=", 80))
|
fmt.Println(strings.Repeat("=", 80))
|
||||||
|
|
||||||
for _, node := range nodes {
|
for _, node := range nodes {
|
||||||
fmt.Printf("%-22s %-26s %-30s\n", node.Fqdn.String(), node.KernelVersion.Fprint(), node.Vnfs.Fprint())
|
fmt.Printf("%-22s %s\n", node.Fqdn.Get(), append(node.GroupProfiles, node.Profiles...))
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -46,7 +46,9 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
|
|||||||
wwlog.Printf(wwlog.VERBOSE, "Evaluating node: %s\n", n.Fqdn.String())
|
wwlog.Printf(wwlog.VERBOSE, "Evaluating node: %s\n", n.Fqdn.String())
|
||||||
if SetVnfs != "" {
|
if SetVnfs != "" {
|
||||||
wwlog.Printf(wwlog.VERBOSE, "Node: %s, Setting vnfs to: %s\n", n.Fqdn.String(), SetVnfs)
|
wwlog.Printf(wwlog.VERBOSE, "Node: %s, Setting vnfs to: %s\n", n.Fqdn.String(), SetVnfs)
|
||||||
err := nodeDB.SetNodeVal(n.Gid.String(), n.Id.String(), "vnfs", SetVnfs)
|
|
||||||
|
n.Vnfs.Set(SetVnfs)
|
||||||
|
err := nodeDB.NodeUpdate(n)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
wwlog.Printf(wwlog.ERROR, "%s\n", err)
|
wwlog.Printf(wwlog.ERROR, "%s\n", err)
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
@@ -54,7 +56,9 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
|
|||||||
}
|
}
|
||||||
if SetKernel != "" {
|
if SetKernel != "" {
|
||||||
wwlog.Printf(wwlog.VERBOSE, "Node: %s, Setting kernel to: %s\n", n.Fqdn.String(), SetKernel)
|
wwlog.Printf(wwlog.VERBOSE, "Node: %s, Setting kernel to: %s\n", n.Fqdn.String(), SetKernel)
|
||||||
err := nodeDB.SetNodeVal(n.Gid.String(), n.Id.String(), "kernel", SetKernel)
|
|
||||||
|
n.KernelVersion.Set(SetKernel)
|
||||||
|
err := nodeDB.NodeUpdate(n)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
wwlog.Printf(wwlog.ERROR, "%s\n", err)
|
wwlog.Printf(wwlog.ERROR, "%s\n", err)
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
@@ -62,7 +66,9 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
|
|||||||
}
|
}
|
||||||
if SetDomainName != "" {
|
if SetDomainName != "" {
|
||||||
wwlog.Printf(wwlog.VERBOSE, "Node: %s, Setting domain name to: %s\n", n.Fqdn, SetDomainName)
|
wwlog.Printf(wwlog.VERBOSE, "Node: %s, Setting domain name to: %s\n", n.Fqdn, SetDomainName)
|
||||||
err := nodeDB.SetNodeVal(n.Gid.String(), n.Id.String(), "domain", SetDomainName)
|
|
||||||
|
n.DomainName.Set(SetDomainName)
|
||||||
|
err := nodeDB.NodeUpdate(n)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
wwlog.Printf(wwlog.ERROR, "%s\n", err)
|
wwlog.Printf(wwlog.ERROR, "%s\n", err)
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
@@ -70,7 +76,9 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
|
|||||||
}
|
}
|
||||||
if SetIpxe != "" {
|
if SetIpxe != "" {
|
||||||
wwlog.Printf(wwlog.VERBOSE, "Node: %s, Setting iPXE template to: %s\n", n.Fqdn, SetIpxe)
|
wwlog.Printf(wwlog.VERBOSE, "Node: %s, Setting iPXE template to: %s\n", n.Fqdn, SetIpxe)
|
||||||
err := nodeDB.SetNodeVal(n.Gid.String(), n.Id.String(), "ipxe", SetIpxe)
|
|
||||||
|
n.Ipxe.Set(SetIpxe)
|
||||||
|
err := nodeDB.NodeUpdate(n)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
wwlog.Printf(wwlog.ERROR, "%s\n", err)
|
wwlog.Printf(wwlog.ERROR, "%s\n", err)
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
@@ -78,7 +86,9 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
|
|||||||
}
|
}
|
||||||
if SetRuntimeOverlay != "" {
|
if SetRuntimeOverlay != "" {
|
||||||
wwlog.Printf(wwlog.VERBOSE, "Node: %s, Setting runtime overlay to: %s\n", n.Fqdn, SetRuntimeOverlay)
|
wwlog.Printf(wwlog.VERBOSE, "Node: %s, Setting runtime overlay to: %s\n", n.Fqdn, SetRuntimeOverlay)
|
||||||
err := nodeDB.SetNodeVal(n.Gid.String(), n.Id.String(), "runtimeoverlay", SetRuntimeOverlay)
|
|
||||||
|
n.RuntimeOverlay.Set(SetRuntimeOverlay)
|
||||||
|
err := nodeDB.NodeUpdate(n)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
wwlog.Printf(wwlog.ERROR, "%s\n", err)
|
wwlog.Printf(wwlog.ERROR, "%s\n", err)
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
@@ -86,7 +96,9 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
|
|||||||
}
|
}
|
||||||
if SetSystemOverlay != "" {
|
if SetSystemOverlay != "" {
|
||||||
wwlog.Printf(wwlog.VERBOSE, "Node: %s, Setting system overlay to: %s\n", n.Fqdn, SetSystemOverlay)
|
wwlog.Printf(wwlog.VERBOSE, "Node: %s, Setting system overlay to: %s\n", n.Fqdn, SetSystemOverlay)
|
||||||
err := nodeDB.SetNodeVal(n.Gid.String(), n.Id.String(), "systemoverlay", SetSystemOverlay)
|
|
||||||
|
n.SystemOverlay.Set(SetSystemOverlay)
|
||||||
|
err := nodeDB.NodeUpdate(n)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
wwlog.Printf(wwlog.ERROR, "%s\n", err)
|
wwlog.Printf(wwlog.ERROR, "%s\n", err)
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
@@ -94,7 +106,9 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
|
|||||||
}
|
}
|
||||||
if SetHostname != "" {
|
if SetHostname != "" {
|
||||||
wwlog.Printf(wwlog.VERBOSE, "Node: %s, Setting hostname to: %s\n", n.Fqdn, SetHostname)
|
wwlog.Printf(wwlog.VERBOSE, "Node: %s, Setting hostname to: %s\n", n.Fqdn, SetHostname)
|
||||||
err := nodeDB.SetNodeVal(n.Gid.String(), n.Id.String(), "hostname", SetHostname)
|
|
||||||
|
n.HostName.Set(SetHostname)
|
||||||
|
err := nodeDB.NodeUpdate(n)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
wwlog.Printf(wwlog.ERROR, "%s\n", err)
|
wwlog.Printf(wwlog.ERROR, "%s\n", err)
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
@@ -102,7 +116,9 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
|
|||||||
}
|
}
|
||||||
if SetIpmiIpaddr != "" {
|
if SetIpmiIpaddr != "" {
|
||||||
wwlog.Printf(wwlog.VERBOSE, "Node: %s, Setting IPMI IP address to: %s\n", n.Fqdn, SetIpmiIpaddr)
|
wwlog.Printf(wwlog.VERBOSE, "Node: %s, Setting IPMI IP address to: %s\n", n.Fqdn, SetIpmiIpaddr)
|
||||||
err := nodeDB.SetNodeVal(n.Gid.String(), n.Id.String(), "ipmiipaddr", SetIpmiIpaddr)
|
|
||||||
|
n.IpmiIpaddr.Set(SetIpmiIpaddr)
|
||||||
|
err := nodeDB.NodeUpdate(n)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
wwlog.Printf(wwlog.ERROR, "%s\n", err)
|
wwlog.Printf(wwlog.ERROR, "%s\n", err)
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
@@ -110,7 +126,9 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
|
|||||||
}
|
}
|
||||||
if SetIpmiUsername != "" {
|
if SetIpmiUsername != "" {
|
||||||
wwlog.Printf(wwlog.VERBOSE, "Node: %s, Setting IPMI IP username to: %s\n", n.Fqdn, SetIpmiUsername)
|
wwlog.Printf(wwlog.VERBOSE, "Node: %s, Setting IPMI IP username to: %s\n", n.Fqdn, SetIpmiUsername)
|
||||||
err := nodeDB.SetNodeVal(n.Gid.String(), n.Id.String(), "ipmiusername", SetIpmiUsername)
|
|
||||||
|
n.IpmiUserName.Set(SetIpmiUsername)
|
||||||
|
err := nodeDB.NodeUpdate(n)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
wwlog.Printf(wwlog.ERROR, "%s\n", err)
|
wwlog.Printf(wwlog.ERROR, "%s\n", err)
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
@@ -118,7 +136,9 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
|
|||||||
}
|
}
|
||||||
if SetIpmiPassword != "" {
|
if SetIpmiPassword != "" {
|
||||||
wwlog.Printf(wwlog.VERBOSE, "Node: %s, Setting IPMI IP password to: %s\n", n.Fqdn, SetIpmiPassword)
|
wwlog.Printf(wwlog.VERBOSE, "Node: %s, Setting IPMI IP password to: %s\n", n.Fqdn, SetIpmiPassword)
|
||||||
err := nodeDB.SetNodeVal(n.Gid.String(), n.Id.String(), "ipmipassword", SetIpmiPassword)
|
|
||||||
|
n.IpmiPassword.Set(SetIpmiPassword)
|
||||||
|
err := nodeDB.NodeUpdate(n)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
wwlog.Printf(wwlog.ERROR, "%s\n", err)
|
wwlog.Printf(wwlog.ERROR, "%s\n", err)
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
@@ -133,20 +153,33 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
|
|||||||
os.Exit(1)
|
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.Fqdn, SetNetDev)
|
||||||
err := nodeDB.DelNodeNet(n.Gid.String(), n.Id.String(), SetNetDev)
|
|
||||||
|
if _, ok := n.NetDevs[SetNetDev]; !ok {
|
||||||
|
wwlog.Printf(wwlog.ERROR, "Network Device doesn't exist: %s\n", SetNetDev)
|
||||||
|
os.Exit(1)
|
||||||
|
}
|
||||||
|
|
||||||
|
delete(n.NetDevs, SetNetDev)
|
||||||
|
err := nodeDB.NodeUpdate(n)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
wwlog.Printf(wwlog.ERROR, "%s\n", err)
|
wwlog.Printf(wwlog.ERROR, "%s\n", err)
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
if SetIpaddr != "" {
|
if SetIpaddr != "" {
|
||||||
if SetNetDev == "" {
|
if SetNetDev == "" {
|
||||||
wwlog.Printf(wwlog.ERROR, "You must include the '--netdev' option\n")
|
wwlog.Printf(wwlog.ERROR, "You must include the '--netdev' option\n")
|
||||||
os.Exit(1)
|
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 Ipaddr to: %s\n", n.Fqdn, SetNetDev, SetIpaddr)
|
wwlog.Printf(wwlog.VERBOSE, "Node: %s:%s, Setting Ipaddr to: %s\n", n.Fqdn, SetNetDev, SetIpaddr)
|
||||||
err := nodeDB.SetNodeNet(n.Gid.String(), n.Id.String(), SetNetDev, "ipaddr", SetIpaddr)
|
|
||||||
|
n.NetDevs[SetNetDev].Ipaddr = SetIpaddr
|
||||||
|
err := nodeDB.NodeUpdate(n)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
wwlog.Printf(wwlog.ERROR, "%s\n", err)
|
wwlog.Printf(wwlog.ERROR, "%s\n", err)
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
@@ -157,8 +190,15 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
|
|||||||
wwlog.Printf(wwlog.ERROR, "You must include the '--netdev' option\n")
|
wwlog.Printf(wwlog.ERROR, "You must include the '--netdev' option\n")
|
||||||
os.Exit(1)
|
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.Fqdn, SetNetDev, SetNetmask)
|
wwlog.Printf(wwlog.VERBOSE, "Node: %s:%s, Setting netmask to: %s\n", n.Fqdn, SetNetDev, SetNetmask)
|
||||||
err := nodeDB.SetNodeNet(n.Gid.String(), n.Id.String(), SetNetDev, "netmask", SetNetmask)
|
|
||||||
|
n.NetDevs[SetNetDev].Netmask = SetNetmask
|
||||||
|
err := nodeDB.NodeUpdate(n)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
wwlog.Printf(wwlog.ERROR, "%s\n", err)
|
wwlog.Printf(wwlog.ERROR, "%s\n", err)
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
@@ -169,8 +209,15 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
|
|||||||
wwlog.Printf(wwlog.ERROR, "You must include the '--netdev' option\n")
|
wwlog.Printf(wwlog.ERROR, "You must include the '--netdev' option\n")
|
||||||
os.Exit(1)
|
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.Fqdn, SetNetDev, SetGateway)
|
wwlog.Printf(wwlog.VERBOSE, "Node: %s:%s, Setting gateway to: %s\n", n.Fqdn, SetNetDev, SetGateway)
|
||||||
err := nodeDB.SetNodeNet(n.Gid.String(), n.Id.String(), SetNetDev, "gateway", SetGateway)
|
|
||||||
|
n.NetDevs[SetNetDev].Gateway = SetGateway
|
||||||
|
err := nodeDB.NodeUpdate(n)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
wwlog.Printf(wwlog.ERROR, "%s\n", err)
|
wwlog.Printf(wwlog.ERROR, "%s\n", err)
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
@@ -181,8 +228,15 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
|
|||||||
wwlog.Printf(wwlog.ERROR, "You must include the '--netdev' option\n")
|
wwlog.Printf(wwlog.ERROR, "You must include the '--netdev' option\n")
|
||||||
os.Exit(1)
|
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.Fqdn, SetNetDev, SetHwaddr)
|
wwlog.Printf(wwlog.VERBOSE, "Node: %s:%s, Setting HW address to: %s\n", n.Fqdn, SetNetDev, SetHwaddr)
|
||||||
err := nodeDB.SetNodeNet(n.Gid.String(), n.Id.String(), SetNetDev, "hwaddr", SetHwaddr)
|
|
||||||
|
n.NetDevs[SetNetDev].Hwaddr = SetHwaddr
|
||||||
|
err := nodeDB.NodeUpdate(n)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
wwlog.Printf(wwlog.ERROR, "%s\n", err)
|
wwlog.Printf(wwlog.ERROR, "%s\n", err)
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
|
|||||||
Reference in New Issue
Block a user