Skip to content

Commit 846803d

Browse files
committed
Merge remote-tracking branch 'apache/4.22'
2 parents 4d54125 + 265b554 commit 846803d

39 files changed

Lines changed: 1031 additions & 193 deletions

File tree

engine/api/src/main/java/org/apache/cloudstack/engine/orchestration/service/NetworkOrchestrationService.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,9 @@ public interface NetworkOrchestrationService {
135135
true,
136136
Scope.Global);
137137

138+
ConfigKey<Integer> VmNetworkThrottlingRate = new ConfigKey<Integer>("Network", Integer.class, "vm.network.throttling.rate", "200",
139+
"Default data transfer rate in megabits per second allowed in User vm's default network.", true, ConfigKey.Scope.Zone);
140+
138141
List<? extends Network> setupNetwork(Account owner, NetworkOffering offering, DeploymentPlan plan, String name, String displayText, boolean isDefault)
139142
throws ConcurrentOperationException;
140143

engine/orchestration/src/main/java/org/apache/cloudstack/engine/orchestration/NetworkOrchestrator.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5065,7 +5065,7 @@ public String getConfigComponentName() {
50655065
@Override
50665066
public ConfigKey<?>[] getConfigKeys() {
50675067
return new ConfigKey<?>[]{NetworkGcWait, NetworkGcInterval, NetworkLockTimeout, DeniedRoutes,
5068-
GuestDomainSuffix, NetworkThrottlingRate, MinVRVersion, DhcpLeaseTimeout,
5068+
GuestDomainSuffix, NetworkThrottlingRate, VmNetworkThrottlingRate, MinVRVersion, DhcpLeaseTimeout,
50695069
PromiscuousMode, MacAddressChanges, ForgedTransmits, MacLearning, RollingRestartEnabled,
50705070
TUNGSTEN_ENABLED, NSX_ENABLED, NETRIS_ENABLED, NETWORK_LB_HAPROXY_MAX_CONN,
50715071
NETWORK_LB_HAPROXY_IDLE_TIMEOUT};

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,9 @@
8888
import com.cloud.upgrade.dao.Upgrade41900to41910;
8989
import com.cloud.upgrade.dao.Upgrade41910to42000;
9090
import com.cloud.upgrade.dao.Upgrade42000to42010;
91-
import com.cloud.upgrade.dao.Upgrade42010to42100;
91+
import com.cloud.upgrade.dao.Upgrade42020to42030;
92+
import com.cloud.upgrade.dao.Upgrade42030to42040;
93+
import com.cloud.upgrade.dao.Upgrade42040to42100;
9294
import com.cloud.upgrade.dao.Upgrade42100to42200;
9395
import com.cloud.upgrade.dao.Upgrade42200to42210;
9496
import com.cloud.upgrade.dao.Upgrade420to421;
@@ -240,7 +242,9 @@ public DatabaseUpgradeChecker() {
240242
.next("4.19.0.0", new Upgrade41900to41910())
241243
.next("4.19.1.0", new Upgrade41910to42000())
242244
.next("4.20.0.0", new Upgrade42000to42010())
243-
.next("4.20.1.0", new Upgrade42010to42100())
245+
.next("4.20.2.0", new Upgrade42020to42030())
246+
.next("4.20.3.0", new Upgrade42030to42040())
247+
.next("4.20.4.0", new Upgrade42040to42100())
244248
.next("4.21.0.0", new Upgrade42100to42200())
245249
.next("4.22.0.0", new Upgrade42200to42210())
246250
.next("4.22.1.0", new Upgrade42210to42300())
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
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+
import java.util.ArrayList;
22+
import java.util.List;
23+
24+
public class Upgrade42030to42040 extends DbUpgradeAbstractImpl implements DbUpgrade, DbUpgradeSystemVmTemplate {
25+
26+
@Override
27+
public String[] getUpgradableVersionRange() {
28+
return new String[]{"4.20.3.0", "4.20.4.0"};
29+
}
30+
31+
@Override
32+
public String getUpgradedVersion() {
33+
return "4.20.4.0";
34+
}
35+
36+
@Override
37+
public boolean supportsRollingUpgrade() {
38+
return false;
39+
}
40+
41+
@Override
42+
public InputStream[] getPrepareScripts() {
43+
return null;
44+
}
45+
46+
@Override
47+
public void performDataMigration(Connection conn) {
48+
final List<String> indexList = new ArrayList<String>();
49+
logger.debug("Dropping index vm_instance_id from usage_vm_instance table if it exists");
50+
indexList.add("vm_instance_id");
51+
DbUpgradeUtils.dropKeysIfExist(conn, "cloud_usage.usage_vm_instance", indexList, false);
52+
}
53+
54+
@Override
55+
public InputStream[] getCleanupScripts() {
56+
return null;
57+
}
58+
}

engine/schema/src/main/java/com/cloud/upgrade/dao/Upgrade42010to42100.java renamed to engine/schema/src/main/java/com/cloud/upgrade/dao/Upgrade42040to42100.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,12 @@
3232
import com.cloud.utils.db.TransactionLegacy;
3333
import com.cloud.utils.exception.CloudRuntimeException;
3434

35-
public class Upgrade42010to42100 extends DbUpgradeAbstractImpl implements DbUpgrade, DbUpgradeSystemVmTemplate {
35+
public class Upgrade42040to42100 extends DbUpgradeAbstractImpl implements DbUpgrade, DbUpgradeSystemVmTemplate {
3636
private SystemVmTemplateRegistration systemVmTemplateRegistration;
3737

3838
@Override
3939
public String[] getUpgradableVersionRange() {
40-
return new String[] {"4.20.1.0", "4.21.0.0"};
40+
return new String[] {"4.20.4.0", "4.21.0.0"};
4141
}
4242

4343
@Override
@@ -52,7 +52,7 @@ public boolean supportsRollingUpgrade() {
5252

5353
@Override
5454
public InputStream[] getPrepareScripts() {
55-
final String scriptFile = "META-INF/db/schema-42010to42100.sql";
55+
final String scriptFile = "META-INF/db/schema-42040to42100.sql";
5656
final InputStream script = Thread.currentThread().getContextClassLoader().getResourceAsStream(scriptFile);
5757
if (script == null) {
5858
throw new CloudRuntimeException("Unable to find " + scriptFile);
@@ -69,7 +69,7 @@ public void performDataMigration(Connection conn) {
6969

7070
@Override
7171
public InputStream[] getCleanupScripts() {
72-
final String scriptFile = "META-INF/db/schema-42010to42100-cleanup.sql";
72+
final String scriptFile = "META-INF/db/schema-42040to42100-cleanup.sql";
7373
final InputStream script = Thread.currentThread().getContextClassLoader().getResourceAsStream(scriptFile);
7474
if (script == null) {
7575
throw new CloudRuntimeException("Unable to find " + scriptFile);

engine/schema/src/main/java/org/apache/cloudstack/resourcedetail/ResourceDetailsDao.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,4 +113,6 @@ public interface ResourceDetailsDao<R extends ResourceDetail> extends GenericDao
113113
long batchExpungeForResources(List<Long> ids, Long batchSize);
114114

115115
String getActualValue(ResourceDetail resourceDetail);
116+
117+
List<R> listDetailsForResourceIdsAndKey(List<Long> resourceIds, String key);
116118
}

engine/schema/src/main/java/org/apache/cloudstack/resourcedetail/ResourceDetailsDaoBase.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,13 @@
1616
// under the License.
1717
package org.apache.cloudstack.resourcedetail;
1818

19+
import java.util.Collections;
1920
import java.util.HashMap;
2021
import java.util.List;
2122
import java.util.Map;
2223
import java.util.stream.Collectors;
2324

25+
import com.cloud.utils.StringUtils;
2426
import org.apache.commons.collections.CollectionUtils;
2527

2628
import com.cloud.utils.Pair;
@@ -48,6 +50,7 @@ public abstract class ResourceDetailsDaoBase<R extends ResourceDetail> extends G
4850
public ResourceDetailsDaoBase() {
4951
AllFieldsSearch = createSearchBuilder();
5052
AllFieldsSearch.and("resourceId", AllFieldsSearch.entity().getResourceId(), SearchCriteria.Op.EQ);
53+
AllFieldsSearch.and("resourceIdIn", AllFieldsSearch.entity().getResourceId(), SearchCriteria.Op.IN);
5154
AllFieldsSearch.and("name", AllFieldsSearch.entity().getName(), SearchCriteria.Op.EQ);
5255
AllFieldsSearch.and("value", AllFieldsSearch.entity().getValue(), SearchCriteria.Op.EQ);
5356
// FIXME SnapshotDetailsVO doesn't have a display field
@@ -266,4 +269,15 @@ public String getActualValue(ResourceDetail resourceDetail) {
266269
}
267270
return resourceDetail.getValue();
268271
}
272+
273+
@Override
274+
public List<R> listDetailsForResourceIdsAndKey(List<Long> resourceIds, String key) {
275+
if (CollectionUtils.isEmpty(resourceIds) || StringUtils.isBlank(key)) {
276+
return Collections.emptyList();
277+
}
278+
SearchCriteria<R> sc = AllFieldsSearch.create();
279+
sc.setParameters("name", key);
280+
sc.setParameters("resourceIdIn", resourceIds.toArray());
281+
return search(sc, null);
282+
}
269283
}

engine/schema/src/main/resources/META-INF/db/schema-42010to42100-cleanup.sql renamed to engine/schema/src/main/resources/META-INF/db/schema-42040to42100-cleanup.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,5 @@
1616
-- under the License.
1717

1818
--;
19-
-- Schema upgrade cleanup from 4.20.1.0 to 4.21.0.0
19+
-- Schema upgrade cleanup from 4.20.4.0 to 4.21.0.0
2020
--;

engine/schema/src/main/resources/META-INF/db/schema-42010to42100.sql renamed to engine/schema/src/main/resources/META-INF/db/schema-42040to42100.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
-- under the License.
1717

1818
--;
19-
-- Schema upgrade from 4.20.1.0 to 4.21.0.0
19+
-- Schema upgrade from 4.20.4.0 to 4.21.0.0
2020
--;
2121

2222
CALL `cloud`.`IDEMPOTENT_ADD_COLUMN`('cloud.backup_schedule', 'max_backups', 'INT(8) UNSIGNED NOT NULL DEFAULT 0 COMMENT ''Maximum number of backups to be retained''');

engine/schema/src/test/java/com/cloud/upgrade/DatabaseUpgradeCheckerTest.java

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,9 @@
4444
import com.cloud.upgrade.dao.Upgrade41120to41200;
4545
import com.cloud.upgrade.dao.Upgrade41510to41520;
4646
import com.cloud.upgrade.dao.Upgrade41610to41700;
47-
import com.cloud.upgrade.dao.Upgrade42010to42100;
47+
import com.cloud.upgrade.dao.Upgrade42020to42030;
48+
import com.cloud.upgrade.dao.Upgrade42030to42040;
49+
import com.cloud.upgrade.dao.Upgrade42040to42100;
4850
import com.cloud.upgrade.dao.Upgrade452to453;
4951
import com.cloud.upgrade.dao.Upgrade453to460;
5052
import com.cloud.upgrade.dao.Upgrade460to461;
@@ -382,22 +384,42 @@ public void isNotStandalone() throws SQLException {
382384
}
383385

384386
@Test
385-
public void testCalculateUpgradePath42010to42100() {
387+
public void testCalculateUpgradePath42010to42030() {
386388

387389
final CloudStackVersion dbVersion = CloudStackVersion.parse("4.20.1.0");
388390
assertNotNull(dbVersion);
389391

390-
final CloudStackVersion currentVersion = CloudStackVersion.parse("4.21.0.0");
392+
final CloudStackVersion currentVersion = CloudStackVersion.parse("4.20.3.0");
391393
assertNotNull(currentVersion);
392394

393395
final DatabaseUpgradeChecker checker = new DatabaseUpgradeChecker();
394396
final DbUpgrade[] upgrades = checker.calculateUpgradePath(dbVersion, currentVersion);
395397

396398
assertNotNull(upgrades);
397399
assertEquals(1, upgrades.length);
398-
assertTrue(upgrades[0] instanceof Upgrade42010to42100);
400+
assertTrue(upgrades[0] instanceof Upgrade42020to42030);
399401

400-
assertArrayEquals(new String[]{"4.20.1.0", "4.21.0.0"}, upgrades[0].getUpgradableVersionRange());
402+
assertArrayEquals(new String[]{"4.20.2.0", "4.20.3.0"}, upgrades[0].getUpgradableVersionRange());
401403
assertEquals(currentVersion.toString(), upgrades[0].getUpgradedVersion());
402404
}
405+
406+
@Test
407+
public void testCalculateUpgradePath42010to42100() {
408+
409+
final CloudStackVersion dbVersion = CloudStackVersion.parse("4.20.1.0");
410+
assertNotNull(dbVersion);
411+
412+
final CloudStackVersion currentVersion = CloudStackVersion.parse("4.21.0.0");
413+
assertNotNull(currentVersion);
414+
415+
final DatabaseUpgradeChecker checker = new DatabaseUpgradeChecker();
416+
final DbUpgrade[] upgrades = checker.calculateUpgradePath(dbVersion, currentVersion);
417+
418+
assertNotNull(upgrades);
419+
assertEquals(3, upgrades.length);
420+
assertTrue(upgrades[0] instanceof Upgrade42020to42030);
421+
assertTrue(upgrades[1] instanceof Upgrade42030to42040);
422+
assertTrue(upgrades[2] instanceof Upgrade42040to42100);
423+
assertEquals(currentVersion.toString(), upgrades[2].getUpgradedVersion());
424+
}
403425
}

0 commit comments

Comments
 (0)