Commit d3d43c85 authored by Giorgos Korfiatis's avatar Giorgos Korfiatis
Browse files

astakos: Move migration script to tools dir

Put the migration script that suspends projects of deactivated users
under astakos/tools, rather than providing it as an snf-manage
parent cad2572f
......@@ -14,8 +14,9 @@ v0.18.1
* Fix a bug in `user-check` management command, where the list of deactivated
users was computed wrongly.
* Move script that suspends projects for deactivated users under
/usr/lib/astakos/tools and fix a bug on the computation of the list
of deactivated users.
.. _Changelog-0.18:
......@@ -14,8 +14,7 @@ Release: UNRELEASED
The Synnefo 0.18.1 release resolves the following issue.
* Fixed a bug in `user-check` management command, where the list of
deactivated users was computed wrongly.
* Fixed a bug on the script that suspends projects for deactivated users.
.. _NEWS-0.18:
......@@ -60,7 +60,7 @@ The upgrade to v0.18 consists of the following steps:
.. code-block:: console$ snf-manage user-check --all-users --suspend-deactivated --noemail --fix$ /usr/lib/astakos/tools/fix_deactivated_users --all-users --noemail --fix
#. Restart services
#!/usr/bin/env python
# Copyright (C) 2010-2016 GRNET S.A.
# This program is free software: you can redistribute it and/or modify
......@@ -13,8 +15,9 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <>.
import string
from datetime import datetime
import sys
import os
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "synnefo.settings")
from optparse import make_option
......@@ -23,20 +26,17 @@ from import SynnefoCommand, CommandError
from import AstakosUser
from import functions, activation_backends
from import is_uuid
from django.conf import settings
class Command(SynnefoCommand):
help = "Check and fix user state"
help = "Check and fix state of projects for deactivated users"
args = "<user ID> (or --all-users)"
option_list = SynnefoCommand.option_list + (
help="Suspend projects if user is deactivated"),
......@@ -78,10 +78,7 @@ class Command(SynnefoCommand):
raise CommandError("Need to specify either a userid "
"or option --all-users.")
userid = None if all_users else args[0]
if options["suspend_deactivated"]:
self.suspend_projects(userid, fix)
self.stderr.write("No action specified.\n")
self.suspend_projects(userid, fix)
def suspend_projects(self, userid, fix):
......@@ -103,9 +100,16 @@ class Command(SynnefoCommand):
reason=SUSPENSION_REASON, fix=fix)
if affected:
verb = "Affected" if fix else "Would affect"
self.stderr.write("%s %s (%s)\n" % (verb,, user.uuid))
count +=1
self.stderr.write("%s %s (%s)\n" %
(verb,, user.uuid))
count += 1
if count:
self.stderr.write("Total %s users.\n" % count)
self.stderr.write("No users affected.\n")
command = Command()
args = sys.argv[:]
args.insert(1, 'fix-deactivated-users')
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment