X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/139200027a3192260b5ea7c2d0c93a8eb5f8eb7e..689901263ebfdd996da3711236615038e6245db3:/services/keep-balance/keep_service.go diff --git a/services/keep-balance/keep_service.go b/services/keep-balance/keep_service.go index f65355d0d5..27d0af8ebd 100644 --- a/services/keep-balance/keep_service.go +++ b/services/keep-balance/keep_service.go @@ -1,3 +1,7 @@ +// Copyright (C) The Arvados Authors. All rights reserved. +// +// SPDX-License-Identifier: AGPL-3.0 + package main import ( @@ -13,6 +17,7 @@ import ( // KeepService represents a keepstore server that is being rebalanced. type KeepService struct { arvados.KeepService + mounts []*KeepMount *ChangeSet } @@ -74,3 +79,28 @@ func (srv *KeepService) put(c *arvados.Client, path string, data interface{}) er return err } + +func (srv *KeepService) discoverMounts(c *arvados.Client) error { + mounts, err := srv.Mounts(c) + if err != nil { + return fmt.Errorf("%s: error retrieving mounts: %v", srv, err) + } + srv.mounts = nil + for _, m := range mounts { + srv.mounts = append(srv.mounts, &KeepMount{ + KeepMount: m, + KeepService: srv, + }) + } + return nil +} + +type KeepMount struct { + arvados.KeepMount + KeepService *KeepService +} + +// String implements fmt.Stringer. +func (mnt *KeepMount) String() string { + return fmt.Sprintf("%s (%s) on %s", mnt.UUID, mnt.DeviceID, mnt.KeepService) +}