blob: 0a29c0d5ca2b9564f1a271649aac7411f3ab1109 [file] [log] [blame]
Sapan Bhatia903918f2014-09-08 03:26:12 -04001from core.models import *
2
3def 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