feat: netssh multi — several hosts side by side in tmux or zellij
netssh multi opens one pane per host in a tmux window or zellij tab. Hosts come from names, tag:TAG (NetBox and static hosts), cluster:NAME (NetBox virtualization clusters; devices by default, --kind vm|all), and groups from the config (@name, nested, with cycle detection). Every pane runs netssh HOST, so lookup, rules, and jump hosts apply. - tmux: a new window inside tmux, else a new session that is attached; tiled layout, pane borders with the host and a [SYNC] marker. - zellij: a generated grid layout; a new tab inside zellij, else a new session. - --sync broadcasts typing to all panes; netssh sync toggles it in the current tmux window or zellij tab. - TUI: Space marks hosts, Ctrl+A marks all, Enter opens them together. - Configurator: multiplexer, panes per window, groups. NetBox SearchAll gains a cluster filter (name to cluster IDs per instance), and cache entries keep the host's cluster for completion and an offline fallback. Panes skip the 24-hour background refresh (checked once by multi) and get HOME/XDG paths but no NETSSH_* values, which would expose tokens in the process list. testenv/tests/15-multi.sh checks real tmux and zellij sessions, including a broadcast command arriving on all three cluster nodes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
dbb99bdded
commit
a31aab4110
24 files changed
+1754
-40
No files matched your search
@@ -617,3 +617,37 @@ func TestValidateHostIn(t *testing.T) {
|
||||
t.Fatal("invalid address accepted")
|
||||
}
|
||||
}
|
||||
|
||||
func TestParseGroupsAndSaveMulti(t *testing.T) {
|
||||
groups, err := parseGroups("K8s: master1, tag:k8s-worker\npve: cluster:pve-fsn1 @k8s\n")
|
||||
want := map[string][]string{"k8s": {"master1", "tag:k8s-worker"}, "pve": {"cluster:pve-fsn1", "@k8s"}}
|
||||
if err != nil || !reflect.DeepEqual(groups, want) {
|
||||
t.Fatalf("got %v %v", groups, err)
|
||||
}
|
||||
if again, _ := parseGroups(formatGroups(groups)); !reflect.DeepEqual(again, want) {
|
||||
t.Fatalf("roundtrip: %v", again)
|
||||
}
|
||||
for _, bad := range []string{"no colon", "tag:x", "bad name: a", "empty:"} {
|
||||
if _, err := parseGroups(bad); err == nil {
|
||||
t.Errorf("%q accepted", bad)
|
||||
}
|
||||
}
|
||||
|
||||
t.Setenv("XDG_CONFIG_HOME", t.TempDir())
|
||||
t.Setenv("HOME", t.TempDir())
|
||||
cfg := config.Config{
|
||||
Hosts: []config.StaticHost{{Name: "a", Address: "10.0.0.1"}},
|
||||
Groups: groups,
|
||||
Multi: config.MultiConfig{Multiplexer: "zellij", PanesPerWindow: 4},
|
||||
}
|
||||
if err := save(cfg); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
loaded, err := config.Load()
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if !reflect.DeepEqual(loaded.Groups, want) || loaded.Multi != cfg.Multi {
|
||||
t.Fatalf("got %v %+v", loaded.Groups, loaded.Multi)
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user