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 | from xossynchronizer.steps.syncstep import SyncStep |
Scott Baker | bba67b6 | 2019-01-28 17:38:21 -0800 | [diff] [blame] | 19 | |
| 20 | class SyncControllerImages(SyncStep): |
Scott Baker | c2fddaa | 2019-01-30 15:45:03 -0800 | [diff] [blame] | 21 | observes = "ControllerImages" |
Scott Baker | bba67b6 | 2019-01-28 17:38:21 -0800 | [diff] [blame] | 22 | requested_interval = 0 |
| 23 | playbook = "sync_controller_images.yaml" |
| 24 | |
| 25 | def fetch_pending(self, deleted): |
Scott Baker | c2fddaa | 2019-01-30 15:45:03 -0800 | [diff] [blame] | 26 | ci = self.model_accessor.ControllerImages() |
| 27 | i = self.model_accessor.Image() |
Scott Baker | bba67b6 | 2019-01-28 17:38:21 -0800 | [diff] [blame] | 28 | i.name = "Lush Loss" |
| 29 | ci.i = i |
| 30 | return [ci] |
| 31 | |
| 32 | def map_sync_inputs(self, controller_image): |
| 33 | image_fields = { |
| 34 | "endpoint": controller_image.controller.auth_url, |
| 35 | "endpoint_v3": controller_image.controller.auth_url_v3, |
| 36 | "admin_user": controller_image.controller.admin_user, |
| 37 | "admin_password": controller_image.controller.admin_password, |
| 38 | "domain": controller_image.controller.domain, |
| 39 | "name": controller_image.image.name, |
| 40 | "filepath": controller_image.image.path, |
| 41 | # name of ansible playbook |
| 42 | "ansible_tag": "%s@%s" |
| 43 | % (controller_image.image.name, controller_image.controller.name), |
| 44 | } |
| 45 | |
| 46 | return image_fields |
| 47 | |
| 48 | def map_sync_outputs(self, controller_image, res): |
| 49 | image_id = res[0]["id"] |
| 50 | controller_image.glance_image_id = image_id |
| 51 | controller_image.backend_status = "1 - OK" |
| 52 | controller_image.save() |