I have read cloudbase-init source code, I found it will work until "HKEY_LOCAL_MACHINE\\SYSTEM\\Setup\\Status\\SysprepStatus" is 7. This may be cause some problem:
sysprep process:
finish making image,then run sysprep.exe /oobe /generalize /shutdown /unattend:path-------->boot instance from this image----->sysprep will work(find device,and install device driver,then set SysprepStatus 7)------------>sysprep do other things,then reboot vm--------->finish user settings------->login interface
because I have installed cloudbase-init, it start when SysprepStatus is 7, In this moment, sysprep is working and cloudbase-init is working too, when cloudbase-init finish running sethostname plugin, it will reboot vm, but this moment, sysprep is doing important system setting. So the VM will crash.
I propose a way to solve this problem, set a flag in a flag_file, if flag_file is not exist or the content is 0, cloudbase-init should not run. set the flag 1, and cloudbase-init stop. if flag is 1, It can work. I have modify the source code:
def wait_for_boot_complete(self):
path = CONF.sysprep_status_path
print path
I have read cloudbase-init source code, I found it will work until "HKEY_LOCAL_ MACHINE\ \SYSTEM\ \Setup\ \Status\ \SysprepStatus" is 7. This may be cause some problem:
sysprep process: path--- ----->boot instance from this image----->sysprep will work(find device,and install device driver,then set SysprepStatus 7)----- ------- >sysprep do other things,then reboot vm--------->finish user settings- ------> login interface
finish making image,then run sysprep.exe /oobe /generalize /shutdown /unattend:
because I have installed cloudbase-init, it start when SysprepStatus is 7, In this moment, sysprep is working and cloudbase-init is working too, when cloudbase-init finish running sethostname plugin, it will reboot vm, but this moment, sysprep is doing important system setting. So the VM will crash.
I propose a way to solve this problem, set a flag in a flag_file, if flag_file is not exist or the content is 0, cloudbase-init should not run. set the flag 1, and cloudbase-init stop. if flag is 1, It can work. I have modify the source code: boot_complete( self): status_ path
def wait_for_
path = CONF.sysprep_
print path
is_exist = os.path. exists( path)
os.write( fp, "1")
LOG.warning( e)
finally:
os.close( fp)
data = os.read(fp, 1)
LOG.warning( e)
return -1
if not is_exist:
try:
fp = os.open(path, os.O_CREAT | os.O_RDWR)
except Exception, e:
return -1
else:
try:
fp = os.open(path, os.O_RDWR)
except Exception, e:
if data == "0":
os.lseek( fp,0,0)
os.write( fp, "1")
os.close( fp)
return -1
os.close( fp)
else: