Skip to content

Commit 4da3265

Browse files
committed
Added DB upgrade path from 42000 to 42010
1 parent 0b508e0 commit 4da3265

File tree

5 files changed

+130
-1
lines changed

5 files changed

+130
-1
lines changed

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@
8888
import com.cloud.upgrade.dao.Upgrade41810to41900;
8989
import com.cloud.upgrade.dao.Upgrade41900to41910;
9090
import com.cloud.upgrade.dao.Upgrade41910to42000;
91+
import com.cloud.upgrade.dao.Upgrade42000to42010;
9192
import com.cloud.upgrade.dao.Upgrade420to421;
9293
import com.cloud.upgrade.dao.Upgrade421to430;
9394
import com.cloud.upgrade.dao.Upgrade430to440;
@@ -230,6 +231,7 @@ public DatabaseUpgradeChecker() {
230231
.next("4.18.1.0", new Upgrade41810to41900())
231232
.next("4.19.0.0", new Upgrade41900to41910())
232233
.next("4.19.1.0", new Upgrade41910to42000())
234+
.next("4.20.0.0", new Upgrade42000to42010())
233235
.build();
234236
}
235237

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
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+
package com.cloud.upgrade.dao;
18+
19+
import java.io.InputStream;
20+
import java.sql.Connection;
21+
22+
import com.cloud.upgrade.SystemVmTemplateRegistration;
23+
import com.cloud.utils.exception.CloudRuntimeException;
24+
25+
public class Upgrade42000to42010 extends DbUpgradeAbstractImpl implements DbUpgrade, DbUpgradeSystemVmTemplate {
26+
private SystemVmTemplateRegistration systemVmTemplateRegistration;
27+
28+
@Override
29+
public String[] getUpgradableVersionRange() {
30+
return new String[] {"4.20.0.0", "4.20.1.0"};
31+
}
32+
33+
@Override
34+
public String getUpgradedVersion() {
35+
return "4.20.1.0";
36+
}
37+
38+
@Override
39+
public boolean supportsRollingUpgrade() {
40+
return false;
41+
}
42+
43+
@Override
44+
public InputStream[] getPrepareScripts() {
45+
final String scriptFile = "META-INF/db/schema-42000to42010.sql";
46+
final InputStream script = Thread.currentThread().getContextClassLoader().getResourceAsStream(scriptFile);
47+
if (script == null) {
48+
throw new CloudRuntimeException("Unable to find " + scriptFile);
49+
}
50+
51+
return new InputStream[] {script};
52+
}
53+
54+
@Override
55+
public void performDataMigration(Connection conn) {
56+
}
57+
58+
@Override
59+
public InputStream[] getCleanupScripts() {
60+
final String scriptFile = "META-INF/db/schema-42000to42010-cleanup.sql";
61+
final InputStream script = Thread.currentThread().getContextClassLoader().getResourceAsStream(scriptFile);
62+
if (script == null) {
63+
throw new CloudRuntimeException("Unable to find " + scriptFile);
64+
}
65+
66+
return new InputStream[] {script};
67+
}
68+
69+
private void initSystemVmTemplateRegistration() {
70+
systemVmTemplateRegistration = new SystemVmTemplateRegistration("");
71+
}
72+
73+
@Override
74+
public void updateSystemVmTemplates(Connection conn) {
75+
logger.debug("Updating System Vm template IDs");
76+
initSystemVmTemplateRegistration();
77+
try {
78+
systemVmTemplateRegistration.updateSystemVmTemplates(conn);
79+
} catch (Exception e) {
80+
throw new CloudRuntimeException("Failed to find / register SystemVM template(s)");
81+
}
82+
}
83+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
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 cleanup from 4.20.0.0 to 4.20.1.0
20+
--;
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
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.20.0.0 to 4.20.0.0
20+
--;
21+
22+
-- Add column api_key_access to user and account tables
23+
CALL `cloud`.`IDEMPOTENT_ADD_COLUMN`('cloud.user', 'api_key_access', 'boolean DEFAULT NULL COMMENT "is api key access allowed for the user" AFTER `secret_key`');
24+
CALL `cloud`.`IDEMPOTENT_ADD_COLUMN`('cloud.account', 'api_key_access', 'boolean DEFAULT NULL COMMENT "is api key access allowed for the account" ');

ui/src/components/view/InfoCard.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -736,7 +736,7 @@
736736
<div class="account-center-tags" v-if="showKeys || resource.apikeyaccess">
737737
<a-divider/>
738738
</div>
739-
<div class="account-center-tags" v-if="resource.apikeyaccess">
739+
<div class="account-center-tags" v-if="resource.apikeyaccess && resource.account">
740740
<div class="resource-detail-item">
741741
<div class="resource-detail-item__label">{{ $t('label.apikeyaccess') }}</div>
742742
<div class="resource-detail-item__details">

0 commit comments

Comments
 (0)