@@ -960,17 +960,55 @@ public boolean deleteStoragePool(String uuid) {
960960 }
961961 }
962962
963+ /**
964+ * Creates a physical disk depending on the {@link StoragePoolType}:
965+ * <ul>
966+ * <li>
967+ * <b>{@link StoragePoolType#RBD}</b>
968+ * <ul>
969+ * <li>
970+ * If it is an erasure code pool, utilizes QemuImg to create the physical disk through the method
971+ * {@link LibvirtStorageAdaptor#createPhysicalDiskByQemuImg(String, KVMStoragePool, PhysicalDiskFormat, Storage.ProvisioningType, long, byte[])}
972+ * </li>
973+ * <li>
974+ * Otherwise, utilize Libvirt to create the physical disk through the method
975+ * {@link LibvirtStorageAdaptor#createPhysicalDiskByLibVirt(String, KVMStoragePool, PhysicalDiskFormat, Storage.ProvisioningType, long)}
976+ * </li>
977+ * </ul>
978+ * </li>
979+ * <li>
980+ * {@link StoragePoolType#NetworkFilesystem} and {@link StoragePoolType#Filesystem}
981+ * <ul>
982+ * <li>
983+ * If the format is {@link PhysicalDiskFormat#QCOW2} or {@link PhysicalDiskFormat#RAW}, utilizes QemuImg to create the physical disk through the method
984+ * {@link LibvirtStorageAdaptor#createPhysicalDiskByQemuImg(String, KVMStoragePool, PhysicalDiskFormat, Storage.ProvisioningType, long, byte[])}
985+ * </li>
986+ * <li>
987+ * If the format is {@link PhysicalDiskFormat#DIR} or {@link PhysicalDiskFormat#TAR}, utilize Libvirt to create the physical disk through the method
988+ * {@link LibvirtStorageAdaptor#createPhysicalDiskByLibVirt(String, KVMStoragePool, PhysicalDiskFormat, Storage.ProvisioningType, long)}
989+ * </li>
990+ * </ul>
991+ * </li>
992+ * <li>
993+ * For the rest of the {@link StoragePoolType} types, utilizes the Libvirt method
994+ * {@link LibvirtStorageAdaptor#createPhysicalDiskByLibVirt(String, KVMStoragePool, PhysicalDiskFormat, Storage.ProvisioningType, long)}
995+ * </li>
996+ * </ul>
997+ */
963998 @ Override
964999 public KVMPhysicalDisk createPhysicalDisk (String name , KVMStoragePool pool ,
9651000 PhysicalDiskFormat format , Storage .ProvisioningType provisioningType , long size , byte [] passphrase ) {
9661001
967- logger .info ("Attempting to create volume " + name + " (" + pool .getType ().toString () + ") in pool "
968- + pool .getUuid () + " with size " + toHumanReadableSize (size ));
1002+ logger .info ("Attempting to create volume {} ({}) in pool {} with size {}" , name , pool .getType ().toString (), pool .getUuid (), toHumanReadableSize (size ));
9691003
9701004 StoragePoolType poolType = pool .getType ();
971- if (poolType .equals (StoragePoolType .RBD )) {
972- return createPhysicalDiskByQemuImg (name , pool , PhysicalDiskFormat .RAW , provisioningType , size , passphrase );
973- } else if (poolType .equals (StoragePoolType .NetworkFilesystem ) || poolType .equals (StoragePoolType .Filesystem )) {
1005+ if (StoragePoolType .RBD .equals (poolType )) {
1006+ Map <String , String > details = pool .getDetails ();
1007+ String dataPool = (details == null ) ? null : details .get (KVMPhysicalDisk .RBD_DEFAULT_DATA_POOL );
1008+
1009+ return (dataPool == null ) ? createPhysicalDiskByLibVirt (name , pool , PhysicalDiskFormat .RAW , provisioningType , size ) :
1010+ createPhysicalDiskByQemuImg (name , pool , PhysicalDiskFormat .RAW , provisioningType , size , passphrase );
1011+ } else if (StoragePoolType .NetworkFilesystem .equals (poolType ) || StoragePoolType .Filesystem .equals (poolType )) {
9741012 switch (format ) {
9751013 case QCOW2 :
9761014 case RAW :
0 commit comments