@@ -799,6 +799,7 @@ private Boolean isCephPrimaryStorageVolume(String volumeUuid) {
799799 public void preCreateVmInstance (CreateVmInstanceMsg msg ) {
800800 settingRootVolume (msg );
801801 settingDataVolume (msg );
802+ settingDataDisks (msg );
802803 }
803804
804805 private void settingRootVolume (CreateVmInstanceMsg msg ) {
@@ -909,15 +910,48 @@ private void settingDataVolume(CreateVmInstanceMsg msg) {
909910
910911 if (config .getAllocate ().getPrimaryStorage () instanceof CephPrimaryStorageAllocateConfig ) {
911912 CephPrimaryStorageAllocateConfig primaryStorageAllocateConfig = (CephPrimaryStorageAllocateConfig ) config .getAllocate ().getPrimaryStorage ();
912- msg .getDataVolumeSystemTags ().add (CephSystemTags .USE_CEPH_PRIMARY_STORAGE_POOL .instantiateTag (
913- map (
914- e (CephSystemTags .USE_CEPH_PRIMARY_STORAGE_POOL_TOKEN , primaryStorageAllocateConfig .getPoolNames ().get (0 ))
915- )
916- ));
913+ if (!isEmpty (primaryStorageAllocateConfig .getPoolNames ())) {
914+ msg .getDataVolumeSystemTags ().add (CephSystemTags .USE_CEPH_PRIMARY_STORAGE_POOL .instantiateTag (
915+ map (
916+ e (CephSystemTags .USE_CEPH_PRIMARY_STORAGE_POOL_TOKEN , primaryStorageAllocateConfig .getPoolNames ().get (0 ))
917+ )
918+ ));
919+ }
917920 }
918921 }
919922 }
920923
924+ private void settingDataDisks (CreateVmInstanceMsg msg ) {
925+ List <DiskAO > diskAOs = msg .getDataDisks ();
926+ if (diskAOs == null ) {
927+ return ;
928+ }
929+ for (DiskAO diskAO : diskAOs ) {
930+ String diskOffering = diskAO .getDiskOfferingUuid ();
931+ if (diskOffering == null || !DiskOfferingSystemTags .DISK_OFFERING_USER_CONFIG .hasTag (diskOffering )) {
932+ continue ;
933+ }
934+ DiskOfferingUserConfig config = OfferingUserConfigUtils .getDiskOfferingConfig (diskOffering , DiskOfferingUserConfig .class );
935+ if (config .getAllocate () == null ) {
936+ continue ;
937+ }
938+
939+ if (diskAO .getSystemTags () == null ) {
940+ diskAO .setSystemTags (new ArrayList <>());
941+ }
942+
943+ if (config .getAllocate ().getPrimaryStorage () instanceof CephPrimaryStorageAllocateConfig ) {
944+ CephPrimaryStorageAllocateConfig primaryStorageAllocateConfig = (CephPrimaryStorageAllocateConfig ) config .getAllocate ().getPrimaryStorage ();
945+ if (!isEmpty (primaryStorageAllocateConfig .getPoolNames ())) {
946+ diskAO .getSystemTags ().add (CephSystemTags .USE_CEPH_PRIMARY_STORAGE_POOL .instantiateTag (
947+ map (
948+ e (CephSystemTags .USE_CEPH_PRIMARY_STORAGE_POOL_TOKEN , primaryStorageAllocateConfig .getPoolNames ().get (0 ))
949+ )
950+ ));
951+ }
952+ }
953+ }
954+ }
921955 @ Override
922956 public void preCreateVolume (VolumeCreateMessage msg ) {
923957 String diskOffering = msg .getDiskOfferingUuid ();
0 commit comments