diff --git a/server/src/com/cloud/upgrade/dao/Upgrade221to222.java b/server/src/com/cloud/upgrade/dao/Upgrade221to222.java new file mode 100644 index 00000000000..2bf13647a1c --- /dev/null +++ b/server/src/com/cloud/upgrade/dao/Upgrade221to222.java @@ -0,0 +1,67 @@ +/** + * Copyright (C) 2010 Cloud.com, Inc. All rights reserved. + * + * This software is licensed under the GNU General Public License v3 or later. + * + * It is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or any later version. + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ +package com.cloud.upgrade.dao; + +import java.io.File; +import java.sql.Connection; + +import com.cloud.utils.PropertiesUtil; +import com.cloud.utils.exception.CloudRuntimeException; + +public class Upgrade221to222 implements DbUpgrade { + + @Override + public File getPrepareScript() { + File file = PropertiesUtil.findConfigFile("schema-221to222.sql"); + if (file == null) { + throw new CloudRuntimeException("Unable to find the upgrade script, schema-221to222.sql"); + } + + return file; + } + + @Override + public void performDataMigration(Connection conn) { + + } + + @Override + public File getCleanupScript() { + File file = PropertiesUtil.findConfigFile("schema-221to222-cleanup.sql"); + if (file == null) { + throw new CloudRuntimeException("Unable to find the upgrade script, schema-221to222-cleanup.sql"); + } + + return file; + } + + @Override + public String[] getUpgradableVersionRange() { + return new String[] { "2.2.1", "2.2.1" }; + } + + @Override + public String getUpgradedVersion() { + return "2.2.2"; + } + + @Override + public boolean supportsRollingUpgrade() { + return false; + } +} diff --git a/setup/db/schema-221to222-cleanup.sql b/setup/db/schema-221to222-cleanup.sql new file mode 100644 index 00000000000..ec7a76b718f --- /dev/null +++ b/setup/db/schema-221to222-cleanup.sql @@ -0,0 +1,2 @@ +alter table firewall_rules drop column is_static_nat; +delete from configuration where name='router.cleanup'; diff --git a/setup/db/schema-221to222.sql b/setup/db/schema-221to222.sql new file mode 100644 index 00000000000..56b7f2a198d --- /dev/null +++ b/setup/db/schema-221to222.sql @@ -0,0 +1,24 @@ +update firewall_rules set purpose='StaticNat' where is_static_nat=1; +alter table user_ip_address add CONSTRAINT `fk_user_ip_address__vm_id` FOREIGN KEY (`vm_id`) REFERENCES `vm_instance`(`id`); +update network_offerings set system_only=1 where name='System-Guest-Network'; +update network_offerings set dns_service=1,userdata_service=1,dhcp_service=1 where system_only=0; +update network_offerings set firewall_service=1, lb_service=1,vpn_service=1,gateway_service=1 where traffic_type='guest' and system_only=0; +alter table domain add column `state` char(32) NOT NULL default 'Active' COMMENT 'state of the domain'; +alter table nics add column `vm_type` char(32) NOT NULL; +update nics set vm_type=(select type from vm_instance where vm_instance.id=nics.instance_id); +INSERT INTO configuration (`category`, `instance`, `component`, `name`, `value`, `description`) VALUES ('Network','DEFAULT','none','network.guest.cidr.limit','22','size limit for guest cidr; cant be less than this value'); +alter table user_statistics add column `network_id` bigint unsigned; +update op_networks set nics_count=1 where id in (select d.network_id from domain_router d, vm_instance i where i.state='Running' and i.id=d.id); +update network_offerings set traffic_type='Guest' where system_only=0; +alter table network_offerings add column `guest_type` char(32) NOT NULL; +update network_offerings set guest_type='System-Guest-Network' where traffic_type='Direct'; +update network_offerings set guest_type='DefaultVirtualizedNetworkOffering' where traffic_type='Virtual'; +update network_offerings set guest_type='DefaultDirectNetworkOffering' where traffic_type='Direct'; +alter table op_it_work add column `vm_type` char(32) NOT NULL; +update op_it_work set vm_type=(select type from vm_instance where vm_instance.id=op_it_work.instance_id); +alter table networks add column `is_security_group_enabled` tinyint NOT NULL DEFAULT 0 COMMENT '1: enabled, 0: not'; +update networks set is_security_group_enabled=0; +alter table data_center add column `is_security_group_enabled` tinyint NOT NULL DEFAULT 0 COMMENT '1: enabled, 0: not'; +update data_center set is_security_group_enabled=0; +update data_center set dns_provider='DhcpServer', dhcp_provider='DhcpServer', userdata_provider='DhcpServer', lb_provider=null, firewall_provider=null, vpn_provider=null, gateway_provider=null where networktype='Basic'; +update network_offerings set specify_vlan=1 where system_only=0 and guest_type='Direct';