tasks

package
v1.5.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 11, 2019 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package tasks wraps the operation of VC. It will invoke the operation and wait until it's finished, and then return the execution result or error message.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsAlreadyPoweredOffError added in v1.5.0

func IsAlreadyPoweredOffError(err error) bool

IsAlreadyPoweredOffError verifies that the error is an InvalidPowerState error and returns true if the existing state from the error is powered off

func IsConcurrentAccessError

func IsConcurrentAccessError(err error) bool

IsConcurrentAccessError checks if a raw fault, soap fault or vim fault is ConcurrentAccess error

func IsInvalidArgumentError

func IsInvalidArgumentError(err error) bool

IsInvalidArgumentError checks if a soap fault or vim fault is InvalidArgument error

func IsInvalidPowerStateError added in v1.4.1

func IsInvalidPowerStateError(err error) bool

IsInvalidPowerStateError is an error certifier function for errors coming back from vsphere. It checks for an InvalidPowerStateFault

func IsInvalidStateError added in v1.4.1

func IsInvalidStateError(err error) bool

IsInvalidStateError is an error certifier function for errors coming back from vsphere. It checks for an InvalidStateFault

func IsMethodDisabledError

func IsMethodDisabledError(err error) bool

IsMethodDisabledError checks if a soap fault or vim fault is MethodDisabled error

func IsNotFoundError

func IsNotFoundError(err error) bool

IsNotFoundError checks if a soap fault or vim fault is ManagementObjectNotFound error

func IsRetryError

func IsRetryError(op trace.Operation, err error) bool

Add an additional retry error InvalidArgument This is added for potential race conditions concerning vSAN host partition Normally VM configuration is provided without user input. If there's InvalidArgument fault, it would more possibly be a system error. Details see: https://github.com/vmware/vic/pull/4597

func IsTransientError

func IsTransientError(op trace.Operation, err error) bool

IsTransientError will return true for vSphere errors, which can be fixed by retry. Currently the error includes TaskInProgress, NetworkDisruptedAndConfigRolledBack, FailToLockFaultToleranceVMs, HostCommunication Retry on NetworkDisruptedAndConfigRolledBack is to workaround vSphere issue

func Wait

func Wait(ctx context.Context, f func(context.Context) (Task, error)) error

Wait wraps govmomi operations and wait the operation to complete Sample usage:

info, err := Wait(ctx, func(ctx), (*object.Reference, *TaskInfo, error) {
   return vm, vm.Reconfigure(ctx, config)
})

func WaitForResult

func WaitForResult(ctx context.Context, f func(context.Context) (Task, error)) (*types.TaskInfo, error)

WaitForResult wraps govmomi operations and wait the operation to complete. Return the operation result Sample usage:

info, err := WaitForResult(ctx, func(ctx) (*TaskInfo, error) {
   return vm, vm.Reconfigure(ctx, config)
})

func WaitForResultAndRetryIf

func WaitForResultAndRetryIf(ctx context.Context, f func(context.Context) (Task, error), shouldRetry func(op trace.Operation, err error) bool) (*types.TaskInfo, error)

WaitForResultAndRetryIf wraps govmomi operations and wait the operation to complete, retrying under specified conditions. Return the operation result Sample usage:

info, err := WaitForResult(ctx, func(ctx) (*TaskInfo, error) {
   return vm, vm.Reconfigure(ctx, config)
})

Types

type Task

type Task interface {
	Wait(ctx context.Context) error
	WaitForResult(ctx context.Context, s progress.Sinker) (*types.TaskInfo, error)
}

FIXME: remove this type and refactor to use object.Task from govmomi

this will require a lot of code being touched in a lot of places.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL