MCPcopy
hub / github.com/lxc/incus / instancePut

Function instancePut

cmd/incusd/instance_put.go:66–213  ·  view source on GitHub ↗

swagger:operation PUT /1.0/instances/{name} instances instance_put Update the instance Updates the instance configuration or trigger a snapshot restore. --- consumes: - application/json produces: - application/json parameters: - in: path name: name description: Instance n

(d *Daemon, r *http.Request)

Source from the content-addressed store, hash-verified

64// "500":
65// $ref: "#/responses/InternalServerError"
66func instancePut(d *Daemon, r *http.Request) response.Response {
67 // Don't mess with instance while in setup mode.
68 <-d.waitReady.Done()
69
70 s := d.State()
71
72 projectName := request.ProjectParam(r)
73
74 // Get the container
75 name, err := pathVar(r, "name")
76 if err != nil {
77 return response.SmartError(err)
78 }
79
80 if internalInstance.IsSnapshot(name) {
81 return response.BadRequest(errors.New("Invalid instance name"))
82 }
83
84 // Handle requests targeted to a container on a different node
85 resp, err := forwardedResponseIfInstanceIsRemote(s, r, projectName, name)
86 if err != nil {
87 return response.SmartError(err)
88 }
89
90 if resp != nil {
91 return resp
92 }
93
94 reverter := revert.New()
95 defer reverter.Fail()
96
97 unlock, err := instanceOperationLock(s.ShutdownCtx, projectName, name)
98 if err != nil {
99 return response.SmartError(err)
100 }
101
102 reverter.Add(func() {
103 unlock()
104 })
105
106 inst, err := instance.LoadByProjectAndName(s, projectName, name)
107 if err != nil {
108 return response.SmartError(err)
109 }
110
111 // Validate the ETag
112 err = localUtil.EtagCheck(r, inst.ETag())
113 if err != nil {
114 return response.PreconditionFailed(err)
115 }
116
117 configRaw := api.InstancePut{}
118 err = json.NewDecoder(r.Body).Decode(&configRaw)
119 if err != nil {
120 return response.BadRequest(err)
121 }
122
123 architecture, err := osarch.ArchitectureID(configRaw.Architecture)

Callers

nothing calls this directly

Calls 15

ProjectParamFunction · 0.92
SmartErrorFunction · 0.92
BadRequestFunction · 0.92
NewFunction · 0.92
LoadByProjectAndNameFunction · 0.92
PreconditionFailedFunction · 0.92
ArchitectureIDFunction · 0.92
GetProfilesIfEnabledFunction · 0.92
GetAllProfileConfigsFunction · 0.92
GetAllProfileDevicesFunction · 0.92
NewURLFunction · 0.92
OperationCreateFunction · 0.92

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…