Exemple #1
0
def configure_sx(application):
    reload(sys)
    sys.setdefaultencoding('utf8')
    settings = config.get_settings()
    logger.debug('Configure called with settings: %s.' % settings)

    # SX initialization
    global _sxcontroller
    if os.path.isfile(settings['sx.admin_key']):
        user_data = sxclient.UserData.from_key_path(settings['sx.admin_key'])
    else:
        user_data = sxclient.UserData.from_key(settings['sx.admin_key'])

    cluster = sxclient.Cluster(
        settings['sx.cluster_name'],
        ip_addresses=settings.get('sx.host_list'),
        is_secure=settings.get('sx.ssl', True),
        port=settings.get('sx.port'),
        verify_ssl_cert=settings.get('sx.verify_cert', True)
    )
    _sxcontroller = sxclient.SXController(cluster, user_data=user_data)
    logger.debug('SXController initialized.')

    # # SX cleanup initialization
    config.register_signal(signal.SIGINT, close_sxcontroller)
    config.register_signal(signal.SIGTERM, close_sxcontroller)
    config.register_signal(signal.SIGQUIT, close_sxcontroller)
    logger.debug('Cleanup actions initialized.')

    # Other stuff
    requests.packages.urllib3.disable_warnings()  # unnecessary noise

    logger.info('Fully configured SX.')
Exemple #2
0
def configure_sx(application):
    reload(sys)
    sys.setdefaultencoding('utf8')
    settings = config.get_settings()
    logger.debug('Configure called with settings: %s.' % settings)

    # SX initialization
    global _sxcontroller
    if os.path.isfile(settings['sx.admin_key']):
        user_data = sxclient.UserData.from_key_path(settings['sx.admin_key'])
    else:
        user_data = sxclient.UserData.from_key(settings['sx.admin_key'])

    cluster = sxclient.Cluster(settings['sx.cluster_name'],
                               ip_addresses=settings.get('sx.host_list'),
                               is_secure=settings.get('sx.ssl', True),
                               port=settings.get('sx.port'),
                               verify_ssl_cert=settings.get(
                                   'sx.verify_cert', True))
    _sxcontroller = sxclient.SXController(cluster, user_data=user_data)
    logger.debug('SXController initialized.')

    # # SX cleanup initialization
    config.register_signal(signal.SIGINT, close_sxcontroller)
    config.register_signal(signal.SIGTERM, close_sxcontroller)
    config.register_signal(signal.SIGQUIT, close_sxcontroller)
    logger.debug('Cleanup actions initialized.')

    # Other stuff
    requests.packages.urllib3.disable_warnings()  # unnecessary noise

    logger.info('Fully configured SX.')
Exemple #3
0

# TODO: there should be a separate process that calls
# _sxdownloader.clean_cached_files() periodically.
# clean_cached_files method is safe.


def cleanup_downloader(sig):
    global _sxdownloader
    if _sxdownloader is None:
        return
    _sxdownloader.close()
    _sxdownloader = None


register_signal(signal.SIGINT, cleanup_downloader)
register_signal(signal.SIGTERM, cleanup_downloader)
register_signal(signal.SIGQUIT, cleanup_downloader)


class ObjectLoader(ObjectProcessor):
    @log_args(logger)
    def get_content_stream(self):
        try:
            downloader = get_downloader()
        except SXClusterNotFound:
            raise NotFound
        except SXClusterFatalError:
            raise Conflict

        return downloader.get_blocks_content_iterator(self.vol_name, self.object_path)
Exemple #4
0

# TODO: there should be a separate process that calls
# _sxdownloader.clean_cached_files() periodically.
# clean_cached_files method is safe.


def cleanup_downloader(sig):
    global _sxdownloader
    if _sxdownloader is None:
        return
    _sxdownloader.close()
    _sxdownloader = None


register_signal(signal.SIGINT, cleanup_downloader)
register_signal(signal.SIGTERM, cleanup_downloader)
register_signal(signal.SIGQUIT, cleanup_downloader)


class ObjectLoader(ObjectProcessor):

    @log_args(logger)
    def get_content_stream(self):
        try:
            downloader = get_downloader()
        except SXClusterNotFound:
            raise NotFound
        except SXClusterFatalError:
            raise Conflict