vSphere Cloud provider null pointer exception

SelectByType function in govmomi will panic if deviceType is not Array,
Chan, Map, Ptr, or Slice.  Also checking if vmDevices or vm are nil,
there is nothing to cleanup.
This commit is contained in:
Davide Agnello 2016-09-02 07:50:19 -07:00
parent dfccabe22f
commit 87e721367e

View File

@ -570,6 +570,9 @@ func getVirtualMachineDevices(cfg *VSphereConfig, ctx context.Context, c *govmom
// Removes SCSI controller which is latest attached to VM.
func cleanUpController(newSCSIController types.BaseVirtualDevice, vmDevices object.VirtualDeviceList, vm *object.VirtualMachine, ctx context.Context) error {
if newSCSIController == nil || vmDevices == nil || vm == nil {
return nil
}
ctls := vmDevices.SelectByType(newSCSIController)
if len(ctls) < 1 {
return ErrNoDevicesFound