Matteo Scandolo | 4a8b4d6 | 2018-03-06 17:18:46 -0800 | [diff] [blame] | 1 | # Copyright 2017-present Open Networking Foundation |
| 2 | # |
| 3 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | # you may not use this file except in compliance with the License. |
| 5 | # You may obtain a copy of the License at |
| 6 | # |
| 7 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | # |
| 9 | # Unless required by applicable law or agreed to in writing, software |
| 10 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | # See the License for the specific language governing permissions and |
| 13 | # limitations under the License. |
| 14 | |
| 15 | import json |
| 16 | from synchronizers.new_base.SyncInstanceUsingAnsible import SyncStep |
| 17 | from synchronizers.new_base.modelaccessor import VOLTService |
| 18 | |
| 19 | from xosconfig import Config |
| 20 | from multistructlog import create_logger |
| 21 | from time import sleep |
| 22 | import requests |
| 23 | from requests.auth import HTTPBasicAuth |
| 24 | |
| 25 | log = create_logger(Config().get('logging')) |
| 26 | |
| 27 | class SyncOLTService(SyncStep): |
| 28 | provides = [VOLTService] |
Matteo Scandolo | 4a8b4d6 | 2018-03-06 17:18:46 -0800 | [diff] [blame] | 29 | observes = VOLTService |
| 30 | |
Matteo Scandolo | 4a8b4d6 | 2018-03-06 17:18:46 -0800 | [diff] [blame] | 31 | def sync_record(self, o): |
Luca Prete | ca974c8 | 2018-05-01 18:06:16 -0700 | [diff] [blame^] | 32 | log.info("synching OLT service", object=str(o), **o.tologdict()) |
Matteo Scandolo | 4a8b4d6 | 2018-03-06 17:18:46 -0800 | [diff] [blame] | 33 | |
| 34 | if o.onu_provisioning == "allow_all": |
Luca Prete | ca974c8 | 2018-05-01 18:06:16 -0700 | [diff] [blame^] | 35 | # TODO: Tell ONOS to create the ONU device (POST xosapi/v1/volt/onudevices) |
Matteo Scandolo | 4a8b4d6 | 2018-03-06 17:18:46 -0800 | [diff] [blame] | 36 | pass |
| 37 | if o.onu_provisioning == "pre_provisioned" or o.onu_provisioning == "oss": |
Luca Prete | ca974c8 | 2018-05-01 18:06:16 -0700 | [diff] [blame^] | 38 | # TODO: Tell ONOS to update the ONU device (POST xosapi/v1/volt/onudevices/<id>) |
| 39 | # ONOS will need to find the <id> |
| 40 | # if onu_provisioning == oss then XOS will need to make a call to the oss server to validate the ONU |
Matteo Scandolo | 4a8b4d6 | 2018-03-06 17:18:46 -0800 | [diff] [blame] | 41 | pass |
| 42 | |
Matteo Scandolo | 4a8b4d6 | 2018-03-06 17:18:46 -0800 | [diff] [blame] | 43 | def delete_record(self, o): |
| 44 | pass |