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"
|
||||
drivers "github.com/docker/machine/drivers"
|
||||
"github.com/docker/machine/hypervisor"
|
||||
"github.com/docker/machine/provider"
|
||||
"github.com/docker/machine/state"
|
||||
)
|
||||
|
||||
|
@ -44,8 +44,8 @@ func (d *FakeDriver) GetMachineName() string {
|
|||
return ""
|
||||
}
|
||||
|
||||
func (d *FakeDriver) GetHypervisorType() hypervisor.HypervisorType {
|
||||
return hypervisor.None
|
||||
func (d *FakeDriver) GetProviderType() provider.ProviderType {
|
||||
return provider.None
|
||||
}
|
||||
|
||||
func (d *FakeDriver) GetIP() (string, error) {
|
||||
|
|
|
@ -15,7 +15,7 @@ import (
|
|||
"github.com/codegangsta/cli"
|
||||
"github.com/docker/machine/drivers"
|
||||
"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/state"
|
||||
"github.com/docker/machine/utils"
|
||||
|
@ -43,6 +43,7 @@ type Driver struct {
|
|||
Region string
|
||||
AMI string
|
||||
SSHKeyID int
|
||||
SSHPort int
|
||||
KeyName string
|
||||
InstanceId string
|
||||
InstanceType string
|
||||
|
@ -64,7 +65,6 @@ type Driver struct {
|
|||
SwarmDiscovery string
|
||||
storePath string
|
||||
keyPath string
|
||||
SSHPort int
|
||||
}
|
||||
|
||||
type CreateFlags struct {
|
||||
|
@ -170,8 +170,8 @@ func NewDriver(machineName string, storePath string, caCert string, privateKey s
|
|||
}, nil
|
||||
}
|
||||
|
||||
func (d *Driver) GetHypervisorType() hypervisor.HypervisorType {
|
||||
return hypervisor.Remote
|
||||
func (d *Driver) GetProviderType() provider.ProviderType {
|
||||
return provider.Remote
|
||||
}
|
||||
|
||||
func (d *Driver) AuthorizePort(ports []*drivers.Port) error {
|
||||
|
|
|
@ -6,7 +6,7 @@ import (
|
|||
"sort"
|
||||
|
||||
"github.com/codegangsta/cli"
|
||||
"github.com/docker/machine/hypervisor"
|
||||
"github.com/docker/machine/provider"
|
||||
"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() (state.State, error)
|
||||
|
||||
// GetHypervisorType returns whether the instance is local/remote
|
||||
GetHypervisorType() hypervisor.HypervisorType
|
||||
// GetProviderType returns whether the instance is local/remote
|
||||
GetProviderType() provider.ProviderType
|
||||
|
||||
// Kill stops a host forcefully
|
||||
Kill() error
|
||||
|
|
|
@ -6,7 +6,7 @@ import (
|
|||
"github.com/codegangsta/cli"
|
||||
"github.com/docker/docker/api"
|
||||
"github.com/docker/machine/drivers"
|
||||
"github.com/docker/machine/hypervisor"
|
||||
"github.com/docker/machine/provider"
|
||||
"github.com/docker/machine/state"
|
||||
)
|
||||
|
||||
|
@ -86,8 +86,8 @@ func (d *Driver) GetState() (state.State, error) {
|
|||
return state.None, nil
|
||||
}
|
||||
|
||||
func (d *Driver) GetHypervisorType() hypervisor.HypervisorType {
|
||||
return hypervisor.None
|
||||
func (d *Driver) GetProviderType() provider.ProviderType {
|
||||
return provider.None
|
||||
}
|
||||
|
||||
func (d *Driver) Kill() error {
|
||||
|
|
26
host.go
26
host.go
|
@ -19,7 +19,7 @@ import (
|
|||
|
||||
log "github.com/Sirupsen/logrus"
|
||||
"github.com/docker/machine/drivers"
|
||||
"github.com/docker/machine/hypervisor"
|
||||
"github.com/docker/machine/provider"
|
||||
"github.com/docker/machine/ssh"
|
||||
"github.com/docker/machine/utils"
|
||||
)
|
||||
|
@ -112,10 +112,10 @@ func ValidateHostName(name string) (string, error) {
|
|||
|
||||
func (h *Host) GetDockerConfigDir() (string, error) {
|
||||
// TODO: this will be refactored in https://github.com/docker/machine/issues/699
|
||||
switch h.Driver.GetHypervisorType() {
|
||||
case hypervisor.Local:
|
||||
switch h.Driver.GetProviderType() {
|
||||
case provider.Local:
|
||||
return "/var/lib/boot2docker", nil
|
||||
case hypervisor.Remote:
|
||||
case provider.Remote:
|
||||
return "/etc/default", nil
|
||||
default:
|
||||
return "", ErrUnknownHypervisorType
|
||||
|
@ -212,10 +212,10 @@ func (h *Host) StartDocker() error {
|
|||
err error
|
||||
)
|
||||
|
||||
switch h.Driver.GetHypervisorType() {
|
||||
case hypervisor.Local:
|
||||
switch h.Driver.GetProviderType() {
|
||||
case provider.Local:
|
||||
cmd, err = h.GetSSHCommand("sudo /etc/init.d/docker start")
|
||||
case hypervisor.Remote:
|
||||
case provider.Remote:
|
||||
cmd, err = h.GetSSHCommand("sudo service docker start")
|
||||
default:
|
||||
return ErrUnknownHypervisorType
|
||||
|
@ -240,10 +240,10 @@ func (h *Host) StopDocker() error {
|
|||
err error
|
||||
)
|
||||
|
||||
switch h.Driver.GetHypervisorType() {
|
||||
case hypervisor.Local:
|
||||
switch h.Driver.GetProviderType() {
|
||||
case provider.Local:
|
||||
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")
|
||||
default:
|
||||
return ErrUnknownHypervisorType
|
||||
|
@ -549,14 +549,14 @@ func (h *Host) SetHostname() error {
|
|||
err error
|
||||
)
|
||||
|
||||
switch h.Driver.GetHypervisorType() {
|
||||
case hypervisor.Local:
|
||||
switch h.Driver.GetProviderType() {
|
||||
case provider.Local:
|
||||
cmd, err = h.GetSSHCommand(fmt.Sprintf(
|
||||
"sudo hostname %s && echo \"%s\" | sudo tee /var/lib/boot2docker/etc/hostname",
|
||||
h.Name,
|
||||
h.Name,
|
||||
))
|
||||
case hypervisor.Remote:
|
||||
case provider.Remote:
|
||||
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",
|
||||
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