blob: ef8598359dfdc150284b1f898c68ea37792bddc0 [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
18from xossynchronizer.steps.syncstep import SyncStep
Scott Bakerbba67b62019-01-28 17:38:21 -080019
20class SyncControllerImages(SyncStep):
Scott Bakerc2fddaa2019-01-30 15:45:03 -080021 observes = "ControllerImages"
Scott Bakerbba67b62019-01-28 17:38:21 -080022 requested_interval = 0
23 playbook = "sync_controller_images.yaml"
24
25 def fetch_pending(self, deleted):
Scott Bakerc2fddaa2019-01-30 15:45:03 -080026 ci = self.model_accessor.ControllerImages()
27 i = self.model_accessor.Image()
Scott Bakerbba67b62019-01-28 17:38:21 -080028 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()