settings.py 11.2 KB
Newer Older
Sofia Papagiannaki's avatar
Sofia Papagiannaki committed
1 2 3 4 5 6 7
from django.conf import settings

# Set the expiration time of newly created auth tokens
# to be this many hours after their creation time.
AUTH_TOKEN_DURATION = getattr(settings, 'ASTAKOS_AUTH_TOKEN_DURATION', 30 * 24)

# Authenticate via Twitter.
8
TWITTER_TOKEN = getattr(settings, 'ASTAKOS_TWITTER_TOKEN', '')
Sofia Papagiannaki's avatar
Sofia Papagiannaki committed
9 10 11 12 13
TWITTER_SECRET = getattr(settings, 'ASTAKOS_TWITTER_SECRET', '')

DEFAULT_USER_LEVEL = getattr(settings, 'ASTAKOS_DEFAULT_USER_LEVEL', 4)

INVITATIONS_PER_LEVEL = getattr(settings, 'ASTAKOS_INVITATIONS_PER_LEVEL', {
14 15 16 17 18
    0: 100,
    1: 2,
    2: 0,
    3: 0,
    4: 0
Sofia Papagiannaki's avatar
Sofia Papagiannaki committed
19 20 21
})

# Address to use for outgoing emails
22 23
DEFAULT_CONTACT_EMAIL = getattr(
    settings, 'ASTAKOS_DEFAULT_CONTACT_EMAIL', 'support@cloud.grnet.gr')
Sofia Papagiannaki's avatar
Sofia Papagiannaki committed
24 25

# Identity Management enabled modules
26 27
# Supported modules are: 'local', 'twitter' and 'shibboleth'
IM_MODULES = getattr(settings, 'ASTAKOS_IM_MODULES', ['local'])
Sofia Papagiannaki's avatar
Sofia Papagiannaki committed
28 29 30 31 32

# Force user profile verification
FORCE_PROFILE_UPDATE = getattr(settings, 'ASTAKOS_FORCE_PROFILE_UPDATE', True)

#Enable invitations
33
INVITATIONS_ENABLED = getattr(settings, 'ASTAKOS_INVITATIONS_ENABLED', False)
Sofia Papagiannaki's avatar
Sofia Papagiannaki committed
34 35 36

COOKIE_NAME = getattr(settings, 'ASTAKOS_COOKIE_NAME', '_pithos2_a')
COOKIE_DOMAIN = getattr(settings, 'ASTAKOS_COOKIE_DOMAIN', None)
37
COOKIE_SECURE = getattr(settings, 'ASTAKOS_COOKIE_SECURE', True)
Sofia Papagiannaki's avatar
Sofia Papagiannaki committed
38

39
IM_STATIC_URL = getattr(settings, 'ASTAKOS_IM_STATIC_URL', '/static/im/')
Sofia Papagiannaki's avatar
Sofia Papagiannaki committed
40

41 42 43
# If set to False and invitations not enabled newly created user will be automatically accepted
MODERATION_ENABLED = getattr(settings, 'ASTAKOS_MODERATION_ENABLED', True)

44 45 46 47
# Set baseurl
BASEURL = getattr(settings, 'ASTAKOS_BASEURL', 'http://pithos.dev.grnet.gr')

# Set service name
48
SITENAME = getattr(settings, 'ASTAKOS_SITENAME', 'GRNET Cloud')
49

50 51 52
# Set recaptcha keys
RECAPTCHA_PUBLIC_KEY = getattr(settings, 'ASTAKOS_RECAPTCHA_PUBLIC_KEY', '')
RECAPTCHA_PRIVATE_KEY = getattr(settings, 'ASTAKOS_RECAPTCHA_PRIVATE_KEY', '')
53 54
RECAPTCHA_OPTIONS = getattr(settings, 'ASTAKOS_RECAPTCHA_OPTIONS',
                            {'theme': 'custom', 'custom_theme_widget': 'okeanos_recaptcha'})
55
RECAPTCHA_USE_SSL = getattr(settings, 'ASTAKOS_RECAPTCHA_USE_SSL', True)
56
RECAPTCHA_ENABLED = getattr(settings, 'ASTAKOS_RECAPTCHA_ENABLED', False)
57

58
# set AstakosUser fields to propagate in the billing system
59
BILLING_FIELDS = getattr(settings, 'ASTAKOS_BILLING_FIELDS', ['is_active'])
60 61

# Queue for billing.
62
QUEUE_CONNECTION = getattr(settings, 'ASTAKOS_QUEUE_CONNECTION', None)  # Example: 'rabbitmq://guest:guest@localhost:5672/astakos'
63 64

