Merge branch '16080-github' refs #16080
[arvados.git] / services / keep-balance / keep_service.go
index 41f22ab7d6c5c2c95ab7f492cbe86ea1ca3bb8dd..e2adf1a4b79942b9457beb2ccd31df31abbb96b9 100644 (file)
@@ -11,12 +11,13 @@ import (
        "io/ioutil"
        "net/http"
 
-       "git.curoverse.com/arvados.git/sdk/go/arvados"
+       "git.arvados.org/arvados.git/sdk/go/arvados"
 )
 
 // KeepService represents a keepstore server that is being rebalanced.
 type KeepService struct {
        arvados.KeepService
+       mounts []*KeepMount
        *ChangeSet
 }
 
@@ -78,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)
+}