api: add the ProviderID attribute to NodeSpec

Signed-off-by: Federico Simoncelli <fsimonce@redhat.com>
This commit is contained in:
Federico Simoncelli
2015-05-05 10:52:20 -04:00
parent faba12951a
commit 2a89428d44
18 changed files with 63 additions and 7 deletions

View File

@@ -18,6 +18,7 @@ package cloudprovider
import (
"errors"
"fmt"
"net"
"strings"
@@ -61,6 +62,18 @@ func GetLoadBalancerName(service *api.Service) string {
return ret
}
func GetInstanceProviderID(cloud Interface, nodeName string) (string, error) {
instances, ok := cloud.Instances()
if !ok {
return "", fmt.Errorf("failed to get instances from cloud provider")
}
instanceID, err := instances.InstanceID(nodeName)
if err != nil {
return "", fmt.Errorf("failed to get instance ID from cloud provider: %v", err)
}
return cloud.ProviderName() + "://" + instanceID, nil
}
// TCPLoadBalancer is an abstract, pluggable interface for TCP load balancers.
type TCPLoadBalancer interface {
// TODO: Break this up into different interfaces (LB, etc) when we have more than one type of service