blob: 7a8b3221cf635ade57bfa5c99a49ba32eb3cee99 [file] [log] [blame]
Siobhan Tully4bc09f22013-04-10 21:15:21 -04001import os
2from django.db import models
Siobhan Tully30fd4292013-05-10 08:59:56 -04003from core.models import PlCoreBase
Siobhan Tully73291342013-05-10 10:50:08 -04004from openstack.manager import OpenStackManager
5
Siobhan Tully4bc09f22013-04-10 21:15:21 -04006
7# Create your models here.
8
9class Key(PlCoreBase):
Siobhan Tully73291342013-05-10 10:50:08 -040010 name = models.CharField(max_length=256)
11 nkey_id = models.CharField(null=True, blank=True, max_length=256, unique=True)
Siobhan Tully4bc09f22013-04-10 21:15:21 -040012 key = models.CharField(max_length=512)
13 type = models.CharField(max_length=256)
14 blacklisted = models.BooleanField(default=False)
Siobhan Tully4bc09f22013-04-10 21:15:21 -040015
Siobhan Tully73291342013-05-10 10:50:08 -040016 def __unicode__(self): return u'%s' % (self.key)
Tony Mack759b57a2013-04-14 21:03:31 -040017
18 def save(self, *args, **kwds):
Siobhan Tully73291342013-05-10 10:50:08 -040019 if not hasattr(self, 'os_manager'):
20 setattr(self, 'os_manager', OpenStackManager())
21 self.os_manager.save_key(self)
Tony Mack759b57a2013-04-14 21:03:31 -040022 super(Key, self).save(*args, **kwds)
23
24 def delete(self, *args, **kwds):
Siobhan Tully73291342013-05-10 10:50:08 -040025 if not hasattr(self, 'os_manager'):
26 setattr(self, 'os_manager', OpenStackManager())
27 self.os_manager.delete_key(self)
Tony Mack759b57a2013-04-14 21:03:31 -040028 super(Key, self).delete(*args, **kwds)
29