Sapan Bhatia | 0a56fdc | 2017-04-21 15:12:57 +0200 | [diff] [blame] | 1 | @property |
| 2 | def gateway_ip(self): |
| 3 | if not self.address_pool: |
| 4 | return None |
| 5 | return self.address_pool.gateway_ip |
| 6 | |
| 7 | @property |
| 8 | def gateway_mac(self): |
| 9 | if not self.address_pool: |
| 10 | return None |
| 11 | return self.address_pool.gateway_mac |
| 12 | |
| 13 | @property |
| 14 | def cidr(self): |
| 15 | if not self.address_pool: |
| 16 | return None |
| 17 | return self.address_pool.cidr |
| 18 | |
| 19 | @property |
| 20 | def netbits(self): |
| 21 | # return number of bits in the network portion of the cidr |
| 22 | if self.cidr: |
| 23 | parts = self.cidr.split("/") |
| 24 | if len(parts) == 2: |
| 25 | return int(parts[1].strip()) |
| 26 | return None |
| 27 | |
| 28 | def cleanup_addresspool(self): |
| 29 | if self.address_pool: |
| 30 | ap = self.address_pool |
| 31 | if ap: |
Scott Baker | 4435ce3 | 2017-05-26 09:44:24 -0700 | [diff] [blame^] | 32 | ap.put_address(self.public_ip) |
Sapan Bhatia | 0a56fdc | 2017-04-21 15:12:57 +0200 | [diff] [blame] | 33 | self.public_ip = None |
| 34 | |
| 35 | def delete(self, *args, **kwargs): |
| 36 | self.cleanup_addresspool() |
| 37 | super(VRouterTenant, self).delete(*args, **kwargs) |
| 38 | |