}
func (conn *Conn) UserSetup(ctx context.Context, options arvados.UserSetupOptions) (map[string]interface{}, error) {
- var setupVM string
- var setupRepo string
- if conn.cluster.Login.LoginCluster != "" {
- if options.VMUUID != "" && options.VMUUID[0:5] != options.UUID[0:5] {
- // When LoginCluster is in effect, and we're
- // setting up a remote user, and we want to
- // give that user access to a local VM, then
- // we need to set up the user on the remote
- // LoginCluster first, followed by calling
- // setup on the local instance to give access
- // to the VM.
- setupVM = options.VMUUID
- options.VMUUID = ""
- }
- if options.RepoName != "" {
- // Similarly, if we want to create a git repo,
- // it should be created on the local cluster,
- // not the remote one.
- setupRepo = options.RepoName
- options.RepoName = ""
+ upstream := conn.localOrLoginCluster()
+ if upstream != conn.local {
+ // When LoginCluster is in effect, and we're setting
+ // up a remote user, and we want to give that user
+ // access to a local VM, we can't include the VM in
+ // the setup call, because the remote cluster won't
+ // recognize it.
+
+ // Similarly, if we want to create a git repo,
+ // it should be created on the local cluster,
+ // not the remote one.
+
+ setupVM := options.VMUUID
+ setupRepo := options.RepoName
+ options.VMUUID = ""
+ options.RepoName = ""
+
+ ret, err := upstream.UserSetup(ctx, options)
+ if err != nil {
+ return ret, err
}
- }
- ret, err := conn.localOrLoginCluster().UserSetup(ctx, options)
- if err != nil {
- return ret, err
- }
-
- if setupVM != "" || setupRepo != "" {
+ // Restore VMUUID and RepoName for the call to local
+ // UserSetup below.
options.VMUUID = setupVM
options.RepoName = setupRepo
- ret, err = conn.local.UserSetup(ctx, options)
}
- return ret, err
+
+ return conn.local.UserSetup(ctx, options)
}
func (conn *Conn) UserUnsetup(ctx context.Context, options arvados.GetOptions) (arvados.User, error) {
"bytes"
"context"
"encoding/json"
- "fmt"
"io"
"math"
"net"
c.Check(err, check.IsNil)
// Make a v2 token of the z3 anonymous user, and use it on z1
- _, anonac1, _ := s.clientsWithToken("z1111", fmt.Sprintf("v2/%v/%v", outAuth.UUID, outAuth.APIToken))
+ _, anonac1, _ := s.clientsWithToken("z1111", outAuth.TokenV2())
outUser2, err := anonac1.CurrentUser()
c.Check(err, check.IsNil)
// z3 anonymous user will be mapped to the z1 anonymous user
c.Check(err, check.IsNil)
// Make a v2 root token to communicate with z3333
- rootctx3, rootac3, _ := s.clientsWithToken("z3333", fmt.Sprintf("v2/%v/%v", outAuth.UUID, outAuth.APIToken))
+ rootctx3, rootac3, _ := s.clientsWithToken("z3333", outAuth.TokenV2())
// Create VM on z3333
var outVM arvados.VirtualMachine