schema: change upgrade path to 4.14 (from 4.13) and intensify check (#4331)

* change upgrade path to 4.14 (from 4.13) and intensify check

* extracted check

Co-authored-by: Pearl Dsilva <pearl.dsilva@shapeblue.com>
This commit is contained in:
Pearl Dsilva 2020-09-22 09:40:51 +05:30 committed by GitHub
parent 238eccc317
commit cfbb4ff3dd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 40 additions and 29 deletions

View File

@ -53,33 +53,6 @@ ALTER TABLE `cloud`.`vm_instance` ADD COLUMN `backup_offering_id` bigint unsigne
ALTER TABLE `cloud`.`vm_instance` ADD COLUMN `backup_external_id` varchar(255) DEFAULT NULL COMMENT 'ID of external backup job or container if any'; ALTER TABLE `cloud`.`vm_instance` ADD COLUMN `backup_external_id` varchar(255) DEFAULT NULL COMMENT 'ID of external backup job or container if any';
ALTER TABLE `cloud`.`vm_instance` ADD COLUMN `backup_volumes` text DEFAULT NULL COMMENT 'details of backedup volumes'; ALTER TABLE `cloud`.`vm_instance` ADD COLUMN `backup_volumes` text DEFAULT NULL COMMENT 'details of backedup volumes';
ALTER TABLE `cloud`.`image_store` ADD COLUMN `readonly` boolean DEFAULT false COMMENT 'defines status of image store';
ALTER VIEW `cloud`.`image_store_view` AS
select
image_store.id,
image_store.uuid,
image_store.name,
image_store.image_provider_name,
image_store.protocol,
image_store.url,
image_store.scope,
image_store.role,
image_store.readonly,
image_store.removed,
data_center.id data_center_id,
data_center.uuid data_center_uuid,
data_center.name data_center_name,
image_store_details.name detail_name,
image_store_details.value detail_value
from
`cloud`.`image_store`
left join
`cloud`.`data_center` ON image_store.data_center_id = data_center.id
left join
`cloud`.`image_store_details` ON image_store_details.store_id = image_store.id;
CREATE TABLE IF NOT EXISTS `cloud`.`backups` ( CREATE TABLE IF NOT EXISTS `cloud`.`backups` (
`id` bigint(20) unsigned NOT NULL AUTO_INCREMENT, `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
`uuid` varchar(40) NOT NULL UNIQUE, `uuid` varchar(40) NOT NULL UNIQUE,

View File

@ -194,3 +194,29 @@ INSERT IGNORE INTO `cloud`.`hypervisor_capabilities`(uuid, hypervisor_type, hype
-- Copy XenServer 8.0 hypervisor guest OS mappings to XenServer8.1 -- Copy XenServer 8.0 hypervisor guest OS mappings to XenServer8.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', '8.1.0', guest_os_name, guest_os_id, utc_timestamp(), 0 FROM `cloud`.`guest_os_hypervisor` WHERE hypervisor_type='Xenserver' AND hypervisor_version='8.0.0'; 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', '8.1.0', guest_os_name, guest_os_id, utc_timestamp(), 0 FROM `cloud`.`guest_os_hypervisor` WHERE hypervisor_type='Xenserver' AND hypervisor_version='8.0.0';
ALTER TABLE `cloud`.`image_store` ADD COLUMN `readonly` boolean DEFAULT false COMMENT 'defines status of image store';
ALTER VIEW `cloud`.`image_store_view` AS
select
image_store.id,
image_store.uuid,
image_store.name,
image_store.image_provider_name,
image_store.protocol,
image_store.url,
image_store.scope,
image_store.role,
image_store.readonly,
image_store.removed,
data_center.id data_center_id,
data_center.uuid data_center_uuid,
data_center.name data_center_name,
image_store_details.name detail_name,
image_store_details.value detail_value
from
`cloud`.`image_store`
left join
`cloud`.`data_center` ON image_store.data_center_id = data_center.id
left join
`cloud`.`image_store_details` ON image_store_details.store_id = image_store.id;

View File

@ -1044,13 +1044,25 @@ public class NfsSecondaryStorageResource extends ServerResourceBase implements S
} }
} }
private boolean shouldPerformDataMigration(DataTO srcData, DataTO destData) {
DataStoreTO srcDataStore = srcData.getDataStore();
DataStoreTO destDataStore = destData.getDataStore();
if (DataStoreRole.Image == srcDataStore.getRole() && DataStoreRole.Image == destDataStore.getRole() &&
srcDataStore instanceof NfsTO && destDataStore instanceof NfsTO &&
((srcData.getObjectType() == DataObjectType.TEMPLATE && destData.getObjectType() == DataObjectType.TEMPLATE) ||
(srcData.getObjectType() == DataObjectType.SNAPSHOT && destData.getObjectType() == DataObjectType.SNAPSHOT) ||
(srcData.getObjectType() == DataObjectType.VOLUME && destData.getObjectType() == DataObjectType.VOLUME))) {
return true;
}
return false;
}
protected Answer execute(CopyCommand cmd) { protected Answer execute(CopyCommand cmd) {
DataTO srcData = cmd.getSrcTO(); DataTO srcData = cmd.getSrcTO();
DataTO destData = cmd.getDestTO(); DataTO destData = cmd.getDestTO();
DataStoreTO srcDataStore = srcData.getDataStore(); DataStoreTO srcDataStore = srcData.getDataStore();
DataStoreTO destDataStore = destData.getDataStore(); DataStoreTO destDataStore = destData.getDataStore();
if (shouldPerformDataMigration(srcData, destData)) {
if (DataStoreRole.Image == srcDataStore.getRole() && DataStoreRole.Image == destDataStore.getRole()) {
return copyFromNfsToNfs(cmd); return copyFromNfsToNfs(cmd);
} }