shwstppr opened a new pull request #3731: [WIP DO NOT MERGE] Enable Direct 
Download for System VMs
URL: https://github.com/apache/cloudstack/pull/3731
 
 
   ## Description
   For registering templates, the direct download feature does not include 
support for system VMs. Administrators can register new system VM templates 
with the direct download flag, however this flag is not honoured, and it is not 
possible to bypass secondary storage when creating/recreating system VMs. 
Changes in this PR modifies this behaviour and enables direct download support 
for system VM templates.
   
   ![Screenshot from 2019-12-23 
16-39-35](https://user-images.githubusercontent.com/153340/71355262-7b329c00-25a4-11ea-8d40-0d87cfab2b84.png)
   ![Screenshot from 2019-12-23 
16-50-18](https://user-images.githubusercontent.com/153340/71355263-7e2d8c80-25a4-11ea-8418-8339f3f37711.png)
   ![Screenshot from 2019-12-23 
16-50-38](https://user-images.githubusercontent.com/153340/71355266-7ff75000-25a4-11ea-80c4-5748b2f268eb.png)
   
   
   ## Types of changes
   <!--- What types of changes does your code introduce? Put an `x` in all the 
boxes that apply: -->
   - [ ] Breaking change (fix or feature that would cause existing 
functionality to change)
   - [ ] New feature (non-breaking change which adds functionality)
   - [ ] Bug fix (non-breaking change which fixes an issue)
   - [x] Enhancement (improves an existing feature and functionality)
   - [ ] Cleanup (Code refactoring and cleanup, that may add test cases)
   
   ## Screenshots (if appropriate):
   
   ## How Has This Been Tested?
   <!-- Please describe in detail how you tested your changes. -->
   <!-- Include details of your testing environment, and the tests you ran to 
-->
   <!-- see how your change affects other areas of the code, etc. -->
   Using API (with CMK) and UI
   ```
   > register template name=DD-Template displaytext=DD-Template 
url=http://172.20.0.1/files/systemvmtemplate-4.11.3-kvm.qcow2.bz2 
zoneids=87b2b96c-101c-4d3a-8966-3655956454ff format=QCOW2 isextractable=false 
passwordEnabled=false isdynamicallyscalable=false 
ostypeid=dbfbbd3a-2568-11ea-8be3-645d8651f45a hypervisor=KVM system=true 
activate=true requireshvm=true details[0].rootDiskController=osdefault 
directdownload=true
   {
     "count": 1,
     "template": [
       {
         "account": "admin",
         "bits": 0,
         "created": "2019-12-23T17:04:05+0530",
         "crossZones": true,
         "details": {
           "rootDiskController": "osdefault"
         },
         "directdownload": true,
         "displaytext": "DD-Template",
         "domain": "ROOT",
         "domainid": "dc0604c5-2568-11ea-8be3-645d8651f45a",
         "format": "QCOW2",
         "hypervisor": "KVM",
         "id": "255ca321-be38-4312-9292-3d47757a2027",
         "isdynamicallyscalable": false,
         "isextractable": false,
         "isfeatured": false,
         "ispublic": false,
         "isready": true,
         "name": "DD-Template",
         "ostypeid": "dbfbbd3a-2568-11ea-8be3-645d8651f45a",
         "ostypename": "Debian GNU/Linux 5.0 (64-bit)",
         "passwordenabled": false,
         "requireshvm": false,
         "size": 302213425,
         "sshkeyenabled": false,
         "state": "Inactive",
         "status": "Bypassed Secondary Storage",
         "tags": [],
         "templatetype": "SYSTEM",
         "zoneid": "87b2b96c-101c-4d3a-8966-3655956454ff",
         "zonename": "KVM-advzone1"
       }
     ]
   }
   
   ```
   
   Database,
   ```
   mysql> SELECT * FROM cloud.vm_template WHERE 
uuid='255ca321-be38-4312-9292-3d47757a2027'\G
   *************************** 1. row ***************************
                      id: 204
             unique_name: routing-204
                    name: DD-Template
                    uuid: 255ca321-be38-4312-9292-3d47757a2027
                  public: 0
                featured: 0
                    type: SYSTEM
                     hvm: 0
                    bits: 64
                     url: 
http://172.20.0.1/files/systemvmtemplate-4.11.3-kvm.qcow2.bz2
                  format: QCOW2
                 created: 2019-12-23 11:34:05
                 removed: NULL
              account_id: 2
                checksum: NULL
            display_text: DD-Template
         enable_password: 0
           enable_sshkey: 0
             guest_os_id: 15
                bootable: 1
             prepopulate: 0
             cross_zones: 1
             extractable: 0
         hypervisor_type: KVM
      source_template_id: NULL
            template_tag: NULL
                sort_key: 0
                    size: 302213425
                   state: Inactive
            update_count: 0
                 updated: NULL
    dynamically_scalable: 0
      parent_template_id: NULL
         direct_download: 1
   activate_after_upload: 1
   ```
   ```
   mysql> SELECT * FROM cloud.template_store_ref WHERE template_id=(SELECT id 
FROM cloud.vm_template WHERE uuid='255ca321-be38-4312-9292-3d47757a2027')\G;
   *************************** 1. row ***************************
                     id: 10
               store_id: NULL
            template_id: 204
                created: 2019-12-23 11:34:05
           last_updated: NULL
                 job_id: NULL
           download_pct: 0
                   size: 302213425
             store_role: Image
          physical_size: 0
         download_state: BYPASSED
              error_str: NULL
             local_path: NULL
           install_path: NULL
                    url: NULL
                  state: Ready
              destroyed: 0
                is_copy: 0
           update_count: 0
                ref_cnt: 0
                updated: NULL
   download_url_created: NULL
           download_url: NULL
   ```
   ```
   mysql> SELECT * FROM cloud.template_spool_ref WHERE template_id=(SELECT id 
FROM cloud.vm_template WHERE uuid='255ca321-be38-4312-9292-3d47757a2027')\G;
   *************************** 1. row ***************************
               id: 4
          pool_id: 1
      template_id: 204
          created: 2019-12-23 11:41:04
     last_updated: NULL
           job_id: NULL
     download_pct: 100
   download_state: DOWNLOADED
        error_str: NULL
       local_path: 6ae40263-9cb1-483c-a302-82d0805c8517
     install_path: 6ae40263-9cb1-483c-a302-82d0805c8517
    template_size: 297232
    marked_for_gc: 0
            state: Ready
     update_count: 0
          updated: NULL
   
   ```
   
   <!-- Please read the 
[CONTRIBUTING](https://github.com/apache/cloudstack/blob/master/CONTRIBUTING.md)
 document -->
   

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to