From 5bfe9c8bede00c9e4c211dd27f06041e2e8a735b Mon Sep 17 00:00:00 2001 From: Andrija Panic <45762285+andrijapanicsb@users.noreply.github.com> Date: Sun, 24 Nov 2019 23:49:45 +0100 Subject: [PATCH 1/6] centos8-new-builtin-templates --- .../main/resources/META-INF/db/schema-41300to41400-cleanup.sql | 3 +++ 1 file changed, 3 insertions(+) diff --git a/engine/schema/src/main/resources/META-INF/db/schema-41300to41400-cleanup.sql b/engine/schema/src/main/resources/META-INF/db/schema-41300to41400-cleanup.sql index 57c4a611f0e7..758c03e2a1fa 100644 --- a/engine/schema/src/main/resources/META-INF/db/schema-41300to41400-cleanup.sql +++ b/engine/schema/src/main/resources/META-INF/db/schema-41300to41400-cleanup.sql @@ -19,3 +19,6 @@ -- Schema upgrade cleanup from 4.13.0.0 to 4.14.0.0 --; +-- Delete an ancient template added in 2.2, which was set as removed in 4.5. For the sake of cleanup and easier overview of builtin templates in DB. +-- This DOES assume one is not running any VMs from this template! +DELETE FROM `cloud`.`vm_template` WHERE `id`=2 AND `unique_name`="centos53-x86_64" AND `name`="CentOS 5.3(64-bit) no GUI (XenServer)"; From 7239a08cedb630d6e0d9bad843e5148281205999 Mon Sep 17 00:00:00 2001 From: Andrija Panic <45762285+andrijapanicsb@users.noreply.github.com> Date: Sun, 24 Nov 2019 23:56:51 +0100 Subject: [PATCH 2/6] New builtin templates based on CentOS8 --- .../main/resources/META-INF/db/schema-41300to41400.sql | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/engine/schema/src/main/resources/META-INF/db/schema-41300to41400.sql b/engine/schema/src/main/resources/META-INF/db/schema-41300to41400.sql index 43e282daa045..1f9f2b3d6c63 100644 --- a/engine/schema/src/main/resources/META-INF/db/schema-41300to41400.sql +++ b/engine/schema/src/main/resources/META-INF/db/schema-41300to41400.sql @@ -21,3 +21,11 @@ -- KVM: enable storage data motion on KVM hypervisor_capabilities UPDATE `cloud`.`hypervisor_capabilities` SET `storage_motion_supported` = 1 WHERE `hypervisor_capabilities`.`hypervisor_type` = 'KVM'; + +-- New builtin templates based on CentOS8, for VMware/KVM/XenServer +DELETE from `cloud`.`vm_template` where id in ('4', '5', '7'); +INSERT INTO `cloud`.`vm_template` (id, uuid, unique_name, name, public, created, type, hvm, bits, account_id, url, checksum, display_text, enable_password, format, guest_os_id, featured, cross_zones, hypervisor_type, extractable) VALUES (4, UUID(), 'default-tmpl-centos8.0-kvm', 'CentOS 8.0(64-bit) no GUI (KVM)', 1, now(), 'BUILTIN', 0, 64, 1, 'http://download.cloudstack.org/releases/4.14/default-tmpl-centos8.0.qcow2.bz2', '80da87ecc67d1e4fcf90079873241619', 'CentOS 8.0(64-bit) no GUI (KVM)', 0, 'QCOW2', 274, 1, 1, 'KVM', 1); +INSERT INTO `cloud`.`vm_template` (id, uuid, unique_name, name, public, created, type, hvm, bits, account_id, url, checksum, enable_password, display_text, format, guest_os_id, featured, cross_zones, hypervisor_type, extractable) VALUES (5, UUID(), 'default-tmpl-centos8.0-xen', 'CentOS 8.0(64-bit) no GUI (XenServer)', 1, now(), 'BUILTIN', 0, 64, 1, 'http://download.cloudstack.org/releases/4.14/default-tmpl-centos8.0.vhd.bz2', '440acfd548a7391b26559c4763377118', 0, 'CentOS 8.0(64-bit) no GUI (XenServer)', 'VHD', 274, 1, 1, 'XenServer', 1); +INSERT INTO `cloud`.`vm_template` (id, uuid, unique_name, name, public, created, type, hvm, bits, account_id, url, checksum, enable_password, display_text, format, guest_os_id, featured, cross_zones, hypervisor_type, extractable) VALUES (7, UUID(), 'default-tmpl-centos8.0-vmware', 'CentOS 8.0(64-bit) no GUI (vSphere)', 1, now(), 'BUILTIN', 0, 64, 1, 'http://download.cloudstack.org/releases/4.14/default-tmpl-centos8.0.ova', '85168c007c6ab85c516274cdf23eda48', 0, 'CentOS 8.0(64-bit) no GUI (vSphere)', 'OVA', 274, 1, 1, 'VMware', 1); +INSERT INTO `cloud`.`vm_template_details` (`id`, `template_id`, `name`, `value`) VALUES (1, 7, 'nicAdapter', 'Vmxnet3'); +INSERT INTO `cloud`.`vm_template_details` (`id`, `template_id`, `name`, `value`) VALUES (2, 7, 'rootDiskController', 'pvscsi'); From 628cafb0a25135754b7d6405acb10ebb35a2c350 Mon Sep 17 00:00:00 2001 From: Andrija Panic <45762285+andrijapanicsb@users.noreply.github.com> Date: Mon, 25 Nov 2019 14:44:46 +0100 Subject: [PATCH 3/6] Set tmpls as active This was a step that was performed in some schema update from 4.2 to 4.3 or so, so I set it here explicitly in the new line as well (for the sake of "historical consistency") --- .../src/main/resources/META-INF/db/schema-41300to41400.sql | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/engine/schema/src/main/resources/META-INF/db/schema-41300to41400.sql b/engine/schema/src/main/resources/META-INF/db/schema-41300to41400.sql index 1f9f2b3d6c63..7ec222b21047 100644 --- a/engine/schema/src/main/resources/META-INF/db/schema-41300to41400.sql +++ b/engine/schema/src/main/resources/META-INF/db/schema-41300to41400.sql @@ -25,7 +25,8 @@ UPDATE `cloud`.`hypervisor_capabilities` SET `storage_motion_supported` = 1 WHER -- New builtin templates based on CentOS8, for VMware/KVM/XenServer DELETE from `cloud`.`vm_template` where id in ('4', '5', '7'); INSERT INTO `cloud`.`vm_template` (id, uuid, unique_name, name, public, created, type, hvm, bits, account_id, url, checksum, display_text, enable_password, format, guest_os_id, featured, cross_zones, hypervisor_type, extractable) VALUES (4, UUID(), 'default-tmpl-centos8.0-kvm', 'CentOS 8.0(64-bit) no GUI (KVM)', 1, now(), 'BUILTIN', 0, 64, 1, 'http://download.cloudstack.org/releases/4.14/default-tmpl-centos8.0.qcow2.bz2', '80da87ecc67d1e4fcf90079873241619', 'CentOS 8.0(64-bit) no GUI (KVM)', 0, 'QCOW2', 274, 1, 1, 'KVM', 1); -INSERT INTO `cloud`.`vm_template` (id, uuid, unique_name, name, public, created, type, hvm, bits, account_id, url, checksum, enable_password, display_text, format, guest_os_id, featured, cross_zones, hypervisor_type, extractable) VALUES (5, UUID(), 'default-tmpl-centos8.0-xen', 'CentOS 8.0(64-bit) no GUI (XenServer)', 1, now(), 'BUILTIN', 0, 64, 1, 'http://download.cloudstack.org/releases/4.14/default-tmpl-centos8.0.vhd.bz2', '440acfd548a7391b26559c4763377118', 0, 'CentOS 8.0(64-bit) no GUI (XenServer)', 'VHD', 274, 1, 1, 'XenServer', 1); +INSERT INTO `cloud`.`vm_template` (id, uuid, unique_name, name, public, created, type, hvm, bits, account_id, url, checksum, enable_password, display_text, format, guest_os_id, featured, cross_zones, hypervisor_type, extractabl) VALUES (5, UUID(), 'default-tmpl-centos8.0-xen', 'CentOS 8.0(64-bit) no GUI (XenServer)', 1, now(), 'BUILTIN', 0, 64, 1, 'http://download.cloudstack.org/releases/4.14/default-tmpl-centos8.0.vhd.bz2', '440acfd548a7391b26559c4763377118', 0, 'CentOS 8.0(64-bit) no GUI (XenServer)', 'VHD', 274, 1, 1, 'XenServer', 1); INSERT INTO `cloud`.`vm_template` (id, uuid, unique_name, name, public, created, type, hvm, bits, account_id, url, checksum, enable_password, display_text, format, guest_os_id, featured, cross_zones, hypervisor_type, extractable) VALUES (7, UUID(), 'default-tmpl-centos8.0-vmware', 'CentOS 8.0(64-bit) no GUI (vSphere)', 1, now(), 'BUILTIN', 0, 64, 1, 'http://download.cloudstack.org/releases/4.14/default-tmpl-centos8.0.ova', '85168c007c6ab85c516274cdf23eda48', 0, 'CentOS 8.0(64-bit) no GUI (vSphere)', 'OVA', 274, 1, 1, 'VMware', 1); +UPDATE `cloud`.`vm_template` SET `state`="Active" WHERE id IN ('4', '5', '7'); INSERT INTO `cloud`.`vm_template_details` (`id`, `template_id`, `name`, `value`) VALUES (1, 7, 'nicAdapter', 'Vmxnet3'); INSERT INTO `cloud`.`vm_template_details` (`id`, `template_id`, `name`, `value`) VALUES (2, 7, 'rootDiskController', 'pvscsi'); From 1a21c3afff95570998564e6ef2d2127330ea62f3 Mon Sep 17 00:00:00 2001 From: Andrija Panic <45762285+andrijapanicsb@users.noreply.github.com> Date: Mon, 25 Nov 2019 17:40:08 +0100 Subject: [PATCH 4/6] typo --- .../src/main/resources/META-INF/db/schema-41300to41400.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/engine/schema/src/main/resources/META-INF/db/schema-41300to41400.sql b/engine/schema/src/main/resources/META-INF/db/schema-41300to41400.sql index 7ec222b21047..8a880fe38f5c 100644 --- a/engine/schema/src/main/resources/META-INF/db/schema-41300to41400.sql +++ b/engine/schema/src/main/resources/META-INF/db/schema-41300to41400.sql @@ -25,7 +25,7 @@ UPDATE `cloud`.`hypervisor_capabilities` SET `storage_motion_supported` = 1 WHER -- New builtin templates based on CentOS8, for VMware/KVM/XenServer DELETE from `cloud`.`vm_template` where id in ('4', '5', '7'); INSERT INTO `cloud`.`vm_template` (id, uuid, unique_name, name, public, created, type, hvm, bits, account_id, url, checksum, display_text, enable_password, format, guest_os_id, featured, cross_zones, hypervisor_type, extractable) VALUES (4, UUID(), 'default-tmpl-centos8.0-kvm', 'CentOS 8.0(64-bit) no GUI (KVM)', 1, now(), 'BUILTIN', 0, 64, 1, 'http://download.cloudstack.org/releases/4.14/default-tmpl-centos8.0.qcow2.bz2', '80da87ecc67d1e4fcf90079873241619', 'CentOS 8.0(64-bit) no GUI (KVM)', 0, 'QCOW2', 274, 1, 1, 'KVM', 1); -INSERT INTO `cloud`.`vm_template` (id, uuid, unique_name, name, public, created, type, hvm, bits, account_id, url, checksum, enable_password, display_text, format, guest_os_id, featured, cross_zones, hypervisor_type, extractabl) VALUES (5, UUID(), 'default-tmpl-centos8.0-xen', 'CentOS 8.0(64-bit) no GUI (XenServer)', 1, now(), 'BUILTIN', 0, 64, 1, 'http://download.cloudstack.org/releases/4.14/default-tmpl-centos8.0.vhd.bz2', '440acfd548a7391b26559c4763377118', 0, 'CentOS 8.0(64-bit) no GUI (XenServer)', 'VHD', 274, 1, 1, 'XenServer', 1); +INSERT INTO `cloud`.`vm_template` (id, uuid, unique_name, name, public, created, type, hvm, bits, account_id, url, checksum, enable_password, display_text, format, guest_os_id, featured, cross_zones, hypervisor_type, extractable) VALUES (5, UUID(), 'default-tmpl-centos8.0-xen', 'CentOS 8.0(64-bit) no GUI (XenServer)', 1, now(), 'BUILTIN', 0, 64, 1, 'http://download.cloudstack.org/releases/4.14/default-tmpl-centos8.0.vhd.bz2', '440acfd548a7391b26559c4763377118', 0, 'CentOS 8.0(64-bit) no GUI (XenServer)', 'VHD', 274, 1, 1, 'XenServer', 1); INSERT INTO `cloud`.`vm_template` (id, uuid, unique_name, name, public, created, type, hvm, bits, account_id, url, checksum, enable_password, display_text, format, guest_os_id, featured, cross_zones, hypervisor_type, extractable) VALUES (7, UUID(), 'default-tmpl-centos8.0-vmware', 'CentOS 8.0(64-bit) no GUI (vSphere)', 1, now(), 'BUILTIN', 0, 64, 1, 'http://download.cloudstack.org/releases/4.14/default-tmpl-centos8.0.ova', '85168c007c6ab85c516274cdf23eda48', 0, 'CentOS 8.0(64-bit) no GUI (vSphere)', 'OVA', 274, 1, 1, 'VMware', 1); UPDATE `cloud`.`vm_template` SET `state`="Active" WHERE id IN ('4', '5', '7'); INSERT INTO `cloud`.`vm_template_details` (`id`, `template_id`, `name`, `value`) VALUES (1, 7, 'nicAdapter', 'Vmxnet3'); From 7b2620388aef13cfb7e69b445ec03d93a99e8d87 Mon Sep 17 00:00:00 2001 From: Andrija Panic <45762285+andrijapanicsb@users.noreply.github.com> Date: Mon, 25 Nov 2019 19:30:05 +0100 Subject: [PATCH 5/6] md5sum of bz2 files --- .../src/main/resources/META-INF/db/schema-41300to41400.sql | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/engine/schema/src/main/resources/META-INF/db/schema-41300to41400.sql b/engine/schema/src/main/resources/META-INF/db/schema-41300to41400.sql index 8a880fe38f5c..d93bd3689bb6 100644 --- a/engine/schema/src/main/resources/META-INF/db/schema-41300to41400.sql +++ b/engine/schema/src/main/resources/META-INF/db/schema-41300to41400.sql @@ -24,8 +24,8 @@ UPDATE `cloud`.`hypervisor_capabilities` SET `storage_motion_supported` = 1 WHER -- New builtin templates based on CentOS8, for VMware/KVM/XenServer DELETE from `cloud`.`vm_template` where id in ('4', '5', '7'); -INSERT INTO `cloud`.`vm_template` (id, uuid, unique_name, name, public, created, type, hvm, bits, account_id, url, checksum, display_text, enable_password, format, guest_os_id, featured, cross_zones, hypervisor_type, extractable) VALUES (4, UUID(), 'default-tmpl-centos8.0-kvm', 'CentOS 8.0(64-bit) no GUI (KVM)', 1, now(), 'BUILTIN', 0, 64, 1, 'http://download.cloudstack.org/releases/4.14/default-tmpl-centos8.0.qcow2.bz2', '80da87ecc67d1e4fcf90079873241619', 'CentOS 8.0(64-bit) no GUI (KVM)', 0, 'QCOW2', 274, 1, 1, 'KVM', 1); -INSERT INTO `cloud`.`vm_template` (id, uuid, unique_name, name, public, created, type, hvm, bits, account_id, url, checksum, enable_password, display_text, format, guest_os_id, featured, cross_zones, hypervisor_type, extractable) VALUES (5, UUID(), 'default-tmpl-centos8.0-xen', 'CentOS 8.0(64-bit) no GUI (XenServer)', 1, now(), 'BUILTIN', 0, 64, 1, 'http://download.cloudstack.org/releases/4.14/default-tmpl-centos8.0.vhd.bz2', '440acfd548a7391b26559c4763377118', 0, 'CentOS 8.0(64-bit) no GUI (XenServer)', 'VHD', 274, 1, 1, 'XenServer', 1); +INSERT INTO `cloud`.`vm_template` (id, uuid, unique_name, name, public, created, type, hvm, bits, account_id, url, checksum, display_text, enable_password, format, guest_os_id, featured, cross_zones, hypervisor_type, extractable) VALUES (4, UUID(), 'default-tmpl-centos8.0-kvm', 'CentOS 8.0(64-bit) no GUI (KVM)', 1, now(), 'BUILTIN', 0, 64, 1, 'http://download.cloudstack.org/releases/4.14/default-tmpl-centos8.0.qcow2.bz2', 'f217c2b8d1e37b7dadea467d0fe14e61', 'CentOS 8.0(64-bit) no GUI (KVM)', 0, 'QCOW2', 274, 1, 1, 'KVM', 1); +INSERT INTO `cloud`.`vm_template` (id, uuid, unique_name, name, public, created, type, hvm, bits, account_id, url, checksum, enable_password, display_text, format, guest_os_id, featured, cross_zones, hypervisor_type, extractable) VALUES (5, UUID(), 'default-tmpl-centos8.0-xen', 'CentOS 8.0(64-bit) no GUI (XenServer)', 1, now(), 'BUILTIN', 0, 64, 1, 'http://download.cloudstack.org/releases/4.14/default-tmpl-centos8.0.vhd.bz2', '0816519171b836b2d2f3062971eaa921', 0, 'CentOS 8.0(64-bit) no GUI (XenServer)', 'VHD', 274, 1, 1, 'XenServer', 1); INSERT INTO `cloud`.`vm_template` (id, uuid, unique_name, name, public, created, type, hvm, bits, account_id, url, checksum, enable_password, display_text, format, guest_os_id, featured, cross_zones, hypervisor_type, extractable) VALUES (7, UUID(), 'default-tmpl-centos8.0-vmware', 'CentOS 8.0(64-bit) no GUI (vSphere)', 1, now(), 'BUILTIN', 0, 64, 1, 'http://download.cloudstack.org/releases/4.14/default-tmpl-centos8.0.ova', '85168c007c6ab85c516274cdf23eda48', 0, 'CentOS 8.0(64-bit) no GUI (vSphere)', 'OVA', 274, 1, 1, 'VMware', 1); UPDATE `cloud`.`vm_template` SET `state`="Active" WHERE id IN ('4', '5', '7'); INSERT INTO `cloud`.`vm_template_details` (`id`, `template_id`, `name`, `value`) VALUES (1, 7, 'nicAdapter', 'Vmxnet3'); From 51bd258de65a4ecd1378f58091693054b8880819 Mon Sep 17 00:00:00 2001 From: Andrija Panic <45762285+andrijapanicsb@users.noreply.github.com> Date: Mon, 25 Nov 2019 19:39:10 +0100 Subject: [PATCH 6/6] don't delete ancient tmpl if VMs exists from it If someone is running a VM from template from ACS 2.2, garbage is the least of his problem... --- .../resources/META-INF/db/schema-41300to41400-cleanup.sql | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/engine/schema/src/main/resources/META-INF/db/schema-41300to41400-cleanup.sql b/engine/schema/src/main/resources/META-INF/db/schema-41300to41400-cleanup.sql index 758c03e2a1fa..485987c2be4b 100644 --- a/engine/schema/src/main/resources/META-INF/db/schema-41300to41400-cleanup.sql +++ b/engine/schema/src/main/resources/META-INF/db/schema-41300to41400-cleanup.sql @@ -20,5 +20,6 @@ --; -- Delete an ancient template added in 2.2, which was set as removed in 4.5. For the sake of cleanup and easier overview of builtin templates in DB. --- This DOES assume one is not running any VMs from this template! -DELETE FROM `cloud`.`vm_template` WHERE `id`=2 AND `unique_name`="centos53-x86_64" AND `name`="CentOS 5.3(64-bit) no GUI (XenServer)"; +-- This DOES assume one is not running any VMs from this template, otherwise we are not deleting the template. +DELETE FROM `cloud`.`vm_template` WHERE `id`=2 AND `unique_name`="centos53-x86_64" AND `name`="CentOS 5.3(64-bit) no GUI (XenServer)" AND NOT EXISTS (SELECT 1 FROM `cloud`.`vm_instance` WHERE vm_template_id=2 AND removed IS NULL); +