# Set where the user should be redirected after logout
Sofia Papagiannaki's avatar
Sofia Papagiannaki committed
65 66 67
LOGOUT_NEXT = getattr(settings, 'ASTAKOS_LOGOUT_NEXT', '')

# Set user email patterns that are automatically activated
68 69
RE_USER_EMAIL_PATTERNS = getattr(
    settings, 'ASTAKOS_RE_USER_EMAIL_PATTERNS', [])
Sofia Papagiannaki's avatar
Sofia Papagiannaki committed
70

71 72
# Messages to display on login page header
# e.g. {'warning': 'This warning message will be displayed on the top of login page'}
Sofia Papagiannaki's avatar
Sofia Papagiannaki committed
73
LOGIN_MESSAGES = getattr(settings, 'ASTAKOS_LOGIN_MESSAGES', [])
Sofia Papagiannaki's avatar
Sofia Papagiannaki committed
74

75 76
# Messages to display on login page header
# e.g. {'warning': 'This warning message will be displayed on the top of signup page'}
Sofia Papagiannaki's avatar
Sofia Papagiannaki committed
77
SIGNUP_MESSAGES = getattr(settings, 'ASTAKOS_SIGNUP_MESSAGES', [])
78 79 80

# Messages to display on login page header
# e.g. {'warning': 'This warning message will be displayed on the top of profile page'}
Sofia Papagiannaki's avatar
Sofia Papagiannaki committed
81
PROFILE_MESSAGES = getattr(settings, 'ASTAKOS_PROFILE_MESSAGES', [])
82 83 84

# Messages to display on all pages
# e.g. {'warning': 'This warning message will be displayed on the top of every page'}
Sofia Papagiannaki's avatar
Sofia Papagiannaki committed
85
GLOBAL_MESSAGES = getattr(settings, 'ASTAKOS_GLOBAL_MESSAGES', [])
86

87 88 89 90
# messages to display as extra actions in account forms
# e.g. {'https://cms.okeanos.grnet.gr/': 'Back to ~okeanos'}
PROFILE_EXTRA_LINKS = getattr(settings, 'ASTAKOS_PROFILE_EXTRA_LINKS', {})

91
# The number of unsuccessful login requests per minute allowed for a specific user
92 93
RATELIMIT_RETRIES_ALLOWED = getattr(
    settings, 'ASTAKOS_RATELIMIT_RETRIES_ALLOWED', 3)
Sofia Papagiannaki's avatar
Sofia Papagiannaki committed
94

95 96 97 98
# If False the email change mechanism is disabled
EMAILCHANGE_ENABLED = getattr(settings, 'ASTAKOS_EMAILCHANGE_ENABLED', False)

# Set the expiration time (in days) of email change requests
99 100
EMAILCHANGE_ACTIVATION_DAYS = getattr(
    settings, 'ASTAKOS_EMAILCHANGE_ACTIVATION_DAYS', 10)
101

102
# Set the astakos main functions logging severity (None to disable)
103
from logging import INFO
104
LOGGING_LEVEL = getattr(settings, 'ASTAKOS_LOGGING_LEVEL', INFO)
Sofia Papagiannaki's avatar
Sofia Papagiannaki committed
105

106
# Configurable email subjects
Sofia Papagiannaki's avatar
Sofia Papagiannaki committed
107 108 109
INVITATION_EMAIL_SUBJECT = getattr(
    settings, 'ASTAKOS_INVITATION_EMAIL_SUBJECT',
    'Invitation to %s alpha2 testing' % SITENAME)
110
GREETING_EMAIL_SUBJECT = getattr(settings, 'ASTAKOS_GREETING_EMAIL_SUBJECT',
Sofia Papagiannaki's avatar
Sofia Papagiannaki committed
111
                                 'Welcome to %s alpha2 testing' % SITENAME)
112
FEEDBACK_EMAIL_SUBJECT = getattr(settings, 'ASTAKOS_FEEDBACK_EMAIL_SUBJECT',
Sofia Papagiannaki's avatar
Sofia Papagiannaki committed
113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130
                                 'Feedback from %s alpha2 testing' % SITENAME)
VERIFICATION_EMAIL_SUBJECT = getattr(
    settings, 'ASTAKOS_VERIFICATION_EMAIL_SUBJECT',
    '%s alpha2 testing account activation is needed' % SITENAME)
ACCOUNT_CREATION_SUBJECT = getattr(
    settings, 'ASTAKOS_ACCOUNT_CREATION_SUBJECT',
    '%s alpha2 testing account created (%%(user)s)' % SITENAME)
GROUP_CREATION_SUBJECT = getattr(settings, 'ASTAKOS_GROUP_CREATION_SUBJECT',
                                 '%s alpha2 testing group created (%%(group)s)' % SITENAME)
