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:
Vipin Balachandran 2019-05-13 15:56:25 -07:00
parent 95d849ebe7
commit 42d240a2eb
2 changed files with 5 additions and 4 deletions

View File

@ -243,7 +243,8 @@ class VMwareAPISession(object):
LOG.debug("Logging into host: %s.", self._host)
session = self.vim.Login(session_manager,
userName=self._server_username,
password=self._server_password)
password=self._server_password,
locale='en')
self._session_id = session.key
# We need to save the username in the session since we may need it
# later to check active session. The SessionIsActive method requires

View File

@ -173,7 +173,7 @@ class VMwareAPISessionTest(base.TestCase):
session_manager = vim_obj.service_content.sessionManager
vim_obj.Login.assert_called_once_with(
session_manager, userName=VMwareAPISessionTest.USERNAME,
password=VMwareAPISessionTest.PASSWORD)
password=VMwareAPISessionTest.PASSWORD, locale='en')
self.assertFalse(vim_obj.TerminateSession.called)
self.assertEqual(session.key, api_session._session_id)
pbm.set_soap_cookie.assert_called_once_with(cookie)
@ -197,7 +197,7 @@ class VMwareAPISessionTest(base.TestCase):
userName=VMwareAPISessionTest.USERNAME)
vim_obj.Login.assert_called_once_with(
session_manager, userName=VMwareAPISessionTest.USERNAME,
password=VMwareAPISessionTest.PASSWORD)
password=VMwareAPISessionTest.PASSWORD, locale='en')
self.assertEqual(new_session_key, api_session._session_id)
def test_create_session_with_existing_active_session(self):
@ -257,7 +257,7 @@ class VMwareAPISessionTest(base.TestCase):
session_manager = vim_obj.service_content.sessionManager
vim_obj.Login.assert_called_once_with(
session_manager, userName=VMwareAPISessionTest.USERNAME,
password=VMwareAPISessionTest.PASSWORD)
password=VMwareAPISessionTest.PASSWORD, locale='en')
api_session.logout()
vim_obj.Logout.assert_called_once_with(
session_manager)