Closed rpaloni closed 3 years ago
Thanks a lot! I was experiencing the same problem when using New-HVPool. After I installed version 12.0 from the ZIP file, all the errors went away. Thank you!
A new parameter filterIncompatibleVms has been added to BaseImageVm_List in version 7.13 of the VMware View API (which is bundled with Powercli 12.1) See BaseImageVm_List documentation
@mlapeyre What does that mean for this issue? I'm just poking around here, but are you suggesting that L7380 should be changed from
$parentList = $baseimage_helper.BaseImageVm_List($services,$vcID)
to
$parentList = $baseimage_helper.BaseImageVm_List($services,$vcID,$null)
The phrasing of "Optional parameter. If not specifing any value, this should be set to null." is a really weird definition of "optional" if you ask me. It does seem like it would break for Horizon < 7.13 if that's simply added as is, too.
I've confirmed that changing that line fixes my problem in a local copy. I think a lot of other places would need that fix, but I'm not sure how to protect against Horizon <7.13 or I'd submit a PR for it. If someone can help describe how to solve for both trains, I'll be happy to work it up.
Same here, i don't know how to handle differents versions of the same methods in an elegant way. :confused: The best way would be probably to maintain several version linked to the major powercli version, but it's a big work/change and it would make maintenance harder.
I too have this issue when calling New-HVPool
. The function Get-HVPoolProvisioningData
calls BaseImageVm_List
with two arguments. I have worked around it by creating a function to return the build number:
function Get-HVServerBuild {
foreach ($cs in $services.ConnectionServer.ConnectionServer_List()) {
if ($cs.general.fqhn -eq $hvServer.name) {
return ($cs.general.version -split '-')[1]
}
}
return 0
}
Then checking the build at the point of the call
if ((Get-HVServerBuild) -lt 16962788) {
$parentList = $base_imageVm_helper.BaseImageVm_List($services,$vcID)
} else {
$parentList = $base_imageVm_helper.BaseImageVm_List($services,$vcID,$null)
}
I think we can call that early and put it into a $script variable and reference it, rather than call it every single time. Thank you for doing that, I’ll see if I can find some time this week to mock that up if you don’t mind (don’t want to steal anyone’s thunder) -- Rob Nelson
Under the assumption that other services will also end up being extended with these option parameters we could update Get-ViewAPIService
to return the build number as well.
Most calls to BaseImageVm_List
follow the same pattern of these two lines:
$BaseImage_service_helper = New-Object VMware.Hv.BaseImageVmService
$parentList = $BaseImage_service_helper.BaseImageVm_List($services, $vcID)
We could wrap up the version check into a single function which just returns the parent list to avoid repeating the code throughout.
function Get-HVBaseImageVmList {
param(
[Parameter(Mandatory = $true)]
$vcID
)
$BaseImage_service_helper = New-Object VMware.Hv.BaseImageVmService
if ($hvBuild -lt 16962788) {
return $BaseImage_service_helper.BaseImageVm_List($services, $vcID)
} else {
return $BaseImage_service_helper.BaseImageVm_List($services, $vcID, $null)
}
}
I have created a pull request - although I'm not wedded to it - see what you think.
Annoyingly it has added this to PR #424 which I already had open for some Syslog functions.
Hello, i think checking the connection server for choosing the method to call is not a good idea: It's possible to use an old Powercli view version (where the command with the extra parameter doesn't exist) new with a more recent Connection Server
I am may be wrong but I think the check should be performed using the client powercli view version (using Get-Module ?) and not the Connection server version.
Yes, you're absolutely right. Weirdly the code does work on my old test machine but only because .general.fqhn
doesn't exist so Get-HVServerBuild
returns 0. Easy enough to update: how about check for module VMware.VimAutomation.HorizonView
less than 12.2.
I've incorporated the Get-Module check rather than the Connection Server version. See what you think...
PR #428 looks really good to me!
My Dev Enviroments:
Installed PowerCLI with PSGallery Repository: ModuleType Version Name ExportedCommands
Manifest 12.1.0.17009493 VMware.PowerCLI
Install "VMware.Hv.Helper" from Zip File Get from here.
With these combination I get the error in Topic.
If I Install PowerCLI 12.0.0.15947286 from PSGallery, I get also some module 12.1 versione and it give me the error.
If I Install PowerCLI 12.0.0.15947286 from ZIP File all modules are 12.0 version and no error was present.