Hi, everybody
A service request has been sent to VMware.
=================================================================
Dear Sir/Madam
I wrote a Perl script to obtain a list of names for Virtual Machine Port Group (also known as Network Labels) from my VMware ESXi server (version 5.1.0, build 799733) as follows:
use strict;
use VMware::VIRuntime;
Opts::parse();
Opts::validate();
Util::connect();
my $host_view = Vim::find_entity_view(view_type => 'HostSystem', filter => {name => 'my_esxi510'}, properties => ['name', 'network']);
$Data::Dumper::Indent = 1;
my $host_networks_ref = $host_view->network;
foreach (@$host_networks_ref) {
my $network_view = Vim::get_view(mo_ref => $_, properties => ['name', 'host', 'vm']);
print Dumper $network_view;
}
Util::disconnect();
I have encountered the following error when running the script above:
>sample.pl
Content-Length header value was wrong, fixed at C:/VMware/vSphereCLI5.5.0/Perl/lib/LWP/Protocol/http.pm line 189.
SOAP Fault:
-----------
Fault string:
Error returned by expat parser: unclosed token
while parsing SOAP body
at line 5, column 3
while parsing SOAP envelope
at line 2, column 3
while parsing HTTP request for method retrieveContents
on object of type vmodl.query.PropertyCollector
at line 1, column 0
Fault detail: InvalidRequestFault
I did some research and it seemed that LWP::Protocol::http could not correctly compare a length for the content of HTTP request with the one defined in ‘Content-Length‘ property when involving an UTF-8 character, because the length() function doesn't deals in physical bytes.
Details
use bytes;
Here we have some questions regarding multi-byte characters.
Any helpful hints and tips are appreciated.
Sincerely,
lee
=================================================================
And the response from VMware has been received as following:
================================================
Thank you for your patience. As per details provided in the problem description, we have logged an internal bug and escalated your request.
It is now assigned to sustaining engineering for resolution. Once we have an update from them, we will communicate the information to you.
Resolution times will vary depending on severity of issue and other factors. We will wait on this case until we receive updates from sustaining engineering.
Please let me know if you have any other concerns.
Case Reported:[NRI] Getting an error "Content-Length header value was wrong"
Status: Waiting on Engineering
================================================
luger_lee,
I did a quick test, but I used the new vSphere Perl SDK 5.5 against a vSphere 5.1 environment. I renamed a distributed virtual port group and a standard port group using the unicode string name you provided in your first post ("HaNetwork-\x{4eee}\x{60f3}\x{30de}\x{30b7}\x{30f3} \x{30cd}\x{30c3}\x{30c8}\x{30ef}\x{30fc}\x{30af}"). This is Kanji right? I haven't done i8n work in ages, so forgive my ignorance there but the string did enter and display correctly into the vSphere client.
In any event, I ran your script (with a small modification, just Dumped the name property) and it ran successfully. This was on Windows 2008 with the vCLI installation of the Perl SDK. Of course, the names displayed in the console was in the unicode encoding format.
Since you should have few issues backwards compat wise from 5.5 to 5.0/5.1, perhaps try a fresh install of vCLI 5.5. It might have a different library version of LWP. I confirmed my vSphere client version is the same as yours (build 786111).
However, I do notice that the SDK does use the content call of the request response, not decoded_content, which is usually better for encoded data (such as unicode). Just can't seem to get the same error with the versions I have.