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 |
| 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 |