Commit 1b469734 authored by Giorgos Korfiatis's avatar Giorgos Korfiatis Committed by Georgios D. Tsoukalas
Browse files

astakos: Merge 3 migration steps in one script

astakos-migrate-0.14 will first run
  snf-manage resource-modify astakos.pending_app --limit-interactive
then migrate the user-specific settings and then run
  snf-manage reconcile-resources-astakos --fix

Option `--usersetting' will run only the second step (data migration).
parent 64da8822
......@@ -88,18 +88,11 @@ Run::
The limit on pending project applications is since 0.14 handled as an
Astakos resource, rather than a custom setting. In order to set this
limit (replacing setting ASTAKOS_PENDING_APPLICATION_LIMIT) run::
astakos-host$ snf-manage resource-modify astakos.pending_app --limit <num>
To take into account the user-specific limits we need a data migration. The
following command populates the user-specific base quota for resource
``astakos.pending_app`` using the deprecated user setting::
Astakos resource, rather than a custom setting. Command::
astakos-host$ astakos-migrate-0.14
Finally, Astakos needs to inform the quota system for the current number
of pending applications per user::
astakos-host$ snf-manage reconcile-resources-astakos --fix
will prompt you to set this limit (replacing setting
ASTAKOS_PENDING_APPLICATION_LIMIT) and then automatically migrate the
user-specific base quota for the new resource ``astakos.pending_app`` using
the deprecated user setting.
......@@ -31,21 +31,31 @@
# interpreted as representing official policies, either expressed
# or implied, of GRNET S.A.
from subprocess import call
import os
os.environ['DJANGO_SETTINGS_MODULE'] = 'synnefo.settings'
from import UserSetting, AstakosUserQuota, Resource
from import qh_sync_users
from optparse import OptionParser
parser = OptionParser()
parser.add_option("--usersetting", dest="usersetting",
action="store_true", default=False,
help="Only migrate user-specific settings",
RESOURCE = 'astakos.pending_app'
def main():
def migrate_user_setting():
print 'Migrating user-specific settings...'
resource = Resource.objects.get(name=RESOURCE)
except Resource.DoesNotExist:
print "Resource 'astakos.pending_app' not found."
print "Resource '%s' not found." % RESOURCE
users = set()
settings = UserSetting.objects.filter(setting=SETTING)
......@@ -64,5 +74,37 @@ def main():
def modify_limit():
command = ['snf-manage', 'resource-modify',
RESOURCE, '--limit-interactive']
print 'Running "%s"...' % ' '.join(command)
r = call(command)
if r != 0:
print ('Setting resource limit failed. Have you registered '
'service astakos?')
print 'Aborting.'
def reconcile():
command = ['snf-manage', 'reconcile-resources-astakos', '--fix']
print 'Running "%s"...' % ' '.join(command)
r = call(command)
def main():
(options, args) = parser.parse_args()
usersetting = options.usersetting
if not usersetting:
if not usersetting:
if __name__ == '__main__':
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