Skip to content

Commit

Permalink
feat: handling CG in table
Browse files Browse the repository at this point in the history
  • Loading branch information
Hardikl committed Oct 23, 2024
1 parent 10bfb15 commit 8fc5c70
Show file tree
Hide file tree
Showing 2 changed files with 234 additions and 190 deletions.
9 changes: 9 additions & 0 deletions cmd/collectors/rest/plugins/snapmirror/snapmirror.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import (
"github.com/netapp/harvest/v2/pkg/util"
"log/slog"
"path/filepath"
"slices"
"strings"
"time"
)
Expand Down Expand Up @@ -231,6 +232,7 @@ func (m *SnapMirror) updateSMLabels(data *matrix.Matrix) {

func (m *SnapMirror) handleCGRelationships(data *matrix.Matrix, keys []string) {
for _, key := range keys {
var cgSourceVolumes, cgDestinationVolumes []string
cgInstance := data.GetInstance(key)
// find cgName from the destination_location, source_location
cgInstance.SetLabel("destination_cg_name", filepath.Base(cgInstance.GetLabel("destination_location")))
Expand Down Expand Up @@ -267,8 +269,15 @@ func (m *SnapMirror) handleCGRelationships(data *matrix.Matrix, keys []string) {
cgVolumeInstance.SetLabel("relationship_id", "")
cgVolumeInstance.SetLabel("source_volume", sourceVol)
cgVolumeInstance.SetLabel("destination_volume", destinationVol)
cgSourceVolumes = append(cgSourceVolumes, sourceVol)
cgDestinationVolumes = append(cgDestinationVolumes, destinationVol)
}
}
// Update parent CG source and destination volumes
slices.Sort(cgSourceVolumes)
slices.Sort(cgDestinationVolumes)
cgInstance.SetLabel("source_volume", strings.Join(cgSourceVolumes, ","))
cgInstance.SetLabel("destination_volume", strings.Join(cgDestinationVolumes, ","))
}
}

Expand Down
Loading

0 comments on commit 8fc5c70

Please sign in to comment.