Let CloudProvider return list of NodeAddress, not just one net.IP
This lets cloud providers populate the NodeAddress array
This commit is contained in:
@@ -119,14 +119,15 @@ func (v *VagrantCloud) getInstanceByAddress(address string) (*SaltMinion, error)
|
||||
return nil, fmt.Errorf("unable to find instance for address: %s", address)
|
||||
}
|
||||
|
||||
// IPAddress returns the address of a particular machine instance.
|
||||
func (v *VagrantCloud) IPAddress(instance string) (net.IP, error) {
|
||||
// NodeAddresses returns the NodeAddress of a particular machine instance.
|
||||
func (v *VagrantCloud) NodeAddresses(instance string) ([]api.NodeAddress, error) {
|
||||
// Due to vagrant not running with a dedicated DNS setup, we return the IP address of a minion as its hostname at this time
|
||||
minion, err := v.getInstanceByAddress(instance)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return net.ParseIP(minion.IP), nil
|
||||
ip := net.ParseIP(minion.IP)
|
||||
return []api.NodeAddress{{Type: api.NodeLegacyHostIP, Address: ip.String()}}, nil
|
||||
}
|
||||
|
||||
// ExternalID returns the cloud provider ID of the specified instance.
|
||||
|
@@ -81,12 +81,14 @@ func TestVagrantCloud(t *testing.T) {
|
||||
t.Fatalf("Invalid instance returned")
|
||||
}
|
||||
|
||||
ip, err := vagrantCloud.IPAddress(instances[0])
|
||||
addrs, err := vagrantCloud.NodeAddresses(instances[0])
|
||||
if err != nil {
|
||||
t.Fatalf("Unexpected error, should have returned a valid IP address: %s", err)
|
||||
t.Fatalf("Unexpected error, should have returned valid NodeAddresses: %s", err)
|
||||
}
|
||||
|
||||
if ip.String() != expectedInstanceIP {
|
||||
if len(addrs) != 1 {
|
||||
t.Fatalf("should have returned exactly one NodeAddress: %v", addrs)
|
||||
}
|
||||
if addrs[0].Address != expectedInstanceIP {
|
||||
t.Fatalf("Invalid IP address returned")
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user