blob: 2dbd74db5b0ebc38b5680339523d46325097192d [file] [log] [blame]
Tony Mack46c2d502013-10-09 13:04:28 -04001import os
2import base64
3from django.db.models import F, Q
4from planetstack.config import Config
5from observer.openstacksyncstep import OpenStackSyncStep
6from core.models.image import Image
7
8class SyncImages(OpenStackSyncStep):
9 provides=[Image]
10 requested_interval=0
11
12 def fetch_pending(self):
13 images = Image.objects.all()
14 image_names = [image.name for image in images]
15
16 new_images = []
17 glance_images = self.driver.shell.glance.get_images()
18 for glance_image in glance_images:
19 if glance_image['name'] not in image_names:
20 image = Image(image_id=glance_image['id'],
21 name=glance_image['name'],
22 disk_format=glance_image['disk_format'],
23 container_format=glance_image['container_format'])
24 new_images.append(image)
25
26 return new_images
27
28 def sync_record(self, image):
29 image.save()