GetNodeForVM returns the node object for a given VM by looking it up from the app's node list.
(vm *api.VM)
| 212 | |
| 213 | // GetNodeForVM returns the node object for a given VM by looking it up from the app's node list. |
| 214 | func (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. |
| 239 | func (vl *VMList) GetVMs() []*api.VM { |