Calculate creds for a user
diff --git a/planetstack/ec2_observer/creds.py b/planetstack/ec2_observer/creds.py
new file mode 100644
index 0000000..0a29c0d
--- /dev/null
+++ b/planetstack/ec2_observer/creds.py
@@ -0,0 +1,16 @@
+from core.models import *
+
+def get_creds(user=None, slice=None, site=None, deployment=None):
+ if (not user or not site):
+ raise Exception('User and Site have to be in context to use EC2')
+
+ cred = UserCredential.objects.filter(user=user)
+ if (not cred):
+ cred = SiteCredential.objects.filter(site=site)
+
+ if (cred):
+ env = 'AWS_ACCESS_KEY_ID=%s AWS_SECRET_ACCESS_KEY=%s'%(cred.key_id, cred.enc_value)
+ else:
+ env = ''
+
+ return env