Skip to content

Commit 73e8b0d

Browse files
committed
Merge branch 'master' into upgrade-govmomi-netip
2 parents b97ae51 + 2420975 commit 73e8b0d

File tree

7 files changed

+64
-18
lines changed

7 files changed

+64
-18
lines changed

cmd/machine.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ func main() {
113113
},
114114
cli.StringFlag{
115115
EnvVar: "MACHINE_STORAGE_PATH",
116-
Name: "s, storage-path",
116+
Name: "storage-path, s",
117117
Value: mcndirs.GetBaseDir(),
118118
Usage: "Configures storage path",
119119
},

docs/AVAILABLE_DRIVER_PLUGINS.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,16 +21,19 @@ with Docker Inc. Use 3rd party plugins at your own risk.
2121

2222
| Name | Repository | Maintainer GitHub Handle | Maintainer Email |
2323
| ---------------------- | ------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------- | ------------------------------------------------------------ |
24+
| 1&1 Cloud Server | <https://github.com/1and1/docker-machine-driver-oneandone> | [StackPointCloud, Inc.](https://github.com/stackpointcloud) | sdk@1and1.com |
2425
| 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 |
2526
| Amazon Cloud Formation | <https://github.com/jeffellin/machine-cloudformation> | [Jeff Ellin](https://github.com/jeffellin) | acf@ellin.com |
2627
| BrightBox | <https://github.com/brightbox/docker-machine-driver-brightbox> | [NeilW](https://github.com/NeilW) | neil@aldur.co.uk |
2728
| CenturyLink Cloud | <https://github.com/CenturyLinkCloud/docker-machine-driver-clc> | [ack](https://github.com/ack) | albert.choi@ctl.io |
29+
| 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 |
2830
| Docker-In-Docker | <https://github.com/nathanleclaire/docker-machine-driver-dind> | [nathanleclaire](https://github.com/nathanleclaire) | nathan.leclaire@gmail.com |
2931
| 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 |
3032
| KVM | <https://github.com/dhiltgen/docker-machine-kvm> | [dhiltgen](https://github.com/dhiltgen) | daniel.hiltgen@docker.com |
3133
| OpenNebula | <https://github.com/OpenNebula/docker-machine-opennebula> | [jmelis](https://github.com/jmelis) | jmelis@opennebula.org |
3234
| OVH Cloud | <https://github.com/yadutaf/docker-machine-driver-ovh> | [yadutaf](https://github.com/yadutaf) | jt@yadutaf.fr |
3335
| Packet | <https://github.com/packethost/docker-machine-driver-packet> | [betawaffle](https://github.com/betawaffle) | andy@packet.net |
36+
| ProfitBricks | <https://github.com/profitbricks/docker-machine-driver-profitbricks> | [StackPointCloud, Inc.](https://github.com/stackpointcloud) | legal90@gmail.com |
3437
| Parallels for OSX | <https://github.com/Parallels/docker-machine-parallels> | [legal90](https://github.com/legal90) | legal90@gmail.com |
3538
| RackHD | <https://github.com/emccode/docker-machine-rackhd> | [kacole2](https://github.com/kacole2) | kendrick.coleman@emc.com |
3639
| SAKURA CLOUD | <https://github.com/yamamoto-febc/docker-machine-sakuracloud> | [yamamoto-febc](https://github.com/yamamoto-febc) | yamamoto.febc@gmail.com |

drivers/openstack/client.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ func (c *GenericClient) CreateInstance(d *Driver) (string, error) {
6363
Name: d.MachineName,
6464
FlavorRef: d.FlavorId,
6565
ImageRef: d.ImageId,
66+
UserData: d.UserData,
6667
SecurityGroups: d.SecurityGroups,
6768
AvailabilityZone: d.AvailabilityZone,
6869
}

