@@ -859,17 +859,55 @@ public boolean deleteStoragePool(String uuid) {
859859 }
860860 }
861861
862+ /**
863+ * Creates a physical disk depending on the {@link StoragePoolType}:
864+ * <ul>
865+ * <li>
866+ * <b>{@link StoragePoolType#RBD}</b>
867+ * <ul>
868+ * <li>
869+ * If it is an erasure code pool, utilizes QemuImg to create the physical disk through the method
870+ * {@link LibvirtStorageAdaptor#createPhysicalDiskByQemuImg(String, KVMStoragePool, PhysicalDiskFormat, Storage.ProvisioningType, long, byte[])}
871+ * </li>
872+ * <li>
873+ * Otherwise, utilize Libvirt to create the physical disk through the method
874+ * {@link LibvirtStorageAdaptor#createPhysicalDiskByLibVirt(String, KVMStoragePool, PhysicalDiskFormat, Storage.ProvisioningType, long)}
875+ * </li>
876+ * </ul>
877+ * </li>
878+ * <li>
879+ * {@link StoragePoolType#NetworkFilesystem} and {@link StoragePoolType#Filesystem}
880+ * <ul>
881+ * <li>
882+ * If the format is {@link PhysicalDiskFormat#QCOW2} or {@link PhysicalDiskFormat#RAW}, utilizes QemuImg to create the physical disk through the method
883+ * {@link LibvirtStorageAdaptor#createPhysicalDiskByQemuImg(String, KVMStoragePool, PhysicalDiskFormat, Storage.ProvisioningType, long, byte[])}
884+ * </li>
885+ * <li>
886+ * If the format is {@link PhysicalDiskFormat#DIR} or {@link PhysicalDiskFormat#TAR}, utilize Libvirt to create the physical disk through the method
887+ * {@link LibvirtStorageAdaptor#createPhysicalDiskByLibVirt(String, KVMStoragePool, PhysicalDiskFormat, Storage.ProvisioningType, long)}
888+ * </li>
889+ * </ul>
890+ * </li>
891+ * <li>
892+ * For the rest of the {@link StoragePoolType} types, utilizes the Libvirt method
893+ * {@link LibvirtStorageAdaptor#createPhysicalDiskByLibVirt(String, KVMStoragePool, PhysicalDiskFormat, Storage.ProvisioningType, long)}
894+ * </li>
895+ * </ul>
896+ */
862897 @ Override
863898 public KVMPhysicalDisk createPhysicalDisk (String name , KVMStoragePool pool ,
864899 PhysicalDiskFormat format , Storage .ProvisioningType provisioningType , long size , byte [] passphrase ) {
865900
866- logger .info ("Attempting to create volume " + name + " (" + pool .getType ().toString () + ") in pool "
867- + pool .getUuid () + " with size " + toHumanReadableSize (size ));
901+ logger .info ("Attempting to create volume {} ({}) in pool {} with size {}" , name , pool .getType ().toString (), pool .getUuid (), toHumanReadableSize (size ));
868902
869903 StoragePoolType poolType = pool .getType ();
870- if (poolType .equals (StoragePoolType .RBD )) {
871- return createPhysicalDiskByQemuImg (name , pool , PhysicalDiskFormat .RAW , provisioningType , size , passphrase );
872- } else if (poolType .equals (StoragePoolType .NetworkFilesystem ) || poolType .equals (StoragePoolType .Filesystem )) {
904+ if (StoragePoolType .RBD .equals (poolType )) {
905+ Map <String , String > details = pool .getDetails ();
906+ String dataPool = (details == null ) ? null : details .get (KVMPhysicalDisk .RBD_DEFAULT_DATA_POOL );
907+
908+ return (dataPool == null ) ? createPhysicalDiskByLibVirt (name , pool , PhysicalDiskFormat .RAW , provisioningType , size ) :
909+ createPhysicalDiskByQemuImg (name , pool , PhysicalDiskFormat .RAW , provisioningType , size , passphrase );
910+ } else if (StoragePoolType .NetworkFilesystem .equals (poolType ) || StoragePoolType .Filesystem .equals (poolType )) {
873911 switch (format ) {
874912 case QCOW2 :
875913 case RAW :
0 commit comments