Set locale to english
oslo.vmware library does not need to emit localized messages from vCenter. Explicitly setting the locale to 'en' during session establishment to avoid UnicodeDecodeError while handling non- english vCenter messages. Change-Id: Ifb26a7832c15af3ed3227c94131fe0b22579e889
This commit is contained in:
parent
95d849ebe7
commit
42d240a2eb
@ -243,7 +243,8 @@ class VMwareAPISession(object):
|
|||||||
LOG.debug("Logging into host: %s.", self._host)
|
LOG.debug("Logging into host: %s.", self._host)
|
||||||
session = self.vim.Login(session_manager,
|
session = self.vim.Login(session_manager,
|
||||||
userName=self._server_username,
|
userName=self._server_username,
|
||||||
password=self._server_password)
|
password=self._server_password,
|
||||||
|
locale='en')
|
||||||
self._session_id = session.key
|
self._session_id = session.key
|
||||||
# We need to save the username in the session since we may need it
|
# We need to save the username in the session since we may need it
|
||||||
# later to check active session. The SessionIsActive method requires
|
# later to check active session. The SessionIsActive method requires
|
||||||
|
@ -173,7 +173,7 @@ class VMwareAPISessionTest(base.TestCase):
|
|||||||
session_manager = vim_obj.service_content.sessionManager
|
session_manager = vim_obj.service_content.sessionManager
|
||||||
vim_obj.Login.assert_called_once_with(
|
vim_obj.Login.assert_called_once_with(
|
||||||
session_manager, userName=VMwareAPISessionTest.USERNAME,
|
session_manager, userName=VMwareAPISessionTest.USERNAME,
|
||||||
password=VMwareAPISessionTest.PASSWORD)
|
password=VMwareAPISessionTest.PASSWORD, locale='en')
|
||||||
self.assertFalse(vim_obj.TerminateSession.called)
|
self.assertFalse(vim_obj.TerminateSession.called)
|
||||||
self.assertEqual(session.key, api_session._session_id)
|
self.assertEqual(session.key, api_session._session_id)
|
||||||
pbm.set_soap_cookie.assert_called_once_with(cookie)
|
pbm.set_soap_cookie.assert_called_once_with(cookie)
|
||||||
@ -197,7 +197,7 @@ class VMwareAPISessionTest(base.TestCase):
|
|||||||
userName=VMwareAPISessionTest.USERNAME)
|
userName=VMwareAPISessionTest.USERNAME)
|
||||||
vim_obj.Login.assert_called_once_with(
|
vim_obj.Login.assert_called_once_with(
|
||||||
session_manager, userName=VMwareAPISessionTest.USERNAME,
|
session_manager, userName=VMwareAPISessionTest.USERNAME,
|
||||||
password=VMwareAPISessionTest.PASSWORD)
|
password=VMwareAPISessionTest.PASSWORD, locale='en')
|
||||||
self.assertEqual(new_session_key, api_session._session_id)
|
self.assertEqual(new_session_key, api_session._session_id)
|
||||||
|
|
||||||
def test_create_session_with_existing_active_session(self):
|
def test_create_session_with_existing_active_session(self):
|
||||||
@ -257,7 +257,7 @@ class VMwareAPISessionTest(base.TestCase):
|
|||||||
session_manager = vim_obj.service_content.sessionManager
|
session_manager = vim_obj.service_content.sessionManager
|
||||||
vim_obj.Login.assert_called_once_with(
|
vim_obj.Login.assert_called_once_with(
|
||||||
session_manager, userName=VMwareAPISessionTest.USERNAME,
|
session_manager, userName=VMwareAPISessionTest.USERNAME,
|
||||||
password=VMwareAPISessionTest.PASSWORD)
|
password=VMwareAPISessionTest.PASSWORD, locale='en')
|
||||||
api_session.logout()
|
api_session.logout()
|
||||||
vim_obj.Logout.assert_called_once_with(
|
vim_obj.Logout.assert_called_once_with(
|
||||||
session_manager)
|
session_manager)
|
||||||
|
Loading…
Reference in New Issue
Block a user