Scott Baker | bba67b6 | 2019-01-28 17:38:21 -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 | |
| 16 | import os |
| 17 | import base64 |
| 18 | import struct |
| 19 | import socket |
| 20 | from netaddr import IPAddress, IPNetwork |
| 21 | from xossynchronizer.steps.syncstep import SyncStep |
| 22 | from xossynchronizer.mock_modelaccessor import * |
| 23 | |
| 24 | class SyncControllerNetworks(SyncStep): |
| 25 | requested_interval = 0 |
| 26 | provides = [Network] |
| 27 | observes = ControllerNetwork |
| 28 | external_dependencies = [User] |
| 29 | playbook = "sync_controller_networks.yaml" |
| 30 | |
| 31 | def fetch_pending(self, deleted): |
| 32 | ci = ControllerNetwork() |
| 33 | i = Network() |
| 34 | i.name = "Lush Loss" |
| 35 | s = Slice() |
| 36 | s.name = "Ghastly Notebook" |
| 37 | i.owner = s |
| 38 | ci.i = i |
| 39 | return [ci] |
| 40 | |
| 41 | def map_sync_outputs(self, controller_network, res): |
| 42 | network_id = res[0]["network"]["id"] |
| 43 | subnet_id = res[1]["subnet"]["id"] |
| 44 | controller_network.net_id = network_id |
| 45 | controller_network.subnet = self.cidr |
| 46 | controller_network.subnet_id = subnet_id |
| 47 | controller_network.backend_status = "1 - OK" |
| 48 | if not controller_network.segmentation_id: |
| 49 | controller_network.segmentation_id = str( |
| 50 | self.get_segmentation_id(controller_network) |
| 51 | ) |
| 52 | controller_network.save() |
| 53 | |
| 54 | def map_sync_inputs(self, controller_network): |
| 55 | pass |
| 56 | |
| 57 | def map_delete_inputs(self, controller_network): |
| 58 | network_fields = {"endpoint": None, "delete": True} |
| 59 | |
| 60 | return network_fields |