Automation

 View Only
  • 1.  How to create Content Library from PowerCLI ?

    Posted Jun 08, 2015 08:10 PM

    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 :smileyhappy:

    Fred Gauvin



  • 2.  RE: How to create Content Library from PowerCLI ?

    Posted Jun 08, 2015 08:57 PM

    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



  • 3.  RE: How to create Content Library from PowerCLI ?

    Posted Jan 18, 2016 07:46 AM

    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-DCBB5D3B5AFE.htmlCreate 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



  • 4.  RE: How to create Content Library from PowerCLI ?

    Posted Mar 09, 2016 08:00 AM

    Try Adding:

    $CreateSpec.publish_info.authentication_method = 'NONE'



  • 5.  RE: How to create Content Library from PowerCLI ?

    Posted Jun 15, 2016 04:33 PM

    So I wrote some functions for content libraries. You can find them here:

    http://poshcode.org/6386

    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.



  • 6.  RE: How to create Content Library from PowerCLI ?

    Posted Nov 14, 2017 02:40 PM

    http://poshcode.org/6386

    Can get a working Link please?



  • 7.  RE: How to create Content Library from PowerCLI ?

    Posted Nov 14, 2017 02:41 PM

    http://poshcode.org/6386

    Can get a working Link please?