From 6ea45db0b2c0d920f13d88811bfe3bc229527b3b Mon Sep 17 00:00:00 2001 From: Ritika Srivastava Date: Wed, 18 Dec 2024 14:32:33 -0800 Subject: [PATCH] Add support for cliques Signed-off-by: Ritika Srivastava --- pkg/providers/baremetal/mnnvl.go | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/pkg/providers/baremetal/mnnvl.go b/pkg/providers/baremetal/mnnvl.go index 2bb41bf..0331974 100644 --- a/pkg/providers/baremetal/mnnvl.go +++ b/pkg/providers/baremetal/mnnvl.go @@ -198,17 +198,26 @@ func getClusterOutput(ctx context.Context, domainMap map[string]domain, nodes [] } scanner := bufio.NewScanner(stdout) + cliqueId := "" + clusterUUID := "" + domainName := "" for scanner.Scan() { nodeLine := scanner.Text() arr := strings.Split(nodeLine, ":") nodeName := arr[0] - clusterUUID := strings.TrimSpace(arr[2]) - if !domainIDExists(clusterUUID, domainMap) { - domainMap[clusterUUID] = domain{ + itemName := strings.TrimSpace(arr[1]) + if itemName == "CliqueId" { + cliqueId = strings.TrimSpace(arr[2]) + continue + } + clusterUUID = strings.TrimSpace(arr[2]) + domainName = clusterUUID + cliqueId + if !domainIDExists(domainName, domainMap) { + domainMap[domainName] = domain{ nodeMap: make(map[string]bool), } } - nodeMap := domainMap[clusterUUID].nodeMap + nodeMap := domainMap[domainName].nodeMap nodeMap[nodeName] = true } if err := scanner.Err(); err != nil { @@ -244,7 +253,7 @@ func toGraph(domainMap map[string]domain, treeRoot *topology.Vertex) *topology.V func generateTopologyConfig(ctx context.Context, cis []topology.ComputeInstances) (*topology.Vertex, error) { domainMap := make(map[string]domain) // domainID: domain nodes := getNodeList(cis) - err := getClusterOutput(ctx, domainMap, nodes, "nvidia-smi -q | grep ClusterUUID") + err := getClusterOutput(ctx, domainMap, nodes, `nvidia-smi -q | grep "ClusterUUID\|CliqueId"`) if err != nil { return nil, fmt.Errorf("getClusterOutput failed: %v", err) }