From 2cd6d1f0431389f86562758b59936346c8626585 Mon Sep 17 00:00:00 2001 From: Ahmet Alp Balkan Date: Mon, 27 Jun 2016 18:51:29 -0700 Subject: [PATCH] azure: add --azure-storage-type flag MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This allows users to specify type of Azure Storage account to be used to run the machine’s disk and enables users to create SSD-backed machines. Fixes #3542. Signed-off-by: Ahmet Alp Balkan --- docs/drivers/azure.md | 2 ++ drivers/azure/azure.go | 13 +++++++++++-- drivers/azure/azureutil/azureutil.go | 4 +++- 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/docs/drivers/azure.md b/docs/drivers/azure.md index cd96ff24..1403016f 100644 --- a/docs/drivers/azure.md +++ b/docs/drivers/azure.md @@ -68,6 +68,7 @@ Optional: - `--azure-static-public-ip`: Assign a static public IP address to the machine. - `--azure-docker-port`: Port number for Docker engine [$AZURE_DOCKER_PORT] - `--azure-environment`: Azure environment (e.g. `AzurePublicCloud`, `AzureChinaCloud`). +- `--azure-storage-type`: Type of Azure Storage account hosting the OS disk of the machine (e.g. `Standard_LRS`, `Premium_LRS`). [vm-image]: https://azure.microsoft.com/en-us/documentation/articles/resource-groups-vm-searching/ [location]: https://azure.microsoft.com/en-us/regions/ @@ -90,6 +91,7 @@ Environment variables and default values: | `--azure-subnet` | `AZURE_SUBNET` | `docker-machine` | | `--azure-subnet-prefix` | `AZURE_SUBNET_PREFIX` | `192.168.0.0/16` | | `--azure-availability-set` | `AZURE_AVAILABILITY_SET` | `docker-machine` | +| `--azure-storage-type` | `AZURE_STORAGE_TYPE` | `Standard_LRS` | | `--azure-open-port` | - | - | | `--azure-private-ip-address` | - | - | | `--azure-use-private-ip` | - | - | diff --git a/drivers/azure/azure.go b/drivers/azure/azure.go index 8df7dcc5..c281d9ce 100644 --- a/drivers/azure/azure.go +++ b/drivers/azure/azure.go @@ -26,7 +26,7 @@ const ( defaultAzureVNet = "docker-machine-vnet" defaultAzureSubnet = "docker-machine" defaultAzureSubnetPrefix = "192.168.0.0/16" - defaultStorageType = storage.StandardLRS + defaultStorageType = string(storage.StandardLRS) defaultAzureAvailabilitySet = "docker-machine" ) @@ -48,6 +48,7 @@ const ( flAzureUsePrivateIP = "azure-use-private-ip" flAzureStaticPublicIP = "azure-static-public-ip" flAzureNoPublicIP = "azure-no-public-ip" + flAzureStorageType = "azure-storage-type" ) const ( @@ -71,6 +72,7 @@ type Driver struct { SubnetName string SubnetPrefix string AvailabilitySet string + StorageType string OpenPorts []string PrivateIPAddr string @@ -177,6 +179,12 @@ func (d *Driver) GetCreateFlags() []mcnflag.Flag { Name: flAzurePrivateIPAddr, Usage: "Specify a static private IP address for the machine", }, + mcnflag.StringFlag{ + Name: flAzureStorageType, + Usage: "Type of Storage Account to host the OS Disk for the machine", + EnvVar: "AZURE_STORAGE_TYPE", + Value: defaultStorageType, + }, mcnflag.BoolFlag{ Name: flAzureUsePrivateIP, Usage: "Use private IP address of the machine to connect", @@ -217,6 +225,7 @@ func (d *Driver) SetConfigFromFlags(fl drivers.DriverOptions) error { {&d.SubnetName, flAzureSubnet}, {&d.SubnetPrefix, flAzureSubnetPrefix}, {&d.AvailabilitySet, flAzureAvailabilitySet}, + {&d.StorageType, flAzureStorageType}, } for _, f := range flags { *f.target = fl.String(f.flag) @@ -322,7 +331,7 @@ func (d *Driver) Create() error { d.ctx.PublicIPAddressID, d.ctx.SubnetID, d.ctx.NetworkSecurityGroupID, d.PrivateIPAddr); err != nil { return err } - if err := c.CreateStorageAccount(d.ctx, d.ResourceGroup, d.Location, defaultStorageType); err != nil { + if err := c.CreateStorageAccount(d.ctx, d.ResourceGroup, d.Location, storage.AccountType(d.StorageType)); err != nil { return err } if err := d.generateSSHKey(d.ctx); err != nil { diff --git a/drivers/azure/azureutil/azureutil.go b/drivers/azure/azureutil/azureutil.go index 2cb12731..7e6a78f6 100644 --- a/drivers/azure/azureutil/azureutil.go +++ b/drivers/azure/azureutil/azureutil.go @@ -357,7 +357,9 @@ func (a AzureClient) createStorageAccount(resourceGroup, location string, storag name := randomAzureStorageAccountName() // if it's not random enough, then you're unlucky f := logutil.Fields{ "name": name, - "location": location} + "location": location, + "type": storageType, + } log.Info("Creating storage account.", f) _, err := a.storageAccountsClient().Create(resourceGroup, name,