Merge branch '15781-multi-value-property-search'
[arvados.git] / services / keep-balance / keep_service.go
index f65355d0d5f885f10ea463d6ebc949f0d35ed64b..e2adf1a4b79942b9457beb2ccd31df31abbb96b9 100644 (file)
@@ -1,3 +1,7 @@
+// Copyright (C) The Arvados Authors. All rights reserved.
+//
+// SPDX-License-Identifier: AGPL-3.0
+
 package main
 
 import (
@@ -7,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
 }
 
@@ -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)
+}