update default platform in APICreateRootVolumeTemplateFromRootVolumeMsg
fixes:
@@ -4,6 +4,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.zstack.core.cloudbus.CloudBus;
import org.zstack.core.componentloader.PluginRegistry;
import org.zstack.core.db.DatabaseFacade;
+import org.zstack.core.db.Q;
import org.zstack.core.db.SimpleQuery;
import org.zstack.core.db.SimpleQuery.Op;
import org.zstack.core.errorcode.ErrorFacade;
@@ -16,6 +17,8 @@ import org.zstack.header.storage.backup.BackupStorageState;
import org.zstack.header.storage.backup.BackupStorageStatus;
import org.zstack.header.storage.backup.BackupStorageVO;
import org.zstack.header.storage.backup.BackupStorageVO_;
+import org.zstack.header.vm.VmInstanceVO;
+import org.zstack.header.vm.VmInstanceVO_;
import org.zstack.header.volume.VolumeFormat;
import org.zstack.header.volume.VolumeState;
import org.zstack.header.volume.VolumeStatus;
@@ -91,7 +94,8 @@ public class ImageApiInterceptor implements ApiMessageInterceptor {
private void validate(APICreateRootVolumeTemplateFromRootVolumeMsg msg) {
if (msg.getPlatform() == null) {
- msg.setPlatform(ImagePlatform.Linux.toString());
+ String platform = Q.New(VmInstanceVO.class).eq(VmInstanceVO_.rootVolumeUuid, msg.getRootVolumeUuid()).select(VmInstanceVO_.platform).findValue();
+ msg.setPlatform(platform == null ? ImagePlatform.Linux.toString() : platform);
}
}
