Эх сурвалжийг харах

HUE-8946 [core] Add back name as argument to import LDAP group or user commands

Romain 6 жил өмнө
parent
commit
e0f6aa3360

+ 14 - 16
apps/useradmin/src/useradmin/management/commands/import_ldap_group.py

@@ -14,6 +14,7 @@
 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 # See the License for the specific language governing permissions and
 # limitations under the License.
+
 from django.core.management.base import BaseCommand, CommandError
 from django.utils.translation import ugettext_lazy as _t, ugettext as _
 
@@ -22,6 +23,7 @@ from desktop.conf import LDAP
 from useradmin import ldap_access
 from useradmin.views import import_ldap_groups
 
+
 class Command(BaseCommand):
   """
   Handler for importing LDAP groups into the Hue database.
@@ -31,22 +33,18 @@ class Command(BaseCommand):
   all unimported users.
   """
   def add_arguments(self, parser):
-    parser.add_argument("--dn", help=_t("Whether or not the user should be imported by "
-                               "distinguished name."),
-                          action="store_true",
-                          default=False)
-    parser.add_argument("--import-members", help=_t("Import users from the group."),
-                                      action="store_true",
-                                      default=False)
-    parser.add_argument("--import-members-recursive", help=_t("Import users from the group, but also do so recursively."),
-                                                action="store_true",
-                                                default=False)
-    parser.add_argument("--sync-users", help=_t("Sync users in the group."),
-                                  action="store_true",
-                                  default=False)
-    parser.add_argument("--server", help=_t("Server to connect to."),
-                              action="store",
-                              default=None)
+    parser.add_argument('group', nargs='+', type=str)
+
+    parser.add_argument("--dn", help=_t("Whether or not the user should be imported by distinguished name."), action="store_true", default=False)
+    parser.add_argument("--import-members", help=_t("Import users from the group."), action="store_true", default=False)
+    parser.add_argument(
+        "--import-members-recursive",
+        help=_t("Import users from the group, but also do so recursively."),
+        action="store_true",
+        default=False
+    )
+    parser.add_argument("--sync-users", help=_t("Sync users in the group."), action="store_true", default=False)
+    parser.add_argument("--server", help=_t("Server to connect to."), action="store",  default=None)
 
   def handle(self, group=None, **options):
     if group is None:

+ 7 - 10
apps/useradmin/src/useradmin/management/commands/import_ldap_user.py

@@ -14,6 +14,7 @@
 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 # See the License for the specific language governing permissions and
 # limitations under the License.
+
 from django.core.management.base import BaseCommand, CommandError
 from django.utils.translation import ugettext_lazy as _t, ugettext as _
 
@@ -22,6 +23,7 @@ from desktop.conf import LDAP
 from useradmin import ldap_access
 from useradmin.views import import_ldap_users
 
+
 class Command(BaseCommand):
   """
   Handler for importing LDAP users into the Hue database.
@@ -29,16 +31,11 @@ class Command(BaseCommand):
   If a user has been previously imported, this will sync their user information.
   """
   def add_arguments(self, parser):
-      parser.add_argument("--dn", help=_t("Whether or not the user should be imported by "
-                               "distinguished name."),
-                          action="store_true",
-                          default=False)
-      parser.add_argument("--sync-groups", help=_t("Sync groups of the users."),
-                                   action="store_true",
-                                   default=False)
-      parser.add_argument("--server", help=_t("Server to connect to."),
-                              action="store",
-                              default=None)
+    parser.add_argument('user', nargs='+', type=str)
+
+    parser.add_argument("--dn", help=_t("Whether or not the user should be imported by distinguished name."), action="store_true", default=False)
+    parser.add_argument("--sync-groups", help=_t("Sync groups of the users."),  action="store_true", default=False)
+    parser.add_argument("--server", help=_t("Server to connect to."), action="store", default=None)
 
   def handle(self, user=None, **options):
     if user is None: