lxd: github.com/lxc/lxd/lxd/operations Index | Files

package operations

import "github.com/lxc/lxd/lxd/operations"


Package Files

linux.go operations.go response.go websocket.go


const (
    // OperationClassTask represents the Task OperationClass
    OperationClassTask operationClass = 1
    // OperationClassWebsocket represents the Websocket OperationClass
    OperationClassWebsocket operationClass = 2
    // OperationClassToken represents the Token OperationClass
    OperationClassToken operationClass = 3

func ForwardedOperationResponse Uses

func ForwardedOperationResponse(project string, op *api.Operation) response.Response

ForwardedOperationResponse creates a response that forwards the metadata of an operation created on another node.

func ForwardedOperationWebSocket Uses

func ForwardedOperationWebSocket(req *http.Request, id string, source *websocket.Conn) response.Response

ForwardedOperationWebSocket returns a new forwarted websocket operation.

func Init Uses

func Init(d bool)

Init sets the debug value for the operations package.

func Lock Uses

func Lock()

Lock locks the operations mutex.

func OperationResponse Uses

func OperationResponse(op *Operation) response.Response

OperationResponse returns an operation response.

func OperationWebSocket Uses

func OperationWebSocket(req *http.Request, op *Operation) response.Response

OperationWebSocket returns a new websocket operation.

func Operations Uses

func Operations() map[string]*Operation

Operations returns a map of operations.

func Unlock Uses

func Unlock()

Unlock unlocks the operations mutex.

type Operation Uses

type Operation struct {
    // contains filtered or unexported fields

Operation represents an operation.

func OperationCreate Uses

func OperationCreate(s *state.State, project string, opClass operationClass, opType db.OperationType, opResources map[string][]string, opMetadata interface{}, onRun func(*Operation) error, onCancel func(*Operation) error, onConnect func(*Operation, *http.Request, http.ResponseWriter) error) (*Operation, error)

OperationCreate creates a new operation and returns it. If it cannot be created, it returns an error.

func OperationGetInternal Uses

func OperationGetInternal(id string) (*Operation, error)

OperationGetInternal returns the operation with the given id. It returns an error if it doesn't exist.

func (*Operation) Cancel Uses

func (op *Operation) Cancel() (chan error, error)

Cancel cancels a running operation. If the operation cannot be cancelled, it returns an error.

func (*Operation) Connect Uses

func (op *Operation) Connect(r *http.Request, w http.ResponseWriter) (chan error, error)

Connect connects a websocket operation. If the operation is not a websocket operation or the operation is not running, it returns an error.

func (*Operation) ID Uses

func (op *Operation) ID() string

ID returns the operation ID.

func (*Operation) Metadata Uses

func (op *Operation) Metadata() map[string]interface{}

Metadata returns the operation Metadata.

func (*Operation) Permission Uses

func (op *Operation) Permission() string

Permission returns the operation permission.

func (*Operation) Project Uses

func (op *Operation) Project() string

Project returns the operation project.

func (*Operation) Render Uses

func (op *Operation) Render() (string, *api.Operation, error)

Render renders the operation structure.

func (*Operation) Resources Uses

func (op *Operation) Resources() map[string][]string

Resources returns the operation resources.

func (*Operation) Run Uses

func (op *Operation) Run() (chan error, error)

Run runs a pending operation. It returns an error if the operation cannot be started.

func (*Operation) SetCanceler Uses

func (op *Operation) SetCanceler(canceler *cancel.Canceler)

SetCanceler sets a canceler.

func (*Operation) SetEventServer Uses

func (op *Operation) SetEventServer(events *events.Server)

SetEventServer allows injection of event server.

func (*Operation) Status Uses

func (op *Operation) Status() api.StatusCode

Status returns the operation status.

func (*Operation) URL Uses

func (op *Operation) URL() string

URL returns the operation URL.

func (*Operation) UpdateMetadata Uses

func (op *Operation) UpdateMetadata(opMetadata interface{}) error

UpdateMetadata updates the metadata of the operation. It returns an error if the operation is not pending or running, or the operation is read-only.

func (*Operation) UpdateResources Uses

func (op *Operation) UpdateResources(opResources map[string][]string) error

UpdateResources updates the resources of the operation. It returns an error if the operation is not pending or running, or the operation is read-only.

func (*Operation) WaitFinal Uses

func (op *Operation) WaitFinal(timeout int) (bool, error)

WaitFinal waits for the operation to be done. If timeout is -1, it will wait indefinitely otherwise it will timeout after {timeout} seconds.

Package operations imports 17 packages (graph) and is imported by 21 packages. Updated 2019-12-01. Refresh now. Tools for package owners.