示例#1
0
func runDriver(driverName string) {
	switch driverName {
	case "amazonec2":
		plugin.RegisterDriver(amazonec2.NewDriver("", ""))
	case "digitalocean":
		plugin.RegisterDriver(digitalocean.NewDriver("", ""))
	case "exoscale":
		plugin.RegisterDriver(exoscale.NewDriver("", ""))
	case "generic":
		plugin.RegisterDriver(generic.NewDriver("", ""))
	case "google":
		plugin.RegisterDriver(google.NewDriver("", ""))
	case "hyperv":
		plugin.RegisterDriver(hyperv.NewDriver("", ""))
	case "none":
		plugin.RegisterDriver(none.NewDriver("", ""))
	case "openstack":
		plugin.RegisterDriver(openstack.NewDriver("", ""))
	case "rackspace":
		plugin.RegisterDriver(rackspace.NewDriver("", ""))
	case "softlayer":
		plugin.RegisterDriver(softlayer.NewDriver("", ""))
	case "virtualbox":
		plugin.RegisterDriver(virtualbox.NewDriver("", ""))
	case "vmwarefusion":
		plugin.RegisterDriver(vmwarefusion.NewDriver("", ""))
	case "vmwarevcloudair":
		plugin.RegisterDriver(vmwarevcloudair.NewDriver("", ""))
	case "vmwarevsphere":
		plugin.RegisterDriver(vmwarevsphere.NewDriver("", ""))
	default:
		fmt.Fprintf(os.Stderr, "Unsupported driver: %s\n", driverName)
		os.Exit(1)
	}
}
示例#2
0
文件: suite_test.go 项目: tsuru/tsuru
func (f *fakeLibMachineAPI) NewHost(driverName string, rawDriver []byte) (*host.Host, error) {
	f.driverName = driverName
	var driverOpts map[string]interface{}
	json.Unmarshal(rawDriver, &driverOpts)
	var driver drivers.Driver
	if driverName == "amazonec2" {
		driver = amazonec2.NewDriver("", "")
		sshKey, err := createTempFile("private ssh key")
		if err != nil {
			return nil, err
		}
		driver.(*amazonec2.Driver).SSHKeyPath = sshKey.Name()
	} else {
		driver = &fakedriver.Driver{}
	}
	var name string
	if m, ok := driverOpts["MachineName"]; ok {
		name = m.(string)
	} else {
		name = driverOpts["MockName"].(string)
	}
	caFile, err := createTempFile("ca")
	if err != nil {
		return nil, err
	}
	certFile, err := createTempFile("cert")
	if err != nil {
		return nil, err
	}
	keyFile, err := createTempFile("key")
	if err != nil {
		return nil, err
	}
	f.tempFiles = append(f.tempFiles, caFile, certFile, keyFile)
	if f.FakeStore == nil {
		f.FakeStore = &persisttest.FakeStore{
			Hosts: make([]*host.Host, 0),
		}
	}
	return &host.Host{
		Name:   name,
		Driver: driver,
		HostOptions: &host.Options{
			EngineOptions: &engine.Options{},
			AuthOptions: &auth.Options{
				CaCertPath:     caFile.Name(),
				ClientCertPath: certFile.Name(),
				ClientKeyPath:  keyFile.Name(),
			},
		},
	}, nil
}
示例#3
0
func NewDriver(driverName, hostName, storePath string) (drivers.Driver, error) {
	var (
		driver drivers.Driver
	)

	switch driverName {
	case "virtualbox":
		driver = virtualbox.NewDriver(hostName, storePath)
	case "digitalocean":
		driver = digitalocean.NewDriver(hostName, storePath)
	case "amazonec2":
		driver = amazonec2.NewDriver(hostName, storePath)
	case "azure":
		driver = azure.NewDriver(hostName, storePath)
	case "exoscale":
		driver = exoscale.NewDriver(hostName, storePath)
	case "generic":
		driver = generic.NewDriver(hostName, storePath)
	case "google":
		driver = google.NewDriver(hostName, storePath)
	case "hyperv":
		driver = hyperv.NewDriver(hostName, storePath)
	case "openstack":
		driver = openstack.NewDriver(hostName, storePath)
	case "rackspace":
		driver = rackspace.NewDriver(hostName, storePath)
	case "softlayer":
		driver = softlayer.NewDriver(hostName, storePath)
	case "vmwarefusion":
		driver = vmwarefusion.NewDriver(hostName, storePath)
	case "vmwarevcloudair":
		driver = vmwarevcloudair.NewDriver(hostName, storePath)
	case "vmwarevsphere":
		driver = vmwarevsphere.NewDriver(hostName, storePath)
	case "none":
		driver = none.NewDriver(hostName, storePath)
	case "aiyara":
		driver = aiyara.NewDriver(hostName, storePath)
	default:
		return nil, fmt.Errorf("Driver %q not recognized", driverName)
	}

	return driver, nil
}
示例#4
0
文件: drivers.go 项目: tsuru/tsuru
func RunDriver(driverName string) error {
	switch driverName {
	case "amazonec2":
		plugin.RegisterDriver(amazonec2.NewDriver("", ""))
	case "azure":
		plugin.RegisterDriver(azure.NewDriver("", ""))
	case "digitalocean":
		plugin.RegisterDriver(digitalocean.NewDriver("", ""))
	case "exoscale":
		plugin.RegisterDriver(exoscale.NewDriver("", ""))
	case "generic":
		plugin.RegisterDriver(generic.NewDriver("", ""))
	case "google":
		plugin.RegisterDriver(google.NewDriver("", ""))
	case "hyperv":
		plugin.RegisterDriver(hyperv.NewDriver("", ""))
	case "none":
		plugin.RegisterDriver(none.NewDriver("", ""))
	case "openstack":
		plugin.RegisterDriver(openstack.NewDriver("", ""))
	case "rackspace":
		plugin.RegisterDriver(rackspace.NewDriver("", ""))
	case "softlayer":
		plugin.RegisterDriver(softlayer.NewDriver("", ""))
	case "virtualbox":
		plugin.RegisterDriver(virtualbox.NewDriver("", ""))
	case "vmwarefusion":
		plugin.RegisterDriver(vmwarefusion.NewDriver("", ""))
	case "vmwarevcloudair":
		plugin.RegisterDriver(vmwarevcloudair.NewDriver("", ""))
	case "vmwarevsphere":
		plugin.RegisterDriver(vmwarevsphere.NewDriver("", ""))
	case "cloudstack":
		plugin.RegisterDriver(cloudstack.NewDriver("", ""))
	default:
		return errors.Errorf("Unsupported driver: %s\n", driverName)
	}
	return nil
}
示例#5
0
func (s *S) TestConfigureDriver(c *check.C) {
	opts := map[string]interface{}{
		"amazonec2-tags":                  "my-tag1",
		"amazonec2-access-key":            "abc",
		"amazonec2-subnet-id":             "net",
		"amazonec2-security-group":        []string{"sg-123", "sg-456"},
		"amazonec2-root-size":             "100",
		"amazonec2-request-spot-instance": "true",
	}
	driver := amazonec2.NewDriver("", "")
	err := configureDriver(driver, opts)
	c.Assert(err, check.NotNil)
	opts["amazonec2-secret-key"] = "cde"
	err = configureDriver(driver, opts)
	c.Assert(err, check.IsNil)
	c.Assert(driver.SecurityGroupNames, check.DeepEquals, []string{"sg-123", "sg-456"})
	c.Assert(driver.SecretKey, check.Equals, "cde")
	c.Assert(driver.SubnetId, check.Equals, "net")
	c.Assert(driver.AccessKey, check.Equals, "abc")
	c.Assert(driver.RetryCount, check.Equals, 5)
	c.Assert(driver.Tags, check.Equals, "my-tag1")
	c.Assert(driver.RootSize, check.Equals, int64(100))
	c.Assert(driver.RequestSpotInstance, check.Equals, true)
}
func main() {
	plugin.RegisterDriver(amazonec2.NewDriver("", ""))
}