Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,12 @@ public String toString() {
}
if (_poolType == PoolType.RBD) {
storagePoolBuilder.append("<source>\n");
storagePoolBuilder.append("<host name='" + _sourceHost + "' port='" + _sourcePort + "'/>\n");
if (_sourcePort > 0) {
storagePoolBuilder.append("<host name='" + _sourceHost + "' port='" + _sourcePort + "'/>\n");
} else {
storagePoolBuilder.append("<host name='" + _sourceHost + "'/>\n");
}

storagePoolBuilder.append("<name>" + _sourceDir + "</name>\n");
if (_authUsername != null) {
storagePoolBuilder.append("<auth username='" + _authUsername + "' type='" + _authType + "'>\n");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public static String RBDStringBuilder(String monHost, int monPort, String authUs

rbdOpts = "rbd:" + image;
rbdOpts += ":mon_host=" + monHost;
if (monPort != 6789) {
if (monPort > 0) {
rbdOpts += "\\\\:" + monPort;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this double escape seems to byte us now ;P during release of 4.15

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@wido @weizhouapache can you comment on if this is the only issue?

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,4 +81,25 @@ public void testRbdStoragePool() {

assertEquals(expectedXml, pool.toString());
}
}

public void testRbdStoragePoolWithoutPort() {
PoolType type = PoolType.RBD;
String name = "myRBDPool";
String uuid = "30a5fb6f-7277-44ce-9065-67e2bfdb0ebb";
String host = "::1";
String dir = "rbd";
String authUsername = "admin";
String secretUuid = "d0d616dd-3446-409e-84d7-44465e325b35";
AuthenticationType auth = AuthenticationType.CEPH;
int port = 0;

LibvirtStoragePoolDef pool = new LibvirtStoragePoolDef(type, name, uuid, host, port, dir, authUsername, auth, secretUuid);

String expectedXml = "<pool type='" + type.toString() + "'>\n<name>" + name + "</name>\n<uuid>" + uuid + "</uuid>\n" +
"<source>\n<host name='" + host + "'/>\n<name>" + dir + "</name>\n" +
"<auth username='" + authUsername + "' type='" + auth.toString() + "'>\n<secret uuid='" + secretUuid + "'/>\n" +
"</auth>\n</source>\n</pool>\n";

assertEquals(expectedXml, pool.toString());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ public DataStore initialize(Map<String, Object> dsInfos) {
parameters.setPath(hostPath.replaceFirst("/", ""));
} else if (scheme.equalsIgnoreCase("rbd")) {
if (port == -1) {
port = 6789;
port = 0;
}
parameters.setType(StoragePoolType.RBD);
parameters.setHost(storageHost);
Expand Down