本文整理汇总了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
}