Skip to content

Commit 4ff6cf3

Browse files
authored
Merge branch 'main' into service_offering_category_feature
2 parents 969debd + 2600965 commit 4ff6cf3

File tree

10 files changed

+40
-59
lines changed

10 files changed

+40
-59
lines changed

PRE-COMMIT.md renamed to PRE_COMMIT.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
# pre-commit
2121

2222
We run [pre-commit](https://pre-commit.com/) with
23-
[GitHub Actions](https://github.com/apache/cloudstack/blob/main/.github/workflows/linter.yml) so installation on your
23+
[GitHub Actions](https://github.com/apache/cloudstack/blob/main/.github/workflows/pre-commit.yml) so installation on your
2424
local machine is currently optional.
2525

2626
The `pre-commit` [configuration file](https://github.com/apache/cloudstack/blob/main/.pre-commit-config.yaml)

api/src/main/java/com/cloud/network/Networks.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ public <T> URI toUri(T value) {
7878
}
7979
@Override
8080
public String getValueFrom(URI uri) {
81-
return uri.getAuthority();
81+
return uri == null ? null : uri.getAuthority();
8282
}
8383
},
8484
Vswitch("vs", String.class), LinkLocal(null, null), Vnet("vnet", Long.class), Storage("storage", Integer.class), Lswitch("lswitch", String.class) {
@@ -96,7 +96,7 @@ public <T> URI toUri(T value) {
9696
*/
9797
@Override
9898
public String getValueFrom(URI uri) {
99-
return uri.getSchemeSpecificPart();
99+
return uri == null ? null : uri.getSchemeSpecificPart();
100100
}
101101
},
102102
Mido("mido", String.class), Pvlan("pvlan", String.class),
@@ -177,7 +177,7 @@ public <T> URI toUri(T value) {
177177
* @return the scheme as BroadcastDomainType
178178
*/
179179
public static BroadcastDomainType getSchemeValue(URI uri) {
180-
return toEnumValue(uri.getScheme());
180+
return toEnumValue(uri == null ? null : uri.getScheme());
181181
}
182182

183183
/**
@@ -191,7 +191,7 @@ public static BroadcastDomainType getTypeOf(String str) throws URISyntaxExceptio
191191
if (com.cloud.dc.Vlan.UNTAGGED.equalsIgnoreCase(str)) {
192192
return Native;
193193
}
194-
return getSchemeValue(new URI(str));
194+
return getSchemeValue(str == null ? null : new URI(str));
195195
}
196196

197197
/**
@@ -220,7 +220,7 @@ public static BroadcastDomainType toEnumValue(String scheme) {
220220
* @return the host part as String
221221
*/
222222
public String getValueFrom(URI uri) {
223-
return uri.getHost();
223+
return uri == null ? null : uri.getHost();
224224
}
225225

226226
/**
@@ -243,7 +243,7 @@ public static String getValue(URI uri) {
243243
* @throws URISyntaxException the string is not even an uri
244244
*/
245245
public static String getValue(String uriString) throws URISyntaxException {
246-
return getValue(new URI(uriString));
246+
return getValue(uriString == null ? null : new URI(uriString));
247247
}
248248

249249
/**

api/src/test/java/com/cloud/network/NetworksTest.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,24 @@ public class NetworksTest {
3737
public void setUp() {
3838
}
3939

40+
@Test
41+
public void nullBroadcastDomainTypeTest() throws URISyntaxException {
42+
BroadcastDomainType type = BroadcastDomainType.getTypeOf(null);
43+
Assert.assertEquals("a null uri should mean a broadcasttype of undecided", BroadcastDomainType.UnDecided, type);
44+
}
45+
46+
@Test
47+
public void nullBroadcastDomainTypeValueTest() {
48+
URI uri = null;
49+
Assert.assertNull(BroadcastDomainType.getValue(uri));
50+
}
51+
52+
@Test
53+
public void nullBroadcastDomainTypeStringValueTest() throws URISyntaxException {
54+
String uriString = null;
55+
Assert.assertNull(BroadcastDomainType.getValue(uriString));
56+
}
57+
4058
@Test
4159
public void emptyBroadcastDomainTypeTest() throws URISyntaxException {
4260
BroadcastDomainType type = BroadcastDomainType.getTypeOf("");

engine/schema/src/main/resources/META-INF/db/schema-42200to42300-cleanup.sql

Lines changed: 0 additions & 20 deletions
This file was deleted.

engine/schema/src/main/resources/META-INF/db/schema-42210to42300-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.22.1.0 to 4.22.3.0
19+
-- Schema upgrade cleanup from 4.22.1.0 to 4.23.0.0
2020
--;

plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/storage/LibvirtStorageAdaptor.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1689,7 +1689,11 @@ to support snapshots(backuped) as qcow2 files. */
16891689
*/
16901690
srcFile = new QemuImgFile(KVMPhysicalDisk.RBDStringBuilder(srcPool, sourcePath));
16911691
srcFile.setFormat(sourceFormat);
1692-
destFile = new QemuImgFile(destPath);
1692+
if (destPool.getType() == StoragePoolType.RBD) {
1693+
destFile = new QemuImgFile(KVMPhysicalDisk.RBDStringBuilder(destPool, destPath));
1694+
} else {
1695+
destFile = new QemuImgFile(destPath);
1696+
}
16931697
destFile.setFormat(destFormat);
16941698

16951699
try {

plugins/storage/volume/scaleio/src/main/java/org/apache/cloudstack/storage/datastore/api/VTreeMigrationInfo.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ public MigrationStatus getMigrationStatus() {
5959
}
6060

6161
public void setMigrationStatus(String migrationStatus) {
62-
this.migrationStatus = EnumUtils.fromString(MigrationStatus.class, migrationStatus, MigrationStatus.None);
62+
this.migrationStatus = EnumUtils.getEnumIgnoreCase(MigrationStatus.class, migrationStatus, MigrationStatus.None);
6363
}
6464

6565
public void setMigrationStatus(MigrationStatus migrationStatus) {

server/src/main/java/com/cloud/api/ApiDBUtils.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1767,7 +1767,7 @@ public static String findJobInstanceUuid(AsyncJob job) {
17671767
return null;
17681768
}
17691769
String jobInstanceId = null;
1770-
ApiCommandResourceType jobInstanceType = EnumUtils.fromString(ApiCommandResourceType.class, job.getInstanceType(), ApiCommandResourceType.None);
1770+
ApiCommandResourceType jobInstanceType = EnumUtils.getEnumIgnoreCase(ApiCommandResourceType.class, job.getInstanceType(), ApiCommandResourceType.None);
17711771

17721772
if (job.getInstanceId() == null) {
17731773
// when assert is hit, implement 'getInstanceId' of BaseAsyncCmd and return appropriate instance id

ui/src/views/AutogenView.vue

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1997,8 +1997,13 @@ export default {
19971997
},
19981998
onSearch (opts) {
19991999
const query = Object.assign({}, this.$route.query)
2000-
const searchFilters = this.$route?.meta?.searchFilters || []
2001-
searchFilters.forEach(key => delete query[key])
2000+
let searchFilters = this.$route?.meta?.searchFilters || []
2001+
if (typeof searchFilters === 'function') {
2002+
searchFilters = searchFilters()
2003+
}
2004+
if (Array.isArray(searchFilters)) {
2005+
searchFilters.forEach(key => delete query[key])
2006+
}
20022007
delete query.name
20032008
delete query.templatetype
20042009
delete query.keyword

utils/src/main/java/com/cloud/utils/EnumUtils.java

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -29,30 +29,4 @@ public static String listValues(Enum<?>[] enums) {
2929
b.append("]");
3030
return b.toString();
3131
}
32-
33-
public static <T extends Enum<T>> T fromString(Class<T> clz, String value, T defaultVal) {
34-
assert (clz != null);
35-
36-
if (value != null) {
37-
try {
38-
return Enum.valueOf(clz, value.trim());
39-
} catch (IllegalArgumentException ex) {
40-
assert (false);
41-
}
42-
}
43-
return defaultVal;
44-
}
45-
46-
public static <T extends Enum<T>> T fromString(Class<T> clz, String value) {
47-
assert (clz != null);
48-
49-
if (value != null) {
50-
try {
51-
return Enum.valueOf(clz, value.trim());
52-
} catch (IllegalArgumentException ex) {
53-
assert (false);
54-
}
55-
}
56-
return null;
57-
}
5832
}

0 commit comments

Comments
 (0)