Merge pull request #8986 from vijayrajah/feature/datadisk-change_name

datadisk name change
This commit is contained in:
Megan Marsh 2020-04-07 11:06:35 -07:00 committed by GitHub
commit 07be1a0a30
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
27 changed files with 89 additions and 16 deletions

View File

@ -394,6 +394,7 @@ type Config struct {
tmpDeploymentName string tmpDeploymentName string
tmpKeyVaultName string tmpKeyVaultName string
tmpOSDiskName string tmpOSDiskName string
tmpDataDiskName string
tmpSubnetName string tmpSubnetName string
tmpVirtualNetworkName string tmpVirtualNetworkName string
tmpNsgName string tmpNsgName string
@ -650,6 +651,7 @@ func setRuntimeValues(c *Config) {
c.tmpNicName = tempName.NicName c.tmpNicName = tempName.NicName
c.tmpPublicIPAddressName = tempName.PublicIPAddressName c.tmpPublicIPAddressName = tempName.PublicIPAddressName
c.tmpOSDiskName = tempName.OSDiskName c.tmpOSDiskName = tempName.OSDiskName
c.tmpDataDiskName = tempName.DataDiskname
c.tmpSubnetName = tempName.SubnetName c.tmpSubnetName = tempName.SubnetName
c.tmpVirtualNetworkName = tempName.VirtualNetworkName c.tmpVirtualNetworkName = tempName.VirtualNetworkName
c.tmpNsgName = tempName.NsgName c.tmpNsgName = tempName.NsgName

View File

@ -37,6 +37,7 @@ func GetVirtualMachineDeployment(config *Config) (*resources.Deployment, error)
DnsNameForPublicIP: &template.TemplateParameter{Value: config.tmpComputeName}, DnsNameForPublicIP: &template.TemplateParameter{Value: config.tmpComputeName},
NicName: &template.TemplateParameter{Value: config.tmpNicName}, NicName: &template.TemplateParameter{Value: config.tmpNicName},
OSDiskName: &template.TemplateParameter{Value: config.tmpOSDiskName}, OSDiskName: &template.TemplateParameter{Value: config.tmpOSDiskName},
DataDiskName: &template.TemplateParameter{Value: config.tmpDataDiskName},
PublicIPAddressName: &template.TemplateParameter{Value: config.tmpPublicIPAddressName}, PublicIPAddressName: &template.TemplateParameter{Value: config.tmpPublicIPAddressName},
SubnetName: &template.TemplateParameter{Value: config.tmpSubnetName}, SubnetName: &template.TemplateParameter{Value: config.tmpSubnetName},
StorageAccountBlobEndpoint: &template.TemplateParameter{Value: config.storageAccountBlobEndpoint}, StorageAccountBlobEndpoint: &template.TemplateParameter{Value: config.storageAccountBlobEndpoint},
@ -96,7 +97,7 @@ func GetVirtualMachineDeployment(config *Config) (*resources.Deployment, error)
if len(config.AdditionalDiskSize) > 0 { if len(config.AdditionalDiskSize) > 0 {
isManaged := config.CustomManagedImageName != "" || (config.ManagedImageName != "" && config.ImagePublisher != "") || config.SharedGallery.Subscription != "" isManaged := config.CustomManagedImageName != "" || (config.ManagedImageName != "" && config.ImagePublisher != "") || config.SharedGallery.Subscription != ""
builder.SetAdditionalDisks(config.AdditionalDiskSize, isManaged, config.diskCachingType) builder.SetAdditionalDisks(config.AdditionalDiskSize, config.tmpDataDiskName, isManaged, config.diskCachingType)
} }
if config.customData != "" { if config.customData != "" {

View File

@ -8,6 +8,9 @@
"adminUsername": { "adminUsername": {
"type": "string" "type": "string"
}, },
"dataDiskName": {
"type": "string"
},
"dnsNameForPublicIP": { "dnsNameForPublicIP": {
"type": "string" "type": "string"
}, },

View File

@ -8,6 +8,9 @@
"adminUsername": { "adminUsername": {
"type": "string" "type": "string"
}, },
"dataDiskName": {
"type": "string"
},
"dnsNameForPublicIP": { "dnsNameForPublicIP": {
"type": "string" "type": "string"
}, },

View File

@ -8,6 +8,9 @@
"adminUsername": { "adminUsername": {
"type": "string" "type": "string"
}, },
"dataDiskName": {
"type": "string"
},
"dnsNameForPublicIP": { "dnsNameForPublicIP": {
"type": "string" "type": "string"
}, },

View File

@ -8,6 +8,9 @@
"adminUsername": { "adminUsername": {
"type": "string" "type": "string"
}, },
"dataDiskName": {
"type": "string"
},
"dnsNameForPublicIP": { "dnsNameForPublicIP": {
"type": "string" "type": "string"
}, },

View File

@ -8,6 +8,9 @@
"adminUsername": { "adminUsername": {
"type": "string" "type": "string"
}, },
"dataDiskName": {
"type": "string"
},
"dnsNameForPublicIP": { "dnsNameForPublicIP": {
"type": "string" "type": "string"
}, },

View File

@ -8,6 +8,9 @@
"adminUsername": { "adminUsername": {
"type": "string" "type": "string"
}, },
"dataDiskName": {
"type": "string"
},
"dnsNameForPublicIP": { "dnsNameForPublicIP": {
"type": "string" "type": "string"
}, },

View File

@ -8,6 +8,9 @@
"adminUsername": { "adminUsername": {
"type": "string" "type": "string"
}, },
"dataDiskName": {
"type": "string"
},
"dnsNameForPublicIP": { "dnsNameForPublicIP": {
"type": "string" "type": "string"
}, },

View File

@ -8,6 +8,9 @@
"adminUsername": { "adminUsername": {
"type": "string" "type": "string"
}, },
"dataDiskName": {
"type": "string"
},
"dnsNameForPublicIP": { "dnsNameForPublicIP": {
"type": "string" "type": "string"
}, },

View File

@ -8,6 +8,9 @@
"adminUsername": { "adminUsername": {
"type": "string" "type": "string"
}, },
"dataDiskName": {
"type": "string"
},
"dnsNameForPublicIP": { "dnsNameForPublicIP": {
"type": "string" "type": "string"
}, },

View File

@ -8,6 +8,9 @@
"adminUsername": { "adminUsername": {
"type": "string" "type": "string"
}, },
"dataDiskName": {
"type": "string"
},
"dnsNameForPublicIP": { "dnsNameForPublicIP": {
"type": "string" "type": "string"
}, },

View File

@ -8,6 +8,9 @@
"adminUsername": { "adminUsername": {
"type": "string" "type": "string"
}, },
"dataDiskName": {
"type": "string"
},
"dnsNameForPublicIP": { "dnsNameForPublicIP": {
"type": "string" "type": "string"
}, },
@ -144,9 +147,9 @@
"createOption": "Empty", "createOption": "Empty",
"diskSizeGB": 32, "diskSizeGB": 32,
"lun": 0, "lun": 0,
"name": "datadisk-1", "name": "[concat(parameters('dataDiskName'),'-1')]",
"vhd": { "vhd": {
"uri": "[concat(parameters('storageAccountBlobEndpoint'),variables('vmStorageAccountContainerName'),'/datadisk-', '1','.vhd')]" "uri": "[concat(parameters('storageAccountBlobEndpoint'),variables('vmStorageAccountContainerName'),parameters('dataDiskName'), '-1','.vhd')]"
} }
} }
], ],

