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 astakos.im.models import UserSetting, AstakosUserQuota, Resource
from astakos.im.quotas 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",
)
SETTING = 'PENDING_APPLICATION_LIMIT'
RESOURCE = 'astakos.pending_app'
def main():
def migrate_user_setting():
print 'Migrating user-specific settings...'
try:
resource = Resource.objects.get(name=RESOURCE)
except Resource.DoesNotExist:
print "Resource 'astakos.pending_app' not found."
return
print "Resource '%s' not found." % RESOURCE
exit()
users = set()
settings = UserSetting.objects.filter(setting=SETTING)
......@@ -64,5 +74,37 @@ def main():
qh_sync_users(users)
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.'
exit()
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:
modify_limit()
print
migrate_user_setting()
if not usersetting:
print
reconcile()
if __name__ == '__main__':
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