I am using VMware API to perform vCenter operation. Used suds to make SDK call. My vCenter is configure for Non English (Japanese) support.
import suds
client = suds.client.Client("http://localhost/sdk/vimService.wsdl", location="https://localhost/sdk")
mo = suds.sudsobject.Property("ServiceInstance")
mo._type = "ServiceInstance"
service_content = client.service.RetrieveServiceContent(mo)
try:
client.service.Login(service_content.sessionManager, username='test', password='test', locale='en_US')
var = client.factory.create('ns0:WaitOptions')
kwargs = {'maxWaitSeconds': "2", 'maxObjectUpdates': "3"}
[setattr(var, key, value) for key, value in kwargs.items()]
client.service.WaitForUpdatesEx(service_content.propertyCollector, version=1, options=var)
except suds.WebFault as e:
print e.args
If I will not set locale
, then is there any error occur in vCenter, it will return you in Non English text. I set locale
and exception will be return in English language.
We set a locale
and its working fine with session
created but if is there any error in Session creation or session is timed out, then it gives error in Non English form.
Please check this code (Call method without create session
)
...
...
mo._type = "ServiceInstance"
service_content = client.service.RetrieveServiceContent(mo)
try:
var = client.factory.create('ns0:WaitOptions')
kwargs = {'maxWaitSeconds': "2", 'maxObjectUpdates': "3"}
[setattr(var, key, value) for key, value in kwargs.items()]
client.service.WaitForUpdatesEx(service_content.propertyCollector, version=1, options=var)
except suds.WebFault as e:
print e.args
Output :
(u"Server raised fault: '\u30bb\u30c3\u30b7\u30e7\u30f3\u304c\u8a8d\u8a3c\u3055\u308c\u3066\u3044\u307e\u305b\u3093\u3002'",)
Translation :
(u"Server raised fault: 'セッションが認証されていません。'",)
# English
(u"Server raised fault: 'Session is not authenticated.',)
Is there any way to set locale
in wsdl url like http://localhost/sdk/vimService.wsdl?local=en_US
?