From 8aff96cfc505069152943631fcd0446244f77f2c Mon Sep 17 00:00:00 2001 From: Nicolas Vazquez Date: Fri, 14 Sep 2018 05:28:28 -0300 Subject: [PATCH] Fixes #2838 exception in Vmware full clones update (#2840) Fixes #2838 --- .../orchestration/VolumeOrchestrator.java | 2 +- .../META-INF/db/schema-41110to41120.sql | 6 ++++++ .../src/com/cloud/vm/UserVmCloneSettingVO.java | 17 ++++++++++++++++- 3 files changed, 23 insertions(+), 2 deletions(-) diff --git a/engine/orchestration/src/org/apache/cloudstack/engine/orchestration/VolumeOrchestrator.java b/engine/orchestration/src/org/apache/cloudstack/engine/orchestration/VolumeOrchestrator.java index e5e0bbfed59..7435a3eaf23 100644 --- a/engine/orchestration/src/org/apache/cloudstack/engine/orchestration/VolumeOrchestrator.java +++ b/engine/orchestration/src/org/apache/cloudstack/engine/orchestration/VolumeOrchestrator.java @@ -1399,7 +1399,7 @@ public class VolumeOrchestrator extends ManagerBase implements VolumeOrchestrati if (cloneSettingVO != null) { if (!cloneSettingVO.getCloneType().equals(cloneType.toString())) { cloneSettingVO.setCloneType(cloneType.toString()); - _vmCloneSettingDao.update(cloneSettingVO.getVmId(), cloneSettingVO); + _vmCloneSettingDao.update(cloneSettingVO.getId(), cloneSettingVO); } } else { UserVmCloneSettingVO vmCloneSettingVO = new UserVmCloneSettingVO(vm.getId(), cloneType.toString()); diff --git a/engine/schema/resources/META-INF/db/schema-41110to41120.sql b/engine/schema/resources/META-INF/db/schema-41110to41120.sql index 4c85bd133e8..8b1b9d9cc31 100644 --- a/engine/schema/resources/META-INF/db/schema-41110to41120.sql +++ b/engine/schema/resources/META-INF/db/schema-41110to41120.sql @@ -22,3 +22,9 @@ -- XenServer 7.5 INSERT IGNORE INTO `cloud`.`hypervisor_capabilities`(uuid, hypervisor_type, hypervisor_version, max_guests_limit, max_data_volumes_limit, storage_motion_supported) values (UUID(), 'XenServer', '7.5.0', 500, 13, 1); INSERT IGNORE INTO `cloud`.`guest_os_hypervisor` (uuid,hypervisor_type, hypervisor_version, guest_os_name, guest_os_id, created, is_user_defined) SELECT UUID(),'Xenserver', '7.5.0', guest_os_name, guest_os_id, utc_timestamp(), 0 FROM `cloud`.`guest_os_hypervisor` WHERE hypervisor_type='Xenserver' AND hypervisor_version='7.4.0'; + +-- Fix Vmware full clones issue +ALTER TABLE `cloud`.`user_vm_clone_setting` +ADD COLUMN `id` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT FIRST, +DROP PRIMARY KEY, +ADD PRIMARY KEY (`id`); \ No newline at end of file diff --git a/engine/schema/src/com/cloud/vm/UserVmCloneSettingVO.java b/engine/schema/src/com/cloud/vm/UserVmCloneSettingVO.java index adca686db57..f50807e4ed3 100644 --- a/engine/schema/src/com/cloud/vm/UserVmCloneSettingVO.java +++ b/engine/schema/src/com/cloud/vm/UserVmCloneSettingVO.java @@ -16,13 +16,23 @@ // under the License. package com.cloud.vm; +import org.apache.cloudstack.api.InternalIdentity; + import javax.persistence.Column; import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; import javax.persistence.Table; @Entity @Table(name = "user_vm_clone_setting") -public class UserVmCloneSettingVO { +public class UserVmCloneSettingVO implements InternalIdentity { + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + @Column(name = "id") + private long id; @Column(name = "vm_id") private Long vmId; @@ -50,4 +60,9 @@ public class UserVmCloneSettingVO { public void setCloneType(String cloneType) { this.cloneType = cloneType; } + + @Override + public long getId() { + return id; + } }