openstack: driver cleanup for new interface

Signed-off-by: Evan Hazlett <ejhazlett@gmail.com>
This commit is contained in:
Evan Hazlett 2015-03-09 23:29:52 -04:00
parent 6456f5c6f6
commit 26389f23f3
1 changed files with 2 additions and 71 deletions

View File

@ -3,8 +3,6 @@ package openstack
import (
"fmt"
"io/ioutil"
"os/exec"
"path"
"path/filepath"
"strings"
"time"
@ -436,69 +434,6 @@ func (d *Driver) Kill() error {
return d.Stop()
}
func (d *Driver) Upgrade() error {
log.Debugf("Upgrading Docker")
cmd, err := d.GetSSHCommand("sudo apt-get update && sudo apt-get install --upgrade lxc-docker")
if err != nil {
return err
}
if err := cmd.Run(); err != nil {
return err
}
return cmd.Run()
}
func (d *Driver) StartDocker() error {
log.Debug("Starting Docker...")
cmd, err := d.GetSSHCommand("sudo service docker start")
if err != nil {
return err
}
if err := cmd.Run(); err != nil {
return err
}
return nil
}
func (d *Driver) StopDocker() error {
log.Debug("Stopping Docker...")
cmd, err := d.GetSSHCommand("sudo service docker stop")
if err != nil {
return err
}
if err := cmd.Run(); err != nil {
return err
}
return nil
}
func (d *Driver) GetDockerConfigDir() string {
return dockerConfigDir
}
func (d *Driver) GetSSHCommand(args ...string) (*exec.Cmd, error) {
ip, err := d.GetIP()
if err != nil {
return nil, err
}
if len(args) != 0 && d.SSHUser != "root" {
cmd := strings.Replace(strings.Join(args, " "), "'", "\\'", -1)
args = []string{"sudo", "sh", "-c", fmt.Sprintf("'%s'", cmd)}
}
log.WithField("MachineId", d.MachineId).Debug("Command: %s", args)
return ssh.GetSSHCommand(ip, d.SSHPort, d.SSHUser, d.sshKeyPath(), args...), nil
}
const (
errorMandatoryEnvOrOption string = "%s must be specified either using the environment variable %s or the CLI option %s"
errorMandatoryOption string = "%s must be specified using the CLI option %s"
@ -658,7 +593,7 @@ func (d *Driver) initNetwork() error {
func (d *Driver) createSSHKey() error {
log.WithField("Name", d.KeyPairName).Debug("Creating Key Pair...")
if err := ssh.GenerateSSHKey(d.sshKeyPath()); err != nil {
if err := ssh.GenerateSSHKey(d.GetSSHKeyPath()); err != nil {
return err
}
publicKey, err := ioutil.ReadFile(d.publicSSHKeyPath())
@ -780,10 +715,6 @@ func (d *Driver) waitForInstanceToStart() error {
return d.waitForSSHServer()
}
func (d *Driver) sshKeyPath() string {
return path.Join(d.storePath, "id_rsa")
}
func (d *Driver) publicSSHKeyPath() string {
return d.sshKeyPath() + ".pub"
return d.GetSSHKeyPath() + ".pub"
}