blob: 31c62f1b24347c840ace038014f204b1e7923653 [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
Scott Bakerc2fddaa2019-01-30 15:45:03 -080018from xossynchronizer.steps.syncstep import DeferredException
19from xossynchronizer.steps.ansiblesyncstep import AnsibleSyncStep
Scott Bakerbba67b62019-01-28 17:38:21 -080020
Scott Bakerc2fddaa2019-01-30 15:45:03 -080021class SyncControllerSlices(AnsibleSyncStep):
Scott Bakerbba67b62019-01-28 17:38:21 -080022 requested_interval = 0
Scott Bakerc2fddaa2019-01-30 15:45:03 -080023 observes = "ControllerSlice"
Scott Bakerbba67b62019-01-28 17:38:21 -080024 playbook = "sync_controller_slices.yaml"
25
26 def map_sync_inputs(self, controller_slice):
27 if getattr(controller_slice, "force_fail", None):
28 raise Exception("Forced failure")
29 elif getattr(controller_slice, "force_defer", None):
30 raise DeferredException("Forced defer")
31
32 tenant_fields = {"endpoint": "endpoint", "name": "Flagrant Haircut"}
33
34 return tenant_fields
35
36 def map_sync_outputs(self, controller_slice, res):
37 controller_slice.save()
38
39 def map_delete_inputs(self, controller_slice):
40 tenant_fields = {
41 "endpoint": "endpoint",
42 "name": "Conscientious Plastic",
43 "delete": True,
44 }
45 return tenant_fields