Skip to content

Commit c3554ec

Browse files
authored
kvm: For ceph only if a port number has been specified define in the XML (apache#4231)
Ceph used to use port 6789 (no need to specify it), but with the messenger v2 from Ceph it switched to port 3300 while 6789 still works. librados/librbd/libvirt will automatically figure out the ports to use if none is specified. Therefor there is no need for CloudStack to explicitely define the port in the XML passed to Libvirt or Qemu. Leave blank if no port number has been defined by the user.
1 parent 9ae1170 commit c3554ec

4 files changed

Lines changed: 30 additions & 4 deletions

File tree

plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/resource/LibvirtStoragePoolDef.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,12 @@ public String toString() {
147147
}
148148
if (_poolType == PoolType.RBD) {
149149
storagePoolBuilder.append("<source>\n");
150-
storagePoolBuilder.append("<host name='" + _sourceHost + "' port='" + _sourcePort + "'/>\n");
150+
if (_sourcePort > 0) {
151+
storagePoolBuilder.append("<host name='" + _sourceHost + "' port='" + _sourcePort + "'/>\n");
152+
} else {
153+
storagePoolBuilder.append("<host name='" + _sourceHost + "'/>\n");
154+
}
155+
151156
storagePoolBuilder.append("<name>" + _sourceDir + "</name>\n");
152157
if (_authUsername != null) {
153158
storagePoolBuilder.append("<auth username='" + _authUsername + "' type='" + _authType + "'>\n");

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public static String RBDStringBuilder(String monHost, int monPort, String authUs
2828

2929
rbdOpts = "rbd:" + image;
3030
rbdOpts += ":mon_host=" + monHost;
31-
if (monPort != 6789) {
31+
if (monPort > 0) {
3232
rbdOpts += "\\\\:" + monPort;
3333
}
3434

plugins/hypervisors/kvm/src/test/java/com/cloud/hypervisor/kvm/resource/LibvirtStoragePoolDefTest.java

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,4 +81,25 @@ public void testRbdStoragePool() {
8181

8282
assertEquals(expectedXml, pool.toString());
8383
}
84-
}
84+
85+
public void testRbdStoragePoolWithoutPort() {
86+
PoolType type = PoolType.RBD;
87+
String name = "myRBDPool";
88+
String uuid = "30a5fb6f-7277-44ce-9065-67e2bfdb0ebb";
89+
String host = "::1";
90+
String dir = "rbd";
91+
String authUsername = "admin";
92+
String secretUuid = "d0d616dd-3446-409e-84d7-44465e325b35";
93+
AuthenticationType auth = AuthenticationType.CEPH;
94+
int port = 0;
95+
96+
LibvirtStoragePoolDef pool = new LibvirtStoragePoolDef(type, name, uuid, host, port, dir, authUsername, auth, secretUuid);
97+
98+
String expectedXml = "<pool type='" + type.toString() + "'>\n<name>" + name + "</name>\n<uuid>" + uuid + "</uuid>\n" +
99+
"<source>\n<host name='" + host + "'/>\n<name>" + dir + "</name>\n" +
100+
"<auth username='" + authUsername + "' type='" + auth.toString() + "'>\n<secret uuid='" + secretUuid + "'/>\n" +
101+
"</auth>\n</source>\n</pool>\n";
102+
103+
assertEquals(expectedXml, pool.toString());
104+
}
105+
}

plugins/storage/volume/default/src/main/java/org/apache/cloudstack/storage/datastore/lifecycle/CloudStackPrimaryDataStoreLifeCycleImpl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ public DataStore initialize(Map<String, Object> dsInfos) {
242242
parameters.setPath(hostPath.replaceFirst("/", ""));
243243
} else if (scheme.equalsIgnoreCase("rbd")) {
244244
if (port == -1) {
245-
port = 6789;
245+
port = 0;
246246
}
247247
parameters.setType(StoragePoolType.RBD);
248248
parameters.setHost(storageHost);

0 commit comments

Comments
 (0)