VMware vSphere

 View Only
  • 1.  REST override or delete library item

    Posted Apr 15, 2019 06:31 AM

    Hi,

    currently I'am testing around with the vSphere REST API in my evaluation trial.

    I try to automatically create a template of an existing VM and then deploy a clone of this template on a weekly basis.

    Creating this template and deploying is straight forward with the REST API. However, deleting an existing template, or at least overriding it, didn't work so far.

    So the question is:

    Is there a way of either override an existing template OR delete an exisitng template via the REST API?

    I used the following REST calls:

    For creating (POST): /vcenter/vm-template/library-items​

    For deploy (POST): /vcenter/vm-template/library-items​/{item}?action=deploy

    I would appreciate any support.

    BR



  • 2.  RE: REST override or delete library item

    Broadcom Employee
    Posted Apr 25, 2019 10:02 AM

    It seems this is a library item you are dealing with.

    why don't you try :

    DELETE https://{server}/rest/com/vmware/content/library/item/id:{library_item_id}

    See REST API - delete



  • 3.  RE: REST override or delete library item

    Posted Oct 10, 2024 07:21 PM

    Do you mind sharing what the JSON body looks like to clone a VM to OVF in the content library?  I'm struggling to get it right.  This is what I've attempted, but guessing I'm not specifying one of the values corrctly.

    {
        "create_spec": {
            "description": "vratst01 test template",
            "flags": [ "" ],
            "name": "vratst02"
        },
        "source":{
            "id": "vm-<removed>",
            "type": "vc:virtualmachine" also VM, vm virtual machine, virtualmachine vcvirtualmachine
        },
        "target":{
            "library_id": "<lib id removed>"
        }
    }



    ------------------------------
    vixold
    ------------------------------