Siobhan Tully | 4bc09f2 | 2013-04-10 21:15:21 -0400 | [diff] [blame] | 1 | import os |
| 2 | from django.db import models |
Siobhan Tully | 30fd429 | 2013-05-10 08:59:56 -0400 | [diff] [blame] | 3 | from core.models import PlCoreBase |
Siobhan Tully | 7329134 | 2013-05-10 10:50:08 -0400 | [diff] [blame] | 4 | from openstack.manager import OpenStackManager |
| 5 | |
Siobhan Tully | 4bc09f2 | 2013-04-10 21:15:21 -0400 | [diff] [blame] | 6 | |
| 7 | # Create your models here. |
| 8 | |
| 9 | class Key(PlCoreBase): |
Siobhan Tully | 7329134 | 2013-05-10 10:50:08 -0400 | [diff] [blame] | 10 | name = models.CharField(max_length=256) |
| 11 | nkey_id = models.CharField(null=True, blank=True, max_length=256, unique=True) |
Siobhan Tully | 4bc09f2 | 2013-04-10 21:15:21 -0400 | [diff] [blame] | 12 | key = models.CharField(max_length=512) |
| 13 | type = models.CharField(max_length=256) |
| 14 | blacklisted = models.BooleanField(default=False) |
Siobhan Tully | 4bc09f2 | 2013-04-10 21:15:21 -0400 | [diff] [blame] | 15 | |
Siobhan Tully | 7329134 | 2013-05-10 10:50:08 -0400 | [diff] [blame] | 16 | def __unicode__(self): return u'%s' % (self.key) |
Tony Mack | 759b57a | 2013-04-14 21:03:31 -0400 | [diff] [blame] | 17 | |
| 18 | def save(self, *args, **kwds): |
Siobhan Tully | 7329134 | 2013-05-10 10:50:08 -0400 | [diff] [blame] | 19 | if not hasattr(self, 'os_manager'): |
| 20 | setattr(self, 'os_manager', OpenStackManager()) |
| 21 | self.os_manager.save_key(self) |
Tony Mack | 759b57a | 2013-04-14 21:03:31 -0400 | [diff] [blame] | 22 | super(Key, self).save(*args, **kwds) |
| 23 | |
| 24 | def delete(self, *args, **kwds): |
Siobhan Tully | 7329134 | 2013-05-10 10:50:08 -0400 | [diff] [blame] | 25 | if not hasattr(self, 'os_manager'): |
| 26 | setattr(self, 'os_manager', OpenStackManager()) |
| 27 | self.os_manager.delete_key(self) |
Tony Mack | 759b57a | 2013-04-14 21:03:31 -0400 | [diff] [blame] | 28 | super(Key, self).delete(*args, **kwds) |
| 29 | |