Sapan Bhatia | 8325e8e | 2014-09-08 03:26:12 -0400 | [diff] [blame] | 1 | from core.models import * |
2 | |||||
3 | def get_creds(user=None, slice=None, site=None, deployment=None): | ||||
4 | if (not user or not site): | ||||
5 | raise Exception('User and Site have to be in context to use EC2') | ||||
6 | |||||
7 | cred = UserCredential.objects.filter(user=user) | ||||
8 | if (not cred): | ||||
9 | cred = SiteCredential.objects.filter(site=site) | ||||
10 | |||||
11 | if (cred): | ||||
12 | env = 'AWS_ACCESS_KEY_ID=%s AWS_SECRET_ACCESS_KEY=%s'%(cred.key_id, cred.enc_value) | ||||
13 | else: | ||||
14 | env = '' | ||||
15 | |||||
16 | return env |