feat: NetBox insights, host tools and configurable TUI
Test / test (pull_request) Successful in 4m15s

- info/open/whois: NetBox details (site, nested locations, rack units,
  role, platform, tenant, IPs per interface), web page, reverse IP lookup
- cache status, site, role, platform, tenant, location chain and rack;
  ask before connecting to hosts in ssh.warn_status (--force skips)
- ssh rules and command restrictions match site/role/platform/tenant/status
- tui.columns selects what the TUI shows; optional TCP reachability column;
  detail view (Ctrl+L), NetBox page (Ctrl+G), status/location filters
- resolver.fallback tries other strategies' addresses when unreachable
- copy-id, known-hosts reset and address-change notices
- export ansible (YAML/INI) and export ssh-config
- token: keyring stores NetBox tokens in the system keyring
- fix stale menu number in testenv configure test

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Sebastian UnterschützandClaude Opus 5.5 committed 2026-11-18 12:33:59 +01:00
1 parent e5bde9c61f
commit 1660bb3098
39 files changed
+4868 -96

No files matched your search

+53 -1
View File
@@ -715,7 +715,59 @@ func TestOperationsRoundTrip(t *testing.T) {
if err != nil {
t.Fatal(err)
}
if got.TUI != cfg.TUI || got.Activity != cfg.Activity || !reflect.DeepEqual(got.Commands, cfg.Commands) || !reflect.DeepEqual(got.SSH, cfg.SSH) {
if !reflect.DeepEqual(got.TUI, cfg.TUI) || got.Activity != cfg.Activity || !reflect.DeepEqual(got.Commands, cfg.Commands) || !reflect.DeepEqual(got.SSH, cfg.SSH) {
t.Fatalf("round trip lost operations: %+v", got)
}
}
func TestSaveRoundtripNetBoxInsightSettings(t *testing.T) {
dir := t.TempDir()
t.Setenv("XDG_CONFIG_HOME", dir)
cfg := config.Config{
NetBox: config.NetBoxConfig{URL: "https://nb.example", Token: "keyring"},
Resolver: config.ResolverConfig{Strategies: []string{"primary_ip"}, Fallback: true, FallbackTimeout: 400},
TUI: config.TUIConfig{HistoryLimit: 10, Columns: []string{"ip", "platform", "reachability"}, ReachabilityTimeout: 900},
SSH: config.SSHConfig{WarnStatus: []string{"planned"}, Rules: []config.SSHRule{{
Match: config.SSHMatch{Platform: "junos", Site: "fsn1", Role: "core", Tenant: "acme", Status: "active"},
SSHOptions: config.SSHOptions{ProxyJump: "jump"},
}}},
Commands: map[string]config.HostCommand{"cli": {Args: []string{"cli", "{address}"}, Match: config.SSHMatch{Platform: "eos"}}},
}
if err := Save(cfg); err != nil {
t.Fatal(err)
}
loaded, err := config.Load()
if err != nil {
t.Fatal(err)
}
if !loaded.Resolver.Fallback || loaded.Resolver.FallbackTimeout != 400 {
t.Fatalf("resolver lost: %+v", loaded.Resolver)
}
if !reflect.DeepEqual(loaded.TUI.Columns, []string{"ip", "platform", "reachability"}) || !loaded.TUI.ReachabilityEnabled() || loaded.TUI.ReachabilityTimeout != 900 {
t.Fatalf("tui lost: %+v", loaded.TUI)
}
if !loaded.SSH.WarnsStatus("planned") || loaded.SSH.WarnsStatus("offline") {
t.Fatalf("warn_status lost: %v", loaded.SSH.WarnStatus)
}
if got := loaded.SSH.Rules[0].Match; got != cfg.SSH.Rules[0].Match {
t.Fatalf("rule match lost: %+v", got)
}
if loaded.Commands["cli"].Match.Platform != "eos" {
t.Fatalf("command match lost: %+v", loaded.Commands["cli"].Match)
}
if !config.IsKeyringToken(loaded.NetBox.Token) || loaded.NetBox.TokenVersion != 0 {
t.Fatalf("keyring token changed: %+v", loaded.NetBox)
}
// Defaults stay implicit, so later default changes reach existing configs.
cfg = config.Config{NetBox: config.NetBoxConfig{URL: "https://nb.example"}, Resolver: config.ResolverConfig{Strategies: []string{"primary_ip"}}}
if err := Save(cfg); err != nil {
t.Fatal(err)
}
data, _ := os.ReadFile(filepath.Join(dir, "netssh.yaml"))
for _, key := range []string{"warn_status", "columns", "reachability", "fallback"} {
if strings.Contains(string(data), key) {
t.Errorf("default %s written:\n%s", key, data)
}
}
}