def test__get_api_servers_one(self):
        CONF.set_override("glance_api_servers", ["https://10.0.0.1:9293"], "glance")
        s1 = service_utils._get_api_server()
        s2 = service_utils._get_api_server()
        self.assertEqual(("10.0.0.1", 9293, True), s1)

        # Only one server, should always get the same one
        self.assertEqual(s1, s2)
Exemple #2
0
    def test__get_api_servers_one(self):
        CONF.set_override('glance_api_servers', ['https://10.0.0.1:9293'],
                          'glance')
        s1 = service_utils._get_api_server()
        s2 = service_utils._get_api_server()
        self.assertEqual(('10.0.0.1', 9293, True), s1)

        # Only one server, should always get the same one
        self.assertEqual(s1, s2)
    def test__get_api_servers_one(self):
        CONF.set_override('glance_api_servers', ['https://10.0.0.1:9293'],
                          'glance')
        s1 = service_utils._get_api_server()
        s2 = service_utils._get_api_server()
        self.assertEqual(('10.0.0.1', 9293, True), s1)

        # Only one server, should always get the same one
        self.assertEqual(s1, s2)
    def test__get_api_servers_two(self):
        CONF.set_override("glance_api_servers", ["http://10.0.0.1:9293", "http://10.0.0.2:9294"], "glance")
        s1 = service_utils._get_api_server()
        s2 = service_utils._get_api_server()
        s3 = service_utils._get_api_server()

        self.assertNotEqual(s1, s2)

        # 2 servers, so cycles to the first again
        self.assertEqual(s1, s3)
Exemple #5
0
    def test__get_api_servers_two(self):
        CONF.set_override('glance_api_servers',
                          ['http://10.0.0.1:9293', 'http://10.0.0.2:9294'],
                          'glance')
        s1 = service_utils._get_api_server()
        s2 = service_utils._get_api_server()
        s3 = service_utils._get_api_server()

        self.assertNotEqual(s1, s2)

        # 2 servers, so cycles to the first again
        self.assertEqual(s1, s3)
    def test__get_api_servers_two(self):
        CONF.set_override('glance_api_servers',
                          ['http://10.0.0.1:9293', 'http://10.0.0.2:9294'],
                          'glance')
        s1 = service_utils._get_api_server()
        s2 = service_utils._get_api_server()
        s3 = service_utils._get_api_server()

        self.assertNotEqual(s1, s2)

        # 2 servers, so cycles to the first again
        self.assertEqual(s1, s3)
    def test__get_api_servers_with_keystone(self, mock_auth, mock_session,
                                            mock_service_url):
        mock_service_url.return_value = 'https://example.com'

        endpoint = service_utils._get_api_server()
        self.assertEqual('https://example.com', endpoint)

        mock_auth.assert_called_once_with('glance')
        mock_session.assert_called_once_with('glance',
                                             auth=mock_auth.return_value)
        mock_service_url.assert_called_once_with(mock_session.return_value,
                                                 service_type='image',
                                                 endpoint_type='public')
    def test__get_api_servers_with_keystone(self, mock_auth, mock_session,
                                            mock_service_url):
        mock_service_url.return_value = 'https://example.com'

        endpoint = service_utils._get_api_server()
        self.assertEqual('https://example.com', endpoint)

        mock_auth.assert_called_once_with('glance')
        mock_session.assert_called_once_with('glance',
                                             auth=mock_auth.return_value)
        mock_service_url.assert_called_once_with(mock_session.return_value,
                                                 service_type='image',
                                                 endpoint_type='public')
Exemple #9
0
 def test__get_api_servers_default(self):
     host, port, use_ssl = service_utils._get_api_server()
     self.assertEqual(CONF.glance.glance_host, host)
     self.assertEqual(CONF.glance.glance_port, port)
     self.assertEqual(CONF.glance.glance_protocol == 'https', use_ssl)
 def test__get_api_servers_default(self):
     host, port, use_ssl = service_utils._get_api_server()
     self.assertEqual(CONF.glance.glance_host, host)
     self.assertEqual(CONF.glance.glance_port, port)
     self.assertEqual(CONF.glance.glance_protocol == 'https', use_ssl)
 def test__get_api_servers_with_host_port(self):
     CONF.set_override('glance_host', 'example.com', 'glance')
     CONF.set_override('glance_port', 42, 'glance')
     CONF.set_override('glance_protocol', 'https', 'glance')
     endpoint = service_utils._get_api_server()
     self.assertEqual('https://example.com:42', endpoint)
 def test__get_api_servers_with_host_port(self):
     CONF.set_override('glance_host', 'example.com', 'glance')
     CONF.set_override('glance_port', 42, 'glance')
     CONF.set_override('glance_protocol', 'https', 'glance')
     endpoint = service_utils._get_api_server()
     self.assertEqual('https://example.com:42', endpoint)