本文整理汇总了Golang中github.com/docker/machine/drivers/virtualbox.NewDriver函数的典型用法代码示例。如果您正苦于以下问题:Golang NewDriver函数的具体用法?Golang NewDriver怎么用?Golang NewDriver使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了NewDriver函数的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: runDriver
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)
}
}
开发者ID:robvanmieghem,项目名称:machine,代码行数:35,代码来源:machine.go
示例2: createVirtualboxHost
func createVirtualboxHost(config MachineConfig) drivers.Driver {
d := virtualbox.NewDriver(constants.MachineName, constants.Minipath)
d.Boot2DockerURL = config.GetISOFileURI()
d.Memory = config.Memory
d.CPU = config.CPUs
d.DiskSize = int(config.DiskSize)
return d
}
开发者ID:rawlingsj,项目名称:gofabric8,代码行数:8,代码来源:cluster.go
示例3: NewHost
func NewHost(create bool, force bool) (*Host, error) {
// Create a Virtualbox host if an existing host doesn't already exist.
client := libmachine.NewClient(mcndirs.GetBaseDir())
existing, err := client.Load(DEFAULT_NAME)
if err != nil {
switch err.(type) {
case mcnerror.ErrHostDoesNotExist:
default:
log.Fatal(err)
}
}
if existing != nil && create && !force {
return nil, errors.New("Host already exists.")
} else if existing != nil && !create {
log.Debug("Existing host found.")
return &Host{
Host: existing,
Client: client,
}, nil
}
if create {
driver := virtualbox.NewDriver(DEFAULT_NAME, mcndirs.GetBaseDir())
driver.CPU = DEFAULT_CPU
driver.Memory = DEFAULT_MEMORY
// Disable the '/Users' mount, we handle that ourselves via
// `docker-unisync`.
driver.NoShare = true
data, err := json.Marshal(driver)
if err != nil {
log.Fatal(err)
}
pluginDriver, err := client.NewPluginDriver("virtualbox", data)
if err != nil {
log.Fatal(err)
}
h, err := client.NewHost(pluginDriver)
if err != nil {
log.Fatal(err)
}
if err := client.Create(h); err != nil {
log.Fatal(err)
}
return &Host{
Host: h,
Client: client,
}, nil
}
return nil, errors.New(fmt.Sprintf("The %v host doesn't exist and create was not specified.", DEFAULT_NAME))
}
开发者ID:Sitback,项目名称:helm,代码行数:58,代码来源:host.go
示例4: StartDriver
// StartDriver starts the desired machine driver if necessary.
func StartDriver() {
if os.Getenv(localbinary.PluginEnvKey) == localbinary.PluginEnvVal {
driverName := os.Getenv(localbinary.PluginEnvDriverName)
switch driverName {
case "virtualbox":
plugin.RegisterDriver(virtualbox.NewDriver("", ""))
case "vmwarefusion":
plugin.RegisterDriver(vmwarefusion.NewDriver("", ""))
default:
glog.Exitf("Unsupported driver: %s\n", driverName)
}
return
}
localbinary.CurrentBinaryIsDockerMachine = true
}
开发者ID:rawlingsj,项目名称:gofabric8,代码行数:16,代码来源:client.go
示例5: main
func main() {
log.IsDebug = true
log.SetOutWriter(os.Stdout)
log.SetErrWriter(os.Stderr)
client := libmachine.NewClient("/tmp/automatic")
hostName := "myfunhost"
// Set some options on the provider...
driver := virtualbox.NewDriver(hostName, "/tmp/automatic")
driver.CPU = 2
driver.Memory = 2048
data, err := json.Marshal(driver)
if err != nil {
log.Fatal(err)
}
pluginDriver, err := client.NewPluginDriver("virtualbox", data)
if err != nil {
log.Fatal(err)
}
h, err := client.NewHost(pluginDriver)
if err != nil {
log.Fatal(err)
}
h.HostOptions.EngineOptions.StorageDriver = "overlay"
if err := client.Create(h); err != nil {
log.Fatal(err)
}
out, err := h.RunSSHCommand("df -h")
if err != nil {
log.Fatal(err)
}
fmt.Printf("Results of your disk space query:\n%s\n", out)
fmt.Println("Powering down machine now...")
if err := h.Stop(); err != nil {
log.Fatal(err)
}
}
开发者ID:usmanismail,项目名称:machine,代码行数:47,代码来源:vbox_create.go
示例6: main
func main() {
log.SetDebug(true)
client := libmachine.NewClient("/tmp/automatic", "/tmp/automatic/certs")
defer client.Close()
hostName := "myfunhost"
// Set some options on the provider...
driver := virtualbox.NewDriver(hostName, "/tmp/automatic")
driver.CPU = 2
driver.Memory = 2048
data, err := json.Marshal(driver)
if err != nil {
log.Error(err)
return
}
h, err := client.NewHost("virtualbox", data)
if err != nil {
log.Error(err)
return
}
h.HostOptions.EngineOptions.StorageDriver = "overlay"
if err := client.Create(h); err != nil {
log.Error(err)
return
}
out, err := h.RunSSHCommand("df -h")
if err != nil {
log.Error(err)
return
}
fmt.Printf("Results of your disk space query:\n%s\n", out)
fmt.Println("Powering down machine now...")
if err := h.Stop(); err != nil {
log.Error(err)
return
}
}
开发者ID:binarytemple,项目名称:machine,代码行数:46,代码来源:vbox_create.go
示例7: NewDriver
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
}
开发者ID:chanwit,项目名称:gattai,代码行数:44,代码来源:driverfactory.go
示例8: createHost
func createHost(api libmachine.API, config MachineConfig) (*host.Host, error) {
var driver interface{}
switch config.VMDriver {
case "virtualbox":
d := virtualbox.NewDriver(constants.MachineName, constants.Minipath)
d.Boot2DockerURL = config.MinikubeISO
d.Memory = config.Memory
d.CPU = config.CPUs
driver = d
case "vmwarefusion":
driver = createVMwareFusionHost(config)
case "kvm":
driver = createKVMHost(config)
default:
glog.Exitf("Unsupported driver: %s\n", config.VMDriver)
}
data, err := json.Marshal(driver)
if err != nil {
return nil, err
}
h, err := api.NewHost(config.VMDriver, data)
if err != nil {
return nil, fmt.Errorf("Error creating new host: %s", err)
}
h.HostOptions.AuthOptions.CertDir = constants.Minipath
h.HostOptions.AuthOptions.StorePath = constants.Minipath
h.HostOptions.EngineOptions = &engine.Options{}
if err := api.Create(h); err != nil {
// Wait for all the logs to reach the client
time.Sleep(2 * time.Second)
return nil, fmt.Errorf("Error creating. %s", err)
}
if err := api.Save(h); err != nil {
return nil, fmt.Errorf("Error attempting to save store: %s", err)
}
return h, nil
}
开发者ID:tschottdorf,项目名称:minikube,代码行数:43,代码来源:cluster.go
示例9: main
func main() {
libmachine.SetDebug(true)
log.SetOutWriter(os.Stdout)
log.SetErrWriter(os.Stderr)
// returns the familiar store at $HOME/.docker/machine
store := libmachine.GetDefaultStore()
// over-ride this for now (don't want to muck with my default store)
store.Path = "/tmp/automatic"
hostName := "myfunhost"
// Set some options on the provider...
driver := virtualbox.NewDriver(hostName, "/tmp/automatic")
driver.CPU = 2
driver.Memory = 2048
h, err := store.NewHost(driver)
if err != nil {
log.Fatal(err)
}
h.HostOptions.EngineOptions.StorageDriver = "overlay"
if err := libmachine.Create(store, h); err != nil {
log.Fatal(err)
}
out, err := h.RunSSHCommand("df -h")
if err != nil {
log.Fatal(err)
}
fmt.Printf("Results of your disk space query:\n%s\n", out)
fmt.Println("Powering down machine now...")
if err := h.Stop(); err != nil {
log.Fatal(err)
}
}
开发者ID:mschygulla,项目名称:machine,代码行数:42,代码来源:vbox_create.go
示例10: RunDriver
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
}
开发者ID:tsuru,项目名称:tsuru,代码行数:39,代码来源:drivers.go
示例11: main
func main() {
plugin.RegisterDriver(virtualbox.NewDriver("", ""))
}
开发者ID:usmanismail,项目名称:machine,代码行数:3,代码来源:machine-driver-virtualbox.go
示例12: streaming
// Streaming the output of an SSH session in virtualbox.
func streaming() {
log.SetDebug(true)
client := libmachine.NewClient("/tmp/automatic", "/tmp/automatic/certs")
defer client.Close()
hostName := "myfunhost"
// Set some options on the provider...
driver := virtualbox.NewDriver(hostName, "/tmp/automatic")
data, err := json.Marshal(driver)
if err != nil {
log.Error(err)
return
}
h, err := client.NewHost("virtualbox", data)
if err != nil {
log.Error(err)
return
}
if err := client.Create(h); err != nil {
log.Error(err)
return
}
h.HostOptions.EngineOptions.StorageDriver = "overlay"
sshClient, err := h.CreateSSHClient()
if err != nil {
log.Error(err)
return
}
stdout, stderr, err := sshClient.Start("yes | head -n 10000")
if err != nil {
log.Error(err)
return
}
defer func() {
_ = stdout.Close()
_ = stderr.Close()
}()
scanner := bufio.NewScanner(stdout)
for scanner.Scan() {
fmt.Println(scanner.Text())
}
if err := scanner.Err(); err != nil {
log.Error(err)
}
if err := sshClient.Wait(); err != nil {
log.Error(err)
}
fmt.Println("Powering down machine now...")
if err := h.Stop(); err != nil {
log.Error(err)
return
}
}
开发者ID:RaulKite,项目名称:machine,代码行数:63,代码来源:main.go
注:本文中的github.com/docker/machine/drivers/virtualbox.NewDriver函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论