tls for openstack/rackspace
Signed-off-by: Evan Hazlett <ejhazlett@gmail.com>
This commit is contained in:
@@ -17,6 +17,10 @@ import (
|
|||||||
"github.com/docker/machine/state"
|
"github.com/docker/machine/state"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
dockerConfigDir = "/etc/docker"
|
||||||
|
)
|
||||||
|
|
||||||
type Driver struct {
|
type Driver struct {
|
||||||
AuthUrl string
|
AuthUrl string
|
||||||
Username string
|
Username string
|
||||||
@@ -41,6 +45,8 @@ type Driver struct {
|
|||||||
SSHPort int
|
SSHPort int
|
||||||
Ip string
|
Ip string
|
||||||
EnableDockerInstall bool
|
EnableDockerInstall bool
|
||||||
|
CaCertPath string
|
||||||
|
PrivateKeyPath string
|
||||||
storePath string
|
storePath string
|
||||||
client Client
|
client Client
|
||||||
}
|
}
|
||||||
@@ -176,20 +182,24 @@ func GetCreateFlags() []cli.Flag {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewDriver(machineName string, storePath string) (drivers.Driver, error) {
|
func NewDriver(machineName string, storePath string, caCert string, privateKey string) (drivers.Driver, error) {
|
||||||
log.WithFields(log.Fields{
|
log.WithFields(log.Fields{
|
||||||
"machineName": machineName,
|
"machineName": machineName,
|
||||||
"storePath": storePath,
|
"storePath": storePath,
|
||||||
|
"caCert": caCert,
|
||||||
|
"privateKey": privateKey,
|
||||||
}).Debug("Instantiating OpenStack driver...")
|
}).Debug("Instantiating OpenStack driver...")
|
||||||
|
|
||||||
return NewDerivedDriver(machineName, storePath, &GenericClient{})
|
return NewDerivedDriver(machineName, storePath, &GenericClient{}, caCert, privateKey)
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewDerivedDriver(machineName string, storePath string, client Client) (*Driver, error) {
|
func NewDerivedDriver(machineName string, storePath string, client Client, caCert string, privateKey string) (*Driver, error) {
|
||||||
return &Driver{
|
return &Driver{
|
||||||
MachineName: machineName,
|
MachineName: machineName,
|
||||||
storePath: storePath,
|
storePath: storePath,
|
||||||
client: client,
|
client: client,
|
||||||
|
CaCertPath: caCert,
|
||||||
|
PrivateKeyPath: privateKey,
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -397,6 +407,38 @@ func (d *Driver) Upgrade() error {
|
|||||||
return fmt.Errorf("unable to upgrade as we are using the custom docker binary with identity auth")
|
return fmt.Errorf("unable to upgrade as we are using the custom docker binary with identity auth")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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) {
|
func (d *Driver) GetSSHCommand(args ...string) (*exec.Cmd, error) {
|
||||||
ip, err := d.GetIP()
|
ip, err := d.GetIP()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -694,21 +736,11 @@ func (d *Driver) waitForInstanceToStart() error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (d *Driver) installDocker() error {
|
func (d *Driver) installDocker() error {
|
||||||
log.WithField("MachineId", d.MachineId).Debug("Adding key to authorized-keys.d...")
|
|
||||||
|
|
||||||
if err := drivers.AddPublicKeyToAuthorizedHosts(d, "/.docker/authorized-keys.d"); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
log.WithField("MachineId", d.MachineId).Debug("Installing docker daemon on the machine")
|
log.WithField("MachineId", d.MachineId).Debug("Installing docker daemon on the machine")
|
||||||
|
|
||||||
if err := d.sshExec([]string{
|
if err := d.sshExec([]string{
|
||||||
`apt-get install -y curl`,
|
`apt-get install -y curl`,
|
||||||
`curl -sSL https://get.docker.com | /bin/sh >/var/log/docker-install.log 2>&1`,
|
`curl -sSL https://get.docker.com | /bin/sh >/var/log/docker-install.log 2>&1`,
|
||||||
`service docker stop`,
|
|
||||||
`curl -sSL https://ehazlett.s3.amazonaws.com/public/docker/linux/docker-1.4.1-136b351e-identity -o /usr/bin/docker`,
|
|
||||||
`echo "export DOCKER_OPTS=\"--auth=identity --host=tcp://0.0.0.0:2376\"" >> /etc/default/docker`,
|
|
||||||
`service docker start`,
|
|
||||||
}); err != nil {
|
}); err != nil {
|
||||||
log.Error("The docker installation failed.")
|
log.Error("The docker installation failed.")
|
||||||
log.Error(
|
log.Error(
|
||||||
|
|||||||
Reference in New Issue
Block a user