Skip to content

Commit

Permalink
Added the ability to get (not just wait for) non-local IP addresses
Browse files Browse the repository at this point in the history
  • Loading branch information
Janos Bonic committed Jun 13, 2022
1 parent a09763c commit f86a4bf
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
12 changes: 12 additions & 0 deletions vm.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,11 @@ type VMClient interface {
// The returned result will be a map of network interface names and the list of IP addresses assigned to them,
// excluding any IP addresses in the specified parameters.
GetVMIPAddresses(id VMID, params VMIPSearchParams, retries ...RetryStrategy) (map[string][]net.IP, error)
// GetVMNonLocalIPAddresses fetches the IP addresses and filters them to return only non-local IP addresses.
//
// The returned result will be a map of network interface names and the list of IP addresses assigned to them,
// excluding any IP addresses in the specified parameters.
GetVMNonLocalIPAddresses(id VMID, retries ...RetryStrategy) (map[string][]net.IP, error)
// WaitForVMIPAddresses waits for at least one IP address to be reported that is not in specified ranges.
//
// The returned result will be a map of network interface names and the list of IP addresses assigned to them,
Expand Down Expand Up @@ -486,6 +491,9 @@ type VM interface {
//
// The optional parameters let you filter the returned interfaces and IP addresses.
GetIPAddresses(params VMIPSearchParams, retries ...RetryStrategy) (map[string][]net.IP, error)
// GetNonLocalIPAddresses fetches the IP addresses, filters them for non-local IP addresses, and returns a map of the
// interface name and list of IP addresses.
GetNonLocalIPAddresses(retries ...RetryStrategy) (map[string][]net.IP, error)
// WaitForIPAddresses waits for at least one IP address to be reported that is not in specified ranges.
//
// The returned result will be a map of network interface names and the list of IP addresses assigned to them,
Expand Down Expand Up @@ -1872,6 +1880,10 @@ func (v *vm) GetIPAddresses(params VMIPSearchParams, retries ...RetryStrategy) (
return v.client.GetVMIPAddresses(v.id, params, retries...)
}

func (v *vm) GetNonLocalIPAddresses(retries ...RetryStrategy) (map[string][]net.IP, error) {
return v.client.GetVMNonLocalIPAddresses(v.id, retries...)
}

func (v *vm) HostID() *HostID {
return v.hostID
}
Expand Down
14 changes: 14 additions & 0 deletions vm_ip_get_nonlocal.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package ovirtclient

import "net"

func (m *mockClient) GetVMNonLocalIPAddresses(id VMID, retries ...RetryStrategy) (
result map[string][]net.IP,
err error,
) {
return waitForIPAddresses(id, nonLocalIPSearchParams, retries, m.logger, m)
}

func (o *oVirtClient) GetVMNonLocalIPAddresses(id VMID, retries ...RetryStrategy) (map[string][]net.IP, error) {
return waitForIPAddresses(id, nonLocalIPSearchParams, retries, o.logger, o)
}

0 comments on commit f86a4bf

Please sign in to comment.