Merge pull request #3995 from boumenot/pr-issue-3965
azure: Allow user to override size of OS disk
This commit is contained in:
commit
17c2c6f4f7
|
@ -81,7 +81,8 @@ type Config struct {
|
||||||
VirtualNetworkResourceGroupName string `mapstructure:"virtual_network_resource_group_name"`
|
VirtualNetworkResourceGroupName string `mapstructure:"virtual_network_resource_group_name"`
|
||||||
|
|
||||||
// OS
|
// OS
|
||||||
OSType string `mapstructure:"os_type"`
|
OSType string `mapstructure:"os_type"`
|
||||||
|
OSDiskSizeGB int32 `mapstructure:"os_disk_size_gb"`
|
||||||
|
|
||||||
// Runtime Values
|
// Runtime Values
|
||||||
UserName string
|
UserName string
|
||||||
|
|
|
@ -55,6 +55,10 @@ func GetVirtualMachineDeployment(config *Config) (*resources.Deployment, error)
|
||||||
builder.SetMarketPlaceImage(config.ImagePublisher, config.ImageOffer, config.ImageSku, config.ImageVersion)
|
builder.SetMarketPlaceImage(config.ImagePublisher, config.ImageOffer, config.ImageSku, config.ImageVersion)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if config.OSDiskSizeGB > 0 {
|
||||||
|
builder.SetOSDiskSizeGB(config.OSDiskSizeGB)
|
||||||
|
}
|
||||||
|
|
||||||
if config.VirtualNetworkName != "" {
|
if config.VirtualNetworkName != "" {
|
||||||
builder.SetVirtualNetwork(
|
builder.SetVirtualNetwork(
|
||||||
config.VirtualNetworkResourceGroupName,
|
config.VirtualNetworkResourceGroupName,
|
||||||
|
|
|
@ -3,10 +3,10 @@ package template
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"strings"
|
||||||
|
|
||||||
"github.com/Azure/azure-sdk-for-go/arm/compute"
|
"github.com/Azure/azure-sdk-for-go/arm/compute"
|
||||||
"github.com/Azure/go-autorest/autorest/to"
|
"github.com/Azure/go-autorest/autorest/to"
|
||||||
"strings"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
@ -128,6 +128,18 @@ func (s *TemplateBuilder) SetImageUrl(imageUrl string, osType compute.OperatingS
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (s *TemplateBuilder) SetOSDiskSizeGB(diskSizeGB int32) error {
|
||||||
|
resource, err := s.getResourceByType(resourceVirtualMachine)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
profile := resource.Properties.StorageProfile
|
||||||
|
profile.OsDisk.DiskSizeGB = to.Int32Ptr(diskSizeGB)
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
func (s *TemplateBuilder) SetVirtualNetwork(virtualNetworkResourceGroup, virtualNetworkName, subnetName string) error {
|
func (s *TemplateBuilder) SetVirtualNetwork(virtualNetworkResourceGroup, virtualNetworkName, subnetName string) error {
|
||||||
s.setVariable("virtualNetworkResourceGroup", virtualNetworkResourceGroup)
|
s.setVariable("virtualNetworkResourceGroup", virtualNetworkResourceGroup)
|
||||||
s.setVariable("virtualNetworkName", virtualNetworkName)
|
s.setVariable("virtualNetworkName", virtualNetworkName)
|
||||||
|
|
|
@ -87,6 +87,7 @@
|
||||||
"osDisk": {
|
"osDisk": {
|
||||||
"caching": "ReadWrite",
|
"caching": "ReadWrite",
|
||||||
"createOption": "FromImage",
|
"createOption": "FromImage",
|
||||||
|
"diskSizeGB": 100,
|
||||||
"image": {
|
"image": {
|
||||||
"uri": "http://azure/custom.vhd"
|
"uri": "http://azure/custom.vhd"
|
||||||
},
|
},
|
||||||
|
|
|
@ -73,6 +73,7 @@ func TestBuildLinux02(t *testing.T) {
|
||||||
|
|
||||||
testSubject.BuildLinux("--test-ssh-authorized-key--")
|
testSubject.BuildLinux("--test-ssh-authorized-key--")
|
||||||
testSubject.SetImageUrl("http://azure/custom.vhd", compute.Linux)
|
testSubject.SetImageUrl("http://azure/custom.vhd", compute.Linux)
|
||||||
|
testSubject.SetOSDiskSizeGB(100)
|
||||||
|
|
||||||
err = testSubject.SetVirtualNetwork("--virtual-network-resource-group--", "--virtual-network--", "--subnet-name--")
|
err = testSubject.SetVirtualNetwork("--virtual-network-resource-group--", "--virtual-network--", "--subnet-name--")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -86,6 +86,9 @@ builder.
|
||||||
automatically configure authentication credentials for the provisioned machine. For
|
automatically configure authentication credentials for the provisioned machine. For
|
||||||
`Linux` this configures an SSH authorized key. For `Windows` this
|
`Linux` this configures an SSH authorized key. For `Windows` this
|
||||||
configures a WinRM certificate.
|
configures a WinRM certificate.
|
||||||
|
|
||||||
|
- `os_disk_size_gb` (int32) Specify the size of the OS disk in GB (gigabytes). Values of zero or less than zero are
|
||||||
|
ignored.
|
||||||
|
|
||||||
- `virtual_network_name` (string) Use a pre-existing virtual network for the VM. This option enables private
|
- `virtual_network_name` (string) Use a pre-existing virtual network for the VM. This option enables private
|
||||||
communication with the VM, no public IP address is **used** or **provisioned**. This value should only be set if
|
communication with the VM, no public IP address is **used** or **provisioned**. This value should only be set if
|
||||||
|
|
Loading…
Reference in New Issue