drivers/openstack/openstack.go

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ type Driver struct {
3737
KeyPairName string
3838
NetworkName string
3939
NetworkId string
40+
UserData []byte
4041
PrivateKeyFile string
4142
SecurityGroups []string
4243
FloatingIpPool string
@@ -161,6 +162,12 @@ func (d *Driver) GetCreateFlags() []mcnflag.Flag {
161162
Usage: "Private keyfile to use for SSH (absolute path)",
162163
Value: "",
163164
},
165+
mcnflag.StringFlag{
166+
EnvVar: "OS_USER_DATA_FILE",
167+
Name: "openstack-user-data-file",
168+
Usage: "File containing an openstack userdata script",
169+
Value: "",
170+
},
164171
mcnflag.StringFlag{
165172
EnvVar: "OS_NETWORK_NAME",
166173
Name: "openstack-net-name",
@@ -270,6 +277,16 @@ func (d *Driver) SetConfigFromFlags(flags drivers.DriverOptions) error {
270277
d.SSHPort = flags.Int("openstack-ssh-port")
271278
d.KeyPairName = flags.String("openstack-keypair-name")
272279
d.PrivateKeyFile = flags.String("openstack-private-key-file")
280+
281+
if flags.String("openstack-user-data-file") != "" {
282+
userData, err := ioutil.ReadFile(flags.String("openstack-user-data-file"))
283+
if err == nil {
284+
d.UserData = userData
285+
} else {
286+
return err
287+
}
288+
}
289+
273290
d.SetSwarmConfigFromFlags(flags)
274291

275292
return d.checkConfig()

libmachine/provision/configure_swarm.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ func configureSwarm(p Provisioner, swarmOptions swarm.Options, authOptions auth.
8686
},
8787
Binds: []string{hostBind},
8888
PortBindings: map[string][]dockerclient.PortBinding{
89-
"3376/tcp": {
89+
fmt.Sprintf("%s/tcp", port): {
9090
{
9191
HostIp: "0.0.0.0",
9292
HostPort: port,
@@ -99,8 +99,8 @@ func configureSwarm(p Provisioner, swarmOptions swarm.Options, authOptions auth.
9999
Image: swarmOptions.Image,
100100
Env: swarmOptions.Env,
101101
ExposedPorts: map[string]struct{}{
102-
"2375/tcp": {},
103-
"3376/tcp": {},
102+
"2375/tcp": {},
103+
fmt.Sprintf("%s/tcp", port): {},
104104
},
105105
Cmd: cmdMaster,
106106
HostConfig: masterHostConfig,

libmachine/ssh/client.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -332,9 +332,12 @@ func NewExternalClient(sshBinaryPath, user, host string, port int, auth *Auth) (
332332
mode := fi.Mode()
333333
log.Debugf("Using SSH private key: %s (%s)", privateKeyPath, mode)
334334
// Private key file should have strict permissions
335-
if mode != 0600 {
336-
// Abort with correct message
337-
return nil, fmt.Errorf("Permissions %#o for '%s' are too open.", mode, privateKeyPath)
335+
perm := mode.Perm()
336+
if perm&0400 == 0 {
337+
return nil, fmt.Errorf("'%s' is not readable", privateKeyPath)
338+
}
339+
if perm&0077 != 0 {
340+
return nil, fmt.Errorf("permissions %#o for '%s' are too open", perm, privateKeyPath)
338341
}
339342
}
340343
args = append(args, "-i", privateKeyPath)

libmachine/ssh/client_test.go

Lines changed: 33 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
package ssh
22

33
import (
4+
"fmt"
5+
"io/ioutil"
6+
"os"
47
"runtime"
58
"testing"
69

@@ -46,39 +49,58 @@ func TestGetSSHCmdArgs(t *testing.T) {
4649
}
4750

4851
func TestNewExternalClient(t *testing.T) {
52+
keyFile, err := ioutil.TempFile("", "docker-machine-tests-dummy-private-key")
53+
if err != nil {
54+
t.Fatal(err)
55+
}
56+
defer keyFile.Close()
57+
58+
keyFilename := keyFile.Name()
59+
defer os.Remove(keyFilename)
60+
4961
cases := []struct {
5062
sshBinaryPath string
5163
user string
5264
host string
5365
port int
5466
auth *Auth
67+
perm os.FileMode
5568
expectedError string
5669
skipOS string
5770
}{
5871
{
59-
sshBinaryPath: "/usr/local/bin/ssh",
60-
user: "docker",
61-
host: "localhost",
62-
port: 22,
6372
auth: &Auth{Keys: []string{"/tmp/private-key-not-exist"}},
6473
expectedError: "stat /tmp/private-key-not-exist: no such file or directory",
6574
skipOS: "none",
6675
},
6776
{
68-
sshBinaryPath: "/usr/local/bin/ssh",
69-
user: "docker",
70-
host: "localhost",
71-
port: 22,
72-
auth: &Auth{Keys: []string{"/dev/null"}},
73-
expectedError: "Permissions 0410000666 for '/dev/null' are too open.",
77+
auth: &Auth{Keys: []string{keyFilename}},
78+
perm: 0400,
79+
skipOS: "windows",
80+
},
81+
{
82+
auth: &Auth{Keys: []string{keyFilename}},
83+
perm: 0100,
84+
expectedError: fmt.Sprintf("'%s' is not readable", keyFilename),
85+
skipOS: "windows",
86+
},
87+
{
88+
auth: &Auth{Keys: []string{keyFilename}},
89+
perm: 0644,
90+
expectedError: fmt.Sprintf("permissions 0644 for '%s' are too open", keyFilename),
7491
skipOS: "windows",
7592
},
7693
}
7794

7895
for _, c := range cases {
7996
if runtime.GOOS != c.skipOS {
97+
keyFile.Chmod(c.perm)
8098
_, err := NewExternalClient(c.sshBinaryPath, c.user, c.host, c.port, c.auth)
81-
assert.EqualError(t, err, c.expectedError)
99+
if c.expectedError != "" {
100+
assert.EqualError(t, err, c.expectedError)
101+
} else {
102+
assert.Equal(t, err, nil)
103+
}
82104
}
83105
}
84106
}

0 commit comments

Comments
 (0)