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

+35
View File
@@ -12,6 +12,8 @@ import (
"strings"
"sync"
"time"
"git.zb-server.de/Sebi/ssh-netbox-wrapper/internal/config"
)
type Client struct {
@@ -20,6 +22,9 @@ type Client struct {
token string
tokenVersion int
httpClient *http.Client
locMu sync.Mutex
locations map[int]locationNode // location ID → name and parent, per client
}
// NewClient creates a NetBox API client. Pass tokenVersion=0 to auto-detect
@@ -227,6 +232,7 @@ func (c *Client) searchDevices(ctx context.Context, query, tag string) ([]HostEn
for _, d := range resp.Results {
entries = append(entries, deviceToEntry(d))
}
c.fillLocations(ctx, entries)
return entries, nil
}
@@ -278,6 +284,7 @@ func (c *Client) fetchAllDevices(ctx context.Context, query, filters string) ([]
break
}
}
c.fillLocations(ctx, all)
return all, nil
}
@@ -370,6 +377,20 @@ func deviceToEntry(d netboxDevice) HostEntry {
if d.Cluster != nil {
e.Cluster = d.Cluster.Name
}
e.Status = d.Status.value()
e.Site, e.Platform, e.Tenant = d.Site.ref(), d.Platform.ref(), d.Tenant.ref()
e.Role = d.Role.ref()
if d.Role == nil {
e.Role = d.DeviceRole.ref()
}
if d.Location != nil {
e.locationID = d.Location.ID
e.Location = []config.Ref{{Name: d.Location.Name, Slug: d.Location.Slug}}
}
if d.Rack != nil {
e.Rack = d.Rack.Name
}
e.Position = rackUnit(d.Position)
return e
}
@@ -387,6 +408,20 @@ func vmToEntry(v netboxVM) HostEntry {
if v.Cluster != nil {
e.Cluster = v.Cluster.Name
}
e.Status = v.Status.value()
e.Site, e.Platform, e.Tenant = v.Site.ref(), v.Platform.ref(), v.Tenant.ref()
e.Role = v.Role.ref()
if v.Role == nil {
e.Role = v.DeviceRole.ref()
}
if v.Location != nil {
e.locationID = v.Location.ID
e.Location = []config.Ref{{Name: v.Location.Name, Slug: v.Location.Slug}}
}
if v.Rack != nil {
e.Rack = v.Rack.Name
}
e.Position = rackUnit(v.Position)
return e
}