stumpr's Posts

Possible condition below.  There was a bug in 5.1 I think as well, I'd have to dig up the KB. Unmounting or Removing Datastore Fails When you try to unmount or remove a datastore, the... See more...
Possible condition below.  There was a bug in 5.1 I think as well, I'd have to dig up the KB. Unmounting or Removing Datastore Fails When you try to unmount or remove a datastore, the operation fails. Problem The operation to unmount or remove a datastore fails if the datastore has any opened files. For these user operations, the vSphere HA agent closes all of the files that it has opened, for example, heartbeat files. If the agent is not reachable by vCenter Server or the agent cannot flush out pending I/Os to close the files, a The HA agent on host '{hostName}' failed to quiesce file activity on datastore '{dsName} fault is triggered. Cause If the datastore to be unmounted or removed is used for heartbeating, vCenter Server excludes it from heartbeating and chooses a new one. However, the agent does not receive the updated heartbeat datastores if it is not reachable, that is, if the host is isolated or in a network partition. In such cases, heartbeat files are not closed and the user operation fails. The operation can also fail if the datastore is not accessible because of storage failures such as all paths down. Note When you remove a VMFS datastore, the datastore is removed from all the hosts in inventory. So if there are any hosts in a vSphere HA cluster that are unreachable or that cannot access the datastore, the operation fails. Solution Ensure that the datastore is accessible and the affected hosts are reachable.
So I think the problem is the ComplexType object doesn't encode_utf8 like it does for SimpleTypes.  It gets to the property with characters that should be encoded and doesn't. You can sort of... See more...
So I think the problem is the ComplexType object doesn't encode_utf8 like it does for SimpleTypes.  It gets to the property with characters that should be encoded and doesn't. You can sort of force it yourself.  I have an example below using Rename_Task().  Should be the same issue in your CreateVM_Task() call.  If you're using someone else's script, you'll probably have to wrap the potential french accent characters in encode_utf8.  You could patch up VICommon.pm.  If that's something you think you need to do, let me know.  Should be able to just do it for the 'string-like' properties during serialization. You will probably get a warning message from LWP about the content header length (I did).  I'm guessing there's something in the HTTP header content-length calculation missing in the VICommon.pm as well. $ perl test.pl --username=administrator --password=* --server=172.16.2.10 --oldvmname=test --newvmname=fenêtres Content-Length header value was wrong, fixed at /Library/Perl/5.18/LWP/Protocol/http.pm line 190. # VM was renamed to 'fenêtres' in the vSphere Client UI #!/usr/bin/perl # Created by Reuben Stump (http://www.virtuin.com) use strict; use warnings; use VMware::VIRuntime; use Encode qw(encode_utf8); my %opts = (   oldvmname => {   type => "=s",   required => 1,   },   newvmname => {   type => "=s",   required => 1,   }, ); Opts::add_options(%opts); Opts::parse(); Opts::validate(); Util::connect(); my ($old_name, $new_name, $vm); $old_name = Opts::get_option('oldvmname'); $new_name = encode_utf8(Opts::get_option('newvmname')); $vm = Vim::find_entity_view(   view_type => 'VirtualMachine',   properties => ['name'],   filter => { 'name' => $old_name } ); die "Failed to find vm '$old_name'" unless $vm; # Rename VM $vm->Rename(newName => $new_name);
You'll actually have to get into the new vSphere 6.0 vCloud Suite SDK for REST (VMware vCloud Suite SDK for REST for vSphere 6.0 - VMware Developer Center). Prior to vSphere 6.0, you probably ... See more...
You'll actually have to get into the new vSphere 6.0 vCloud Suite SDK for REST (VMware vCloud Suite SDK for REST for vSphere 6.0 - VMware Developer Center). Prior to vSphere 6.0, you probably need to look at the PowerCLI commands.  There's an internal API that's used against the inventory service in 5.x.  I did some packet captures can you can probably replicate the call (mix of xpath + SOAP).  But didn't seem worth the effort.
Have you tried it with a full VMware Admin account?  Definitely looks like a permission issue.
VMware-vSphere-Perl-SDK-5.5.0-1384587 broken with perl 5.20 Take a look at that thread, might be helpful.
I don't think it will be useful.  It's basically summarizing the Network object (VSS PG); not the HostSystem SSH daemon.  The accessible flag there is just saying "at least one host is attached t... See more...
I don't think it will be useful.  It's basically summarizing the Network object (VSS PG); not the HostSystem SSH daemon.  The accessible flag there is just saying "at least one host is attached to this network". I believe if connectionState indicates the host is unavailable, that means you lost connection to the management agent on the ESXi host, and all the data in the API is probably old (defunct). I think if your target is SSH, I would do port scan to 22 or an openssl handshake (pick your fav script language or tool) to validate it's up.  Assuming the host has connectivity to the vSphere system (connectionState ok), then you could also review the SSHD service configuration from the API, verify it's running and also check the lockdown mode flags (which disable SSH).  But assuming your port 22 or ssl handshake is failing, that information is more about why vs "is it working".
You might want to use runtime.connectionState.  This will tell you that the host is reachable by vCenter. Ping would be another way, though that won't tell you if SSH is running.  You might wa... See more...
You might want to use runtime.connectionState.  This will tell you that the host is reachable by vCenter. Ping would be another way, though that won't tell you if SSH is running.  You might want to script a basic SSL handshake process against the hosts (perhaps ping or check runtime.connectionState first to save on some overhead).  You could also monitor the SSHD service settings through vCenter (or the Host API).  If it's running and the firewall port for SSHD is open, you're probably safe to say SSH is available.  Or a simple port scan as well (restricted to TCP:22). I've done the port scan (nmap) process in the past and it's generally worked out as a reliable way to validate SSH is enabled, running and accessible on ESXi.
Yeah, afraid of that.  You'll have to use WinRM or WMI to remote execute the tools installer.  Or bake it into the Windows templates.
I think you forgot the installerOptions named parameter: $target_vm->UpgradeTools_Task(installerOptions => qq|/S /v "/qn REBOOT=R ADDLOCAL=ALL REMOVE=Hgfs"|);
Yes, so GuestOps lets you run scripts or progams in the GuestOS through the VMware Tools channel.  However, since you are trying to install VMware Tools, that's not an option In terms of au... See more...
Yes, so GuestOps lets you run scripts or progams in the GuestOS through the VMware Tools channel.  However, since you are trying to install VMware Tools, that's not an option In terms of automating the VMware Tools install, you can get more information from the vSphere 5 documentation.  There's an option for unattended installation of VMware tools in vCenter. vSphere Documentation Center Sorry, missed the original question.  For API invocation, I haven't tried it, but UpgradeTools_Task() may be the solution.  You'll see the installerOptions property, which is just a string command line argument.  So I would guess despite the name it will also invoke the base setup.exe (and do an install).  Never tried it myself though.  I found a reference to using it with PowerCLI (which is the same API call) for installation, so once you have your command line arguments correct, should do what you need.
I would pre-fetch the DVS items: my $dv_switches = Vim::find_entity_views(view_type => 'DistributedVirtualSwitch', properties => ['name', 'uuid']); Then, you can look it up by UUID: ... See more...
I would pre-fetch the DVS items: my $dv_switches = Vim::find_entity_views(view_type => 'DistributedVirtualSwitch', properties => ['name', 'uuid']); Then, you can look it up by UUID: ($this_dvs) = grep {$_->{'uuid'} eq $the_uuid} @$dv_switches; This will give you the best performance as well, since you don't have to hit the API for every query (just the efficient first all DVS query).  You can add additional data from the DVSwitch object if you need it in your logic.
You can review the vpxd logs to start.  Might be something indicating the problem there.
You should be able to use the property Datastore.summary.multipleHostAccess. 
If you're using dmidecode, then you need the uuid set.  But, even with the hyphen format, usually dmidecode handles it - uuid.location = "56 4d 1f bc b8 82 0a af-fe c4 2b a6 e7 04 0e a5" ... See more...
If you're using dmidecode, then you need the uuid set.  But, even with the hyphen format, usually dmidecode handles it - uuid.location = "56 4d 1f bc b8 82 0a af-fe c4 2b a6 e7 04 0e a5" dmidecode -t system # dmidecode 2.11 SMBIOS 2.4 present. Handle 0x0001, DMI type 1, 27 bytes System Information   Manufacturer: VMware, Inc.   Product Name: VMware Virtual Platform   Version: None   Serial Number: VMware-56 4d 1f bc b8 82 0a af-fe c4 2b a6 e7 04 0e a5   UUID: 564D1FBC-B882-0AAF-FEC4-2BA6E7040EA5   Wake-up Type: Power Switch   SKU Number: Not Specified   Family: Not Specified Notice the UUID matches the uuid.location.  Have you tried dmidecode -s system-uuid?  That number (with a little character manipulation) should get you results.
That happens, yes.  I meant you can add your own custom UUID field: myCompany.uuid = "..." Then you can access it from the API tooling later.  Is the problem that you are using non-VMware s... See more...
That happens, yes.  I meant you can add your own custom UUID field: myCompany.uuid = "..." Then you can access it from the API tooling later.  Is the problem that you are using non-VMware script tooling to get the UUID from the VM afterwards?
It would be trivial to reformat the UUID without spaces and hyphens via Perl (of if you're using the CLI tools, awk/sed/powercli, etc).  Is there something more complicated with your UUID format ... See more...
It would be trivial to reformat the UUID without spaces and hyphens via Perl (of if you're using the CLI tools, awk/sed/powercli, etc).  Is there something more complicated with your UUID format in your CMDB?  You could also generate your own UUID values with an appropriate library, then add them into the VMX settings of the VirtualMachines during creation time.  Then you'd have UUIDs in the format you prefer.
You can handle that in a few different ways. I usually do something like an eval loop and try to hit the ESXi API (assuming it isn't in lockdown mode). Once the API is up, you can be pretty su... See more...
You can handle that in a few different ways. I usually do something like an eval loop and try to hit the ESXi API (assuming it isn't in lockdown mode). Once the API is up, you can be pretty sure it can be added to vCenter.  Since you'll need the SSL thumbprint of the ESXi host anyway, usually you can just get that from ESXi API endpoint, or the web file service. lamw explains how to do it with openssl here I explain it here I once looked at using the Net::SSLeay library (if you are comfortable with the CTX_* properties from the OpenSSL C lib) to do the thumbprint extract as well. Basically, you'll loop-eval the call to the ESXi web service(s), generate the thumbprint, and add the host to vCenter.  I usually implement a method with a timeout-waitloop for the host reboot (e.g., 10m timeout & 30s retry intervals)
Probably the easiest way is to check the HostSystem's runtime.connectionState. $host = Vim::find_entity_view(view_type => 'HostSystem', properties => ['name', 'runtime.connectionState'], fil... See more...
Probably the easiest way is to check the HostSystem's runtime.connectionState. $host = Vim::find_entity_view(view_type => 'HostSystem', properties => ['name', 'runtime.connectionState'], filter => {'name' => $host_name}); $connected = 0; until ($connected) {      $host->update_view_data();      $connected = $host->{'runtime.connectionState'};      # Add a timeout break here } # ...do something with newly rebooted host I've also used runtime.bootTime in the past, where I wait for the value to be greater than the previous time XSD string recorded before the reboot request (with a long timeout to avoid any problems).  This is better than the connectionState option since it handles the window between the reboot request and the actual reboot.  It *shouldn't* update until the host is connected again (and available for you call to leave maintenanceMode). Using these values works even when the host is not connected (cached by the vCenter API service), so you can wait for them to change (and in the case of connectionState, change again).  You'll just have to account for the window from the request to reboot and the actual reboot before you start polling using connectionState. You can probably drop your ping logic as well if you properly code around the API state variables for the Host.
What does the API report for the Task status?  Maybe it's a GUI client bug?
I know that was a feature request for a future VCSIM, to mirror inventory tree to some degree. I haven't tried this myself, but perhaps you can manipulate the SIM inventory after creation.  So... See more...
I know that was a feature request for a future VCSIM, to mirror inventory tree to some degree. I haven't tried this myself, but perhaps you can manipulate the SIM inventory after creation.  So create enough (or more than) what you have today, then rename/delete/relocate objects to get a like-for-like tree?  I know some functions don't work against the SIM inventory, but I believe you can work with rename...just not sure about creating and destroying.  Need to check it out with my SIM.