Beispiel #1
0
 def test_get_images_region(self):
     """test get_images_region with a master region"""
     glancesync = GlanceSync(self.config)
     result = glancesync.get_images_region('Valladolid')
     result.sort(key=lambda image: int(image.id))
     expected = self.images_master
     expected.sort(key=lambda image: int(image.id))
     self.assertEquals(len(result), 20)
     self.assertEquals(result, expected)
Beispiel #2
0
 def test_get_images_region_other(self):
     """test get_images_region with a region on other target"""
     glancesync = GlanceSync(self.config)
     result = glancesync.get_images_region('other:Madrid')
     result.sort(key=lambda image: int(image.id))
     expected = self.images_Madrid
     expected.sort(key=lambda image: int(image.id))
     self.assertEquals(len(result), 20)
     self.assertEquals(result, expected)
 def test_get_images_region_other(self):
     """test get_images_region with a region on other target"""
     glancesync = GlanceSync(self.config)
     result = glancesync.get_images_region('other:Madrid')
     result.sort(key=lambda image: int(image.id))
     expected = self.images_Madrid
     expected.sort(key=lambda image: int(image.id))
     self.assertEquals(len(result), 20)
     self.assertEquals(result, expected)
 def test_get_images_region(self):
     """test get_images_region with a master region"""
     glancesync = GlanceSync(self.config)
     result = glancesync.get_images_region('Valladolid')
     result.sort(key=lambda image: int(image.id))
     expected = self.images_master
     expected.sort(key=lambda image: int(image.id))
     self.assertEquals(len(result), 20)
     self.assertEquals(result, expected)
Beispiel #5
0
 def test_get_images_region_master(self):
     """test get_images_region with a master region, with 'master:' prefix
     """
     glancesync = GlanceSync(self.config)
     result = glancesync.get_images_region('master:Burgos')
     result.sort(key=lambda image: int(image.id))
     expected = self.images_Burgos
     expected.sort(key=lambda image: int(image.id))
     self.assertEquals(len(result), 20)
     self.assertEquals(result, expected)
 def test_get_images_region_master(self):
     """test get_images_region with a master region, with 'master:' prefix
     """
     glancesync = GlanceSync(self.config)
     result = glancesync.get_images_region('master:Burgos')
     result.sort(key=lambda image: int(image.id))
     expected = self.images_Burgos
     expected.sort(key=lambda image: int(image.id))
     self.assertEquals(len(result), 20)
     self.assertEquals(result, expected)
def get_status(regionid, token=None):
    """
    Lists information the status of the synchronization of the images in
    the region <regionid>. Keep in mind that <regionid> is the name of
    the region.

    :param regionid: Region name how you can obtain from the Keystone
                     service. Example: Spain2.
    :param token: The token of the request to be authorized.
    :return: JSON response message with the detailed information about
             the images and the sincronization status.
    """

    message = "GET, get information about the synchronization status in the region: {}".format(regionid)

    logger_api.info(message)

    image_name = request.args.get('image')

    glancesync = GlanceSync(options_dict=None)
    list_images = glancesync.get_images_region(regionid, only_tenant_images=False)

    x = Images()
    for item in list_images:
        try:
            if image_name is None or item.name == image_name:
                x.add([item.id, item.name, item.status, None])
        except Exception as e:
            print(e)

    if list_images:
        logger_api.info('Return result: %s', x.dump())
        response = make_response(x.dump(), httplib.OK)
    else:
        response = make_response('{}', httplib.OK)

    response.headers[SERVER_HEADER] = SERVER
    response.headers[CONTENT_TYPE] = JSON_TYPE

    return response