Additional SCSI controller types support (#7525)
This allows the user to specify new controller types. Before when specifying 'scsi', govmomi defaults to lsilogic-parallel. This patch allows the user to now specify 'scsi-lsi-parallel', 'scsi-buslogic', scsi-paravirtual', and 'scsi-lsi-sas'. Resolves issue https://github.com/hashicorp/terraform/issues/7202
This commit is contained in:
parent
8fa75ea383
commit
71c694cc5f
|
@ -26,6 +26,15 @@ var DefaultDNSServers = []string{
|
||||||
"8.8.4.4",
|
"8.8.4.4",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var DiskControllerTypes = []string{
|
||||||
|
"scsi",
|
||||||
|
"scsi-lsi-parallel",
|
||||||
|
"scsi-buslogic",
|
||||||
|
"scsi-paravirtual",
|
||||||
|
"scsi-lsi-sas",
|
||||||
|
"ide",
|
||||||
|
}
|
||||||
|
|
||||||
type networkInterface struct {
|
type networkInterface struct {
|
||||||
deviceName string
|
deviceName string
|
||||||
label string
|
label string
|
||||||
|
@ -421,9 +430,15 @@ func resourceVSphereVirtualMachine() *schema.Resource {
|
||||||
Default: "scsi",
|
Default: "scsi",
|
||||||
ValidateFunc: func(v interface{}, k string) (ws []string, errors []error) {
|
ValidateFunc: func(v interface{}, k string) (ws []string, errors []error) {
|
||||||
value := v.(string)
|
value := v.(string)
|
||||||
if value != "scsi" && value != "ide" {
|
found := false
|
||||||
|
for _, t := range DiskControllerTypes {
|
||||||
|
if t == value {
|
||||||
|
found = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if !found {
|
||||||
errors = append(errors, fmt.Errorf(
|
errors = append(errors, fmt.Errorf(
|
||||||
"only 'scsi' and 'ide' are supported values for 'controller_type'"))
|
"Supported values for 'controller_type' are %v", strings.Join(DiskControllerTypes, ", ")))
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
},
|
},
|
||||||
|
@ -1160,8 +1175,24 @@ func addHardDisk(vm *object.VirtualMachine, size, iops int64, diskType string, d
|
||||||
log.Printf("[DEBUG] vm devices: %#v\n", devices)
|
log.Printf("[DEBUG] vm devices: %#v\n", devices)
|
||||||
|
|
||||||
var controller types.BaseVirtualController
|
var controller types.BaseVirtualController
|
||||||
controller, err = devices.FindDiskController(controller_type)
|
switch controller_type {
|
||||||
if err != nil {
|
case "scsi":
|
||||||
|
controller, err = devices.FindDiskController(controller_type)
|
||||||
|
case "scsi-lsi-parallel":
|
||||||
|
controller = devices.PickController(&types.VirtualLsiLogicController{})
|
||||||
|
case "scsi-buslogic":
|
||||||
|
controller = devices.PickController(&types.VirtualBusLogicController{})
|
||||||
|
case "scsi-paravirtual":
|
||||||
|
controller = devices.PickController(&types.ParaVirtualSCSIController{})
|
||||||
|
case "scsi-lsi-sas":
|
||||||
|
controller = devices.PickController(&types.VirtualLsiLogicSASController{})
|
||||||
|
case "ide":
|
||||||
|
controller, err = devices.FindDiskController(controller_type)
|
||||||
|
default:
|
||||||
|
return fmt.Errorf("[ERROR] Unsupported disk controller provided: %v", controller_type)
|
||||||
|
}
|
||||||
|
|
||||||
|
if err != nil || controller == nil {
|
||||||
log.Printf("[DEBUG] Couldn't find a %v controller. Creating one..", controller_type)
|
log.Printf("[DEBUG] Couldn't find a %v controller. Creating one..", controller_type)
|
||||||
|
|
||||||
var c types.BaseVirtualDevice
|
var c types.BaseVirtualDevice
|
||||||
|
@ -1172,6 +1203,30 @@ func addHardDisk(vm *object.VirtualMachine, size, iops int64, diskType string, d
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("[ERROR] Failed creating SCSI controller: %v", err)
|
return fmt.Errorf("[ERROR] Failed creating SCSI controller: %v", err)
|
||||||
}
|
}
|
||||||
|
case "scsi-lsi-parallel":
|
||||||
|
// Create scsi controller
|
||||||
|
c, err = devices.CreateSCSIController("lsilogic")
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("[ERROR] Failed creating SCSI controller: %v", err)
|
||||||
|
}
|
||||||
|
case "scsi-buslogic":
|
||||||
|
// Create scsi controller
|
||||||
|
c, err = devices.CreateSCSIController("buslogic")
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("[ERROR] Failed creating SCSI controller: %v", err)
|
||||||
|
}
|
||||||
|
case "scsi-paravirtual":
|
||||||
|
// Create scsi controller
|
||||||
|
c, err = devices.CreateSCSIController("pvscsi")
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("[ERROR] Failed creating SCSI controller: %v", err)
|
||||||
|
}
|
||||||
|
case "scsi-lsi-sas":
|
||||||
|
// Create scsi controller
|
||||||
|
c, err = devices.CreateSCSIController("lsilogic-sas")
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("[ERROR] Failed creating SCSI controller: %v", err)
|
||||||
|
}
|
||||||
case "ide":
|
case "ide":
|
||||||
// Create ide controller
|
// Create ide controller
|
||||||
c, err = devices.CreateIDEController()
|
c, err = devices.CreateIDEController()
|
||||||
|
@ -1188,10 +1243,10 @@ func addHardDisk(vm *object.VirtualMachine, size, iops int64, diskType string, d
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
controller, err = devices.FindDiskController(controller_type)
|
controller = devices.PickController(c.(types.BaseVirtualController))
|
||||||
if err != nil {
|
if controller == nil {
|
||||||
log.Printf("[ERROR] Could not find the new %v controller: %v", controller_type, err)
|
log.Printf("[ERROR] Could not find the new %v controller", controller_type)
|
||||||
return err
|
return fmt.Errorf("Could not find the new %v controller", controller_type)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue