# Managed Object - Task(vim.Task)

Property of
  ClusterAttemptedVmInfo, ManagedEntity, ScheduledTaskInfo, StoragePlacementResult, TaskInfo, TaskInProgress, TaskManager, VsanUpgradeSystemUpgradeHistoryItem
Extends
  ExtensibleManagedObject
See also
  LocalizableMessage, MethodFault, TaskInfo, TaskInfoState
Since
  2.0

## Managed Object Description

A task is used to monitor and potentially cancel long running operations.

Properties

Name | Type | Description
--- | --- | ---
info | TaskInfo | Detailed information about this task.
Properties inherited from ExtensibleManagedObject
availableField, value

Methods

Methods defined in this Managed Object
CancelTask, SetTaskDescription, SetTaskState, UpdateProgress
Methods inherited from ExtensibleManagedObject
setCustomValue

# CancelTask(cancel)

Cancels a running or queued task. A task may only be canceled if it is cancelable. Multiple cancel requests will be treated as a single cancelation request. Canceling a completed or already canceled task will throw an InvalidState exception.

If a task is canceled, its runtime state will be set to error and its error state will be set to RequestCanceled.

A cancel operation is asynchronous. The operation may return before the task is canceled.

Required Privileges
  None

Parameters

Name | Type | Description
--- | --- | ---
_this | ManagedObjectReference | A reference to the Task used to make the method call.

Return Value

Type | Description
--- | ---
None

Faults

Type | Description
--- | ---
InvalidState | Thrown if the task is already canceled or completed.
RuntimeFault | Thrown if any type of runtime fault is thrown that is not covered by the other faults; for example, a communication error.

Events

Type
None

Show WSDL type definition
<element xmlns="http://www.w3.org/2001/XMLSchema" xmlns:sms="urn:sms" name="CancelTask" type="sms:CancelTaskRequestType"/> <element xmlns="http://www.w3.org/2001/XMLSchema" xmlns:sms="urn:sms" name="CancelTaskResponse"> <complexType/> </element>

# SetTaskDescription(UpdateDescription)

Updates task description to describe the current phase of the task.

Required Privileges
  Task.Update
Since
  vSphere API 4.0

Parameters

Name | Type | Description
--- | --- | ---
_this | ManagedObjectReference | A reference to the Task used to make the method call.
description P | LocalizableMessage | New description for task Since vSphere API 4.0

P Required privilege: description

Return Value

Type | Description
--- | ---
None

Faults

Type | Description
--- | ---
RuntimeFault | Thrown if any type of runtime fault is thrown that is not covered by the other faults; for example, a communication error.

Events

Type
None

Show WSDL type definition
<element xmlns="http://www.w3.org/2001/XMLSchema" xmlns:sms="urn:sms" name="SetTaskDescription" type="sms:SetTaskDescriptionRequestType"/> <element xmlns="http://www.w3.org/2001/XMLSchema" xmlns:sms="urn:sms" name="SetTaskDescriptionResponse"> <complexType/> </element>

# SetTaskState(setState)

Sets task state and optionally sets results or fault, as appropriate for state

Required Privileges
  Task.Update
Since
  VI API 2.5

Parameters

Name | Type | Description
--- | --- | ---
_this | ManagedObjectReference | A reference to the Task used to make the method call.
state P | TaskInfoState | New state for task Since VI API 2.5
result* P | xsd:anyType | Result to set, valid only if task state is TaskInfo.State.success Since VI API 2.5
fault* P | MethodFault | Fault to set, valid only if task state is error. The fault must be a of a fault type that directly or indirectly extends VimFault. Since VI API 2.5

*Need not be set P Required privilege - see tooltip for details

Return Value

Type | Description
--- | ---
None

Faults

Type | Description
--- | ---
InvalidState | Thrown if attempting to change states after task is completed or in error, or attempting to set the result or fault incorrectly
RuntimeFault | Thrown if any type of runtime fault is thrown that is not covered by the other faults; for example, a communication error.

Events

Type
None

Show WSDL type definition
<element xmlns="http://www.w3.org/2001/XMLSchema" xmlns:sms="urn:sms" name="SetTaskState" type="sms:SetTaskStateRequestType"/> <element xmlns="http://www.w3.org/2001/XMLSchema" xmlns:sms="urn:sms" name="SetTaskStateResponse"> <complexType/> </element>

# UpdateProgress

Sets percentage done for this task and recalculates overall percentage done. If a percentDone value of less than zero or greater than 100 is specified, a value of zero or 100 respectively is used.

Required Privileges
  Task.Update
Since
  VI API 2.5

Parameters

Name | Type | Description
--- | --- | ---
_this | ManagedObjectReference | A reference to the Task used to make the method call.
percentDone P | xsd:int | Percentage to set for this task Since VI API 2.5

P Required privilege: percentDone

Return Value

Type | Description
--- | ---
None

Faults

Type | Description
--- | ---
InvalidState | Thrown if task is not running
OutOfBounds | VirtualCenter 2.x servers throw this fault if percentDone is less than 0 or greater than 100. Newer versions behave as described above, and never throw this fault.
RuntimeFault | Thrown if any type of runtime fault is thrown that is not covered by the other faults; for example, a communication error.

Events

Type
None

Show WSDL type definition
<element xmlns="http://www.w3.org/2001/XMLSchema" xmlns:sms="urn:sms" name="UpdateProgress" type="sms:UpdateProgressRequestType"/> <element xmlns="http://www.w3.org/2001/XMLSchema" xmlns:sms="urn:sms" name="UpdateProgressResponse"> <complexType/> </element>