blob: 2241fece9cde660c1e1e705aaa3c7e8022beecbb [file] [log] [blame]
Scott Bakerb63ea792016-08-11 10:24:48 -07001import os
2import base64
Scott Bakerb63ea792016-08-11 10:24:48 -07003from xos.config import Config
Scott Baker8b75e852016-08-16 15:04:59 -07004from synchronizers.openstack.openstacksyncstep import OpenStackSyncStep
Scott Bakeraf599eb2017-03-21 12:43:26 -07005from synchronizers.new_base.syncstep import *
6from xos.logger import observer_logger as logger
7from synchronizers.new_base.ansible_helper import *
8from synchronizers.new_base.modelaccessor import *
Scott Bakerb63ea792016-08-11 10:24:48 -07009
10class SyncControllerImages(OpenStackSyncStep):
11 provides=[ControllerImages]
12 observes = ControllerImages
13 requested_interval=0
14 playbook='sync_controller_images.yaml'
15
16 def fetch_pending(self, deleted):
17 if (deleted):
18 return []
19
Scott Bakeraf599eb2017-03-21 12:43:26 -070020 return super(SyncControllerImages, self).fetch_pending(deleted)
Scott Bakerb63ea792016-08-11 10:24:48 -070021
22 def map_sync_inputs(self, controller_image):
23 image_fields = {'endpoint':controller_image.controller.auth_url,
24 'endpoint_v3': controller_image.controller.auth_url_v3,
25 'admin_user':controller_image.controller.admin_user,
26 'admin_password':controller_image.controller.admin_password,
27 'domain': controller_image.controller.domain,
28 'name':controller_image.image.name,
29 'filepath':controller_image.image.path,
30 'ansible_tag': '%s@%s'%(controller_image.image.name,controller_image.controller.name), # name of ansible playbook
31 }
32
33 return image_fields
34
35 def map_sync_outputs(self, controller_image, res):
36 image_id = res[0]['id']
37 controller_image.glance_image_id = image_id
38 controller_image.backend_status = '1 - OK'
39 controller_image.save()