Author: arkurth
Date: Fri Apr 5 18:19:58 2013
New Revision: 1465083
URL: http://svn.apache.org/r1465083
Log:
VCL-685
Updated vSphere_SDK.pm::_get_resource_pool_view to check if
vmprofile.resourcepath is not configured and only 1 resource pool was found on
the host. If so, it skips the next step of looping through the resource pools.
This makes it a bit more efficient.
Improved regex in initialize which determines whether the VM host's name is a
full DNS hostname or a short name. Added check to make sure there's is a
letter. This allows the VM hostname to be an IP address. Otherwise it was
truncating the IP address.
Modified:
vcl/trunk/managementnode/lib/VCL/Module/Provisioning/VMware/vSphere_SDK.pm
Modified:
vcl/trunk/managementnode/lib/VCL/Module/Provisioning/VMware/vSphere_SDK.pm
URL:
http://svn.apache.org/viewvc/vcl/trunk/managementnode/lib/VCL/Module/Provisioning/VMware/vSphere_SDK.pm?rev=1465083&r1=1465082&r2=1465083&view=diff
==============================================================================
--- vcl/trunk/managementnode/lib/VCL/Module/Provisioning/VMware/vSphere_SDK.pm
(original)
+++ vcl/trunk/managementnode/lib/VCL/Module/Provisioning/VMware/vSphere_SDK.pm
Fri Apr 5 18:19:58 2013
@@ -131,7 +131,7 @@ sub initialize {
);
# Also add URLs containing the short host name if the VM hostname is a
full DNS name
- if ($vmhost_hostname =~ /\./) {
+ if ($vmhost_hostname =~ /[a-z]\./i) {
my ($vmhost_short_name) = $vmhost_hostname =~ /^([^\.]+)/;
push @possible_vmhost_urls, "https://$vmhost_short_name/sdk";
push @possible_vmhost_urls,
"https://$vmhost_short_name:8333/sdk";
@@ -164,7 +164,7 @@ sub initialize {
last;
}
}
-
+
if (!$vim) {
notify($ERRORS{'DEBUG'}, 0, "failed to connect to VM host
$vmhost_hostname");
return;
@@ -2797,8 +2797,26 @@ sub _get_resource_pool_view {
$resource_pool_path_fixed =~ s/\/Resources($|\/?)/$1/g;
$resource_pools->{$resource_pool_path_fixed} =
$resource_pool_view;
}
- notify($ERRORS{'DEBUG'}, 0, "retrieved resource pools on VM host
$vmhost_name:\n" . join("\n", sort keys %$resource_pools));
+ if (!$resource_pools) {
+ notify($ERRORS{'WARNING'}, 0, "failed to retrieve any resource
pools on host $vmhost_name");
+ return;
+ }
+ elsif (!$vmhost_profile_resource_path) {
+ if (scalar(keys %$resource_pools) > 1) {
+ notify($ERRORS{'WARNING'}, 0, "unable to determine
which resource pool to use, resource path not configured in VM profile and
multiple resource paths exist on host $vmhost_name:\n" . join("\n", sort keys
%$resource_pools));
+ return;
+ }
+ else {
+ my $resource_pool_name = (keys %$resource_pools)[0];
+ $self->{resource_pool_view_object} =
$resource_pools->{$resource_pool_name};
+ notify($ERRORS{'DEBUG'}, 0, "resource path not
configured in VM profile, returning the only resource pool found on VM host
$vmhost_name: $resource_pool_name");
+ return $self->{resource_pool_view_object};
+ }
+ }
+ else {
+ notify($ERRORS{'DEBUG'}, 0, "retrieved resource pools on VM
host $vmhost_name:\n" . join("\n", sort keys %$resource_pools));
+ }
my %potential_matches;
for my $resource_pool_path (sort keys %$resource_pools) {