Verified Commit 3ea0089e authored by Tomasz Maczukin's avatar Tomasz Maczukin Committed by Steve Azzopardi

Add --google-min-cpu-platform option for machine creation

Signed-off-by: Tomasz Maczukin's avatarTomasz Maczukin <[email protected]>
parent e06eb72a
......@@ -40,6 +40,7 @@ type ComputeUtil struct {
SwarmMaster bool
SwarmHost string
openPorts []string
minCPUPlatform string
operationBackoffFactory *backoffFactory
}
......@@ -82,6 +83,7 @@ func newComputeUtil(driver *Driver) (*ComputeUtil, error) {
SwarmHost: driver.SwarmHost,
openPorts: driver.OpenPorts,
operationBackoffFactory: driver.OperationBackoffFactory,
minCPUPlatform: driver.MinCPUPlatform,
}, nil
}
......@@ -248,9 +250,10 @@ func (c *ComputeUtil) createInstance(d *Driver) error {
}
instance := &raw.Instance{
Name: c.instanceName,
Description: "docker host vm",
MachineType: c.zoneURL + "/machineTypes/" + d.MachineType,
Name: c.instanceName,
Description: "docker host vm",
MachineType: c.zoneURL + "/machineTypes/" + d.MachineType,
MinCpuPlatform: c.minCPUPlatform,
Disks: []*raw.AttachedDisk{
{
Boot: true,
......
......@@ -40,6 +40,7 @@ type Driver struct {
*drivers.BaseDriver
Zone string
MachineType string
MinCPUPlatform string
MachineImage string
DiskType string
Address string
......@@ -70,6 +71,7 @@ const (
defaultDiskSize = 10
defaultNetwork = "default"
defaultSubnetwork = ""
defaultMinCPUPlatform = ""
defaultGoogleOperationBackoffInitialInterval = 1
defaultGoogleOperationBackoffRandomizationFactor = "0.5"
......@@ -94,6 +96,12 @@ func (d *Driver) GetCreateFlags() []mcnflag.Flag {
Value: defaultMachineType,
EnvVar: "GOOGLE_MACHINE_TYPE",
},
mcnflag.StringFlag{
Name: "google-min-cpu-platform",
Usage: "Minimal CPU Platform for created VM (use friendly name e.g. 'Intel Sandy Bridge')",
EnvVar: "GOOGLE_MIN_CPU_PLATFORM",
Value: defaultMinCPUPlatform,
},
mcnflag.StringFlag{
Name: "google-machine-image",
Usage: "GCE Machine Image Absolute URL",
......@@ -221,6 +229,7 @@ func NewDriver(machineName string, storePath string) *Driver {
Network: defaultNetwork,
Subnetwork: defaultSubnetwork,
ServiceAccount: defaultServiceAccount,
MinCPUPlatform: defaultMinCPUPlatform,
Scopes: defaultScopes,
BaseDriver: &drivers.BaseDriver{
SSHUser: defaultUser,
......@@ -259,6 +268,7 @@ func (d *Driver) SetConfigFromFlags(flags drivers.DriverOptions) error {
d.UseExisting = flags.Bool("google-use-existing")
if !d.UseExisting {
d.MachineType = flags.String("google-machine-type")
d.MinCPUPlatform = flags.String("google-min-cpu-platform")
d.MachineImage = flags.String("google-machine-image")
d.MachineImage = strings.TrimPrefix(d.MachineImage, "https://www.googleapis.com/compute/v1/projects/")
d.DiskSize = flags.Int("google-disk-size")
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment