mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
CLOUDSTACK-10034: Use libvirt to create new volumes and not rados-java (#2039)
Since libvirt 1.2.2 libvirt will properly create volumes using RBD format 2. We can use libvirt to creates the volumes which strips a bit of code from the CloudStack Agent's responsbility. RBD format 2 is already used by all volumes created by CloudStack. This format is the most recent format of RBD and is still actively being developed. This removes the support for Ubuntu 12.04 as that does not have the proper libvirt version available. Signed-off-by: Wido den Hollander wido@widodh.nl We can use libvirt to creates the volumes which strips a bit of code from the CloudStack Agent's responsbility. RBD format 2 is already used by all volumes created by CloudStack. This format is the most recent format of RBD and is still actively being developed. This removes the support for Ubuntu 12.04 as that does not have the proper libvirt version available. Signed-off-by: Wido den Hollander <wido@widodh.nl>
This commit is contained in:
parent
6203013ec6
commit
2867080979
3
debian/control
vendored
3
debian/control
vendored
@ -22,7 +22,8 @@ Description: CloudStack server library
|
||||
|
||||
Package: cloudstack-agent
|
||||
Architecture: all
|
||||
Depends: ${python:Depends}, openjdk-8-jre-headless | java8-runtime-headless | java8-runtime, cloudstack-common (= ${source:Version}), lsb-base (>= 4.0), libcommons-daemon-java, openssh-client, qemu-kvm (>= 1.0), libvirt-bin (>= 0.9.8), uuid-runtime, iproute, ebtables, vlan, jsvc, ipset, python-libvirt, ethtool, iptables, lsb-release, init-system-helpers (>= 1.14~)
|
||||
Depends: ${python:Depends}, openjdk-8-jre-headless | java8-runtime-headless | java8-runtime, cloudstack-common (= ${source:Version}), lsb-base (>= 4.0), libcommons-daemon-java, openssh-client, qemu-kvm (>= 1.0), libvirt-bin (>= 1.2.2), uuid-runtime, iproute, ebtables, vlan, jsvc, ipset, python-libvirt, ethtool, iptables, lsb-release, init-system-helpers (>= 1.14~)
|
||||
Recommends: init-system-helpers
|
||||
Conflicts: cloud-agent, cloud-agent-libs, cloud-agent-deps, cloud-agent-scripts
|
||||
Description: CloudStack agent
|
||||
The CloudStack agent is in charge of managing shared computing resources in
|
||||
|
||||
@ -659,25 +659,25 @@ public class LibvirtStorageAdaptor implements StorageAdaptor {
|
||||
s_logger.info("Attempting to create volume " + name + " (" + pool.getType().toString() + ") in pool "
|
||||
+ pool.getUuid() + " with size " + size);
|
||||
|
||||
switch (pool.getType()){
|
||||
case RBD:
|
||||
return createPhysicalDiskOnRBD(name, pool, format, provisioningType, size);
|
||||
case NetworkFilesystem:
|
||||
case Filesystem:
|
||||
switch (format){
|
||||
case QCOW2:
|
||||
return createPhysicalDiskByQemuImg(name, pool, format, provisioningType, size);
|
||||
case RAW:
|
||||
return createPhysicalDiskByQemuImg(name, pool, format, provisioningType, size);
|
||||
case DIR:
|
||||
return createPhysicalDiskByLibVirt(name, pool, format, provisioningType, size);
|
||||
case TAR:
|
||||
switch (pool.getType()) {
|
||||
case RBD:
|
||||
return createPhysicalDiskByLibVirt(name, pool, format, provisioningType, size);
|
||||
case NetworkFilesystem:
|
||||
case Filesystem:
|
||||
switch (format) {
|
||||
case QCOW2:
|
||||
return createPhysicalDiskByQemuImg(name, pool, format, provisioningType, size);
|
||||
case RAW:
|
||||
return createPhysicalDiskByQemuImg(name, pool, format, provisioningType, size);
|
||||
case DIR:
|
||||
return createPhysicalDiskByLibVirt(name, pool, format, provisioningType, size);
|
||||
case TAR:
|
||||
return createPhysicalDiskByLibVirt(name, pool, format, provisioningType, size);
|
||||
default:
|
||||
throw new CloudRuntimeException("Unexpected disk format is specified.");
|
||||
}
|
||||
default:
|
||||
throw new CloudRuntimeException("Unexpected disk format is specified.");
|
||||
}
|
||||
default:
|
||||
return createPhysicalDiskByLibVirt(name, pool, format, provisioningType, size);
|
||||
return createPhysicalDiskByLibVirt(name, pool, format, provisioningType, size);
|
||||
}
|
||||
}
|
||||
|
||||
@ -748,50 +748,6 @@ public class LibvirtStorageAdaptor implements StorageAdaptor {
|
||||
return disk;
|
||||
}
|
||||
|
||||
private KVMPhysicalDisk createPhysicalDiskOnRBD(String name, KVMStoragePool pool,
|
||||
PhysicalDiskFormat format, Storage.ProvisioningType provisioningType, long size) {
|
||||
String volPath = null;
|
||||
|
||||
/**
|
||||
* To have RBD function properly we want RBD images of format 2
|
||||
* libvirt currently defaults to format 1
|
||||
*
|
||||
* This has been fixed in libvirt 1.2.2, but that's not upstream
|
||||
* in all distributions
|
||||
*
|
||||
* For that reason we use the native RBD bindings to create the
|
||||
* RBD image until libvirt creates RBD format 2 by default
|
||||
*/
|
||||
|
||||
try {
|
||||
s_logger.info("Creating RBD image " + pool.getSourceDir() + "/" + name + " with size " + size);
|
||||
|
||||
Rados r = new Rados(pool.getAuthUserName());
|
||||
r.confSet("mon_host", pool.getSourceHost() + ":" + pool.getSourcePort());
|
||||
r.confSet("key", pool.getAuthSecret());
|
||||
r.confSet("client_mount_timeout", "30");
|
||||
r.connect();
|
||||
s_logger.debug("Succesfully connected to Ceph cluster at " + r.confGet("mon_host"));
|
||||
|
||||
IoCTX io = r.ioCtxCreate(pool.getSourceDir());
|
||||
Rbd rbd = new Rbd(io);
|
||||
rbd.create(name, size, rbdFeatures, rbdOrder);
|
||||
|
||||
r.ioCtxDestroy(io);
|
||||
} catch (RadosException e) {
|
||||
throw new CloudRuntimeException(e.toString());
|
||||
} catch (RbdException e) {
|
||||
throw new CloudRuntimeException(e.toString());
|
||||
}
|
||||
|
||||
volPath = pool.getSourceDir() + "/" + name;
|
||||
KVMPhysicalDisk disk = new KVMPhysicalDisk(volPath, name, pool);
|
||||
disk.setFormat(PhysicalDiskFormat.RAW);
|
||||
disk.setSize(size);
|
||||
disk.setVirtualSize(size);
|
||||
return disk;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean connectPhysicalDisk(String name, KVMStoragePool pool, Map<String, String> details) {
|
||||
// this is for managed storage that needs to prep disks prior to use
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user