Let CloudProvider return list of NodeAddress, not just one net.IP

This lets cloud providers populate the NodeAddress array
This commit is contained in:
Justin Santa Barbara
2015-03-11 16:37:11 -07:00
parent 7d53425bbc
commit bc16d83a51
14 changed files with 54 additions and 46 deletions

View File

@@ -350,17 +350,18 @@ func getAddressByName(api *gophercloud.ServiceClient, name string) (string, erro
return s, nil
}
func (i *Instances) IPAddress(name string) (net.IP, error) {
glog.V(2).Infof("IPAddress(%v) called", name)
func (i *Instances) NodeAddresses(name string) ([]api.NodeAddress, error) {
glog.V(2).Infof("NodeAddresses(%v) called", name)
ip, err := getAddressByName(i.compute, name)
if err != nil {
return nil, err
}
glog.V(2).Infof("IPAddress(%v) => %v", name, ip)
glog.V(2).Infof("NodeAddresses(%v) => %v", name, ip)
return net.ParseIP(ip), err
// net.ParseIP().String() is to maintain compatibility with the old code
return []api.NodeAddress{{Type: api.NodeLegacyHostIP, Address: net.ParseIP(ip).String()}}, nil
}
// ExternalID returns the cloud provider ID of the specified instance.