mirror of https://github.com/docker/docs.git
rename HypervisorType to ProviderType
Signed-off-by: Evan Hazlett <ejhazlett@gmail.com>
This commit is contained in:
parent
c76d1a253f
commit
3347d1e82f
|
@ -12,7 +12,7 @@ import (
|
||||||
|
|
||||||
"github.com/codegangsta/cli"
|
"github.com/codegangsta/cli"
|
||||||
drivers "github.com/docker/machine/drivers"
|
drivers "github.com/docker/machine/drivers"
|
||||||
"github.com/docker/machine/hypervisor"
|
"github.com/docker/machine/provider"
|
||||||
"github.com/docker/machine/state"
|
"github.com/docker/machine/state"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -44,8 +44,8 @@ func (d *FakeDriver) GetMachineName() string {
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *FakeDriver) GetHypervisorType() hypervisor.HypervisorType {
|
func (d *FakeDriver) GetProviderType() provider.ProviderType {
|
||||||
return hypervisor.None
|
return provider.None
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *FakeDriver) GetIP() (string, error) {
|
func (d *FakeDriver) GetIP() (string, error) {
|
||||||
|
|
|
@ -15,7 +15,7 @@ import (
|
||||||
"github.com/codegangsta/cli"
|
"github.com/codegangsta/cli"
|
||||||
"github.com/docker/machine/drivers"
|
"github.com/docker/machine/drivers"
|
||||||
"github.com/docker/machine/drivers/amazonec2/amz"
|
"github.com/docker/machine/drivers/amazonec2/amz"
|
||||||
"github.com/docker/machine/hypervisor"
|
"github.com/docker/machine/provider"
|
||||||
"github.com/docker/machine/ssh"
|
"github.com/docker/machine/ssh"
|
||||||
"github.com/docker/machine/state"
|
"github.com/docker/machine/state"
|
||||||
"github.com/docker/machine/utils"
|
"github.com/docker/machine/utils"
|
||||||
|
@ -43,6 +43,7 @@ type Driver struct {
|
||||||
Region string
|
Region string
|
||||||
AMI string
|
AMI string
|
||||||
SSHKeyID int
|
SSHKeyID int
|
||||||
|
SSHPort int
|
||||||
KeyName string
|
KeyName string
|
||||||
InstanceId string
|
InstanceId string
|
||||||
InstanceType string
|
InstanceType string
|
||||||
|
@ -64,7 +65,6 @@ type Driver struct {
|
||||||
SwarmDiscovery string
|
SwarmDiscovery string
|
||||||
storePath string
|
storePath string
|
||||||
keyPath string
|
keyPath string
|
||||||
SSHPort int
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type CreateFlags struct {
|
type CreateFlags struct {
|
||||||
|
@ -170,8 +170,8 @@ func NewDriver(machineName string, storePath string, caCert string, privateKey s
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *Driver) GetHypervisorType() hypervisor.HypervisorType {
|
func (d *Driver) GetProviderType() provider.ProviderType {
|
||||||
return hypervisor.Remote
|
return provider.Remote
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *Driver) AuthorizePort(ports []*drivers.Port) error {
|
func (d *Driver) AuthorizePort(ports []*drivers.Port) error {
|
||||||
|
|
|
@ -6,7 +6,7 @@ import (
|
||||||
"sort"
|
"sort"
|
||||||
|
|
||||||
"github.com/codegangsta/cli"
|
"github.com/codegangsta/cli"
|
||||||
"github.com/docker/machine/hypervisor"
|
"github.com/docker/machine/provider"
|
||||||
"github.com/docker/machine/state"
|
"github.com/docker/machine/state"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -57,8 +57,8 @@ type Driver interface {
|
||||||
// GetState returns the state that the host is in (running, stopped, etc)
|
// GetState returns the state that the host is in (running, stopped, etc)
|
||||||
GetState() (state.State, error)
|
GetState() (state.State, error)
|
||||||
|
|
||||||
// GetHypervisorType returns whether the instance is local/remote
|
// GetProviderType returns whether the instance is local/remote
|
||||||
GetHypervisorType() hypervisor.HypervisorType
|
GetProviderType() provider.ProviderType
|
||||||
|
|
||||||
// Kill stops a host forcefully
|
// Kill stops a host forcefully
|
||||||
Kill() error
|
Kill() error
|
||||||
|
|
|
@ -6,7 +6,7 @@ import (
|
||||||
"github.com/codegangsta/cli"
|
"github.com/codegangsta/cli"
|
||||||
"github.com/docker/docker/api"
|
"github.com/docker/docker/api"
|
||||||
"github.com/docker/machine/drivers"
|
"github.com/docker/machine/drivers"
|
||||||
"github.com/docker/machine/hypervisor"
|
"github.com/docker/machine/provider"
|
||||||
"github.com/docker/machine/state"
|
"github.com/docker/machine/state"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -86,8 +86,8 @@ func (d *Driver) GetState() (state.State, error) {
|
||||||
return state.None, nil
|
return state.None, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *Driver) GetHypervisorType() hypervisor.HypervisorType {
|
func (d *Driver) GetProviderType() provider.ProviderType {
|
||||||
return hypervisor.None
|
return provider.None
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *Driver) Kill() error {
|
func (d *Driver) Kill() error {
|
||||||
|
|
26
host.go
26
host.go
|
@ -19,7 +19,7 @@ import (
|
||||||
|
|
||||||
log "github.com/Sirupsen/logrus"
|
log "github.com/Sirupsen/logrus"
|
||||||
"github.com/docker/machine/drivers"
|
"github.com/docker/machine/drivers"
|
||||||
"github.com/docker/machine/hypervisor"
|
"github.com/docker/machine/provider"
|
||||||
"github.com/docker/machine/ssh"
|
"github.com/docker/machine/ssh"
|
||||||
"github.com/docker/machine/utils"
|
"github.com/docker/machine/utils"
|
||||||
)
|
)
|
||||||
|
@ -112,10 +112,10 @@ func ValidateHostName(name string) (string, error) {
|
||||||
|
|
||||||
func (h *Host) GetDockerConfigDir() (string, error) {
|
func (h *Host) GetDockerConfigDir() (string, error) {
|
||||||
// TODO: this will be refactored in https://github.com/docker/machine/issues/699
|
// TODO: this will be refactored in https://github.com/docker/machine/issues/699
|
||||||
switch h.Driver.GetHypervisorType() {
|
switch h.Driver.GetProviderType() {
|
||||||
case hypervisor.Local:
|
case provider.Local:
|
||||||
return "/var/lib/boot2docker", nil
|
return "/var/lib/boot2docker", nil
|
||||||
case hypervisor.Remote:
|
case provider.Remote:
|
||||||
return "/etc/default", nil
|
return "/etc/default", nil
|
||||||
default:
|
default:
|
||||||
return "", ErrUnknownHypervisorType
|
return "", ErrUnknownHypervisorType
|
||||||
|
@ -212,10 +212,10 @@ func (h *Host) StartDocker() error {
|
||||||
err error
|
err error
|
||||||
)
|
)
|
||||||
|
|
||||||
switch h.Driver.GetHypervisorType() {
|
switch h.Driver.GetProviderType() {
|
||||||
case hypervisor.Local:
|
case provider.Local:
|
||||||
cmd, err = h.GetSSHCommand("sudo /etc/init.d/docker start")
|
cmd, err = h.GetSSHCommand("sudo /etc/init.d/docker start")
|
||||||
case hypervisor.Remote:
|
case provider.Remote:
|
||||||
cmd, err = h.GetSSHCommand("sudo service docker start")
|
cmd, err = h.GetSSHCommand("sudo service docker start")
|
||||||
default:
|
default:
|
||||||
return ErrUnknownHypervisorType
|
return ErrUnknownHypervisorType
|
||||||
|
@ -240,10 +240,10 @@ func (h *Host) StopDocker() error {
|
||||||
err error
|
err error
|
||||||
)
|
)
|
||||||
|
|
||||||
switch h.Driver.GetHypervisorType() {
|
switch h.Driver.GetProviderType() {
|
||||||
case hypervisor.Local:
|
case provider.Local:
|
||||||
cmd, err = h.GetSSHCommand("if [ -e /var/run/docker.pid ]; then sudo /etc/init.d/docker stop ; fi")
|
cmd, err = h.GetSSHCommand("if [ -e /var/run/docker.pid ]; then sudo /etc/init.d/docker stop ; fi")
|
||||||
case hypervisor.Remote:
|
case provider.Remote:
|
||||||
cmd, err = h.GetSSHCommand("sudo service docker stop")
|
cmd, err = h.GetSSHCommand("sudo service docker stop")
|
||||||
default:
|
default:
|
||||||
return ErrUnknownHypervisorType
|
return ErrUnknownHypervisorType
|
||||||
|
@ -549,14 +549,14 @@ func (h *Host) SetHostname() error {
|
||||||
err error
|
err error
|
||||||
)
|
)
|
||||||
|
|
||||||
switch h.Driver.GetHypervisorType() {
|
switch h.Driver.GetProviderType() {
|
||||||
case hypervisor.Local:
|
case provider.Local:
|
||||||
cmd, err = h.GetSSHCommand(fmt.Sprintf(
|
cmd, err = h.GetSSHCommand(fmt.Sprintf(
|
||||||
"sudo hostname %s && echo \"%s\" | sudo tee /var/lib/boot2docker/etc/hostname",
|
"sudo hostname %s && echo \"%s\" | sudo tee /var/lib/boot2docker/etc/hostname",
|
||||||
h.Name,
|
h.Name,
|
||||||
h.Name,
|
h.Name,
|
||||||
))
|
))
|
||||||
case hypervisor.Remote:
|
case provider.Remote:
|
||||||
cmd, err = h.GetSSHCommand(fmt.Sprintf(
|
cmd, err = h.GetSSHCommand(fmt.Sprintf(
|
||||||
"echo \"127.0.0.1 %s\" | sudo tee -a /etc/hosts && sudo hostname %s && echo \"%s\" | sudo tee /etc/hostname",
|
"echo \"127.0.0.1 %s\" | sudo tee -a /etc/hosts && sudo hostname %s && echo \"%s\" | sudo tee /etc/hostname",
|
||||||
h.Name,
|
h.Name,
|
||||||
|
|
|
@ -1,25 +0,0 @@
|
||||||
package hypervisor
|
|
||||||
|
|
||||||
// HypervisorType represents the type of hypervisor a machine is using
|
|
||||||
type HypervisorType int
|
|
||||||
|
|
||||||
const (
|
|
||||||
None HypervisorType = iota
|
|
||||||
Local
|
|
||||||
Remote
|
|
||||||
)
|
|
||||||
|
|
||||||
var hypervisorTypes = []string{
|
|
||||||
"",
|
|
||||||
"Local",
|
|
||||||
"Remote",
|
|
||||||
}
|
|
||||||
|
|
||||||
// Given a type, returns its string representation
|
|
||||||
func (h HypervisorType) String() string {
|
|
||||||
if int(h) >= 0 && int(h) < len(hypervisorTypes) {
|
|
||||||
return hypervisorTypes[h]
|
|
||||||
} else {
|
|
||||||
return ""
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -0,0 +1,25 @@
|
||||||
|
package provider
|
||||||
|
|
||||||
|
// ProviderType represents the type of a provider for a machine
|
||||||
|
type ProviderType int
|
||||||
|
|
||||||
|
const (
|
||||||
|
None ProviderType = iota
|
||||||
|
Local
|
||||||
|
Remote
|
||||||
|
)
|
||||||
|
|
||||||
|
var providerTypes = []string{
|
||||||
|
"",
|
||||||
|
"Local",
|
||||||
|
"Remote",
|
||||||
|
}
|
||||||
|
|
||||||
|
// Given a type, returns its string representation
|
||||||
|
func (t ProviderType) String() string {
|
||||||
|
if int(t) >= 0 && int(t) < len(providerTypes) {
|
||||||
|
return providerTypes[t]
|
||||||
|
} else {
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue