Finally, I modify configdrive.py to dismount CDROM, and tested in windows 2016 Std server.
Update: just tested windows 2012 R2, also work.
C:\Program Files\Cloudbase Solutions\Cloudbase-Init\Python\Lib\site-packages\cloudbaseinit\metadata\services\configdrive.py
import os
import shutil
+import ctypes
... ...
def cleanup(self):
LOG.debug('Deleting metadata folder: %r', self._mgr.target_path)
shutil.rmtree(self._mgr.target_path, ignore_errors=True)
self._metadata_path = None
+ drive_letter = os.popen('wmic logicaldisk where VolumeName="config-2" get Caption | findstr /I ":"').read()
+ if drive_letter:
+ LOG.debug('Eject metadata drive: %s', str(drive_letter).rstrip())
+ ctypes.windll.WINMM.mciSendStringW(u"open " + str(drive_letter).rstrip() + " type cdaudio alias d_drive", None, 0, None)
+ ctypes.windll.WINMM.mciSendStringW(u"set d_drive door open", None, 0, None)