Reading s_tag from the subscriber
Change-Id: Id0be35c520dfa0316885d84f7089ef045e58dc70
diff --git a/xos/synchronizer/models/convenience/voltserviceinstance.py b/xos/synchronizer/models/convenience/voltserviceinstance.py
index fdae09e..6c59ef6 100644
--- a/xos/synchronizer/models/convenience/voltserviceinstance.py
+++ b/xos/synchronizer/models/convenience/voltserviceinstance.py
@@ -21,45 +21,6 @@
class ORMWrapperVOLTServiceInstance(ORMWrapperServiceInstance):
- @property
- def vsg(self):
- log.warning('VOLTServiceInstance.vsg is DEPRECATED, use get_westbound_service_instance_properties instead')
- links = self.stub.ServiceInstanceLink.objects.filter(subscriber_service_instance_id = self.id)
- for link in links:
- # cast from ServiceInstance to VSGTenant
- vsgs = self.stub.VSGServiceInstance.objects.filter(id = link.provider_service_instance.id)
- if vsgs:
- return vsgs[0]
- return None
-
- # DEPRECATED
- @property
- def vcpe(self):
- log.warning('VOLTServiceInstance.vcpe is DEPRECATED, use VOLTServiceInstance.vsg instead')
- return self.vsg
-
- @property
- def subscriber(self):
- log.warning(
- 'VOLTServiceInstance.subscriber is DEPRECATED, use get_westbound_service_instance_properties instead')
- # NOTE this assume that each VOLT has just 1 subscriber, is that right?
- try:
- links = self.stub.ServiceInstanceLink.objects.filter(provider_service_instance_id = self.id)
- for link in links:
- subs = self.stub.ServiceInstance.objects.filter(id=link.subscriber_service_instance_id)
- if subs:
- return subs[0].leaf_model
- return None
- except Exception, e:
- log.warning('Error while locating subscriber for vOLTServiceInstance with id %s: %s' % (self.id, e.message))
- return None
-
- @property
- def c_tag(self):
- log.warning(
- 'VOLTServiceInstance.c_tag is DEPRECATED, use get_westbound_service_instance_properties instead')
- return self.subscriber.c_tag
-
def get_olt_device_by_subscriber(self):
pon_port = self.get_pon_port_by_subscriber()
return pon_port.olt_device
@@ -71,18 +32,6 @@
return onu.pon_port
@property
- def s_tag(self):
- try:
- pon_port = self.get_pon_port_by_subscriber()
-
- if pon_port:
- return pon_port.s_tag
- return None
- except Exception, e:
- log.exception('Error while reading s_tag: %s' % e.message)
- return None
-
- @property
def switch_datapath_id(self):
try:
olt_device = self.get_olt_device_by_subscriber()
diff --git a/xos/synchronizer/models/models.py b/xos/synchronizer/models/models.py
index 046e744..4d5b8b8 100644
--- a/xos/synchronizer/models/models.py
+++ b/xos/synchronizer/models/models.py
@@ -92,39 +92,6 @@
class Meta:
proxy = True
- def generate_tag(self):
- # NOTE this method will loop if available c_tags are ended
- tag = random.randint(16, 4096)
- if tag in self.get_used_s_tags():
- return self.generate_tag()
- return tag
-
- def get_used_s_tags(self):
- same_olt_device = OLTDevice.objects.filter(device_id=self.olt_device)
- return [s.c_tag for s in same_olt_device]
-
- def save(self, *args, **kwargs):
- # validate s_tag
- if hasattr(self, 's_tag') and self.s_tag is not None:
- is_update_with_same_tag = False
-
- if not self.is_new:
- # if it is an update, but the tag is the same, skip validation
- existing = PONPort.objects.filter(s_tag=self.s_tag)
-
- if len(existing) > 0 and existing[0].s_tag == self.s_tag and existing[0].id == self.id:
- is_update_with_same_tag = True
-
- if self.s_tag in self.get_used_s_tags() and not is_update_with_same_tag:
- raise XOSValidationError(
- "The s_tag you specified (%s) has already been used on device %s" % (self.s_tag, self.onu_device))
-
- if not hasattr(self, "s_tag") or self.s_tag is None:
- self.s_tag = self.generate_tag()
-
- super(PONPort, self).save(*args, **kwargs)
-
-
class NNIPort(NNIPort_decl):
class Meta:
proxy = True
diff --git a/xos/synchronizer/models/volt.xproto b/xos/synchronizer/models/volt.xproto
index de66517..6871a3b 100644
--- a/xos/synchronizer/models/volt.xproto
+++ b/xos/synchronizer/models/volt.xproto
@@ -52,11 +52,10 @@
}
message PONPort (PortBase){
- option verbose_name = "OLT PON Port";
- option description="OLT Side PON Port";
+ option verbose_name = "PON Port";
+ option description="PON Port";
required manytoone olt_device->OLTDevice:pon_ports = 1 [db_index = True, null = False, blank = False];
- required int32 s_tag = 2 [help_text = "S Tag", null = False, db_index = False, blank = False];
}
message NNIPort (PortBase) {
@@ -80,8 +79,8 @@
}
message PONONUPort (PortBase) {
- option verbose_name = "ONU PON Port";
- option description="ONU Side PON Port";
+ option verbose_name = "ANI Port";
+ option description="ANI Port";
required manytoone onu_device->ONUDevice:pononu_ports = 1 [db_index = True, null = False, blank = False];
}