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