View File

@ -8,6 +8,9 @@
"adminUsername": { "adminUsername": {
"type": "string" "type": "string"
}, },
"dataDiskName": {
"type": "string"
},
"dnsNameForPublicIP": { "dnsNameForPublicIP": {
"type": "string" "type": "string"
}, },
@ -147,7 +150,7 @@
"managedDisk": { "managedDisk": {
"storageAccountType": "Standard_LRS" "storageAccountType": "Standard_LRS"
}, },
"name": "datadisk-1" "name": "[concat(parameters('dataDiskName'),'-1')]"
} }
], ],
"imageReference": { "imageReference": {

View File

@ -8,6 +8,9 @@
"adminUsername": { "adminUsername": {
"type": "string" "type": "string"
}, },
"dataDiskName": {
"type": "string"
},
"dnsNameForPublicIP": { "dnsNameForPublicIP": {
"type": "string" "type": "string"
}, },

View File

@ -15,6 +15,7 @@ type TempName struct {
KeyVaultName string KeyVaultName string
ResourceGroupName string ResourceGroupName string
OSDiskName string OSDiskName string
DataDiskname string
NicName string NicName string
SubnetName string SubnetName string
PublicIPAddressName string PublicIPAddressName string
@ -30,6 +31,7 @@ func NewTempName() *TempName {
tempName.DeploymentName = fmt.Sprintf("pkrdp%s", suffix) tempName.DeploymentName = fmt.Sprintf("pkrdp%s", suffix)
tempName.KeyVaultName = fmt.Sprintf("pkrkv%s", suffix) tempName.KeyVaultName = fmt.Sprintf("pkrkv%s", suffix)
tempName.OSDiskName = fmt.Sprintf("pkros%s", suffix) tempName.OSDiskName = fmt.Sprintf("pkros%s", suffix)
tempName.DataDiskname = fmt.Sprintf("pkrdd%s", suffix)
tempName.NicName = fmt.Sprintf("pkrni%s", suffix) tempName.NicName = fmt.Sprintf("pkrni%s", suffix)
tempName.PublicIPAddressName = fmt.Sprintf("pkrip%s", suffix) tempName.PublicIPAddressName = fmt.Sprintf("pkrip%s", suffix)
tempName.SubnetName = fmt.Sprintf("pkrsn%s", suffix) tempName.SubnetName = fmt.Sprintf("pkrsn%s", suffix)

View File

@ -231,7 +231,7 @@ func (s *TemplateBuilder) SetOSDiskSizeGB(diskSizeGB int32) error {
return nil return nil
} }
func (s *TemplateBuilder) SetAdditionalDisks(diskSizeGB []int32, isManaged bool, cachingType compute.CachingTypes) error { func (s *TemplateBuilder) SetAdditionalDisks(diskSizeGB []int32, dataDiskname string, isManaged bool, cachingType compute.CachingTypes) error {
resource, err := s.getResourceByType(resourceVirtualMachine) resource, err := s.getResourceByType(resourceVirtualMachine)
if err != nil { if err != nil {
return err return err
@ -243,7 +243,8 @@ func (s *TemplateBuilder) SetAdditionalDisks(diskSizeGB []int32, isManaged bool,
for i, additionalSize := range diskSizeGB { for i, additionalSize := range diskSizeGB {
dataDisks[i].DiskSizeGB = to.Int32Ptr(additionalSize) dataDisks[i].DiskSizeGB = to.Int32Ptr(additionalSize)
dataDisks[i].Lun = to.IntPtr(i) dataDisks[i].Lun = to.IntPtr(i)
dataDisks[i].Name = to.StringPtr(fmt.Sprintf("datadisk-%d", i+1)) // dataDisks[i].Name = to.StringPtr(fmt.Sprintf("%s-%d", dataDiskname, i+1))
dataDisks[i].Name = to.StringPtr(fmt.Sprintf("[concat(parameters('dataDiskName'),'-%d')]", i+1))
dataDisks[i].CreateOption = "Empty" dataDisks[i].CreateOption = "Empty"
dataDisks[i].Caching = cachingType dataDisks[i].Caching = cachingType
if isManaged { if isManaged {
@ -251,7 +252,7 @@ func (s *TemplateBuilder) SetAdditionalDisks(diskSizeGB []int32, isManaged bool,
dataDisks[i].ManagedDisk = profile.OsDisk.ManagedDisk dataDisks[i].ManagedDisk = profile.OsDisk.ManagedDisk
} else { } else {
dataDisks[i].Vhd = &compute.VirtualHardDisk{ dataDisks[i].Vhd = &compute.VirtualHardDisk{
URI: to.StringPtr(fmt.Sprintf("[concat(parameters('storageAccountBlobEndpoint'),variables('vmStorageAccountContainerName'),'/datadisk-', '%d','.vhd')]", i+1)), URI: to.StringPtr(fmt.Sprintf("[concat(parameters('storageAccountBlobEndpoint'),variables('vmStorageAccountContainerName'),parameters('dataDiskName'), '-%d','.vhd')]", i+1)),
} }
dataDisks[i].ManagedDisk = nil dataDisks[i].ManagedDisk = nil
} }
@ -581,7 +582,10 @@ const BasicTemplate = `{
}, },
"vmName": { "vmName": {
"type": "string" "type": "string"
} },
"dataDiskName": {
"type": "string"
}
}, },
"variables": { "variables": {
"addressPrefix": "10.0.0.0/16", "addressPrefix": "10.0.0.0/16",

View File

@ -8,6 +8,9 @@
"adminUsername": { "adminUsername": {
"type": "string" "type": "string"
}, },
"dataDiskName": {
"type": "string"
},
"dnsNameForPublicIP": { "dnsNameForPublicIP": {
"type": "string" "type": "string"
}, },

View File

@ -8,6 +8,9 @@
"adminUsername": { "adminUsername": {
"type": "string" "type": "string"
}, },
"dataDiskName": {
"type": "string"
},
"dnsNameForPublicIP": { "dnsNameForPublicIP": {
"type": "string" "type": "string"
}, },

View File

@ -8,6 +8,9 @@
"adminUsername": { "adminUsername": {
"type": "string" "type": "string"
}, },
"dataDiskName": {
"type": "string"
},
"dnsNameForPublicIP": { "dnsNameForPublicIP": {
"type": "string" "type": "string"
}, },

View File

@ -8,6 +8,9 @@
"adminUsername": { "adminUsername": {
"type": "string" "type": "string"
}, },
"dataDiskName": {
"type": "string"
},
"dnsNameForPublicIP": { "dnsNameForPublicIP": {
"type": "string" "type": "string"
}, },

View File

@ -8,6 +8,9 @@
"adminUsername": { "adminUsername": {
"type": "string" "type": "string"
}, },
"dataDiskName": {
"type": "string"
},
"dnsNameForPublicIP": { "dnsNameForPublicIP": {
"type": "string" "type": "string"
}, },
@ -161,7 +164,7 @@
"managedDisk": { "managedDisk": {
"storageAccountType": "Premium_LRS" "storageAccountType": "Premium_LRS"
}, },
"name": "datadisk-1" "name": "[concat(parameters('dataDiskName'),'-1')]"
}, },
{ {
"caching": "ReadWrite", "caching": "ReadWrite",
@ -171,7 +174,7 @@
"managedDisk": { "managedDisk": {
"storageAccountType": "Premium_LRS" "storageAccountType": "Premium_LRS"
}, },
"name": "datadisk-2" "name": "[concat(parameters('dataDiskName'),'-2')]"
} }
], ],
"imageReference": { "imageReference": {

View File

@ -8,6 +8,9 @@
"adminUsername": { "adminUsername": {
"type": "string" "type": "string"
}, },
"dataDiskName": {
"type": "string"
},
"dnsNameForPublicIP": { "dnsNameForPublicIP": {
"type": "string" "type": "string"
}, },
@ -158,9 +161,9 @@
"createOption": "Empty", "createOption": "Empty",
"diskSizeGB": 32, "diskSizeGB": 32,
"lun": 0, "lun": 0,
"name": "datadisk-1", "name": "[concat(parameters('dataDiskName'),'-1')]",
"vhd": { "vhd": {
"uri": "[concat(parameters('storageAccountBlobEndpoint'),variables('vmStorageAccountContainerName'),'/datadisk-', '1','.vhd')]" "uri": "[concat(parameters('storageAccountBlobEndpoint'),variables('vmStorageAccountContainerName'),parameters('dataDiskName'), '-1','.vhd')]"
} }
}, },
{ {
@ -168,9 +171,9 @@
"createOption": "Empty", "createOption": "Empty",
"diskSizeGB": 64, "diskSizeGB": 64,
"lun": 1, "lun": 1,
"name": "datadisk-2", "name": "[concat(parameters('dataDiskName'),'-2')]",
"vhd": { "vhd": {
"uri": "[concat(parameters('storageAccountBlobEndpoint'),variables('vmStorageAccountContainerName'),'/datadisk-', '2','.vhd')]" "uri": "[concat(parameters('storageAccountBlobEndpoint'),variables('vmStorageAccountContainerName'),parameters('dataDiskName'), '-2','.vhd')]"
} }
} }
], ],

View File

@ -8,6 +8,9 @@
"adminUsername": { "adminUsername": {
"type": "string" "type": "string"
}, },
"dataDiskName": {
"type": "string"
},
"dnsNameForPublicIP": { "dnsNameForPublicIP": {
"type": "string" "type": "string"
}, },

View File

@ -8,6 +8,9 @@
"adminUsername": { "adminUsername": {
"type": "string" "type": "string"
}, },
"dataDiskName": {
"type": "string"
},
"dnsNameForPublicIP": { "dnsNameForPublicIP": {
"type": "string" "type": "string"
}, },

View File

@ -138,7 +138,7 @@ func TestBuildWindows01(t *testing.T) {
t.Fatal(err) t.Fatal(err)
} }
err = testSubject.SetAdditionalDisks([]int32{32, 64}, true, compute.CachingTypesReadWrite) err = testSubject.SetAdditionalDisks([]int32{32, 64}, "datadisk", true, compute.CachingTypesReadWrite)
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
} }
@ -166,7 +166,7 @@ func TestBuildWindows02(t *testing.T) {
t.Fatal(err) t.Fatal(err)
} }
err = testSubject.SetAdditionalDisks([]int32{32, 64}, false, compute.CachingTypesReadWrite) err = testSubject.SetAdditionalDisks([]int32{32, 64}, "datadisk", false, compute.CachingTypesReadWrite)
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
} }

View File

@ -27,6 +27,7 @@ type TemplateParameters struct {
ObjectId *TemplateParameter `json:"objectId,omitempty"` ObjectId *TemplateParameter `json:"objectId,omitempty"`
NicName *TemplateParameter `json:"nicName,omitempty"` NicName *TemplateParameter `json:"nicName,omitempty"`
OSDiskName *TemplateParameter `json:"osDiskName,omitempty"` OSDiskName *TemplateParameter `json:"osDiskName,omitempty"`
DataDiskName *TemplateParameter `json:"dataDiskName,omitempty"`
PublicIPAddressName *TemplateParameter `json:"publicIPAddressName,omitempty"` PublicIPAddressName *TemplateParameter `json:"publicIPAddressName,omitempty"`
StorageAccountBlobEndpoint *TemplateParameter `json:"storageAccountBlobEndpoint,omitempty"` StorageAccountBlobEndpoint *TemplateParameter `json:"storageAccountBlobEndpoint,omitempty"`
SubnetName *TemplateParameter `json:"subnetName,omitempty"` SubnetName *TemplateParameter `json:"subnetName,omitempty"`