Separate minion controller from master.

This commit is contained in:
Deyuan Deng
2014-10-21 21:21:44 -04:00
parent 41f0929384
commit 019b7fc74c
12 changed files with 267 additions and 291 deletions

View File

@@ -18,6 +18,7 @@ package cloudprovider
import (
"io"
"os"
"sync"
"github.com/golang/glog"
@@ -60,3 +61,35 @@ func GetCloudProvider(name string, config io.Reader) (Interface, error) {
}
return f(config)
}
// InitCloudProvider creates an instance of the named cloud provider.
func InitCloudProvider(name string, configFilePath string) Interface {
var config *os.File
if name == "" {
glog.Info("No cloud provider specified.")
return nil
}
if configFilePath != "" {
var err error
config, err = os.Open(configFilePath)
if err != nil {
glog.Fatalf("Couldn't open cloud provider configuration %s: %#v",
configFilePath, err)
}
defer config.Close()
}
cloud, err := GetCloudProvider(name, config)
if err != nil {
glog.Fatalf("Couldn't init cloud provider %q: %#v", name, err)
}
if cloud == nil {
glog.Fatalf("Unknown cloud provider: %s", name)
}
return cloud
}