예제 #1
0
    def __init__(self, regions, override_d=None):
        """init object"""
        GlanceSync.init_logs()
        self.glancesync = GlanceSync(options_dict=override_d)

        regions_expanded = list()
        already_sorted = True
        for region in regions:
            if region.endswith(':'):
                regions_expanded.extend(self.glancesync.get_regions(
                    target=region[:-1]))
                already_sorted = False
            else:
                regions_expanded.append(region)

        regions = regions_expanded
        if not regions:
            regions = self.glancesync.get_regions()
            already_sorted = False

        if not already_sorted:
            regions_unsorted = regions
            regions = list()
            for region in self.glancesync.preferable_order:
                if region in regions_unsorted:
                    regions.append(region)
                    regions_unsorted.remove(region)

            regions.extend(regions_unsorted)
        self.regions = regions
예제 #2
0
from flask import request

from fiwareglancesync.app.app import db
from fiwareglancesync.app.mod_auth.models import User
from fiwareglancesync.app.settings.settings import CONTENT_TYPE, SERVER_HEADER, SERVER, JSON_TYPE
from fiwareglancesync.app.settings.settings import logger_api
from fiwareglancesync.glancesync import GlanceSync
from fiwareglancesync.utils.utils import Images, Task
from openstack_auth import authorized
from region_manager import check_region


# Define the blueprint: 'auth', set its url prefix: app.url/regions
mod_auth = Blueprint('auth', __name__, url_prefix='/regions')

GlanceSync.init_logs()


# Set the route and accepted methods
@mod_auth.route('/<regionid>', methods=['GET'])
@authorized
@check_region
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.