subnets and slivers work when openstack is disable or unavailable
[plstackapi.git] / plstackapi / core / models / subnet.py
1 import os
2 import commands    
3 from django.db import models
4 from plstackapi.core.models import PlCoreBase
5 from plstackapi.core.models import Slice
6
7 # Create your models here.
8
9 class Subnet(PlCoreBase):
10     subnet_id = models.CharField(max_length=256, unique=True)
11     cidr = models.CharField(max_length=20)
12     ip_version = models.IntegerField()
13     start = models.IPAddressField()
14     end = models.IPAddressField()
15     slice = models.ForeignKey(Slice, related_name='subnet')
16
17     def __unicode__(self):  return u'%s' % (self.slice.name)
18
19     def save(self, *args, **kwds):
20         self.os_manager.save_subnet(self)
21         super(Subnet, self).save(*args, **kwds)
22
23     def delete(self, *args, **kwds):
24         self.os_manager.delete_subnet(self)
25         super(Subnet, self).delete(*args, **kwds)