From e497e26cb42f13ad82ed52958bf023f27931c357 Mon Sep 17 00:00:00 2001 From: mslacken Date: Tue, 20 Sep 2022 21:05:54 +0200 Subject: [PATCH] Use primary netdev for ssh --- internal/app/wwctl/ssh/main.go | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/internal/app/wwctl/ssh/main.go b/internal/app/wwctl/ssh/main.go index be2a0f95..10ac5e53 100644 --- a/internal/app/wwctl/ssh/main.go +++ b/internal/app/wwctl/ssh/main.go @@ -40,21 +40,25 @@ func CobraRunE(cmd *cobra.Command, args []string) error { } for _, node := range nodes { - - if _, ok := node.NetDevs["default"]; !ok { - fmt.Fprintf(os.Stderr, "%s: Default network device doesn't exist\n", node.Id.Get()) + var primaryNet string + for netName := range node.NetDevs { + 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 } - - if node.NetDevs["default"].Ipaddr.Get() == "" { - fmt.Fprintf(os.Stderr, "%s: Default network IP address not configured\n", node.Id.Get()) + if node.NetDevs[primaryNet].Ipaddr.Get() == "" { + fmt.Fprintf(os.Stderr, "%s: Primary network IP address not configured\n", node.Id.Get()) continue } nodename := node.Id.Print() var command []string - command = append(command, node.NetDevs["default"].Ipaddr.Get()) + command = append(command, node.NetDevs[primaryNet].Ipaddr.Get()) command = append(command, args[1:]...) batchpool.Submit(func() {