fix: interface_name strategy, instance hosts in sftp/scp, alias rewrites
Found by the new Docker test environment against a real NetBox 4.7: - The interface_name strategy filtered IP addresses with interface_name and vminterface_name, which NetBox ignores, so it returned the first address of the host instead of the named interface's. Use the real filters interface and vminterface; a missing interface (HTTP 400) falls through to the next strategy. - sftp and scp took instance-qualified hosts (prod/web01:/path) for local paths, because a "/" comes before the ":". Such arguments are remote when the prefix is a configured NetBox instance. - Shell aliases of instance-qualified hosts ran the shortcut rules on "instance/host", so anchored rewrite rules never matched. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
3c9e54b254
commit
55e7a5106b
10 files changed
+144
-11
No files matched your search
@@ -235,7 +235,7 @@ func TestGetIPsWithFilter(t *testing.T) {
|
||||
defer srv.Close()
|
||||
|
||||
c := NewClient(srv.URL, "token", 0)
|
||||
ips, err := c.GetIPsWithFilter(context.Background(), "device_id=1&interface_name=mgmt0")
|
||||
ips, err := c.GetIPsWithFilter(context.Background(), "device_id=1&interface=mgmt0")
|
||||
if err != nil {
|
||||
t.Fatalf("GetIPsWithFilter: %v", err)
|
||||
}
|
||||
|
||||
@@ -78,7 +78,7 @@ func TestMultiSourceSearchAndRouting(t *testing.T) {
|
||||
if err != nil || len(ips) != 1 || ips[0] != tc.ip {
|
||||
t.Fatalf("wrong IP source: %v, %v", ips, err)
|
||||
}
|
||||
ips, err = c.GetIPsWithFilterForHost(ctx, host, "device_id=1&interface_name=mgmt0")
|
||||
ips, err = c.GetIPsWithFilterForHost(ctx, host, "device_id=1&interface=mgmt0")
|
||||
if err != nil || len(ips) != 1 || ips[0] != tc.ip {
|
||||
t.Fatalf("wrong interface source: %v, %v", ips, err)
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user