Merge branch 'master' into upgrade-govmomi-netip

This commit is contained in:
Tristan Keen 2016-05-31 22:11:18 +01:00
commit 73e8b0de2b
7 changed files with 64 additions and 18 deletions

View File

@ -113,7 +113,7 @@ func main() {
},
cli.StringFlag{
EnvVar: "MACHINE_STORAGE_PATH",
Name: "s, storage-path",
Name: "storage-path, s",
Value: mcndirs.GetBaseDir(),
Usage: "Configures storage path",
},

View File

@ -21,16 +21,19 @@ with Docker Inc. Use 3rd party plugins at your own risk.
| Name | Repository | Maintainer GitHub Handle | Maintainer Email |
| ---------------------- | ------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------- | ------------------------------------------------------------ |
| 1&1 Cloud Server | <https://github.com/1and1/docker-machine-driver-oneandone> | [StackPointCloud, Inc.](https://github.com/stackpointcloud) | sdk@1and1.com |
| Aliyun ECS | <https://github.com/denverdino/docker-machine-driver-aliyunecs> | [denverdino](https://github.com/denverdino)<br/>[menglingwei](https://github.com/menglingwei) | denverdino@gmail.com<br/>v.con@qq.com |
| Amazon Cloud Formation | <https://github.com/jeffellin/machine-cloudformation> | [Jeff Ellin](https://github.com/jeffellin) | acf@ellin.com |
| BrightBox | <https://github.com/brightbox/docker-machine-driver-brightbox> | [NeilW](https://github.com/NeilW) | neil@aldur.co.uk |
| CenturyLink Cloud | <https://github.com/CenturyLinkCloud/docker-machine-driver-clc> | [ack](https://github.com/ack) | albert.choi@ctl.io |
| Citrix XenServer | <https://github.com/xenserver/docker-machine-driver-xenserver> | [robertbreker](https://github.com/robertbreker)<br>[phusl](https://github.com/phusl) | robert.breker@citrix.com<br>phus.lu@citrix.com |
| Docker-In-Docker | <https://github.com/nathanleclaire/docker-machine-driver-dind> | [nathanleclaire](https://github.com/nathanleclaire) | nathan.leclaire@gmail.com |
| HPE OneView | <https://github.com/HewlettPackard/docker-machine-oneview> | [wenlock](https://github.com/wenlock)<br>[miqui](https://github.com/miqui) | wenlock@hpe.com<br>miqui@hpe.com |
| KVM | <https://github.com/dhiltgen/docker-machine-kvm> | [dhiltgen](https://github.com/dhiltgen) | daniel.hiltgen@docker.com |
| OpenNebula | <https://github.com/OpenNebula/docker-machine-opennebula> | [jmelis](https://github.com/jmelis) | jmelis@opennebula.org |
| OVH Cloud | <https://github.com/yadutaf/docker-machine-driver-ovh> | [yadutaf](https://github.com/yadutaf) | jt@yadutaf.fr |
| Packet | <https://github.com/packethost/docker-machine-driver-packet> | [betawaffle](https://github.com/betawaffle) | andy@packet.net |
| ProfitBricks | <https://github.com/profitbricks/docker-machine-driver-profitbricks> | [StackPointCloud, Inc.](https://github.com/stackpointcloud) | legal90@gmail.com |
| Parallels for OSX | <https://github.com/Parallels/docker-machine-parallels> | [legal90](https://github.com/legal90) | legal90@gmail.com |
| RackHD | <https://github.com/emccode/docker-machine-rackhd> | [kacole2](https://github.com/kacole2) | kendrick.coleman@emc.com |
| SAKURA CLOUD | <https://github.com/yamamoto-febc/docker-machine-sakuracloud> | [yamamoto-febc](https://github.com/yamamoto-febc) | yamamoto.febc@gmail.com |

View File

@ -63,6 +63,7 @@ func (c *GenericClient) CreateInstance(d *Driver) (string, error) {
Name: d.MachineName,
FlavorRef: d.FlavorId,
ImageRef: d.ImageId,
UserData: d.UserData,
SecurityGroups: d.SecurityGroups,
AvailabilityZone: d.AvailabilityZone,
}

View File