HELPDESK_NOTIFICATION_EMAIL_SUBJECT = getattr(
    settings, 'ASTAKOS_HELPDESK_NOTIFICATION_EMAIL_SUBJECT',
    '%s alpha2 testing account activated (%%(user)s)' % SITENAME)
EMAIL_CHANGE_EMAIL_SUBJECT = getattr(
    settings, 'ASTAKOS_EMAIL_CHANGE_EMAIL_SUBJECT',
    'Email change on %s alpha2 testing' % SITENAME)
PASSWORD_RESET_EMAIL_SUBJECT = getattr(
    settings, 'ASTAKOS_PASSWORD_RESET_EMAIL_SUBJECT',
    'Password reset on %s alpha2 testing' % SITENAME)
Sofia Papagiannaki's avatar
Sofia Papagiannaki committed
131

132
# Set the quota holder component URI
133
QUOTAHOLDER_URL = getattr(settings, 'ASTAKOS_QUOTAHOLDER_URL', '')
Kostas Papadimitriou's avatar
Kostas Papadimitriou committed
134
QUOTAHOLDER_TOKEN = getattr(settings, 'ASTAKOS_QUOTAHOLDER_TOKEN', '')
135 136

# Set the cloud service properties
root's avatar
root committed
137
SERVICES = getattr(settings, 'ASTAKOS_SERVICES', {
138 139 140 141
    'cyclades': {
        'url': 'https://node1.example.com/ui/',
        'resources': [{
            'name':'vm',
142
            'group':'compute',
143 144 145
            'uplimit':2,
            'desc': 'Number of virtual machines'
            },{
root's avatar
root committed
146
            'name':'disk',
147
            'group':'compute',
root's avatar
root committed
148
            'uplimit':30*1024*1024*1024,
149
            'unit':'bytes',
150 151 152
            'desc': 'Virtual machine disk size'
            },{
            'name':'cpu',
153
            'group':'compute',
root's avatar
root committed
154
            'uplimit':6,
155 156 157
            'desc': 'Number of virtual machine processors'
            },{
            'name':'ram',
158
            'group':'compute',
root's avatar
root committed
159
            'uplimit':6*1024*1024*1024,
160
            'unit':'bytes',
161
            'desc': 'Virtual machines'
162 163
            },{
            'name':'network.private',
root's avatar
root committed
164
            'group':'network',
165 166 167 168
            'uplimit':1,
            'desc': 'Private networks'
            }
        ]
169 170 171 172 173
    },
    'pithos+': {
        'url': 'https://node2.example.com/ui/',
        'resources':[{
            'name':'diskspace',
174
            'group':'storage',
175 176 177 178 179 180
            'uplimit':5 * 1024 * 1024 * 1024,
            'unit':'bytes',
            'desc': 'Pithos account diskspace'
            }]
    }
})
181 182 183 184

# Set the billing URI
AQUARIUM_URL = getattr(settings, 'ASTAKOS_AQUARIUM_URL', '')

Sofia Papagiannaki's avatar
Sofia Papagiannaki committed
185
# Set how many objects should be displayed per page
Sofia Papagiannaki's avatar
Sofia Papagiannaki committed
186 187
PAGINATE_BY = getattr(settings, 'ASTAKOS_PAGINATE_BY', 8)

Olga Brani's avatar
Fixes  
Olga Brani committed
188 189 190
# Set how many objects should be displayed per page in show all groups page
PAGINATE_BY_ALL = getattr(settings, 'ASTAKOS_PAGINATE_BY_ALL', 15)

Sofia Papagiannaki's avatar
Sofia Papagiannaki committed
191 192
# Enforce token renewal on password change/reset
NEWPASSWD_INVALIDATE_TOKEN = getattr(
root's avatar
root committed
193
    settings, 'ASTAKOS_NEWPASSWD_INVALIDATE_TOKEN', True)
Olga Brani's avatar
Olga Brani committed
194 195 196 197 198 199


