示例#1
0
文件: status.py 项目: alanoe/pulp
    def get(self, request):
        """
        Show current status of pulp server.

        :param request: WSGI request object
        :type request: django.core.handlers.wsgi.WSGIRequest

        :return: Response showing surrent server status
        :rtype: django.http.HttpResponse
        """
        pulp_version = status_manager.get_version()
        pulp_db_connection = status_manager.get_mongo_conn_status()
        pulp_messaging_connection = status_manager.get_broker_conn_status()

        # do not ask for the worker list unless we have a DB connection
        if pulp_db_connection['connected']:
            # convert Worker documents to dicts
            pulp_workers = [w.to_mongo().to_dict() for w in status_manager.get_workers()]
        else:
            pulp_workers = []

        # 'api_version' is deprecated and can go away in 3.0, bz #1171763
        status_data = {'api_version': '2',
                       'versions': pulp_version,
                       'database_connection': pulp_db_connection,
                       'messaging_connection': pulp_messaging_connection,
                       'known_workers': pulp_workers}

        return generate_json_response_with_pulp_encoder(status_data)
示例#2
0
    def get(self, request):
        """
        Show current status of pulp server.

        :param request: WSGI request object
        :type request: django.core.handlers.wsgi.WSGIRequest

        :return: Response showing surrent server status
        :rtype: django.http.HttpResponse
        """
        pulp_version = status_manager.get_version()
        pulp_db_connection = status_manager.get_mongo_conn_status()
        pulp_messaging_connection = status_manager.get_broker_conn_status()

        # do not ask for the worker list unless we have a DB connection
        if pulp_db_connection['connected']:
            # convert Worker documents to dicts
            pulp_workers = [
                w.to_mongo().to_dict() for w in status_manager.get_workers()
            ]
        else:
            pulp_workers = []

        # 'api_version' is deprecated and can go away in 3.0, bz #1171763
        status_data = {
            'api_version': '2',
            'versions': pulp_version,
            'database_connection': pulp_db_connection,
            'messaging_connection': pulp_messaging_connection,
            'known_workers': pulp_workers
        }

        return generate_json_response_with_pulp_encoder(status_data)
示例#3
0
    def GET(self):
        pulp_version = status_manager.get_version()
        pulp_db_connection = status_manager.get_mongo_conn_status()
        pulp_messaging_connection = status_manager.get_broker_conn_status()

        # do not ask for the worker list unless we have a DB connection
        if pulp_db_connection['connected']:
            pulp_workers = [w for w in status_manager.get_workers()]
        else:
            pulp_workers = []

        # 'api_version' is deprecated and can go away in 3.0, bz #1171763
        status_data = {'api_version': '2',
                       'versions': pulp_version,
                       'database_connection': pulp_db_connection,
                       'messaging_connection': pulp_messaging_connection,
                       'known_workers': pulp_workers}

        return self.ok(status_data)
示例#4
0
文件: status.py 项目: ipanova/pulp
    def GET(self):
        pulp_version = status_manager.get_version()
        pulp_db_connection = status_manager.get_mongo_conn_status()
        pulp_messaging_connection = status_manager.get_broker_conn_status()

        # do not ask for the worker list unless we have a DB connection
        if pulp_db_connection['connected']:
            pulp_workers = [w for w in status_manager.get_workers()]
        else:
            pulp_workers = []

        # 'api_version' is deprecated and can go away in 3.0, bz #1171763
        status_data = {
            'api_version': '2',
            'versions': pulp_version,
            'database_connection': pulp_db_connection,
            'messaging_connection': pulp_messaging_connection,
            'known_workers': pulp_workers
        }

        return self.ok(status_data)
示例#5
0
    def test_get_mongo_conn_status_exception(self, mock_get_database):
        mock_get_database.side_effect = Exception("boom!")

        self.assertEquals(status_manager.get_mongo_conn_status(),
                          {'connected': False})
示例#6
0
 def test_get_mongo_conn_status(self, mock_get_database):
     self.assertEquals(status_manager.get_mongo_conn_status(),
                       {'connected': True})
示例#7
0
    def test_get_mongo_conn_status_exception(self, mock_get_database):
        mock_get_database.side_effect = Exception("boom!")

        self.assertEquals(status_manager.get_mongo_conn_status(), {'connected': False})
示例#8
0
 def test_get_mongo_conn_status(self, mock_get_database):
     self.assertEquals(status_manager.get_mongo_conn_status(), {'connected': True})