예제 #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
파일: test_status.py 프로젝트: alanoe/pulp
    def test_get_broker_conn_status_exception(self, mock_celery):
        mock_conn = Mock()
        mock_conn.connect.side_effect = Exception("boom!")
        mock_celery.connection.return_value = mock_conn

        self.assertEquals(status_manager.get_broker_conn_status(), {'connected': False})
예제 #5
0
파일: test_status.py 프로젝트: alanoe/pulp
    def test_get_broker_conn_status(self, mock_celery):
        mock_celery.connection = Mock()

        self.assertEquals(status_manager.get_broker_conn_status(), {'connected': True})