Andrea Campanella | 65e91e6 | 2017-05-22 17:50:37 +0200 | [diff] [blame] | 1 | from header import * |
| 2 | |
| 3 | |
| 4 | |
| 5 | #from core.models.tenant import Tenant |
| 6 | from core.models import Tenant |
| 7 | |
| 8 | |
| 9 | |
| 10 | |
| 11 | |
| 12 | |
| 13 | |
| 14 | |
| 15 | |
| 16 | |
| 17 | |
| 18 | |
| 19 | |
| 20 | |
| 21 | |
| 22 | |
| 23 | |
| 24 | |
| 25 | |
| 26 | |
| 27 | |
| 28 | class EnterpriseLocation(Tenant): |
| 29 | |
| 30 | KIND = "metronetwork" |
| 31 | |
| 32 | class Meta: |
| 33 | app_label = "metronet" |
| 34 | name = "metronet" |
| 35 | verbose_name = "Enterprise Localation" |
| 36 | |
| 37 | # Primitive Fields (Not Relations) |
| 38 | name = CharField( blank = False, max_length = 256, null = False, db_index = False ) |
| 39 | cord_site_ip = CharField( help_text = "ip of the local site", max_length = 64, null = False, db_index = False, blank = False ) |
| 40 | cord_site_ip = CharField( help_text = "ip of the local site", max_length = 64, null = False, db_index = False, blank = False ) |
| 41 | cord_site_port = IntegerField( help_text = "port of the local site", max_length = 256, null = False, db_index = False, blank = False ) |
| 42 | cord_site_username = CharField( help_text = "username of the local site", max_length = 64, null = False, db_index = False, blank = False ) |
| 43 | cord_site_password = CharField( help_text = "password of the local site", max_length = 64, null = False, db_index = False, blank = False ) |
| 44 | cord_site_type = CharField( default = "xos", choices = "(('onos', 'ONOS'), ('xos', 'XOS')", max_length = 64, blank = False, null = False, db_index = False ) |
| 45 | |
| 46 | |
| 47 | # Relations |
| 48 | |
| 49 | |
| 50 | |
| 51 | pass |
| 52 | |
| 53 | |
| 54 | |
| 55 | |
| 56 | class OnosModel(PlCoreBase): |
| 57 | |
| 58 | KIND = "metronetwork" |
| 59 | |
| 60 | class Meta: |
| 61 | app_label = "metronet" |
| 62 | name = "metronet" |
| 63 | verbose_name = "Open Netowrk Operating System" |
| 64 | |
| 65 | # Primitive Fields (Not Relations) |
| 66 | name = CharField( blank = False, max_length = 256, null = False, db_index = False ) |
| 67 | onos_ip = CharField( help_text = "ip of the transport manager", max_length = 64, null = False, db_index = False, blank = False ) |
| 68 | onos_port = IntegerField( help_text = "port of the transport manager", max_length = 256, null = False, db_index = False, blank = False ) |
| 69 | onos_username = CharField( help_text = "username of the transport manager", max_length = 64, null = False, db_index = False, blank = False ) |
| 70 | onos_password = CharField( help_text = "password of the transport manager", max_length = 64, null = False, db_index = False, blank = False ) |
| 71 | onos_type = CharField( default = "local", choices = "(('local', 'Local'), ('global', 'Global')", max_length = 64, blank = False, null = False, db_index = False ) |
| 72 | |
| 73 | |
| 74 | # Relations |
| 75 | |
| 76 | |
| 77 | |
| 78 | pass |
| 79 | |
| 80 | |
| 81 | |
| 82 | |
| 83 | class UserNetworkInterface(PlCoreBase): |
| 84 | |
| 85 | KIND = "metronetwork" |
| 86 | |
| 87 | class Meta: |
| 88 | app_label = "metronet" |
| 89 | name = "metronet" |
| 90 | verbose_name = "User Network Interface" |
| 91 | |
| 92 | # Primitive Fields (Not Relations) |
| 93 | tenant = CharField( help_text = "tenat name", max_length = 256, null = False, db_index = False, blank = False ) |
| 94 | cpe_id = CharField( blank = False, max_length = 1024, null = False, db_index = False ) |
| 95 | latlng = CharField( help_text = "location, i.e. [37.773972, -122.431297]", max_length = 256, null = False, db_index = False, blank = False ) |
| 96 | name = CharField( blank = False, max_length = 256, null = False, db_index = False ) |
| 97 | |
| 98 | |
| 99 | # Relations |
| 100 | |
| 101 | |
| 102 | def __unicode__(self): return u'%s' % (self.name) |
| 103 | |
| 104 | def save(self, *args, **kwargs): |
| 105 | |
| 106 | if self.latlng: |
| 107 | try: |
| 108 | latlng_value = getattr(self, 'latlng').strip() |
| 109 | if (latlng_value.startswith('[') and latlng_value.endswith(']') and latlng_value.index(',') > 0): |
| 110 | lat = latlng_value[1: latlng_value.index(',')].strip() |
| 111 | lng = latlng_value[latlng_value.index(',') + 1: len(latlng_value) - 1].strip() |
| 112 | |
| 113 | # If lat and lng are not floats, the code below should result in an error. |
| 114 | lat_validation = float(lat) |
| 115 | lng_validation = float(lng) |
| 116 | else: |
| 117 | raise ValueError("The lat/lng value is not formatted correctly.") |
| 118 | except: |
| 119 | raise ValueError("The lat/lng value is not formatted correctly.") |
| 120 | |
| 121 | super(UserNetworkInterface, self).save(*args, **kwargs) |
| 122 | pass |
| 123 | |
| 124 | |
| 125 | |
| 126 | |
| 127 | class BandwidthProfile(PlCoreBase): |
| 128 | |
| 129 | KIND = "metronetwork" |
| 130 | |
| 131 | class Meta: |
| 132 | app_label = "metronet" |
| 133 | name = "metronet" |
| 134 | verbose_name = "Bandwidth Profile" |
| 135 | |
| 136 | # Primitive Fields (Not Relations) |
| 137 | name = CharField( blank = False, max_length = 256, null = False, db_index = False ) |
| 138 | cbs = IntegerField( help_text = "committed burst size", null = False, blank = False, db_index = False ) |
| 139 | ebs = IntegerField( help_text = "expected burst size", null = False, blank = False, db_index = False ) |
| 140 | cir = IntegerField( help_text = "committed information rate", null = False, blank = False, db_index = False ) |
| 141 | eir = IntegerField( help_text = "expected information rate", null = False, blank = False, db_index = False ) |
| 142 | |
| 143 | |
| 144 | # Relations |
| 145 | |
| 146 | |
| 147 | def __unicode__(self): return u'%s' % (self.name) |
| 148 | pass |
| 149 | |
| 150 | |
| 151 | |
| 152 | |
| 153 | class ELine(PlCoreBase): |
| 154 | |
| 155 | KIND = "metronetwork" |
| 156 | |
| 157 | class Meta: |
| 158 | app_label = "metronet" |
| 159 | name = "metronet" |
| 160 | verbose_name = "Ethernet Virtual Private Line" |
| 161 | |
| 162 | # Primitive Fields (Not Relations) |
| 163 | name = CharField( blank = False, max_length = 256, null = False, db_index = False ) |
| 164 | connect_point_1_id = CharField( blank = False, max_length = 256, null = False, db_index = False ) |
| 165 | connect_point_2_id = CharField( blank = False, max_length = 64, null = False, db_index = False ) |
| 166 | vlanids = TextField( help_text = "comma separated list of vlanIds", null = False, blank = False, db_index = False ) |
| 167 | cord_site_username = CharField( blank = False, max_length = 64, null = False, db_index = False ) |
| 168 | bwp = CharField( help_text = "bandwidth profile name", max_length = 256, null = False, db_index = False, blank = False ) |
| 169 | |
| 170 | |
| 171 | # Relations |
| 172 | |
| 173 | |
| 174 | def __unicode__(self): return u'%s' % (self.name) |
| 175 | pass |
| 176 | |
| 177 | |