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 |
Tony Mack | 336e0f9 | 2014-11-30 15:53:08 -0500 | [diff] [blame] | 4 | from core.models import User,Site,Slice,Controller |
Tony Mack | d84b1ff | 2015-03-09 13:03:56 -0400 | [diff] [blame] | 5 | from core.models.plcorebase import StrippedCharField |
Sapan Bhatia | 7bcec3b | 2014-09-08 10:42:23 -0400 | [diff] [blame] | 6 | from encrypted_fields import EncryptedCharField |
Tony Mack | 336e0f9 | 2014-11-30 15:53:08 -0500 | [diff] [blame] | 7 | from core.models import Controller,ControllerLinkManager,ControllerLinkDeletionManager |
Sapan Bhatia | 7bcec3b | 2014-09-08 10:42:23 -0400 | [diff] [blame] | 8 | |
| 9 | class UserCredential(PlCoreBase): |
Sapan Bhatia | 475c597 | 2014-11-05 10:32:41 -0500 | [diff] [blame] | 10 | user = models.ForeignKey(User, related_name='usercredentials', help_text="The User this credential is associated with") |
Sapan Bhatia | 7bcec3b | 2014-09-08 10:42:23 -0400 | [diff] [blame] | 11 | |
| 12 | name = models.SlugField(help_text="The credential type, e.g. ec2", max_length=128) |
Tony Mack | d84b1ff | 2015-03-09 13:03:56 -0400 | [diff] [blame] | 13 | key_id = StrippedCharField(help_text="The backend id of this credential", max_length=1024) |
Sapan Bhatia | 7bcec3b | 2014-09-08 10:42:23 -0400 | [diff] [blame] | 14 | enc_value = EncryptedCharField(help_text="The key value of this credential", max_length=1024) |
| 15 | |
| 16 | |
| 17 | def __unicode__(self): |
| 18 | return self.name |
| 19 | |
| 20 | class SiteCredential(PlCoreBase): |
Sapan Bhatia | 475c597 | 2014-11-05 10:32:41 -0500 | [diff] [blame] | 21 | site = models.ForeignKey(Site, related_name='sitecredentials', help_text="The User this credential is associated with") |
Sapan Bhatia | 7bcec3b | 2014-09-08 10:42:23 -0400 | [diff] [blame] | 22 | |
| 23 | name = models.SlugField(help_text="The credential type, e.g. ec2", max_length=128) |
Scott Baker | aaa46ed | 2015-03-10 11:55:28 -0700 | [diff] [blame] | 24 | key_id = StrippedCharField(help_text="The backend id of this credential", max_length=1024) |
Sapan Bhatia | 7bcec3b | 2014-09-08 10:42:23 -0400 | [diff] [blame] | 25 | enc_value = EncryptedCharField(help_text="The key value of this credential", max_length=1024) |
| 26 | |
| 27 | |
| 28 | def __unicode__(self): |
| 29 | return self.name |
| 30 | |
| 31 | class SliceCredential(PlCoreBase): |
Sapan Bhatia | 475c597 | 2014-11-05 10:32:41 -0500 | [diff] [blame] | 32 | slice = models.ForeignKey(Slice, related_name='slicecredentials', help_text="The User this credential is associated with") |
Sapan Bhatia | 7bcec3b | 2014-09-08 10:42:23 -0400 | [diff] [blame] | 33 | |
| 34 | name = models.SlugField(help_text="The credential type, e.g. ec2", max_length=128) |
Tony Mack | d84b1ff | 2015-03-09 13:03:56 -0400 | [diff] [blame] | 35 | key_id = StrippedCharField(help_text="The backend id of this credential", max_length=1024) |
Sapan Bhatia | 7bcec3b | 2014-09-08 10:42:23 -0400 | [diff] [blame] | 36 | enc_value = EncryptedCharField(help_text="The key value of this credential", max_length=1024) |
| 37 | |
| 38 | |
| 39 | def __unicode__(self): |
| 40 | return self.name |
Sapan Bhatia | 31138dd | 2014-09-01 01:45:28 -0400 | [diff] [blame] | 41 | |
Tony Mack | 336e0f9 | 2014-11-30 15:53:08 -0500 | [diff] [blame] | 42 | class ControllerCredential(PlCoreBase): |
| 43 | objects = ControllerLinkManager() |
| 44 | deleted_objects = ControllerLinkDeletionManager() |
| 45 | controller = models.ForeignKey(Controller, related_name='controllercredentials', help_text="The User this credential is associated with") |
Sapan Bhatia | 31138dd | 2014-09-01 01:45:28 -0400 | [diff] [blame] | 46 | |
| 47 | name = models.SlugField(help_text="The credential type, e.g. ec2", max_length=128) |
| 48 | key_id = models.CharField(help_text="The backend id of this credential", max_length=1024) |
| 49 | enc_value = EncryptedCharField(help_text="The key value of this credential", max_length=1024) |
| 50 | |
| 51 | |
| 52 | def __unicode__(self): |
| 53 | return self.name |