Revision ae883db3

b/docs/upgrade/upgrade-0.14.rst
88 88

  
89 89

  
90 90
The limit on pending project applications is since 0.14 handled as an
91
Astakos resource, rather than a custom setting. In order to set this
92
limit (replacing setting ASTAKOS_PENDING_APPLICATION_LIMIT) run::
93

  
94
    astakos-host$ snf-manage resource-modify astakos.pending_app --limit <num>
95

  
96
To take into account the user-specific limits we need a data migration. The
97
following command populates the user-specific base quota for resource
98
``astakos.pending_app`` using the deprecated user setting::
91
Astakos resource, rather than a custom setting. Command::
99 92

  
100 93
    astakos-host$ astakos-migrate-0.14
101 94

  
102
Finally, Astakos needs to inform the quota system for the current number
103
of pending applications per user::
104

  
105
    astakos-host$ snf-manage reconcile-resources-astakos --fix
95
will prompt you to set this limit (replacing setting
96
ASTAKOS_PENDING_APPLICATION_LIMIT) and then automatically migrate the
97
user-specific base quota for the new resource ``astakos.pending_app`` using
98
the deprecated user setting.
b/snf-astakos-app/astakos/scripts/upgrade/migrate_014.py
31 31
# interpreted as representing official policies, either expressed
32 32
# or implied, of GRNET S.A.
33 33

  
34
from subprocess import call
34 35
import os
35 36
os.environ['DJANGO_SETTINGS_MODULE'] = 'synnefo.settings'
36 37
from astakos.im.models import UserSetting, AstakosUserQuota, Resource
37 38
from astakos.im.quotas import qh_sync_users
38 39

  
40
from optparse import OptionParser
41

  
42
parser = OptionParser()
43
parser.add_option("--usersetting", dest="usersetting",
44
                  action="store_true", default=False,
45
                  help="Only migrate user-specific settings",
46
                  )
47

  
39 48
SETTING = 'PENDING_APPLICATION_LIMIT'
40 49
RESOURCE = 'astakos.pending_app'
41 50

  
42 51

  
43
def main():
52
def migrate_user_setting():
53
    print 'Migrating user-specific settings...'
44 54
    try:
45 55
        resource = Resource.objects.get(name=RESOURCE)
46 56
    except Resource.DoesNotExist:
47
        print "Resource 'astakos.pending_app' not found."
48
        return
57
        print "Resource '%s' not found." % RESOURCE
58
        exit()
49 59

  
50 60
    users = set()
51 61
    settings = UserSetting.objects.filter(setting=SETTING)
......
64 74
    qh_sync_users(users)
65 75

  
66 76

  
77
def modify_limit():
78
    command = ['snf-manage', 'resource-modify',
79
               RESOURCE, '--limit-interactive']
80
    print 'Running "%s"...' % ' '.join(command)
81
    r = call(command)
82

  
83
    if r != 0:
84
        print ('Setting resource limit failed. Have you registered '
85
               'service astakos?')
86
        print 'Aborting.'
87
        exit()
88

  
89

  
90
def reconcile():
91
    command = ['snf-manage', 'reconcile-resources-astakos', '--fix']
92
    print 'Running "%s"...' % ' '.join(command)
93
    r = call(command)
94

  
95

  
96
def main():
97
    (options, args) = parser.parse_args()
98
    usersetting = options.usersetting
99

  
100
    if not usersetting:
101
        modify_limit()
102
        print
103
    migrate_user_setting()
104
    if not usersetting:
105
        print
106
        reconcile()
107

  
108

  
67 109
if __name__ == '__main__':
68 110
    main()

Also available in: Unified diff