You can use the REST API catalog service to change a lease. For actions that require user input, you may need to edit the template prior to submitting the request.

Pourquoi et quand exécuter cette tâche

This command leverages the links for the change lease action from the command used in the Syntax for Navigating to the Children of a Deployed Resource example.

    {
        "@type": "link",
        "rel": "GET Template: {com.vmware.csp.component.iaas.proxy.provider@resource.action.name.machine.ChangeLease}",
        "href": "https://$host/api/consumer/resources/dd37b7a1-829c-4773-b5be-b229453eca4a/actions/b5739e30-871d-48c7-9012-f2a7cf431dc1/requests/template"
    },
    {
        "@type": "link",
        "rel": "POST: {com.vmware.csp.component.iaas.proxy.provider@resource.action.name.machine.ChangeLease}",
        "href": "https://$host/api/consumer/resources/dd37b7a1-829c-4773-b5be-b229453eca4a/actions/b5739e30-871d-48c7-9012-f2a7cf431dc1/requests"
    },

Procédure

  1. Get the template for the resource action request.
    $curl --insecure -s
    			 -H" Content-Type: multipart/form-data" -H "Authorization: Bearer $token" https://$host/catalog-service/api/consumer/resources/dd37b7a1-829c-4773-b5be-b229453eca4a/actions/b5739e30-871d-48c7-9012-f2a7cf431dc1/requests/template

    This example command returns a response.

    HTTP/1.1 200 OK   
    Server: Apache-Coyote/1.1   
    Cache-Control: no-cache, no-store   
    Pragma: no-cache   
    Expires: Sat, 01 August 2015 23:04:50 GMT
    Content-Type: application/json;charset=UTF-8   
    Date: Sat, 01 August 2015 13:04:50 GMT
    {
      "type": "com.vmware.vcac.catalog.domain.request.CatalogResourceRequest",
      "resourceId": "dd37b7a1-829c-4773-b5be-b229453eca4a",
      "actionId": "b5739e30-871d-48c7-9012-f2a7cf431dc1",
      "description": null,
      "data": {
        "provider-ExpirationDate": "2015-07-29T16:44:13.846Z"
      }
    }
    
  2. Edit the template as desired. The template is populated with default values. In this example, the value of provider-ExpirationDate is set to the time at which the template was requested in UTC. Edit this value (for example, to change the expiration to a month from now).
  3. Use a POST command to send the template without modification to the corresponding URI.
    $curl --insecure -s
    			 -H" Content-Type: multipart/form-data" -H "Authorization: Bearer $token" https://$hosts/catalog-service/api/consumer/resources/dd37b7a1-829c-4773-b5be-b229453eca4a/actions/b5739e30-871d-48c7-9012-f2a7cf431dc1/requests
    Accept: application/json
    Content-Type: application/json 
    Authorization: Bearer $token
    {
      "type": "com.vmware.vcac.catalog.domain.request.CatalogResourceRequest",
      "resourceId": "dd37b7a1-829c-4773-b5be-b229453eca4a",
      "actionId": "b5739e30-871d-48c7-9012-f2a7cf431dc1",
      "description": null,
      "data": {
        "provider-ExpirationDate": "2015-08-29T16:44:13.846Z"
      }
    }

Résultats

This POST command returns a response indicating success or failure, such as HTTP/1.1 201 CREATED for success.