Skip to content

Commit 036fffc

Browse files
committed
Add upgrade path from 4.3 to 4.4
1 parent dc037b8 commit 036fffc

4 files changed

Lines changed: 308 additions & 0 deletions

File tree

engine/schema/src/com/cloud/upgrade/DatabaseUpgradeChecker.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@
6565
import com.cloud.upgrade.dao.Upgrade410to420;
6666
import com.cloud.upgrade.dao.Upgrade420to421;
6767
import com.cloud.upgrade.dao.Upgrade421to430;
68+
import com.cloud.upgrade.dao.Upgrade430to440;
6869
import com.cloud.upgrade.dao.UpgradeSnapshot217to224;
6970
import com.cloud.upgrade.dao.UpgradeSnapshot223to224;
7071
import com.cloud.upgrade.dao.VersionDao;
@@ -193,6 +194,8 @@ public DatabaseUpgradeChecker() {
193194

194195
_upgradeMap.put("4.2.1", new DbUpgrade[] {new Upgrade421to430()});
195196

197+
_upgradeMap.put("4.3.0", new DbUpgrade[] {new Upgrade430to440()});
198+
196199
//CP Upgrades
197200
_upgradeMap.put("3.0.3", new DbUpgrade[] {new Upgrade303to304(), new Upgrade304to305(), new Upgrade305to306(), new Upgrade306to307(), new Upgrade307to410(),
198201
new Upgrade410to420(), new Upgrade420to421(), new Upgrade421to430()});
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
// Licensed to the Apache Software Foundation (ASF) under one
2+
// or more contributor license agreements. See the NOTICE file
3+
// distributed with this work for additional information
4+
// regarding copyright ownership. The ASF licenses this file
5+
// to you under the Apache License, Version 2.0 (the
6+
// "License"); you may not use this file except in compliance
7+
// with the License. You may obtain a copy of the License at
8+
//
9+
// http://www.apache.org/licenses/LICENSE-2.0
10+
//
11+
// Unless required by applicable law or agreed to in writing,
12+
// software distributed under the License is distributed on an
13+
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
// KIND, either express or implied. See the License for the
15+
// specific language governing permissions and limitations
16+
// under the License.
17+
18+
package com.cloud.upgrade.dao;
19+
20+
import java.io.File;
21+
import java.sql.Connection;
22+
23+
import org.apache.log4j.Logger;
24+
25+
import com.cloud.utils.exception.CloudRuntimeException;
26+
import com.cloud.utils.script.Script;
27+
28+
public class Upgrade430to440 implements DbUpgrade {
29+
final static Logger s_logger = Logger.getLogger(Upgrade430to440.class);
30+
31+
@Override
32+
public String[] getUpgradableVersionRange() {
33+
return new String[] {"4.3.0", "4.4.0"};
34+
}
35+
36+
@Override
37+
public String getUpgradedVersion() {
38+
return "4.4.0";
39+
}
40+
41+
@Override
42+
public boolean supportsRollingUpgrade() {
43+
return false;
44+
}
45+
46+
@Override
47+
public File[] getPrepareScripts() {
48+
String script = Script.findScript("", "db/schema-430to440.sql");
49+
if (script == null) {
50+
throw new CloudRuntimeException("Unable to find db/schema-4310to440.sql");
51+
}
52+
53+
return new File[] { new File(script) };
54+
}
55+
56+
@Override
57+
public void performDataMigration(Connection conn) {
58+
}
59+
60+
@Override
61+
public File[] getCleanupScripts() {
62+
String script = Script.findScript("", "db/schema-430to440-cleanup.sql");
63+
if (script == null) {
64+
throw new CloudRuntimeException("Unable to find db/schema-430to440-cleanup.sql");
65+
}
66+
67+
return new File[] { new File(script) };
68+
}
69+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
-- Licensed to the Apache Software Foundation (ASF) under one
2+
-- or more contributor license agreements. See the NOTICE file
3+
-- distributed with this work for additional information
4+
-- regarding copyright ownership. The ASF licenses this file
5+
-- to you under the Apache License, Version 2.0 (the
6+
-- "License"); you may not use this file except in compliance
7+
-- with the License. You may obtain a copy of the License at
8+
--
9+
-- http://www.apache.org/licenses/LICENSE-2.0
10+
--
11+
-- Unless required by applicable law or agreed to in writing,
12+
-- software distributed under the License is distributed on an
13+
-- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
-- KIND, either express or implied. See the License for the
15+
-- specific language governing permissions and limitations
16+
-- under the License.
17+
18+
--;
19+
-- Schema cleanup from 4.3.0 to 4.4.0;
20+
--;
21+
22+

setup/db/db/schema-430to440.sql

Lines changed: 214 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,214 @@
1+
-- Licensed to the Apache Software Foundation (ASF) under one
2+
-- or more contributor license agreements. See the NOTICE file
3+
-- distributed with this work for additional information
4+
-- regarding copyright ownership. The ASF licenses this file
5+
-- to you under the Apache License, Version 2.0 (the
6+
-- "License"); you may not use this file except in compliance
7+
-- with the License. You may obtain a copy of the License at
8+
--
9+
-- http://www.apache.org/licenses/LICENSE-2.0
10+
--
11+
-- Unless required by applicable law or agreed to in writing,
12+
-- software distributed under the License is distributed on an
13+
-- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
-- KIND, either express or implied. See the License for the
15+
-- specific language governing permissions and limitations
16+
-- under the License.
17+
18+
--;
19+
-- Schema upgrade from 4.3.0 to 4.4.0;
20+
--;
21+
22+
-- Disable foreign key checking
23+
SET foreign_key_checks = 0;
24+
25+
ALTER TABLE `cloud`.`disk_offering` ADD `cache_mode` VARCHAR( 16 ) NOT NULL DEFAULT 'none' COMMENT 'The disk cache mode to use for disks created with this offering';
26+
27+
DROP VIEW IF EXISTS `cloud`.`disk_offering_view`;
28+
CREATE VIEW `cloud`.`disk_offering_view` AS
29+
select
30+
disk_offering.id,
31+
disk_offering.uuid,
32+
disk_offering.name,
33+
disk_offering.display_text,
34+
disk_offering.disk_size,
35+
disk_offering.min_iops,
36+
disk_offering.max_iops,
37+
disk_offering.created,
38+
disk_offering.tags,
39+
disk_offering.customized,
40+
disk_offering.customized_iops,
41+
disk_offering.removed,
42+
disk_offering.use_local_storage,
43+
disk_offering.system_use,
44+
disk_offering.bytes_read_rate,
45+
disk_offering.bytes_write_rate,
46+
disk_offering.iops_read_rate,
47+
disk_offering.iops_write_rate,
48+
disk_offering.cache_mode,
49+
disk_offering.sort_key,
50+
disk_offering.type,
51+
disk_offering.display_offering,
52+
domain.id domain_id,
53+
domain.uuid domain_uuid,
54+
domain.name domain_name,
55+
domain.path domain_path
56+
from
57+
`cloud`.`disk_offering`
58+
left join
59+
`cloud`.`domain` ON disk_offering.domain_id = domain.id
60+
where
61+
disk_offering.state='ACTIVE';
62+
63+
DROP VIEW IF EXISTS `cloud`.`service_offering_view`;
64+
CREATE VIEW `cloud`.`service_offering_view` AS
65+
select
66+
service_offering.id,
67+
disk_offering.uuid,
68+
disk_offering.name,
69+
disk_offering.display_text,
70+
disk_offering.created,
71+
disk_offering.tags,
72+
disk_offering.removed,
73+
disk_offering.use_local_storage,
74+
disk_offering.system_use,
75+
disk_offering.bytes_read_rate,
76+
disk_offering.bytes_write_rate,
77+
disk_offering.iops_read_rate,
78+
disk_offering.iops_write_rate,
79+
disk_offering.cache_mode,
80+
service_offering.cpu,
81+
service_offering.speed,
82+
service_offering.ram_size,
83+
service_offering.nw_rate,
84+
service_offering.mc_rate,
85+
service_offering.ha_enabled,
86+
service_offering.limit_cpu_use,
87+
service_offering.host_tag,
88+
service_offering.default_use,
89+
service_offering.vm_type,
90+
service_offering.sort_key,
91+
service_offering.is_volatile,
92+
service_offering.deployment_planner,
93+
domain.id domain_id,
94+
domain.uuid domain_uuid,
95+
domain.name domain_name,
96+
domain.path domain_path
97+
from
98+
`cloud`.`service_offering`
99+
inner join
100+
`cloud`.`disk_offering` ON service_offering.id = disk_offering.id
101+
left join
102+
`cloud`.`domain` ON disk_offering.domain_id = domain.id
103+
where
104+
disk_offering.state='Active';
105+
106+
DROP VIEW IF EXISTS `cloud`.`volume_view`;
107+
CREATE VIEW `cloud`.`volume_view` AS
108+
select
109+
volumes.id,
110+
volumes.uuid,
111+
volumes.name,
112+
volumes.device_id,
113+
volumes.volume_type,
114+
volumes.size,
115+
volumes.min_iops,
116+
volumes.max_iops,
117+
volumes.created,
118+
volumes.state,
119+
volumes.attached,
120+
volumes.removed,
121+
volumes.pod_id,
122+
volumes.display_volume,
123+
volumes.format,
124+
volumes.path,
125+
account.id account_id,
126+
account.uuid account_uuid,
127+
account.account_name account_name,
128+
account.type account_type,
129+
domain.id domain_id,
130+
domain.uuid domain_uuid,
131+
domain.name domain_name,
132+
domain.path domain_path,
133+
projects.id project_id,
134+
projects.uuid project_uuid,
135+
projects.name project_name,
136+
data_center.id data_center_id,
137+
data_center.uuid data_center_uuid,
138+
data_center.name data_center_name,
139+
data_center.networktype data_center_type,
140+
vm_instance.id vm_id,
141+
vm_instance.uuid vm_uuid,
142+
vm_instance.name vm_name,
143+
vm_instance.state vm_state,
144+
vm_instance.vm_type,
145+
user_vm.display_name vm_display_name,
146+
volume_store_ref.size volume_store_size,
147+
volume_store_ref.download_pct,
148+
volume_store_ref.download_state,
149+
volume_store_ref.error_str,
150+
volume_store_ref.created created_on_store,
151+
disk_offering.id disk_offering_id,
152+
disk_offering.uuid disk_offering_uuid,
153+
disk_offering.name disk_offering_name,
154+
disk_offering.display_text disk_offering_display_text,
155+
disk_offering.use_local_storage,
156+
disk_offering.system_use,
157+
disk_offering.bytes_read_rate,
158+
disk_offering.bytes_write_rate,
159+
disk_offering.iops_read_rate,
160+
disk_offering.iops_write_rate,
161+
disk_offering.cache_mode,
162+
storage_pool.id pool_id,
163+
storage_pool.uuid pool_uuid,
164+
storage_pool.name pool_name,
165+
cluster.hypervisor_type,
166+
vm_template.id template_id,
167+
vm_template.uuid template_uuid,
168+
vm_template.extractable,
169+
vm_template.type template_type,
170+
resource_tags.id tag_id,
171+
resource_tags.uuid tag_uuid,
172+
resource_tags.key tag_key,
173+
resource_tags.value tag_value,
174+
resource_tags.domain_id tag_domain_id,
175+
resource_tags.account_id tag_account_id,
176+
resource_tags.resource_id tag_resource_id,
177+
resource_tags.resource_uuid tag_resource_uuid,
178+
resource_tags.resource_type tag_resource_type,
179+
resource_tags.customer tag_customer,
180+
async_job.id job_id,
181+
async_job.uuid job_uuid,
182+
async_job.job_status job_status,
183+
async_job.account_id job_account_id
184+
from
185+
`cloud`.`volumes`
186+
inner join
187+
`cloud`.`account` ON volumes.account_id = account.id
188+
inner join
189+
`cloud`.`domain` ON volumes.domain_id = domain.id
190+
left join
191+
`cloud`.`projects` ON projects.project_account_id = account.id
192+
left join
193+
`cloud`.`data_center` ON volumes.data_center_id = data_center.id
194+
left join
195+
`cloud`.`vm_instance` ON volumes.instance_id = vm_instance.id
196+
left join
197+
`cloud`.`user_vm` ON user_vm.id = vm_instance.id
198+
left join
199+
`cloud`.`volume_store_ref` ON volumes.id = volume_store_ref.volume_id
200+
left join
201+
`cloud`.`disk_offering` ON volumes.disk_offering_id = disk_offering.id
202+
left join
203+
`cloud`.`storage_pool` ON volumes.pool_id = storage_pool.id
204+
left join
205+
`cloud`.`cluster` ON storage_pool.cluster_id = cluster.id
206+
left join
207+
`cloud`.`vm_template` ON volumes.template_id = vm_template.id OR volumes.iso_id = vm_template.id
208+
left join
209+
`cloud`.`resource_tags` ON resource_tags.resource_id = volumes.id
210+
and resource_tags.resource_type = 'Volume'
211+
left join
212+
`cloud`.`async_job` ON async_job.instance_id = volumes.id
213+
and async_job.instance_type = 'Volume'
214+
and async_job.job_status = 0;

0 commit comments

Comments
 (0)