本文整理匯總了Golang中github.com/Azure/azure-sdk-for-go/arm/compute.DiskCreateOptionTypes函數的典型用法代碼示例。如果您正苦於以下問題:Golang DiskCreateOptionTypes函數的具體用法?Golang DiskCreateOptionTypes怎麽用?Golang DiskCreateOptionTypes使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了DiskCreateOptionTypes函數的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: expandAzureRmVirtualMachineDataDisk
func expandAzureRmVirtualMachineDataDisk(d *schema.ResourceData) ([]compute.DataDisk, error) {
disks := d.Get("storage_data_disk").([]interface{})
data_disks := make([]compute.DataDisk, 0, len(disks))
for _, disk_config := range disks {
config := disk_config.(map[string]interface{})
name := config["name"].(string)
vhd := config["vhd_uri"].(string)
createOption := config["create_option"].(string)
lun := int32(config["lun"].(int))
disk_size := int32(config["disk_size_gb"].(int))
data_disk := compute.DataDisk{
Name: &name,
Vhd: &compute.VirtualHardDisk{
URI: &vhd,
},
Lun: &lun,
DiskSizeGB: &disk_size,
CreateOption: compute.DiskCreateOptionTypes(createOption),
}
data_disks = append(data_disks, data_disk)
}
return data_disks, nil
}
示例2: expandAzureRMVirtualMachineScaleSetsStorageProfileOsDisk
func expandAzureRMVirtualMachineScaleSetsStorageProfileOsDisk(d *schema.ResourceData) (*compute.VirtualMachineScaleSetOSDisk, error) {
osDiskConfigs := d.Get("storage_profile_os_disk").(*schema.Set).List()
osDiskConfig := osDiskConfigs[0].(map[string]interface{})
name := osDiskConfig["name"].(string)
image := osDiskConfig["image"].(string)
caching := osDiskConfig["caching"].(string)
osType := osDiskConfig["os_type"].(string)
createOption := osDiskConfig["create_option"].(string)
var vhdContainers []string
containers := osDiskConfig["vhd_containers"].(*schema.Set).List()
for _, v := range containers {
str := v.(string)
vhdContainers = append(vhdContainers, str)
}
osDisk := &compute.VirtualMachineScaleSetOSDisk{
Name: &name,
Caching: compute.CachingTypes(caching),
OsType: compute.OperatingSystemTypes(osType),
CreateOption: compute.DiskCreateOptionTypes(createOption),
VhdContainers: &vhdContainers,
}
if image != "" {
osDisk.Image = &compute.VirtualHardDisk{
URI: &image,
}
}
return osDisk, nil
}
示例3: expandAzureRmVirtualMachineOsDisk
func expandAzureRmVirtualMachineOsDisk(d *schema.ResourceData) (*compute.OSDisk, error) {
disks := d.Get("storage_os_disk").(*schema.Set).List()
if len(disks) != 1 {
return nil, fmt.Errorf("[ERROR] Only 1 OS Disk Can be specified for an Azure RM Virtual Machine")
}
disk := disks[0].(map[string]interface{})
name := disk["name"].(string)
vhdURI := disk["vhd_uri"].(string)
createOption := disk["create_option"].(string)
osDisk := &compute.OSDisk{
Name: &name,
Vhd: &compute.VirtualHardDisk{
URI: &vhdURI,
},
CreateOption: compute.DiskCreateOptionTypes(createOption),
}
if v := disk["caching"].(string); v != "" {
osDisk.Caching = compute.CachingTypes(v)
}
return osDisk, nil
}
示例4: expandAzureRmVirtualMachineOsDisk
func expandAzureRmVirtualMachineOsDisk(d *schema.ResourceData) (*compute.OSDisk, error) {
disks := d.Get("storage_os_disk").(*schema.Set).List()
disk := disks[0].(map[string]interface{})
name := disk["name"].(string)
vhdURI := disk["vhd_uri"].(string)
imageURI := disk["image_uri"].(string)
createOption := disk["create_option"].(string)
osDisk := &compute.OSDisk{
Name: &name,
Vhd: &compute.VirtualHardDisk{
URI: &vhdURI,
},
CreateOption: compute.DiskCreateOptionTypes(createOption),
}
if v := disk["image_uri"].(string); v != "" {
osDisk.Image = &compute.VirtualHardDisk{
URI: &imageURI,
}
}
if v := disk["os_type"].(string); v != "" {
if v == "linux" {
osDisk.OsType = compute.Linux
} else if v == "windows" {
osDisk.OsType = compute.Windows
} else {
return nil, fmt.Errorf("[ERROR] os_type must be 'linux' or 'windows'")
}
}
if v := disk["caching"].(string); v != "" {
osDisk.Caching = compute.CachingTypes(v)
}
if v := disk["disk_size_gb"].(int); v != 0 {
diskSize := int32(v)
osDisk.DiskSizeGB = &diskSize
}
return osDisk, nil
}