Sapan Bhatia | 7bcec3b | 2014-09-08 10:42:23 -0400 | [diff] [blame] | 1 | import os |
| 2 | from django.db import models |
| 3 | from core.models import PlCoreBase |
| 4 | from core.models import User,Site,Slice |
| 5 | from encrypted_fields import EncryptedCharField |
| 6 | |
| 7 | class UserCredential(PlCoreBase): |
| 8 | user = models.ForeignKey(User, related_name='credentials', help_text="The User this credential is associated with") |
| 9 | |
| 10 | name = models.SlugField(help_text="The credential type, e.g. ec2", max_length=128) |
| 11 | key_id = models.CharField(help_text="The backend id of this credential", max_length=1024) |
| 12 | enc_value = EncryptedCharField(help_text="The key value of this credential", max_length=1024) |
| 13 | |
| 14 | |
| 15 | def __unicode__(self): |
| 16 | return self.name |
| 17 | |
| 18 | class SiteCredential(PlCoreBase): |
| 19 | site = models.ForeignKey(Site, related_name='credentials', help_text="The User this credential is associated with") |
| 20 | |
| 21 | name = models.SlugField(help_text="The credential type, e.g. ec2", max_length=128) |
| 22 | key_id = models.CharField(help_text="The backend id of this credential", max_length=1024) |
| 23 | enc_value = EncryptedCharField(help_text="The key value of this credential", max_length=1024) |
| 24 | |
| 25 | |
| 26 | def __unicode__(self): |
| 27 | return self.name |
| 28 | |
| 29 | class SliceCredential(PlCoreBase): |
| 30 | slice = models.ForeignKey(Slice, related_name='credentials', help_text="The User this credential is associated with") |
| 31 | |
| 32 | name = models.SlugField(help_text="The credential type, e.g. ec2", max_length=128) |
| 33 | key_id = models.CharField(help_text="The backend id of this credential", max_length=1024) |
| 34 | enc_value = EncryptedCharField(help_text="The key value of this credential", max_length=1024) |
| 35 | |
| 36 | |
| 37 | def __unicode__(self): |
| 38 | return self.name |
Sapan Bhatia | 31138dd | 2014-09-01 01:45:28 -0400 | [diff] [blame^] | 39 | |
| 40 | class DeploymentCredential(PlCoreBase): |
| 41 | deployment = models.ForeignKey(Deployment, related_name='credentials', help_text="The User this credential is associated with") |
| 42 | |
| 43 | name = models.SlugField(help_text="The credential type, e.g. ec2", max_length=128) |
| 44 | key_id = models.CharField(help_text="The backend id of this credential", max_length=1024) |
| 45 | enc_value = EncryptedCharField(help_text="The key value of this credential", max_length=1024) |
| 46 | |
| 47 | |
| 48 | def __unicode__(self): |
| 49 | return self.name |