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