Пример #1
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)
Пример #2
0
    def test_get_version(self, mock_get_distribution):
        mock_distribution = Mock()
        mock_distribution.version = "1.2.3"
        mock_get_distribution.return_value = mock_distribution

        self.assertEquals(status_manager.get_version(),
                          {'platform_version': '1.2.3'})
Пример #3
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)
Пример #4
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)
Пример #5
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)
Пример #6
0
    def test_get_version(self, mock_get_distribution):
        mock_distribution = Mock()
        mock_distribution.version = "1.2.3"
        mock_get_distribution.return_value = mock_distribution

        self.assertEquals(status_manager.get_version(), {'platform_version': '1.2.3'})