MCPcopy Create free account
hub / github.com/devnullvoid/pvetui / GetNodeForVM

Method GetNodeForVM

internal/ui/components/vm_list.go:214–236  ·  view source on GitHub ↗

GetNodeForVM returns the node object for a given VM by looking it up from the app's node list.

(vm *api.VM)

Source from the content-addressed store, hash-verified

212
213// GetNodeForVM returns the node object for a given VM by looking it up from the app's node list.
214func (vl *VMList) GetNodeForVM(vm *api.VM) *api.Node {
215 if vm == nil || vl.app == nil {
216 return nil
217 }
218
219 // Get nodes from the app's node list
220 nodes := vl.app.nodeList.GetNodes()
221 for _, node := range nodes {
222 if node != nil && node.Name == vm.Node {
223 // In group mode, ensure we match the source profile as well
224 // Node names might collide across clusters, so SourceProfile is crucial
225 if vm.SourceProfile != "" && node.SourceProfile != "" {
226 if node.SourceProfile == vm.SourceProfile {
227 return node
228 }
229 continue
230 }
231 return node
232 }
233 }
234
235 return nil
236}
237
238// GetVMs returns the internal sorted VMs slice.
239func (vl *VMList) GetVMs() []*api.VM {

Callers

nothing calls this directly

Calls 1

GetNodesMethod · 0.65

Tested by

no test coverage detected