Use primary netdev for ssh

This commit is contained in:
mslacken
2022-09-20 21:05:54 +02:00
parent fc39209fbb
commit e497e26cb4

View File

@@ -40,21 +40,25 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
} }
for _, node := range nodes { for _, node := range nodes {
var primaryNet string
if _, ok := node.NetDevs["default"]; !ok { for netName := range node.NetDevs {
fmt.Fprintf(os.Stderr, "%s: Default network device doesn't exist\n", node.Id.Get()) if node.NetDevs[netName].Primary.GetB() {
primaryNet = netName
}
}
if primaryNet == "" {
fmt.Fprintf(os.Stderr, "%s: Primary network device doesn't exist\n", node.Id.Get())
continue continue
} }
if node.NetDevs[primaryNet].Ipaddr.Get() == "" {
if node.NetDevs["default"].Ipaddr.Get() == "" { fmt.Fprintf(os.Stderr, "%s: Primary network IP address not configured\n", node.Id.Get())
fmt.Fprintf(os.Stderr, "%s: Default network IP address not configured\n", node.Id.Get())
continue continue
} }
nodename := node.Id.Print() nodename := node.Id.Print()
var command []string var command []string
command = append(command, node.NetDevs["default"].Ipaddr.Get()) command = append(command, node.NetDevs[primaryNet].Ipaddr.Get())
command = append(command, args[1:]...) command = append(command, args[1:]...)
batchpool.Submit(func() { batchpool.Submit(func() {