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

Function LoadByProjectAndName

internal/server/instance/instance_utils.go:321–360  ·  view source on GitHub ↗

LoadByProjectAndName loads an instance by project and name.

(s *state.State, projectName string, instanceName string)

Source from the content-addressed store, hash-verified

319
320// LoadByProjectAndName loads an instance by project and name.
321func LoadByProjectAndName(s *state.State, projectName string, instanceName string) (Instance, error) {
322 // Get the DB record
323 var args db.InstanceArgs
324 var p *api.Project
325 err := s.DB.Cluster.Transaction(context.TODO(), func(ctx context.Context, tx *db.ClusterTx) error {
326 proj, err := cluster.GetProject(ctx, tx.Tx(), projectName)
327 if err != nil {
328 return err
329 }
330
331 p, err = proj.ToAPI(ctx, tx.Tx())
332 if err != nil {
333 return err
334 }
335
336 inst, err := LoadInstanceDatabaseObject(ctx, tx, projectName, instanceName)
337 if err != nil {
338 return err
339 }
340
341 instArgs, err := tx.InstancesToInstanceArgs(ctx, true, *inst)
342 if err != nil {
343 return err
344 }
345
346 args = instArgs[inst.ID]
347
348 return nil
349 })
350 if err != nil {
351 return nil, err
352 }
353
354 inst, err := Load(s, args, *p)
355 if err != nil {
356 return nil, fmt.Errorf("Failed to load instance: %w", err)
357 }
358
359 return inst, nil
360}
361
362// LoadNodeAll loads all instances on this server.
363func LoadNodeAll(s *state.State, instanceType instancetype.Type) ([]Instance, error) {

Callers 15

BridgeUpdateACLsFunction · 0.92
InstanceByVolumeNameFunction · 0.92
UpdateCustomVolumeMethod · 0.92
UnixHotplugRunHandlersFunction · 0.92
USBRunHandlersFunction · 0.92
unixRunHandlersFunction · 0.92
DeleteMethod · 0.92
ExportMethod · 0.92
getRootDiskDeviceMethod · 0.92
DeleteMethod · 0.92

Calls 8

GetProjectFunction · 0.92
TxMethod · 0.80
ErrorfMethod · 0.80
ToAPIMethod · 0.65
LoadFunction · 0.50
TransactionMethod · 0.45

Tested by 1

Used in the wild real call sites across dependent graphs

searching dependent graphs…