blob: 6837d7a9caafd0b382c02f4f87c9e197350d413d [file] [log] [blame]
Matteo Scandolof0441032017-08-08 13:05:26 -07001
2# Copyright 2017-present Open Networking Foundation
3#
4# Licensed under the Apache License, Version 2.0 (the "License");
5# you may not use this file except in compliance with the License.
6# You may obtain a copy of the License at
7#
8# http://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS,
12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13# See the License for the specific language governing permissions and
14# limitations under the License.
15
16
Scott Bakerb63ea792016-08-11 10:24:48 -070017import os
18import base64
Scott Baker8b75e852016-08-16 15:04:59 -070019from synchronizers.openstack.openstacksyncstep import OpenStackSyncStep
Scott Bakeraf599eb2017-03-21 12:43:26 -070020from synchronizers.new_base.syncstep import *
Scott Bakeraf599eb2017-03-21 12:43:26 -070021from synchronizers.new_base.ansible_helper import *
22from synchronizers.new_base.modelaccessor import *
Scott Bakerb63ea792016-08-11 10:24:48 -070023
24class SyncControllerImages(OpenStackSyncStep):
25 provides=[ControllerImages]
26 observes = ControllerImages
27 requested_interval=0
28 playbook='sync_controller_images.yaml'
29
30 def fetch_pending(self, deleted):
31 if (deleted):
32 return []
33
Scott Bakeraf599eb2017-03-21 12:43:26 -070034 return super(SyncControllerImages, self).fetch_pending(deleted)
Scott Bakerb63ea792016-08-11 10:24:48 -070035
36 def map_sync_inputs(self, controller_image):
37 image_fields = {'endpoint':controller_image.controller.auth_url,
38 'endpoint_v3': controller_image.controller.auth_url_v3,
39 'admin_user':controller_image.controller.admin_user,
40 'admin_password':controller_image.controller.admin_password,
Zack Williams9cb1f3a2017-08-20 19:35:03 -070041 'admin_project': 'admin',
Scott Bakerb63ea792016-08-11 10:24:48 -070042 'domain': controller_image.controller.domain,
43 'name':controller_image.image.name,
44 'filepath':controller_image.image.path,
45 'ansible_tag': '%s@%s'%(controller_image.image.name,controller_image.controller.name), # name of ansible playbook
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()