}
private StoragePool createRBDStoragePool(Connect conn, String uuid, String host, int port, String userInfo, String path) {
LibvirtStoragePoolDef spd;
StoragePool sp = null;
Secret s = null;
String[] userInfoTemp = userInfo.split(":");
if (userInfoTemp.length == 2) {
LibvirtSecretDef sd = new LibvirtSecretDef(usage.CEPH, uuid);
sd.setCephName(userInfoTemp[0] + "@" + host + ":" + port + "/" + path);
try {
s_logger.debug(sd.toString());
s = conn.secretDefineXML(sd.toString());
s.setValue(Base64.decodeBase64(userInfoTemp[1]));
} catch (LibvirtException e) {
s_logger.error("Failed to define the libvirt secret: " + e.toString());
if (s != null) {
try {
s.undefine();
s.free();
} catch (LibvirtException l) {
s_logger.debug("Failed to undefine the libvirt secret: " + l.toString());
}
}
return null;
}
spd = new LibvirtStoragePoolDef(poolType.RBD, uuid, uuid, host, port, path, userInfoTemp[0], authType.CEPH, uuid);
} else {
spd = new LibvirtStoragePoolDef(poolType.RBD, uuid, uuid, host, port, path, "");
}
try {
s_logger.debug(spd.toString());
sp = conn.storagePoolCreateXML(spd.toString(), 0);
return sp;
} catch (LibvirtException e) {
s_logger.debug("Failed to create RBD storage pool: " + e.toString());
if (sp != null) {
try {
if (sp.isPersistent() == 1) {
sp.destroy();
sp.undefine();
} else {
sp.destroy();
}
sp.free();
} catch (LibvirtException l) {
s_logger.debug("Failed to undefine RBD storage pool: " + l.toString());
}
}