RESOURCES_PRESENTATION_DATA = getattr(
    settings, 'ASTAKOS_RESOURCES_PRESENTATION_DATA', {
        'groups': {
             'compute': {
Olga Brani's avatar
Olga Brani committed
200
                'help_text':'Compute resources (amount of VMs, CPUs, RAM, System disk) ',
Olga Brani's avatar
Olga Brani committed
201 202
                'is_abbreviation':False,
                'report_desc':'',
Kostas Papadimitriou's avatar
Kostas Papadimitriou committed
203
                 'verbose_name':'compute',
Olga Brani's avatar
Olga Brani committed
204 205
            },
            'storage': {
Olga Brani's avatar
Olga Brani committed
206
                'help_text':'Storage resources (amount of space to store files on Pithos) ',
Olga Brani's avatar
Olga Brani committed
207 208
                'is_abbreviation':False,
                'report_desc':'',
Kostas Papadimitriou's avatar
Kostas Papadimitriou committed
209
                 'verbose_name':'storage',
Olga Brani's avatar
Olga Brani committed
210
            },
Olga Brani's avatar
Olga Brani committed
211 212 213 214 215 216
            'network': {
                'help_text':' Network resources (amount of Private Networks)  ',
                'is_abbreviation':False,
                'report_desc':'',
                'verbose_name':'network',
            },
Olga Brani's avatar
Olga Brani committed
217 218 219
        },
        'resources': {
            'pithos+.diskspace': {
Olga Brani's avatar
Olga Brani committed
220 221
                'help_text':'This is the space on Pithos for storing files and VM Images. ',
                'help_text_input_each':'This is the total amount of space on Pithos that will be granted to each user of this Project ',
Olga Brani's avatar
Olga Brani committed
222
                'is_abbreviation':False,
Olga Brani's avatar
Olga Brani committed
223
                'report_desc':'Storage Space',
Olga Brani's avatar
Olga Brani committed
224
                'placeholder':'eg. 10GB',
Olga Brani's avatar
Olga Brani committed
225
                'verbose_name':'Storage Space',
Olga Brani's avatar
Olga Brani committed
226 227
            },
            'cyclades.vm': {
Olga Brani's avatar
Olga Brani committed
228 229
                'help_text':'These are the VMs one can create on the Cyclades UI ',
                'help_text_input_each':'This is the total number of VMs that will be granted to each user of this Project ',
Olga Brani's avatar
Olga Brani committed
230 231 232
                'is_abbreviation':True,
                'report_desc':'Virtual Machines',
                'placeholder':'eg. 2',
Kostas Papadimitriou's avatar
Kostas Papadimitriou committed
233
                'verbose_name':'vm',
Olga Brani's avatar
Olga Brani committed
234 235
            },
            'cyclades.disk': {
Olga Brani's avatar
Olga Brani committed
236 237
                'help_text':'This is the System Disk that the VMs have that run the OS ',
                'help_text_input_each':"This is the total amount of System Disk that will be granted to each user of this Project (this refers to the total System Disk of all VMs, not each VM's System Disk)  ",
Olga Brani's avatar
Olga Brani committed
238
                'is_abbreviation':False,
Olga Brani's avatar
Olga Brani committed
239
                'report_desc':'System Disk',
Olga Brani's avatar
Olga Brani committed
240
                'placeholder':'eg. 5GB, 2GB etc',
Olga Brani's avatar
Olga Brani committed
241
                'verbose_name':'System Disk'
Olga Brani's avatar
Olga Brani committed
242 243
            },
            'cyclades.ram': {
Olga Brani's avatar
Olga Brani committed
244 245
                'help_text':'RAM used by VMs ',
                'help_text_input_each':'This is the total amount of RAM that will be granted to each user of this Project (on all VMs)  ',
Olga Brani's avatar
Olga Brani committed
246 247 248 249 250 251
                'is_abbreviation':True,
                'report_desc':'RAM',
                'placeholder':'eg. 4GB',
                'verbose_name':'ram'
            },
            'cyclades.cpu': {
Olga Brani's avatar
Olga Brani committed
252 253
                'help_text':'CPUs used by VMs ',
                'help_text_input_each':'This is the total number of CPUs that will be granted to each user of this Project (on all VMs)  ',
Olga Brani's avatar
Olga Brani committed
254 255 256 257 258 259
                'is_abbreviation':True,
                'report_desc':'CPUs',
                'placeholder':'eg. 1',
                'verbose_name':'cpu'
            },
            'cyclades.network.private': {
Olga Brani's avatar
Olga Brani committed
260 261
                'help_text':'These are the Private Networks one can create on the Cyclades UI. ',
                'help_text_input_each':'This is the total number of Private Networks that will be granted to each user of this Project ',
Olga Brani's avatar
Olga Brani committed
262
                'is_abbreviation':False,
Olga Brani's avatar
Olga Brani committed
263
                'report_desc':'Private Networks',
Olga Brani's avatar
Olga Brani committed
264 265 266
                'placeholder':'eg. 1',
                'verbose_name':'private network'
            }
Kostas Papadimitriou's avatar
Kostas Papadimitriou committed
267

Olga Brani's avatar
Olga Brani committed
268
        }
Kostas Papadimitriou's avatar
Kostas Papadimitriou committed
269

Olga Brani's avatar
Olga Brani committed
270
    })
271 272

# Permit local account migration
273
ENABLE_LOCAL_ACCOUNT_MIGRATION = getattr(settings, 'ASTAKOS_ENABLE_LOCAL_ACCOUNT_MIGRATION', True)