Merge pull request #2432 from dgageot/provision-logs

Add more logs to provisioner
This commit is contained in:
Jean-Laurent de Morlhon 2015-11-27 09:50:42 +01:00
commit aa36205174
15 changed files with 55 additions and 5 deletions

View File

@ -9,6 +9,7 @@ import (
"github.com/docker/machine/libmachine/auth" "github.com/docker/machine/libmachine/auth"
"github.com/docker/machine/libmachine/drivers" "github.com/docker/machine/libmachine/drivers"
"github.com/docker/machine/libmachine/engine" "github.com/docker/machine/libmachine/engine"
"github.com/docker/machine/libmachine/log"
"github.com/docker/machine/libmachine/mcnutils" "github.com/docker/machine/libmachine/mcnutils"
"github.com/docker/machine/libmachine/provision" "github.com/docker/machine/libmachine/provision"
"github.com/docker/machine/libmachine/provision/pkgaction" "github.com/docker/machine/libmachine/provision/pkgaction"
@ -135,14 +136,13 @@ func (h *Host) Upgrade() error {
return err return err
} }
log.Info("Upgrading docker...")
if err := provisioner.Package("docker", pkgaction.Upgrade); err != nil { if err := provisioner.Package("docker", pkgaction.Upgrade); err != nil {
return err return err
} }
if err := provisioner.Service("docker", serviceaction.Restart); err != nil { log.Info("Restarting docker...")
return err return provisioner.Service("docker", serviceaction.Restart)
}
return nil
} }
func (h *Host) GetURL() (string, error) { func (h *Host) GetURL() (string, error) {

View File

@ -121,7 +121,7 @@ func (api *Client) Create(h *host.Host) error {
return fmt.Errorf("Error detecting OS: %s", err) return fmt.Errorf("Error detecting OS: %s", err)
} }
log.Info("Provisioning created instance...") log.Infof("Provisioning with %s...", provisioner.String())
if err := provisioner.Provision(*h.HostOptions.SwarmOptions, *h.HostOptions.AuthOptions, *h.HostOptions.EngineOptions); err != nil { if err := provisioner.Provision(*h.HostOptions.SwarmOptions, *h.HostOptions.AuthOptions, *h.HostOptions.EngineOptions); err != nil {
return fmt.Errorf("Error running provisioning: %s", err) return fmt.Errorf("Error running provisioning: %s", err)
} }

View File

@ -29,6 +29,10 @@ type ArchProvisioner struct {
SystemdProvisioner SystemdProvisioner
} }
func (provisioner *ArchProvisioner) String() string {
return "arch"
}
func (provisioner *ArchProvisioner) CompatibleWithHost() bool { func (provisioner *ArchProvisioner) CompatibleWithHost() bool {
return provisioner.OsReleaseInfo.ID == provisioner.OsReleaseID || provisioner.OsReleaseInfo.IDLike == provisioner.OsReleaseID return provisioner.OsReleaseInfo.ID == provisioner.OsReleaseID || provisioner.OsReleaseInfo.IDLike == provisioner.OsReleaseID
} }

View File

