Преглед изворни кода

[commands] Remove promote_to_superuser Hue command (#3715)

Harsh Gupta пре 1 година
родитељ
комит
7f1227fd42

+ 0 - 68
apps/useradmin/src/useradmin/management/commands/promote_to_superuser.py

@@ -1,68 +0,0 @@
-#!/usr/bin/env python
-# Licensed to Cloudera, Inc. under one
-# or more contributor license agreements.  See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership.  Cloudera, Inc. licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License.  You may obtain a copy of the License at
-#
-#   http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# 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.
-
-import os
-import sys
-import time
-import datetime
-import re
-import logging
-
-from django.core.management.base import BaseCommand, CommandError
-from django.contrib.auth.models import User
-
-import desktop.conf
-
-from django.utils.translation import gettext_lazy as _t, gettext as _
-
-LOG = logging.getLogger()
-
-
-class Command(BaseCommand):
-  """
-  Handler for promoting a user to superuser
-  """
-  def add_arguments(self, parser):
-    parser.add_argument("--usernames", help=_t("User(s) to promote to superuser."), nargs='+', action="store", required=True)
-
-  def handle(self, *args, **options):
-    if options.get("usernames"):
-      try:
-        LOG.warn("Promoting user %s to superuser" % options['usernames'])
-
-        user_exist = []
-        user_not_exist = []
-        usernames = options["usernames"]
-
-        for user in usernames:
-          is_exist = User.objects.filter(username=user).exists()
-          if (is_exist):
-            new_super = User.objects.get(username=user)
-            new_super.is_superuser = True
-            new_super.save()
-            user_exist.append(user)
-          else:
-            user_not_exist.append(user)
-
-        if (user_exist):
-          LOG.info("User(s) promoted to superuser: %s" % user_exist)
-
-        if (user_not_exist):
-          LOG.info("User(s) does not exist: %s" % user_not_exist)
-
-      except Exception as e:
-        LOG.error("EXCEPTION: promoting user %s to superuser failed: %s" % (options['username'], e))

+ 0 - 4
tools/ops/script_runner/README.md

@@ -38,7 +38,6 @@ Type `script_runner help <sub-command>` for help on a specific subcommand.
 `estimate_concurrent_users`
 `hue_desktop_document_cleanup`
 `list_groups`
-`promote_to_superuser`
 `emove_doc2_without_content_object`
 `remove_duplicate_user_preferences`
 `remove_orphaned_docs`
@@ -63,9 +62,6 @@ This checks the access logs and try to estimate the number of active users over
 - `script_runner list_groups`
 This shows all of the groups that exist in Hue.
 
-- `script_runner promote_to_superuser --username cconner`
-This promotes a non-superuser to a superuser.
-
 - `script_runner remove_doc2_without_content_object`
 This removes bad doc2 objects that do not have the content object.
 

+ 0 - 70
tools/ops/script_runner/lib/custom_commands/management/commands/promote_to_superuser.py

@@ -1,70 +0,0 @@
-#!/usr/bin/env python
-
-# Licensed to Cloudera, Inc. under one
-# or more contributor license agreements.  See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership.  Cloudera, Inc. licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License.  You may obtain a copy of the License at
-#
-#     http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# 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.
-
-import os
-import sys
-import time
-import datetime
-import re
-import logging
-
-from django.core.management.base import BaseCommand, CommandError
-from django.contrib.auth.models import User
-
-import desktop.conf
-
-if sys.version_info[0] > 2:
-  from django.utils.translation import gettext_lazy as _t, gettext as _
-else:
-  from django.utils.translation import ugettext_lazy as _t, ugettext as _
-
-LOG = logging.getLogger(__name__)
-
-
-class Command(BaseCommand):
-    """
-    Handler for promoting a user to superuser
-    """
-
-    try:
-        from optparse import make_option
-        option_list = BaseCommand.option_list + (
-            make_option("--username", help=_t("User to delete case sensitive. "),
-                        action="store"),
-        )
-
-    except AttributeError, e:
-        baseoption_test = 'BaseCommand' in str(e) and 'option_list' in str(e)
-        if baseoption_test:
-            def add_arguments(self, parser):
-                parser.add_argument("--username", help=_t("User to delete case sensitive."),
-                                    action="store")
-        else:
-            LOG.exception(str(e))
-            sys.exit(1)
-
-    def handle(self, *args, **options):
-        LOG.warn("Promoting user %s to superuser" % options['username'])
-
-        try:
-            new_super = User.objects.get(username = options['username'])
-            new_super.is_superuser = True
-            new_super.save()
-
-        except Exception as e:
-            LOG.warn("EXCEPTION: promoting user %s to superuser failed: %s" % (options['username'], e))