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

Function LoadByName

internal/server/network/network_load.go:49–77  ·  view source on GitHub ↗

LoadByName loads an instantiated network from the database by project and name.

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

Source from the content-addressed store, hash-verified

47
48// LoadByName loads an instantiated network from the database by project and name.
49func LoadByName(s *state.State, projectName string, name string) (Network, error) {
50 var id int64
51 var netInfo *api.Network
52 var netNodes map[int64]db.NetworkNode
53
54 err := s.DB.Cluster.Transaction(context.TODO(), func(ctx context.Context, tx *db.ClusterTx) error {
55 var err error
56
57 id, netInfo, netNodes, err = tx.GetNetworkInAnyState(ctx, projectName, name)
58
59 return err
60 })
61 if err != nil {
62 return nil, err
63 }
64
65 driverFunc, ok := drivers[netInfo.Type]
66 if !ok {
67 return nil, ErrUnknownDriver
68 }
69
70 n := driverFunc()
71 err = n.init(s, id, projectName, netInfo, netNodes)
72 if err != nil {
73 return nil, err
74 }
75
76 return n, nil
77}
78
79// PatchPreCheck checks if there are any unavailable networks.
80func PatchPreCheck() error {

Callers 15

ContentMethod · 0.92
validateConfigMethod · 0.92
validateConfigMethod · 0.92
RegisterMethod · 0.92
validateConfigMethod · 0.92
validateConfigMethod · 0.92
RegisterMethod · 0.92
validateConfigMethod · 0.92
networkPeersGetFunction · 0.92
networkPeersPostFunction · 0.92
networkPeerDeleteFunction · 0.92

Calls 3

GetNetworkInAnyStateMethod · 0.80
initMethod · 0.65
TransactionMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…