blob: 543c0df765ec174012a1f30e5120be0dc3bb6617 [file] [log] [blame]
Matteo Scandolo75298822018-05-22 11:25:42 -07001
2# Copyright 2017-present Open Networking Foundation
3#
4# Licensed under the Apache License, Version 2.0 (the "License");
5# you may not use this file except in compliance with the License.
6# You may obtain a copy of the License at
7#
8# http://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS,
12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13# See the License for the specific language governing permissions and
14# limitations under the License.
15
16
17from synchronizers.new_base.modelaccessor import RCORDSubscriber, model_accessor
18from synchronizers.new_base.policy import Policy
19
20class OSSServiceInstancePolicy(Policy):
21 model_name = "HippieOSSServiceInstance"
22
23 def handle_update(self, si):
24 self.logger.debug("MODEL_POLICY: handle_update for HippieOSSServiceInstance %s " % si.id)
25 if not si.valid:
26 # NOTE we don't do anything if the ONU has not been activated
27 self.logger.debug("MODEL_POLICY: skipping handle_update for HippieOSSServiceInstance %s as valid is %s" % (si.id, si.valid))
28 pass
29 else:
30 self.logger.debug("MODEL_POLICY: creating RCORDSubscriber for HippieOSSServiceInstance %s as valid is %s" % (si.id, si.valid))
31 subscriber = RCORDSubscriber()
32 subscriber.onu_device = si.serial_number
33 subscriber.uni_port_id = si.uni_port_id
34
35 # If the OSS returns a c_tag use that one
36 if si.c_tag:
37 subscriber.c_tag = si.c_tag
38
39 subscriber.save()
40
41 def handle_delete(self, si):
42 pass