16263: Add omitempty to GetOptions
authorPeter Amstutz <peter.amstutz@curii.com>
Mon, 30 Mar 2020 18:43:36 +0000 (14:43 -0400)
committerPeter Amstutz <peter.amstutz@curii.com>
Mon, 13 Apr 2020 15:27:03 +0000 (11:27 -0400)
Don't try to migrate if activate_remote_user fails.

Arvados-DCO-1.1-Signed-off-by: Peter Amstutz <peter.amstutz@curii.com>

sdk/go/arvados/api.go
sdk/python/arvados/commands/federation_migrate.py

index 7bb3bfaa748a50adcbd60c2fa2b6add4312ec3dd..d5f5dcaf83dcb1444b40d9da0da600102b8d207c 100644 (file)
@@ -60,11 +60,11 @@ var (
 )
 
 type GetOptions struct {
-       UUID         string   `json:"uuid"`
+       UUID         string   `json:"uuid",omitempty`
        Select       []string `json:"select"`
        IncludeTrash bool     `json:"include_trash"`
-       ForwardedFor string   `json:"forwarded_for"`
-       Remote       string   `json:"remote"`
+       ForwardedFor string   `json:"forwarded_for",omitempty`
+       Remote       string   `json:"remote",omitempty`
 }
 
 type UntrashOptions struct {
index b66aa5d7cb0a315c153ed09dbb53cdc5dd785e35..344390b48c920016c1b914f37de9482baa8161b7 100755 (executable)
@@ -352,6 +352,8 @@ def main():
                 continue
 
             # cluster where the migration is happening
+            remote_users = {}
+            got_error = False
             for migratecluster in clusters:
                 migratearv = clusters[migratecluster]
 
@@ -361,14 +363,20 @@ def main():
 
                 newuser = activate_remote_user(args, email, homearv, migratearv, old_user_uuid, new_user_uuid)
                 if newuser is None:
-                    continue
+                    got_error = True
+                remote_users[migratecluster] = newuser
+
+            if not got_error:
+                for migratecluster in clusters:
+                    migratearv = clusters[migratecluster]
+                    newuser = remote_users[migratecluster]
 
-                print("(%s) Migrating %s to %s on %s" % (email, old_user_uuid, new_user_uuid, migratecluster))
+                    print("(%s) Migrating %s to %s on %s" % (email, old_user_uuid, new_user_uuid, migratecluster))
 
-                migrate_user(args, migratearv, email, new_user_uuid, old_user_uuid)
+                    migrate_user(args, migratearv, email, new_user_uuid, old_user_uuid)
 
-                if newuser['username'] != username:
-                    update_username(args, email, new_user_uuid, username, migratecluster, migratearv)
+                    if newuser['username'] != username:
+                        update_username(args, email, new_user_uuid, username, migratecluster, migratearv)
 
 if __name__ == "__main__":
     main()