diff --git a/pkg/hhfab/vlabhelpers.go b/pkg/hhfab/vlabhelpers.go index 2adddf02..e5cf0226 100644 --- a/pkg/hhfab/vlabhelpers.go +++ b/pkg/hhfab/vlabhelpers.go @@ -114,24 +114,9 @@ func (c *Config) VLABAccess(ctx context.Context, vlab *VLAB, t VLABAccessType, n } else if entry.IsSwitch { slog.Debug("SSH through control node", "name", name, "type", "switch") - kubeconfig := filepath.Join(c.WorkDir, VLABDir, VLABKubeConfig) - kube, err := kubeutil.NewClientWithCache(ctx, kubeconfig, wiringapi.SchemeBuilder) + swIP, err := c.getSwitchIP(ctx, name) if err != nil { - return fmt.Errorf("creating kube client: %w", err) - } - - sw := &wiringapi.Switch{} - if err := kube.Get(ctx, client.ObjectKey{Name: name, Namespace: metav1.NamespaceDefault}, sw); err != nil { - return fmt.Errorf("getting switch: %w", err) - } - - if sw.Spec.IP == "" { - return fmt.Errorf("switch IP not found: %s", name) //nolint:goerr113 - } - - swIP, err := netip.ParsePrefix(sw.Spec.IP) - if err != nil { - return fmt.Errorf("parsing switch IP: %w", err) + return fmt.Errorf("getting switch IP: %w", err) } proxyCmd := fmt.Sprintf("ssh %s -i %s -W %%h:%%p -p %d core@127.0.0.1", @@ -144,7 +129,7 @@ func (c *Config) VLABAccess(ctx context.Context, vlab *VLAB, t VLABAccessType, n args = append(SSHQuietFlags, "-i", filepath.Join(VLABDir, VLABSSHKeyFile), "-o", "ProxyCommand="+proxyCmd, - "admin@"+swIP.Addr().String(), + "admin@"+swIP, ) } else { return fmt.Errorf("SSH not available: %s", name) //nolint:goerr113