From a639dc839d3b573057e5dd3145e0694270749570 Mon Sep 17 00:00:00 2001 From: Timothy Jones Date: Mon, 1 Jan 2018 16:14:00 +1300 Subject: [PATCH 01/12] Add ssh-port flag to the amazonec2 driver Also changes the description of the amazonec2-ssh-user flag to be more consistent with other drivers. Signed-off-by: Timothy Jones --- drivers/amazonec2/amazonec2.go | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/drivers/amazonec2/amazonec2.go b/drivers/amazonec2/amazonec2.go index c512c9163c..79307f7f75 100644 --- a/drivers/amazonec2/amazonec2.go +++ b/drivers/amazonec2/amazonec2.go @@ -39,6 +39,7 @@ const ( defaultVolumeType = "gp2" defaultZone = "a" defaultSecurityGroup = machineSecurityGroupName + defaultSSHPort = 22 defaultSSHUser = "ubuntu" defaultSpotPrice = "0.50" defaultBlockDurationMinutes = 0 @@ -203,9 +204,15 @@ func (d *Driver) GetCreateFlags() []mcnflag.Flag { Usage: "AWS IAM Instance Profile", EnvVar: "AWS_INSTANCE_PROFILE", }, + mcnflag.IntFlag{ + Name: "amazonec2-ssh-port", + Usage: "SSH port", + Value: defaultSSHPort, + EnvVar: "AWS_SSH_PORT", + }, mcnflag.StringFlag{ Name: "amazonec2-ssh-user", - Usage: "Set the name of the ssh user", + Usage: "SSH username", Value: defaultSSHUser, EnvVar: "AWS_SSH_USER", }, @@ -286,6 +293,7 @@ func NewDriver(hostName, storePath string) *Driver { SpotPrice: defaultSpotPrice, BlockDurationMinutes: defaultBlockDurationMinutes, BaseDriver: &drivers.BaseDriver{ + SSHPort: defaultSSHPort, SSHUser: defaultSSHUser, MachineName: hostName, StorePath: storePath, @@ -354,7 +362,7 @@ func (d *Driver) SetConfigFromFlags(flags drivers.DriverOptions) error { d.VolumeType = flags.String("amazonec2-volume-type") d.IamInstanceProfile = flags.String("amazonec2-iam-instance-profile") d.SSHUser = flags.String("amazonec2-ssh-user") - d.SSHPort = 22 + d.SSHPort = flags.Int("amazonec2-ssh-port") d.PrivateIPOnly = flags.Bool("amazonec2-private-address-only") d.UsePrivateIP = flags.Bool("amazonec2-use-private-address") d.Monitoring = flags.Bool("amazonec2-monitoring") @@ -817,6 +825,14 @@ func (d *Driver) GetSSHHostname() (string, error) { return d.GetIP() } +func (d *Driver) GetSSHPort() (int, error) { + if d.SSHPort == 0 { + d.SSHPort = defaultSSHPort + } + + return d.SSHPort, nil +} + func (d *Driver) GetSSHUsername() string { if d.SSHUser == "" { d.SSHUser = defaultSSHUser @@ -1119,11 +1135,11 @@ func (d *Driver) configureSecurityGroupPermissions(group *ec2.SecurityGroup) ([] perms := []*ec2.IpPermission{} - if !hasPorts["22/tcp"] { + if !hasPorts[fmt.Sprintf("%d/tcp", d.BaseDriver.SSHPort)] { perms = append(perms, &ec2.IpPermission{ IpProtocol: aws.String("tcp"), - FromPort: aws.Int64(22), - ToPort: aws.Int64(22), + FromPort: aws.Int64(int64(d.BaseDriver.SSHPort)), + ToPort: aws.Int64(int64(d.BaseDriver.SSHPort)), IpRanges: []*ec2.IpRange{{CidrIp: aws.String(ipRange)}}, }) } From 56ab5f039bbef8a0ae1be5f5d60278ec1f16f6ba Mon Sep 17 00:00:00 2001 From: Jason-ZW Date: Mon, 11 Jun 2018 15:57:27 +0800 Subject: [PATCH 02/12] Add nonempty flag Signed-off-by: Jason-ZW --- drivers/vmwarefusion/fusion_darwin.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/vmwarefusion/fusion_darwin.go b/drivers/vmwarefusion/fusion_darwin.go index 1211304e31..fb22c96ab5 100644 --- a/drivers/vmwarefusion/fusion_darwin.go +++ b/drivers/vmwarefusion/fusion_darwin.go @@ -436,7 +436,7 @@ func (d *Driver) Start() error { return err } else if !os.IsNotExist(err) { // create mountpoint and mount shared folder - command := "([ ! -d " + shareDir + " ]&& sudo mkdir " + shareDir + "; sudo mount --bind /mnt/hgfs/" + shareDir + " " + shareDir + ") || ([ -f /usr/local/bin/vmhgfs-fuse ]&& sudo /usr/local/bin/vmhgfs-fuse -o allow_other .host:/" + shareName + " " + shareDir + ") || sudo mount -t vmhgfs -o uid=$(id -u),gid=$(id -g) .host:/" + shareName + " " + shareDir + command := "([ ! -d " + shareDir + " ]&& sudo mkdir " + shareDir + "; sudo mount --bind /mnt/hgfs/" + shareDir + " " + shareDir + ") || ([ -f /usr/local/bin/vmhgfs-fuse ]&& sudo /usr/local/bin/vmhgfs-fuse -o nonempty -o allow_other .host:/" + shareName + " " + shareDir + ") || sudo mount -t vmhgfs -o uid=$(id -u),gid=$(id -g) .host:/" + shareName + " " + shareDir vmrun("-gu", B2DUser, "-gp", B2DPass, "runScriptInGuest", d.vmxPath(), "/bin/sh", command) } } From 5bc065d6eb72a0fccaf04e162ff3e723b7dc5b09 Mon Sep 17 00:00:00 2001 From: Gerard Braad Date: Tue, 12 Jun 2018 09:37:14 +0000 Subject: [PATCH 03/12] Allow localized names for Virtual Switch Signed-off-by: Gerard Braad --- drivers/hyperv/hyperv.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/hyperv/hyperv.go b/drivers/hyperv/hyperv.go index 6740f295e4..a980cf11f4 100644 --- a/drivers/hyperv/hyperv.go +++ b/drivers/hyperv/hyperv.go @@ -273,7 +273,7 @@ func (d *Driver) Create() error { func (d *Driver) chooseVirtualSwitch() (string, error) { if d.VSwitch == "" { // Default to the first external switche and in the process avoid DockerNAT - stdout, err := cmdOut("(Hyper-V\\Get-VMSwitch -SwitchType External).Name") + stdout, err := cmdOut("[Console]::OutputEncoding = [Text.Encoding]::UTF8; (Hyper-V\\Get-VMSwitch -SwitchType External).Name") if err != nil { return "", err } @@ -287,7 +287,7 @@ func (d *Driver) chooseVirtualSwitch() (string, error) { return switches[0], nil } - stdout, err := cmdOut("(Hyper-V\\Get-VMSwitch).Name") + stdout, err := cmdOut("[Console]::OutputEncoding = [Text.Encoding]::UTF8; (Hyper-V\\Get-VMSwitch).Name") if err != nil { return "", err } From bfa0cf6750900c6affa3e7b908c4bf894a71b2ef Mon Sep 17 00:00:00 2001 From: Peter Schultz Date: Tue, 3 Jul 2018 09:15:02 +0200 Subject: [PATCH 04/12] drivers/google: Add support for non-default service account Add the --google-service-account flag to create VMs that are not provisioned with the default service account. Signed-off-by: Peter Schultz --- drivers/google/compute_util.go | 2 +- drivers/google/google.go | 44 +++++++++++++++++++++------------- 2 files changed, 28 insertions(+), 18 deletions(-) diff --git a/drivers/google/compute_util.go b/drivers/google/compute_util.go index 3940269e07..e095bab0c0 100644 --- a/drivers/google/compute_util.go +++ b/drivers/google/compute_util.go @@ -265,7 +265,7 @@ func (c *ComputeUtil) createInstance(d *Driver) error { }, ServiceAccounts: []*raw.ServiceAccount{ { - Email: "default", + Email: d.ServiceAccount, Scopes: strings.Split(d.Scopes, ","), }, }, diff --git a/drivers/google/google.go b/drivers/google/google.go index ab9df17922..18a07ee452 100644 --- a/drivers/google/google.go +++ b/drivers/google/google.go @@ -26,6 +26,7 @@ type Driver struct { Preemptible bool UseInternalIP bool UseInternalIPOnly bool + ServiceAccount string Scopes string DiskSize int Project string @@ -35,15 +36,16 @@ type Driver struct { } const ( - defaultZone = "us-central1-a" - defaultUser = "docker-user" - defaultMachineType = "n1-standard-1" - defaultImageName = "ubuntu-os-cloud/global/images/ubuntu-1604-xenial-v20170721" - defaultScopes = "https://www.googleapis.com/auth/devstorage.read_only,https://www.googleapis.com/auth/logging.write,https://www.googleapis.com/auth/monitoring.write" - defaultDiskType = "pd-standard" - defaultDiskSize = 10 - defaultNetwork = "default" - defaultSubnetwork = "" + defaultZone = "us-central1-a" + defaultUser = "docker-user" + defaultMachineType = "n1-standard-1" + defaultImageName = "ubuntu-os-cloud/global/images/ubuntu-1604-xenial-v20170721" + defaultServiceAccount = "default" + defaultScopes = "https://www.googleapis.com/auth/devstorage.read_only,https://www.googleapis.com/auth/logging.write,https://www.googleapis.com/auth/monitoring.write" + defaultDiskType = "pd-standard" + defaultDiskSize = 10 + defaultNetwork = "default" + defaultSubnetwork = "" ) // GetCreateFlags registers the flags this driver adds to @@ -79,6 +81,12 @@ func (d *Driver) GetCreateFlags() []mcnflag.Flag { Usage: "GCE Project", EnvVar: "GOOGLE_PROJECT", }, + mcnflag.StringFlag{ + Name: "google-service-account", + Usage: "GCE Service Account for the VM (email address)", + Value: defaultServiceAccount, + EnvVar: "GOOGLE_SERVICE_ACCOUNT", + }, mcnflag.StringFlag{ Name: "google-scopes", Usage: "GCE Scopes (comma-separated if multiple scopes)", @@ -150,14 +158,15 @@ func (d *Driver) GetCreateFlags() []mcnflag.Flag { // NewDriver creates a Driver with the specified storePath. func NewDriver(machineName string, storePath string) *Driver { return &Driver{ - Zone: defaultZone, - DiskType: defaultDiskType, - DiskSize: defaultDiskSize, - MachineType: defaultMachineType, - MachineImage: defaultImageName, - Network: defaultNetwork, - Subnetwork: defaultSubnetwork, - Scopes: defaultScopes, + Zone: defaultZone, + DiskType: defaultDiskType, + DiskSize: defaultDiskSize, + MachineType: defaultMachineType, + MachineImage: defaultImageName, + Network: defaultNetwork, + Subnetwork: defaultSubnetwork, + ServiceAccount: defaultServiceAccount, + Scopes: defaultScopes, BaseDriver: &drivers.BaseDriver{ SSHUser: defaultUser, MachineName: machineName, @@ -205,6 +214,7 @@ func (d *Driver) SetConfigFromFlags(flags drivers.DriverOptions) error { d.Preemptible = flags.Bool("google-preemptible") d.UseInternalIP = flags.Bool("google-use-internal-ip") || flags.Bool("google-use-internal-ip-only") d.UseInternalIPOnly = flags.Bool("google-use-internal-ip-only") + d.ServiceAccount = flags.String("google-service-account") d.Scopes = flags.String("google-scopes") d.Tags = flags.String("google-tags") d.OpenPorts = flags.StringSlice("google-open-port") From 1e3fa2d2cf0cd4b9b54728a9146897a3990a18f0 Mon Sep 17 00:00:00 2001 From: xinau Date: Tue, 6 Nov 2018 14:41:13 +0000 Subject: [PATCH 05/12] added flag for openstack metadata Signed-off-by: xinau --- drivers/openstack/client.go | 1 + drivers/openstack/openstack.go | 24 ++++++++++++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/drivers/openstack/client.go b/drivers/openstack/client.go index ef84f407db..8b47b86e49 100644 --- a/drivers/openstack/client.go +++ b/drivers/openstack/client.go @@ -69,6 +69,7 @@ func (c *GenericClient) CreateInstance(d *Driver) (string, error) { SecurityGroups: d.SecurityGroups, AvailabilityZone: d.AvailabilityZone, ConfigDrive: d.ConfigDrive, + Metadata: d.GetMetadata(), } if d.NetworkId != "" { serverOpts.Networks = []servers.Network{ diff --git a/drivers/openstack/openstack.go b/drivers/openstack/openstack.go index b6ec9823eb..7e305d840a 100644 --- a/drivers/openstack/openstack.go +++ b/drivers/openstack/openstack.go @@ -49,6 +49,7 @@ type Driver struct { FloatingIpPoolId string IpVersion int ConfigDrive bool + metadata string client Client // ExistingKey keeps track of whether the key was created by us or we used an existing one. If an existing one was used, we shouldn't delete it when the machine is deleted. ExistingKey bool @@ -233,6 +234,12 @@ func (d *Driver) GetCreateFlags() []mcnflag.Flag { Name: "openstack-config-drive", Usage: "Enables the OpenStack config drive for the instance", }, + mcnflag.StringFlag{ + EnvVar: "OS_METADATA", + Name: "openstack-metadata", + Usage: "OpenStack Instance Metadata (e.g. key1,value1,key2,value2)", + Value: "", + }, } } @@ -286,6 +293,7 @@ func (d *Driver) SetConfigFromFlags(flags drivers.DriverOptions) error { d.ImageName = flags.String("openstack-image-name") d.NetworkId = flags.String("openstack-net-id") d.NetworkName = flags.String("openstack-net-name") + d.metadata = flags.String("openstack-metadata") if flags.String("openstack-sec-groups") != "" { d.SecurityGroups = strings.Split(flags.String("openstack-sec-groups"), ",") } @@ -487,6 +495,22 @@ func (d *Driver) Remove() error { return nil } +func (d *Driver) GetMetadata() map[string]string { + metadata := make(map[string]string) + + if d.metadata != "" { + items := strings.Split(d.metadata, ",") + if len(items) > 0 && len(items)%2 != 0 { + log.Warnf("Metadata are not key value in pairs. %d elements found", len(items)) + } + for i := 0; i < len(items)-1; i += 2 { + metadata[items[i]] = items[i+1] + } + } + + return metadata +} + 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" From 7c5bd371800de564e7dfbbabf295aa9b5f389a50 Mon Sep 17 00:00:00 2001 From: Mohit Agarwal Date: Sun, 18 Nov 2018 15:30:04 +0530 Subject: [PATCH 06/12] drivers/softlayer: don't set the request method again It would be set by the request returned by http.NewRequest. Signed-off-by: Mohit Agarwal --- drivers/softlayer/softlayer.go | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/softlayer/softlayer.go b/drivers/softlayer/softlayer.go index 5b12d70303..6d10905dd8 100644 --- a/drivers/softlayer/softlayer.go +++ b/drivers/softlayer/softlayer.go @@ -114,7 +114,6 @@ func (c *Client) newRequest(method, uri string, body interface{}) ([]byte, error } req.SetBasicAuth(c.User, c.ApiKey) - req.Method = method resp, err := client.Do(req) if err != nil { From 8300259a372aa9343f26383715276616710c7834 Mon Sep 17 00:00:00 2001 From: Albin Gustavsson Date: Tue, 8 Jan 2019 23:42:55 +0100 Subject: [PATCH 07/12] Add AWS region eu-north-1 Signed-off-by: Albin Gustavsson --- drivers/amazonec2/region.go | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/amazonec2/region.go b/drivers/amazonec2/region.go index ce52857746..ae990d67ea 100644 --- a/drivers/amazonec2/region.go +++ b/drivers/amazonec2/region.go @@ -19,6 +19,7 @@ var regionDetails map[string]*region = map[string]*region{ "ca-central-1": {"ami-8d9e19e9"}, "cn-north-1": {"ami-cc4499a1"}, // Note: this is 20180126 "cn-northwest-1": {"ami-fd0e1a9f"}, // Note: this is 20180126 + "eu-north-1": {"ami-017ff17f"}, "eu-central-1": {"ami-bc4925d3"}, "eu-west-1": {"ami-0b541372"}, "eu-west-2": {"ami-ff46a298"}, From da59a6ef041870f56387859b9940d83e228eff97 Mon Sep 17 00:00:00 2001 From: Joffrey F Date: Mon, 14 Jan 2019 15:07:04 -0800 Subject: [PATCH 08/12] Remove @shin- from active maintainers list Signed-off-by: Joffrey F --- MAINTAINERS | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/MAINTAINERS b/MAINTAINERS index ce9bfa76ef..b6521e25d1 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -13,9 +13,12 @@ people = [ "dgageot", "jeanlaurent", - "shin-", ] + [Org.Alumni] + people = [ + "shin-", + ] [people] # A reference list of all people associated with the project. @@ -36,5 +39,5 @@ [people.shin-] Name = "Joffrey F" - Email = "joffrey@docker.com" + Email = "f.joffrey@gmail.com" GitHub = "shin-" From 60613ca470897ae9cfe375d8905383695a2781fd Mon Sep 17 00:00:00 2001 From: David Gageot Date: Thu, 17 Jan 2019 14:10:07 -0500 Subject: [PATCH 09/12] Remove myself from the list of maintainers Signed-off-by: David Gageot --- MAINTAINERS | 5 ----- 1 file changed, 5 deletions(-) diff --git a/MAINTAINERS b/MAINTAINERS index b6521e25d1..fec4cb053b 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -27,11 +27,6 @@ # ADD YOURSELF HERE IN ALPHABETICAL ORDER - [people.dgageot] - Name = "David Gageot" - Email = "david.gageot@docker.com" - GitHub = "dgageot" - [people.jeanlaurent] Name = "Jean-Laurent de Morlhon" Email = "jeanlaurent@docker.com" From 7de3f3c0f429ab0a8018da3406aad5fd594dd003 Mon Sep 17 00:00:00 2001 From: Ulysses Souza Date: Thu, 24 Jan 2019 16:42:49 +0100 Subject: [PATCH 10/12] Removing "dgageot" handle form "Core maintainers" since it's description doesn't exist anymore (see 60613ca470897ae9cfe375d8905383695a2781fd) Signed-off-by: Ulysses Souza --- MAINTAINERS | 1 - 1 file changed, 1 deletion(-) diff --git a/MAINTAINERS b/MAINTAINERS index fec4cb053b..bc91f51300 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -11,7 +11,6 @@ [Org] [Org."Core maintainers"] people = [ - "dgageot", "jeanlaurent", ] From 173a41dd536bf2d7cac4126950c698c590f1f3fd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Anders=20F=20Bj=C3=B6rklund?= Date: Sat, 2 Mar 2019 14:12:46 +0100 Subject: [PATCH 11/12] Fix broken IsVTXDisabled detection on AMD CPU MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit VMX is in FeatureNames, but SVM is in ExtraFeatureNames This meant that detection *always* failed for SVM (AMD) Thanks to user @hilbertxia Signed-off-by: Anders F Björklund --- drivers/virtualbox/vtx_intel.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/virtualbox/vtx_intel.go b/drivers/virtualbox/vtx_intel.go index 3f1352ae06..852f451d13 100644 --- a/drivers/virtualbox/vtx_intel.go +++ b/drivers/virtualbox/vtx_intel.go @@ -6,7 +6,7 @@ import "github.com/intel-go/cpuid" // IsVTXDisabled checks if VT-x is disabled in the CPU. func (d *Driver) IsVTXDisabled() bool { - if cpuid.HasFeature(cpuid.VMX) || cpuid.HasFeature(cpuid.SVM) { + if cpuid.HasFeature(cpuid.VMX) || cpuid.HasExtraFeature(cpuid.SVM) { return false } From 8eb98e336b1144cffb9909edace0896235a62c51 Mon Sep 17 00:00:00 2001 From: Serhii R Date: Tue, 14 May 2019 15:29:42 +0300 Subject: [PATCH 12/12] set storage driver to overlay2 for archlinux Signed-off-by: Serhii R --- libmachine/provision/arch.go | 2 +- libmachine/provision/arch_test.go | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/libmachine/provision/arch.go b/libmachine/provision/arch.go index 6a73998301..86dc90cd74 100644 --- a/libmachine/provision/arch.go +++ b/libmachine/provision/arch.go @@ -94,7 +94,7 @@ func (provisioner *ArchProvisioner) Provision(swarmOptions swarm.Options, authOp provisioner.EngineOptions = engineOptions swarmOptions.Env = engineOptions.Env - storageDriver, err := decideStorageDriver(provisioner, "overlay", engineOptions.StorageDriver) + storageDriver, err := decideStorageDriver(provisioner, "overlay2", engineOptions.StorageDriver) if err != nil { return err } diff --git a/libmachine/provision/arch_test.go b/libmachine/provision/arch_test.go index 4aa19b61a6..6533ed39a2 100644 --- a/libmachine/provision/arch_test.go +++ b/libmachine/provision/arch_test.go @@ -14,7 +14,7 @@ func TestArchDefaultStorageDriver(t *testing.T) { p := NewArchProvisioner(&fakedriver.Driver{}).(*ArchProvisioner) p.SSHCommander = provisiontest.NewFakeSSHCommander(provisiontest.FakeSSHCommanderOptions{}) p.Provision(swarm.Options{}, auth.Options{}, engine.Options{}) - if p.EngineOptions.StorageDriver != "overlay" { - t.Fatal("Default storage driver should be overlay") + if p.EngineOptions.StorageDriver != "overlay2" { + t.Fatal("Default storage driver should be overlay2") } }