Some progress today..
Setup grab some of the needed objects.
$copyme = get-civmtemplate -catalog "Origin" -name centos7 $targetCatalog = get-catalog -name "RELEASE" $targetCatalogId = $targetCatalog.id $targetCatalogCiview = get-ciview -id $targetCatalogId $catalogEd = $targetCatalog.ExtensionData
Build out what I think is needed as a new object to pass to the copy function.
$sourceVapp = New-Object VMware.VimAutomation.Cloud.Views.Task $sourceVapp.id = $copyme.id $sourceVapp.name = "centTest" $sourceVapp.description = "test clone"
First stab at building the actual command to copy the template.
Exception calling "Copy_Task" with "1" argument(s): "Bad request - Bad request - Error on line 1 of document : Premature end of file. Nested exception: Premature end of file." At line:1 char:1 + $catalogEd.copy_task($sourceVapp) + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : NotSpecified: (:) , MethodInvocationException + FullyQualifiedErrorId : CloudException
What is the deal with methods that say "void" in front of them? Assuming not to use those ones?
Copy Method void Copy(VMware.VimAutomation.Cloud.Views.Reference source, string name, string description)
Ok looks like I'm not building the correct objects to pass.
Here is the copy_task method I'm attempting to use.
Copy_Task Method VMware.VimAutomation.Cloud.Views.Task Copy_Task(VMware.VimAutomation.Cloud.Views.Reference source, string name, string description), VMware.VimAutomation.Cloud.Views.Task Copy_Task(VMware.VimAutomation.Cloud.Views.CopyOrMoveCatalogItemParams copyOrMoveCatalogItemParams)
What is the deal with multiple descriptions on this line?
Which object needs to be passed to copy_task()?
The void in front means these methods do not return anything.
The multiple descriptions mean that you can call the method with different numbers/types of parameters.Blog: http://lucd.info | Twitter: @LucD22 | PowerCLI Reference co-author: http://tinyurl.com/hkn4glz
Ok I got it sorted out finally..
Tip one use search-cloud to find the specific object types you need. Also if you're not seeing some objects add "admin" in front of the query type. The other thing was this VMware.VimAutomation.Cloud.Views.CopyOrMoveCatalogItemParams object. Getting that built with the correct values is key. Here is what ended up working for me.
$copyme = search-cloud -querytype admincatalogitem -name centos7 -Filter 'CatalogName==Origin' $targetCatalog = search-cloud -querytype admincatalog -name "RELEASE" $catalogEd = (get-catalog $targetCatalog).ExtensionData $copyParms = New-Object VMware.VimAutomation.Cloud.Views.CopyOrMoveCatalogItemParams $copyParms.source = $copyme.id $copyParms.name = "centos7" $catalogEd.copy_task($copyParms)