コード例 #1
0
ファイル: app.py プロジェクト: pombredanne/vmaas
def main():
    """ The main function. It creates VmaaS application, servers, run everything."""

    vmaas_app = Application()

    server = tornado.httpserver.HTTPServer(vmaas_app)
    server.bind(PUBLIC_API_PORT)
    num_servers = int(os.getenv("MAX_VMAAS_SERVERS", MAX_SERVERS))
    server.start(num_servers)  # start forking here
    init_logging(num_servers)
    LOGGER.info("Starting (version %s).", VMAAS_VERSION)

    # The rest stuff must be done only after forking
    BaseHandler.db_cache = Cache()
    BaseHandler.updates_api = UpdatesAPI(BaseHandler.db_cache)
    BaseHandler.repo_api = RepoAPI(BaseHandler.db_cache)
    BaseHandler.cve_api = CveAPI(BaseHandler.db_cache)
    BaseHandler.errata_api = ErrataAPI(BaseHandler.db_cache)
    BaseHandler.dbchange_api = DBChange(BaseHandler.db_cache)

    vmaas_app.websocket_reconnect()
    vmaas_app.reconnect_callback = PeriodicCallback(
        vmaas_app.websocket_reconnect, WEBSOCKET_RECONNECT_INTERVAL * 1000)
    vmaas_app.reconnect_callback.start()

    IOLoop.instance().start()
コード例 #2
0
def load_cache_to_apis():
    """Reload cache in APIs."""
    BaseHandler.updates_api = UpdatesAPI(BaseHandler.db_cache)
    BaseHandler.repo_api = RepoAPI(BaseHandler.db_cache)
    BaseHandler.cve_api = CveAPI(BaseHandler.db_cache)
    BaseHandler.errata_api = ErrataAPI(BaseHandler.db_cache)
    BaseHandler.packages_api = PackagesAPI(BaseHandler.db_cache)
    BaseHandler.vulnerabilities_api = VulnerabilitiesAPI(BaseHandler.db_cache, BaseHandler.updates_api)
    BaseHandler.dbchange_api = DBChange(BaseHandler.db_cache)
コード例 #3
0
ファイル: test_errata.py プロジェクト: Josca/vmaas
    def setup_api(self, load_cache):
        """Setup ErrataAPI object from self.cache"""
        # WORKAROUND: tzinfo from date is lost after loading YAML
        errata_detail = self.cache.errata_detail[ERRATA_NAME]
        errata_detail_list = list(errata_detail)
        errata_detail_list[ERRATA_UPDATED] = errata_detail[ERRATA_UPDATED].replace(tzinfo=pytz.utc)
        errata_detail_list[ERRATA_ISSUED] = errata_detail[ERRATA_ISSUED].replace(tzinfo=pytz.utc)
        self.cache.errata_detail[ERRATA_NAME] = errata_detail_list

        # make errata_detail without ERRATA_UPDATED
        errata_detail2 = self.cache.errata_detail[ERRATA_NAME]
        errata_detail_list2 = list(errata_detail2)
        errata_detail_list2[ERRATA_UPDATED] = None
        self.cache.errata_detail["RHSA-W/O:MODIFIED"] = errata_detail_list2

        self.errata_api = ErrataAPI(self.cache)
コード例 #4
0
 def __init__(self):
     handlers = [
         (r"/api/internal/refresh/?", RefreshHandler),  # GET request
         (r"/api/v1/updates/?", UpdatesHandler),  # POST request
         (r"/api/v1/updates/[a-zA-Z0-9-._:]+",
          UpdatesHandler),  # GET request with package name
         (r"/api/v1/cves/?", CVEHandler),
         (r"/api/v1/cves/[a-zA-Z0-9*-]+", CVEHandler),
         (r"/api/v1/repos/?", ReposHandler),
         (r"/api/v1/repos/[a-zA-Z0-9*-_]+", ReposHandler),
         (r"/api/v1/errata/?", ErrataHandler),  # POST request
         (r"/api/v1/errata/[a-zA-Z0-9*-:]+", ErrataHandler)  # GET request
     ]
     cursor = Database().cursor()
     self.updatesapi = UpdatesAPI(cursor)
     self.cveapi = CveAPI(cursor)
     self.repoapi = RepoAPI(cursor)
     self.errataapi = ErrataAPI(cursor)
     tornado.web.Application.__init__(self, handlers)