You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@cloudstack.apache.org by "Sudhansu Sahu (JIRA)" <ji...@apache.org> on 2016/12/01 05:48:58 UTC

[jira] [Commented] (CLOUDSTACK-9637) Template create from snapshot does not populate vm_template_details

    [ https://issues.apache.org/jira/browse/CLOUDSTACK-9637?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15710990#comment-15710990 ] 

Sudhansu Sahu commented on CLOUDSTACK-9637:
-------------------------------------------

TemplateManagerImpl.java

While creating template from snapshot, the template details are copied from user vm details. In the absence of VM, the template details are not populated. 

{noformat}
        privateTemplate = new VMTemplateVO(nextTemplateId, name, ImageFormat.RAW, isPublic, featured, isExtractable,
                TemplateType.USER, null, requiresHvmValue, bitsValue, templateOwner.getId(), null, description,
                passwordEnabledValue, guestOS.getId(), true, hyperType, templateTag, cmd.getDetails(), false, isDynamicScalingEnabled);

        if (sourceTemplateId != null) {
            if (s_logger.isDebugEnabled()) {
                s_logger.debug("This template is getting created from other template, setting source template Id to: " + sourceTemplateId);
            }
        }
        privateTemplate.setSourceTemplateId(sourceTemplateId);

        VMTemplateVO template = _tmpltDao.persist(privateTemplate);
        // Increment the number of templates
        if (template != null) {
            Map<String, String> details = new HashMap<String, String>();
            if (volume != null) {
                Long vmId = volume.getInstanceId();
                if (vmId != null) {
                    UserVmVO userVm = _userVmDao.findById(vmId);
                    if (userVm != null) {
                        _userVmDao.loadDetails(userVm);
                        details.putAll(userVm.getDetails());
                    }
                }
            }
            if (cmd.getDetails() != null) {
                details.remove("Encrypted.Password"); // new password will be generated during vm deployment from password enabled template
                details.putAll(cmd.getDetails());
            }
            if (!details.isEmpty()) {
                privateTemplate.setDetails(details);
                _tmpltDao.saveDetails(privateTemplate);
            }

            _resourceLimitMgr.incrementResourceCount(templateOwner.getId(), ResourceType.template);
            _resourceLimitMgr.incrementResourceCount(templateOwner.getId(), ResourceType.secondary_storage,
                    new Long(volume != null ? volume.getSize() : snapshot.getSize()));
        }

{noformat}

Solution:
if details is empty then copy template details from parent template.

> Template create from snapshot does not populate vm_template_details
> -------------------------------------------------------------------
>
>                 Key: CLOUDSTACK-9637
>                 URL: https://issues.apache.org/jira/browse/CLOUDSTACK-9637
>             Project: CloudStack
>          Issue Type: Bug
>      Security Level: Public(Anyone can view this level - this is the default.) 
>          Components: Management Server
>    Affects Versions: 4.8.0
>         Environment:  VMware ESX , CS 4.8.0
>            Reporter: Sudhansu Sahu
>            Assignee: Sudhansu Sahu
>
> ISSUE
> ============
> Template create from snapshot does not populate vm_template_details
> TROUBLESHOOTING
> ==================
> {noformat}
> mysql> select id,name,uuid,instance_name,vm_template_id from vm_instance where uuid='453313f5-ef97-461a-94f5-0838617fe826'
>     -> ;
> +----+-------+--------------------------------------+---------------+----------------+
> | id | name  | uuid                                 | instance_name | vm_template_id |
> +----+-------+--------------------------------------+---------------+----------------+
> |  9 | vm001 | 453313f5-ef97-461a-94f5-0838617fe826 | i-2-9-VM      |            202 |
> +----+-------+--------------------------------------+---------------+----------------+
> 1 row in set (0.00 sec)
> mysql> select id,name,source_template_id from vm_template where id=202; 
> +-----+--------+--------------------+
> | id  | name   | source_template_id |
> +-----+--------+--------------------+
> | 202 | Debian |               NULL |
> +-----+--------+--------------------+
> 1 row in set (0.00 sec)
> mysql> select * from vm_template_details where template_id=202; 
> +----+-------------+--------------------+-------+---------+
> | id | template_id | name               | value | display |
> +----+-------------+--------------------+-------+---------+
> |  1 |         202 | keyboard           | us    |       1 |
> |  2 |         202 | nicAdapter         | E1000 |       1 |
> |  3 |         202 | rootDiskController | scsi  |       1 |
> +----+-------------+--------------------+-------+---------+
> 3 rows in set (0.00 sec)
> mysql> select id,name,source_template_id from vm_template where source_template_id=202;
> +-----+----------------+--------------------+
> | id  | name           | source_template_id |
> +-----+----------------+--------------------+
> | 203 | derived-debian |                202 |
> +-----+----------------+--------------------+
> 1 row in set (0.00 sec)
> mysql> select * from vm_template_details where template_id=203;
> Empty set (0.00 sec)
> {noformat}
> REPRO STEPS
> ==================
> 1. Register a template A and specify property:
> Root disk controller: scsi
> NIC adapter type: E1000
> Keyboard type: us
> 2. Create a vm instance from template A
> 3. Take volume snapshot for vm instance
> 4. Delete VM instance
> 5. Switch to "Storage->Snapshots", convert snapshot to a template B
> 6. Observe template B does not inherit property from template A, the table vm_template_details is empty
> EXPECTED BEHAVIOR
> ==================
> Template should inherit property from source template
>  
> ACTUAL BEHAVIOR
> ==================
> Detail template property lost



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)