Hello,
My Name is Fred and I have a Content Library problem...
I have been looking around for the set of functions in PowerCLI to perform some tasks on VMWare new feature called Content Library.
Basically, what I need to do is automate the following functionnalities :
Library Creation
- Create a new Content Library ( with Name, Notes, Server and DataStore )
- List templates stored in a Content Library
- Clone an existing VM to template in library. ( Clone to template in Library... )
Library Usage
- Create a new VM from a Template in the Content Library. ( New VM from This Template ... )
I can manually perform all those tasks using the vcenter web client, but really need a powershell script to do it as it will be used for autonomous tests.
Thanks in advance for any suggestions other than SOAP, AutoIT and stuff like that
Fred Gauvin
There are currently (powerCLI 6R1) no cmdlets for working with Content Libraries, but you can use the API methods.
See for example Create a Local Content Library on an Existing Datastore
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Dear colleagues!
I tried the examples described in the article on the link above
http://pubs.vmware.com/vsphere-60/topic/com.vmware.powercli.ug.doc/GUID-E2EF7911-7CFD-4541-B638-DCBB...Create a Local Content Library on an Existing Datastore
However, the script execution results in an error. Search Internet resources is not suggested workarounds.
My script is:
$ContentLibrary = Get-CisService com.vmware.content.local_library
$DatastoreID = (Get-Datastore -Name "content-library").extensiondata.moref.value
$CreateSpec = $ContentLibrary.help.create.create_spec.CreateExample()
$CreateSpec.server_guid = $null
$CreateSpec.name = "test Content Library 2"
$CreateSpec.description = "A New sample Content Library from PowerCLI"
$CreateSpec.type = "LOCAL"
$CreateSpec.publish_info.persist_json_enabled = $false
$CreateSpec.publish_info.published = $false
$DatastoreID = [VMware.VimAutomation.Cis.Core.Types.V1.ID]$DatastoreID
$StorageSpec = New-Object PSObject -Property @{
datastore_id = $DatastoreID
type = "DATASTORE"
}
$CreateSpec.storage_backings.Add($StorageSpec)
$UniqueID = [guid]::NewGuid().tostring()
$ContentLibrary.create($UniqueID, $CreateSpec)
The result of the last line - ($ContentLibrary.create($UniqueID, $CreateSpec)):
A server error occurred: 'com.vmware.vapi.std.errors.internal_server_error':
Provider method implementation threw unexpected exception: null (Server error
id: 'vapi.bindings.method.impl.unexpected'). Check
$Error[0].Exception.ServerError for more details.
At line:1 char:1
+ $ContentLibrary.create($UniqueID, $CreateSpec)
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : OperationStopped: (:) [], CisServerException
+ FullyQualifiedErrorId : VMware.VimAutomation.Cis.Core.Types.V1.CisServer
Exception
I would be grateful for your help in solving this problem.
With Best Regards,
AIRRA
Try Adding:
$CreateSpec.publish_info.authentication_method = 'NONE'
So I wrote some functions for content libraries. You can find them here:
It does most of what you asked for.
- Clone an existing VM to template in library. ( Clone to template in Library... )
This has to be done by first exporting the vm as ovf and then importing the ovf to the library.
Library Usage
- Create a new VM from a Template in the Content Library. ( New VM from This Template ... )
This has to be done by first exporting the ovf from the library and then deploying the ovf.
Can get a working Link please?
Can get a working Link please?