Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Bug Reference & Branch

CLOUDSTACK-....

...

template-upload branch off master

Introduction

To register a Cloudstack accepts only urls to add a template/volume. If the user has a downloaded template/upload volume available, one needs he has to host it either on dropbox etc. or run apache server so as to get downloadable url. 

This feature some where as cloudstack only accepts a url. This eliminates that and enables the user to quickly directly upload a the template/volume to cloudstack and eliminates the dependency on an external http server.

use cases

  1. Anyone A user, who wants to quickly upload a template /volume and test cloudstack without having the need to host it.and launch a vm with it on cludstack
  2. A user, who want to upload a volume and attach it to a vm on cloudstack

Design

  1. Management Server generates a unique pre-shared key (PSK) on install and shares it with the SSVM agent. Nobody else has access to this key of course.
  2. New API request "GetUploadParams" encoded the usual CloudStack API way using api keys. Request parameters include format, hypervisor, md5 sum
  3. Management Server response to (b) returns post url to upload the file along with signature generated using PSK and a params json which is to be sent while uploading the file. 
  4. API user makes a POST request over HTTPS to the URL obtained in (c)
  5. The Apache web server on the SSVM matches the url, decrypts and passes on to the SSVM java agent as plain HTTP. The SSVM agent checks the signature against the params using the key PSK1. Once the params are verified, it writes to the NFS storage to the location encoded in the URL. 
  6. Once the upload completes, the MD5 checksum is compared (if available from step c). 

API changes

  1. new API GetUploadParams which takes all the params as the registertemplate/uploadvolume except for URL and  which returns all the required params plus a post URL to be used to uploadVolume/registerTemplate

    1. volume upload api

      Parameter NameDescriptionRequired
      typevolume or template uploadtrue
      formatthe format for the volume. Possible values include QCOW2, OVA, and VHD.true
      namethe name of the volumetrue
      zoneidthe ID of the zone the volume is to be hosted ontrue
      accountan optional accountName. Must be used with domainId.false
      checksumthe MD5 checksum value of this volumefalse
      domainidan optional domainId. If the account parameter is used, domainId must also be used.false
      imagestoreuuidImage store uuidfalse
      projectidUpload volume for the projectfalse
    2. template upload api

       

      Parameter NameDescriptionRequired
      typevolume or template uploadtrue
      displaytextthe display text of the template. This is usually used for display purposes.true
      formatthe format for the template. Possible values include QCOW2, RAW, and VHD.true
      hypervisorthe target hypervisor for the templatetrue
      namethe name of the templatetrue
      ostypeidthe ID of the OS Type that best represents the OS of this template.true
      zoneidthe ID of the zone the template is to be hosted ontrue
      accountan optional accountName. Must be used with domainId.false
      bits32 or 64 bits support. 64 by defaultfalse
      checksumthe MD5 checksum value of this templatefalse
      detailsTemplate details in key/value pairs.false
      domainidan optional domainId. If the account parameter is used, domainId must also be used.false
      isdynamicallyscalabletrue if template contains XS/VMWare tools inorder to support dynamic scaling of VM cpu/memoryfalse
      isextractabletrue if the template or its derivatives are extractable; default is falsefalse
      isfeaturedtrue if this template is a featured template, false otherwisefalse
      ispublictrue if the template is available to all accounts; default is truefalse
      isroutingtrue if the template type is routing i.e., if template is used to deploy routerfalse
      passwordenabledtrue if the template supports the password reset feature; default is falsefalse
      projectidRegister template for the projectfalse
      requireshvmtrue if this template requires HVMfalse
      sshkeyenabledtrue if the template supports the sshkey upload feature; default is falsefalse
      templatetagthe tag for this template.false

       

      A sample request and response would look below
      request params: 

      name=lxc1
      displayText=lxc1
      zoneid=-1
      format=TAR
      isextractable=false
      passwordEnabled=false
      isdynamicallyscalable=false
      osTypeId=1b510c30-3352-11e4-aaca-a5c7f57670d0
      hypervisor=LXC
      requireshvm=false


      response params: { "postURL":"https://ssvmpublicip/upload/key",params:{"store":{"com.cloud.agent.api.to.NfsTO":"nfs://10.147.28.7/export/home/rajani/lxc/secondary"}, "hvm":false,"description":"lxc1","maxDownloadSizeInBytes":53687091200,"id":207,"resourceType":"TEMPLATE","installPath":"template/tmpl/2/207", "format":"TAR","accountId":2,"name":"207-2-09c78adc-065f-3dc8-9621-9e7a036d7dc9"}}

      key in the postURL would be generated using PSK initially shared between agent and Management Server.

  2. POST url to post the data on to SSVM. url: https://ssvmpublicip/upload/key params: params returned from previous call file: file to upload
    response: 200 OK on successful upload, 401 Authorization error, 500 internal server incase the file upload fails.
    • At any point while this post is active, the api user should be able to call the listtemplates/listvolumes api to get the upload status of it

...