Scott Baker | b63ea79 | 2016-08-11 10:24:48 -0700 | [diff] [blame] | 1 | import os |
| 2 | import base64 |
Scott Baker | b63ea79 | 2016-08-11 10:24:48 -0700 | [diff] [blame] | 3 | from xos.config import Config |
Scott Baker | 8b75e85 | 2016-08-16 15:04:59 -0700 | [diff] [blame] | 4 | from synchronizers.openstack.openstacksyncstep import OpenStackSyncStep |
Scott Baker | af599eb | 2017-03-21 12:43:26 -0700 | [diff] [blame] | 5 | from synchronizers.new_base.syncstep import * |
| 6 | from xos.logger import observer_logger as logger |
| 7 | from synchronizers.new_base.ansible_helper import * |
| 8 | from synchronizers.new_base.modelaccessor import * |
Scott Baker | b63ea79 | 2016-08-11 10:24:48 -0700 | [diff] [blame] | 9 | |
| 10 | class 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 Baker | af599eb | 2017-03-21 12:43:26 -0700 | [diff] [blame] | 20 | return super(SyncControllerImages, self).fetch_pending(deleted) |
Scott Baker | b63ea79 | 2016-08-11 10:24:48 -0700 | [diff] [blame] | 21 | |
| 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() |