@ -41,6 +41,10 @@ type Boot2DockerProvisioner struct {
SwarmOptions swarm.Options SwarmOptions swarm.Options
} }
func (provisioner *Boot2DockerProvisioner) String() string {
return "boot2docker"
}
func (provisioner *Boot2DockerProvisioner) Service(name string, action serviceaction.ServiceAction) error { func (provisioner *Boot2DockerProvisioner) Service(name string, action serviceaction.ServiceAction) error {
_, err := provisioner.SSHCommand(fmt.Sprintf("sudo /etc/init.d/%s %s", name, action.String())) _, err := provisioner.SSHCommand(fmt.Sprintf("sudo /etc/init.d/%s %s", name, action.String()))
return err return err

View File

@ -19,3 +19,7 @@ func NewCentosProvisioner(d drivers.Driver) Provisioner {
type CentosProvisioner struct { type CentosProvisioner struct {
*RedHatProvisioner *RedHatProvisioner
} }
func (provisioner *CentosProvisioner) String() string {
return "centos"
}

View File

@ -38,6 +38,10 @@ type CoreOSProvisioner struct {
SystemdProvisioner SystemdProvisioner
} }
func (provisioner *CoreOSProvisioner) String() string {
return "coreOS"
}
func (provisioner *CoreOSProvisioner) SetHostname(hostname string) error { func (provisioner *CoreOSProvisioner) SetHostname(hostname string) error {
log.Debugf("SetHostname: %s", hostname) log.Debugf("SetHostname: %s", hostname)

View File

@ -29,6 +29,10 @@ type DebianProvisioner struct {
SystemdProvisioner SystemdProvisioner
} }
func (provisioner *DebianProvisioner) String() string {
return "debian"
}
func (provisioner *DebianProvisioner) Package(name string, action pkgaction.PackageAction) error { func (provisioner *DebianProvisioner) Package(name string, action pkgaction.PackageAction) error {
var packageAction string var packageAction string

View File

@ -19,3 +19,7 @@ func NewFedoraProvisioner(d drivers.Driver) Provisioner {
type FedoraProvisioner struct { type FedoraProvisioner struct {
*RedHatProvisioner *RedHatProvisioner
} }
func (provisioner *FedoraProvisioner) String() string {
return "fedora"
}

View File

@ -21,6 +21,7 @@ type SSHCommander interface {
// Provisioner defines distribution specific actions // Provisioner defines distribution specific actions
type Provisioner interface { type Provisioner interface {
fmt.Stringer
SSHCommander SSHCommander
// Create the files for the daemon to consume configuration settings (return struct of content and path) // Create the files for the daemon to consume configuration settings (return struct of content and path)

View File

@ -52,6 +52,10 @@ type RancherProvisioner struct {
GenericProvisioner GenericProvisioner
} }
func (provisioner *RancherProvisioner) String() string {
return "rancheros"
}
func (provisioner *RancherProvisioner) Service(name string, action serviceaction.ServiceAction) error { func (provisioner *RancherProvisioner) Service(name string, action serviceaction.ServiceAction) error {
command := fmt.Sprintf("sudo system-docker %s %s", action.String(), name) command := fmt.Sprintf("sudo system-docker %s %s", action.String(), name)

View File

@ -61,6 +61,10 @@ type RedHatProvisioner struct {
SystemdProvisioner SystemdProvisioner
} }
func (provisioner *RedHatProvisioner) String() string {
return "redhat"
}
func (provisioner *RedHatProvisioner) SetHostname(hostname string) error { func (provisioner *RedHatProvisioner) SetHostname(hostname string) error {
// we have to have SetHostname here as well to use the RedHat provisioner // we have to have SetHostname here as well to use the RedHat provisioner
// SSHCommand to add the tty allocation // SSHCommand to add the tty allocation

View File

@ -76,6 +76,10 @@ type SUSEProvisioner struct {
GenericProvisioner GenericProvisioner
} }
func (provisioner *SUSEProvisioner) String() string {
return "suse"
}
func (provisioner *SUSEProvisioner) Service(name string, action serviceaction.ServiceAction) error { func (provisioner *SUSEProvisioner) Service(name string, action serviceaction.ServiceAction) error {
reloadDaemon := false reloadDaemon := false
switch action { switch action {

View File

@ -13,6 +13,10 @@ type SystemdProvisioner struct {
GenericProvisioner GenericProvisioner
} }
func (p *SystemdProvisioner) String() string {
return "redhat"
}
func NewSystemdProvisioner(osReleaseID string, d drivers.Driver) SystemdProvisioner { func NewSystemdProvisioner(osReleaseID string, d drivers.Driver) SystemdProvisioner {
return SystemdProvisioner{ return SystemdProvisioner{
GenericProvisioner{ GenericProvisioner{

View File

@ -30,6 +30,10 @@ type UbuntuSystemdProvisioner struct {
SystemdProvisioner SystemdProvisioner
} }
func (provisioner *UbuntuSystemdProvisioner) String() string {
return "ubuntu(systemd)"
}
func (provisioner *UbuntuSystemdProvisioner) CompatibleWithHost() bool { func (provisioner *UbuntuSystemdProvisioner) CompatibleWithHost() bool {
const FirstUbuntuSystemdVersion = 15.04 const FirstUbuntuSystemdVersion = 15.04

View File

@ -39,6 +39,10 @@ type UbuntuProvisioner struct {
GenericProvisioner GenericProvisioner
} }
func (provisioner *UbuntuProvisioner) String() string {
return "ubuntu(upstart)"
}
func (provisioner *UbuntuProvisioner) CompatibleWithHost() bool { func (provisioner *UbuntuProvisioner) CompatibleWithHost() bool {
const FirstUbuntuSystemdVersion = 15.04 const FirstUbuntuSystemdVersion = 15.04
isUbuntu := provisioner.OsReleaseInfo.ID == provisioner.OsReleaseID isUbuntu := provisioner.OsReleaseInfo.ID == provisioner.OsReleaseID
@ -151,6 +155,7 @@ func (provisioner *UbuntuProvisioner) Provision(swarmOptions swarm.Options, auth
} }
} }
log.Info("Installing Docker...")
if err := installDockerGeneric(provisioner, engineOptions.InstallURL); err != nil { if err := installDockerGeneric(provisioner, engineOptions.InstallURL); err != nil {
return err return err
} }