@ -37,6 +37,7 @@ type Driver struct {
KeyPairName string
NetworkName string
NetworkId string
UserData []byte
PrivateKeyFile string
SecurityGroups []string
FloatingIpPool string
@ -161,6 +162,12 @@ func (d *Driver) GetCreateFlags() []mcnflag.Flag {
Usage: "Private keyfile to use for SSH (absolute path)",
Value: "",
},
mcnflag.StringFlag{
EnvVar: "OS_USER_DATA_FILE",
Name: "openstack-user-data-file",
Usage: "File containing an openstack userdata script",
Value: "",
},
mcnflag.StringFlag{
EnvVar: "OS_NETWORK_NAME",
Name: "openstack-net-name",
@ -270,6 +277,16 @@ func (d *Driver) SetConfigFromFlags(flags drivers.DriverOptions) error {
d.SSHPort = flags.Int("openstack-ssh-port")
d.KeyPairName = flags.String("openstack-keypair-name")
d.PrivateKeyFile = flags.String("openstack-private-key-file")
if flags.String("openstack-user-data-file") != "" {
userData, err := ioutil.ReadFile(flags.String("openstack-user-data-file"))
if err == nil {
d.UserData = userData
} else {
return err
}
}
d.SetSwarmConfigFromFlags(flags)
return d.checkConfig()

View File

@ -86,7 +86,7 @@ func configureSwarm(p Provisioner, swarmOptions swarm.Options, authOptions auth.
},
Binds: []string{hostBind},
PortBindings: map[string][]dockerclient.PortBinding{
"3376/tcp": {
fmt.Sprintf("%s/tcp", port): {
{
HostIp: "0.0.0.0",
HostPort: port,
@ -100,7 +100,7 @@ func configureSwarm(p Provisioner, swarmOptions swarm.Options, authOptions auth.
Env: swarmOptions.Env,
ExposedPorts: map[string]struct{}{
"2375/tcp": {},
"3376/tcp": {},
fmt.Sprintf("%s/tcp", port): {},
},
Cmd: cmdMaster,
HostConfig: masterHostConfig,

View File

@ -332,9 +332,12 @@ func NewExternalClient(sshBinaryPath, user, host string, port int, auth *Auth) (
mode := fi.Mode()
log.Debugf("Using SSH private key: %s (%s)", privateKeyPath, mode)
// Private key file should have strict permissions
if mode != 0600 {
// Abort with correct message
return nil, fmt.Errorf("Permissions %#o for '%s' are too open.", mode, privateKeyPath)
perm := mode.Perm()
if perm&0400 == 0 {
return nil, fmt.Errorf("'%s' is not readable", privateKeyPath)
}
if perm&0077 != 0 {
return nil, fmt.Errorf("permissions %#o for '%s' are too open", perm, privateKeyPath)
}
}
args = append(args, "-i", privateKeyPath)

View File

@ -1,6 +1,9 @@
package ssh
import (
"fmt"
"io/ioutil"
"os"
"runtime"
"testing"
@ -46,39 +49,58 @@ func TestGetSSHCmdArgs(t *testing.T) {
}
func TestNewExternalClient(t *testing.T) {
keyFile, err := ioutil.TempFile("", "docker-machine-tests-dummy-private-key")
if err != nil {
t.Fatal(err)
}
defer keyFile.Close()
keyFilename := keyFile.Name()
defer os.Remove(keyFilename)
cases := []struct {
sshBinaryPath string
user string
host string
port int
auth *Auth
perm os.FileMode
expectedError string
skipOS string
}{
{
sshBinaryPath: "/usr/local/bin/ssh",
user: "docker",
host: "localhost",
port: 22,
auth: &Auth{Keys: []string{"/tmp/private-key-not-exist"}},
expectedError: "stat /tmp/private-key-not-exist: no such file or directory",
skipOS: "none",
},
{
sshBinaryPath: "/usr/local/bin/ssh",
user: "docker",
host: "localhost",
port: 22,
auth: &Auth{Keys: []string{"/dev/null"}},
expectedError: "Permissions 0410000666 for '/dev/null' are too open.",
auth: &Auth{Keys: []string{keyFilename}},
perm: 0400,
skipOS: "windows",
},
{
auth: &Auth{Keys: []string{keyFilename}},
perm: 0100,
expectedError: fmt.Sprintf("'%s' is not readable", keyFilename),
skipOS: "windows",
},
{
auth: &Auth{Keys: []string{keyFilename}},
perm: 0644,
expectedError: fmt.Sprintf("permissions 0644 for '%s' are too open", keyFilename),
skipOS: "windows",
},
}
for _, c := range cases {
if runtime.GOOS != c.skipOS {
keyFile.Chmod(c.perm)
_, err := NewExternalClient(c.sshBinaryPath, c.user, c.host, c.port, c.auth)
if c.expectedError != "" {
assert.EqualError(t, err, c.expectedError)
} else {
assert.Equal(t, err, nil)
}
}
}
}