lxd/operations.go
func operationGet(d *Daemon, r *http.Request) Response {
	id := mux.Vars(r)["id"]

	var body *api.Operation

	// First check if the query is for a local operation from this node
	op, err := operationGetInternal(id)
	if err == nil {
		_, body, err = op.Render()
		if err != nil {
			return SmartError(err)
		}

		return SyncResponse(true, body)
	}

	// Then check if the query is from an operation on another node, and, if so, forward it
	var address string
	err = d.cluster.Transaction(func(tx *db.ClusterTx) error {
		operation, err := tx.OperationByUUID(id)
		if err != nil {
			return err
		}

		address = operation.NodeAddress
		return nil
	})
	if err != nil {
		return SmartError(err)
	}

	cert := d.endpoints.NetworkCert()
	client, err := cluster.Connect(address, cert, false)
	if err != nil {
		return SmartError(err)
	}

	body, _, err = client.GetOperation(id)
	if err != nil {
		return SmartError(err)
	}

	return SyncResponse(true, body)
}
func operationGet(d *Daemon, r *http.Request) Response {
	id := mux.Vars(r)["id"]

	var body *api.Operation

	// First check if the query is for a local operation from this node
	op, err := operationGetInternal(id)
	if err == nil {
		_, body, err = op.Render()
		if err != nil {
			return SmartError(err)
		}

		return SyncResponse(true, body)
	}

	// Then check if the query is from an operation on another node, and, if so, forward it
	var address string
	err = d.cluster.Transaction(func(tx *db.ClusterTx) error {
		operation, err := tx.OperationByUUID(id)
		if err != nil {
			return err
		}

		address = operation.NodeAddress
		return nil
	})
	if err != nil {
		return SmartError(err)
	}

	cert := d.endpoints.NetworkCert()
	client, err := cluster.Connect(address, cert, false)
	if err != nil {
		return SmartError(err)
	}

	body, _, err = client.GetOperation(id)
	if err != nil {
		return SmartError(err)
	}

	return SyncResponse(true, body)
}
// API functions