Siobhan Tully | 4bc09f2 | 2013-04-10 21:15:21 -0400 | [diff] [blame] | 1 | import os |
Tony Mack | 31d3413 | 2013-04-15 00:02:06 -0400 | [diff] [blame] | 2 | import commands |
Siobhan Tully | 4bc09f2 | 2013-04-10 21:15:21 -0400 | [diff] [blame] | 3 | from django.db import models |
| 4 | from plstackapi.core.models import PlCoreBase |
| 5 | from plstackapi.core.models import Slice |
Siobhan Tully | 4bc09f2 | 2013-04-10 21:15:21 -0400 | [diff] [blame] | 6 | |
| 7 | # Create your models here. |
| 8 | |
| 9 | class Subnet(PlCoreBase): |
Tony Mack | cdec090 | 2013-04-15 00:38:49 -0400 | [diff] [blame] | 10 | subnet_id = models.CharField(max_length=256, unique=True) |
Siobhan Tully | 4bc09f2 | 2013-04-10 21:15:21 -0400 | [diff] [blame] | 11 | cidr = models.CharField(max_length=20) |
| 12 | ip_version = models.IntegerField() |
| 13 | start = models.IPAddressField() |
| 14 | end = models.IPAddressField() |
Tony Mack | 771f4b9 | 2013-04-12 01:49:57 -0400 | [diff] [blame] | 15 | slice = models.ForeignKey(Slice, related_name='subnet') |
Siobhan Tully | 4bc09f2 | 2013-04-10 21:15:21 -0400 | [diff] [blame] | 16 | |
Tony Mack | f79ad8e | 2013-04-12 13:52:44 -0400 | [diff] [blame] | 17 | def __unicode__(self): return u'%s' % (self.slice.name) |
Siobhan Tully | 4bc09f2 | 2013-04-10 21:15:21 -0400 | [diff] [blame] | 18 | |
Tony Mack | 31d3413 | 2013-04-15 00:02:06 -0400 | [diff] [blame] | 19 | def save(self, *args, **kwds): |
Tony Mack | 951dab4 | 2013-05-02 19:51:45 -0400 | [diff] [blame^] | 20 | self.os_manager.save_subnet(self) |
Tony Mack | 31d3413 | 2013-04-15 00:02:06 -0400 | [diff] [blame] | 21 | super(Subnet, self).save(*args, **kwds) |
| 22 | |
| 23 | def delete(self, *args, **kwds): |
Tony Mack | 951dab4 | 2013-05-02 19:51:45 -0400 | [diff] [blame^] | 24 | self.os_manager.delete_subnet(self) |
Tony Mack | 31d3413 | 2013-04-15 00:02:06 -0400 | [diff] [blame] | 25 | super(Subnet, self).delete(*args, **kwds) |