updating subscriber status (if pre-provisioned) to create the chain
Change-Id: I7afe3cd87271edcb9c3a24c2b0235662000bf4d9
diff --git a/samples/oss-service-instance-invalid.yaml b/samples/oss-service-instance-invalid.yaml
index 5bca7fb..d440985 100644
--- a/samples/oss-service-instance-invalid.yaml
+++ b/samples/oss-service-instance-invalid.yaml
@@ -34,5 +34,4 @@
name: Invalid ONU example
of_dpid: "of:1234"
serial_number: 845f10885b5c479daab9e825c1f4ced8
- uni_port_id: 16
diff --git a/samples/oss-service-instance-valid.yaml b/samples/oss-service-instance-valid.yaml
index c840d10..6638fbe 100644
--- a/samples/oss-service-instance-valid.yaml
+++ b/samples/oss-service-instance-valid.yaml
@@ -34,5 +34,4 @@
name: valid ONU example
of_dpid: "of:1234"
serial_number: BRCM1234
- uni_port_id: 16
diff --git a/xos/synchronizer/model_policies/model_policy_hippieossserviceinstance.py b/xos/synchronizer/model_policies/model_policy_hippieossserviceinstance.py
index 3008a57..5a380dd 100644
--- a/xos/synchronizer/model_policies/model_policy_hippieossserviceinstance.py
+++ b/xos/synchronizer/model_policies/model_policy_hippieossserviceinstance.py
@@ -35,35 +35,48 @@
if si.valid == "valid":
# reactivating the ONUDevice
- onu = ONUDevice.objects.get(serial_number=si.serial_number)
+ try:
+ onu = ONUDevice.objects.get(serial_number=si.serial_number)
+ except IndexError:
+ raise Exception("MODEL_POLICY: cannot find ONUDevice [%s] for HippieOSSServiceInstance %s" % (si.serial_number, si.id))
if onu.admin_state == "DISABLED":
- self.logger.debug("MODEL_POLICY: enabling ONUDevice [%s] for HippieOSSServiceInstance %s" % (
- si.serial_number, si.id))
+ self.logger.debug("MODEL_POLICY: enabling ONUDevice [%s] for HippieOSSServiceInstance %s" % (si.serial_number, si.id))
onu.admin_state = "ENABLED"
onu.save(always_update_timestamp=True)
# NOTE this assumes that an ONUDevice has only one Subscriber
try:
+ subscriber_changed = False
subscriber = RCORDSubscriber.objects.get(onu_device=si.serial_number)
+ self.logger.debug("MODEL_POLICY: found subscriber for valid ONU", onu=si.serial_number)
# If the OSS returns a c_tag and the subscriber doesn't already have his one
if si.c_tag and not subscriber.c_tag:
self.logger.debug("MODEL_POLICY: updating c_tag for RCORDSubscriber %s and HippieOSSServiceInstance %s" % (subscriber.id, si.id))
subscriber.c_tag = si.c_tag
- else:
- # if we're not changing anything in the subscriber, we don't need to update it
+ subscriber_changed = True
+
+ # if the subscriber was in pre-provisioned state, change it's status, otherwise leave it as is
+ if subscriber.status == "pre-provisioned":
+ subscriber.status = "awaiting-auth"
+ self.logger.debug("MODEL_POLICY: setting subscriber status", status=subscriber.status)
+ subscriber_changed = True
+
+ if not subscriber_changed:
+ # do not trigger an update unless it's needed
return
- except IndexError, e:
+ except IndexError:
self.logger.debug("MODEL_POLICY: creating RCORDSubscriber for HippieOSSServiceInstance %s" % si.id)
subscriber = RCORDSubscriber()
subscriber.onu_device = si.serial_number
+ subscriber.status == "awaiting-auth"
# If the OSS returns a c_tag use that one
if si.c_tag:
subscriber.c_tag = si.c_tag
- subscriber.save()
+ subscriber.save(always_update_timestamp=True)
return
def handle_delete(self, si):
diff --git a/xos/synchronizer/steps/sync_hippie_oss_service_instance.py b/xos/synchronizer/steps/sync_hippie_oss_service_instance.py
index e45f058..94b73b7 100644
--- a/xos/synchronizer/steps/sync_hippie_oss_service_instance.py
+++ b/xos/synchronizer/steps/sync_hippie_oss_service_instance.py
@@ -53,7 +53,8 @@
o.valid = "valid"
- # FIXME why without this model_policies won't run the handle_update?
+ # we need to update the timestamp to run model_policies again, but we don't want to loop over the sync_steps
+ # maybe we need an "after_sync" model policy method?
o.no_sync = True
o.save(always_update_timestamp=True)