blob: 55dfe4eb454018dae0aa0ceb5b84c5cca6fb2762 [file] [log] [blame]
Scott Bakerbba67b62019-01-28 17:38:21 -08001# 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
16import os
17import base64
18import struct
19import socket
20from netaddr import IPAddress, IPNetwork
21from xossynchronizer.steps.syncstep import SyncStep
Scott Bakerbba67b62019-01-28 17:38:21 -080022
23class SyncControllerNetworks(SyncStep):
24 requested_interval = 0
Scott Bakerc2fddaa2019-01-30 15:45:03 -080025 observes = "ControllerNetwork"
26 external_dependencies = ["User"]
Scott Bakerbba67b62019-01-28 17:38:21 -080027 playbook = "sync_controller_networks.yaml"
28
29 def fetch_pending(self, deleted):
Scott Bakerc2fddaa2019-01-30 15:45:03 -080030 ci = self.model_accessor.ControllerNetwork()
31 i = self.model_accessor.Network()
Scott Bakerbba67b62019-01-28 17:38:21 -080032 i.name = "Lush Loss"
Scott Bakerc2fddaa2019-01-30 15:45:03 -080033 s = self.model_accessor.Slice()
Scott Bakerbba67b62019-01-28 17:38:21 -080034 s.name = "Ghastly Notebook"
35 i.owner = s
36 ci.i = i
37 return [ci]
38
39 def map_sync_outputs(self, controller_network, res):
40 network_id = res[0]["network"]["id"]
41 subnet_id = res[1]["subnet"]["id"]
42 controller_network.net_id = network_id
43 controller_network.subnet = self.cidr
44 controller_network.subnet_id = subnet_id
45 controller_network.backend_status = "1 - OK"
46 if not controller_network.segmentation_id:
47 controller_network.segmentation_id = str(
48 self.get_segmentation_id(controller_network)
49 )
50 controller_network.save()
51
52 def map_sync_inputs(self, controller_network):
53 pass
54
55 def map_delete_inputs(self, controller_network):
56 network_fields = {"endpoint": None, "delete": True}
57
58 return network_fields