Environmental statement:
OS windows2008r2
OpenStack Mitaka
This article modifies the host password by metadata injection method, in the cloud host with a change password, reset password script, to modify, reset the role of the cloud host password; Now the script that modifies and resets the password is a Python script, so this image requires Python to be installed in the image. Pywin32, as the result of the current test is that the Cloud-init in the Windows system, will only be initiated at the time of initialization, and then will not start again, so there is a password reset script, The script that resets the password generates a Reset-administrator system service in the system, which needs to modify the startup type to "delayed self-booting"; If any of the great gods see it, they want to be able to point twos.
Original link: http://readshlinux.blog.51cto.com/9322509/1902888
1. Installing a virtual machine in KVM
650) this.width=650; "Src=" https://s2.51cto.com/wyfs02/M01/8E/36/wKiom1i41BGB4qtvAADUxCM7Bk0127.png-wh_500x0-wm_ 3-wmp_4-s_1616061957.png "title=" clipboard (a). png "alt=" wkiom1i41bgb4qtvaaduxcm7bk0127.png-wh_50 "/>
650) this.width=650; "Src=" https://s5.51cto.com/wyfs02/M01/8E/34/wKioL1i41ELxgbAKAAGTHL8Rk7k795.png-wh_500x0-wm_ 3-wmp_4-s_2366953565.png "title=" clipboard (6). png "alt=" wkiol1i41elxgbakaagthl8rk7k795.png-wh_50 "/>
650) this.width=650; "Src=" https://s4.51cto.com/wyfs02/M02/8E/34/wKioL1i41HOB84RBAAF860LwDes439.png-wh_500x0-wm_ 3-wmp_4-s_2681214709.png "title=" clipboard. png "alt=" wkiol1i41hob84rbaaf860lwdes439.png-wh_50 "/>
Then start the installation
2. Virtual driver for virtual installation in KVM
Disconnect----> Mount Virtios-win.iso----> Install device driver
Install the following 3 will be OK
VioStor
Vioserial
Netkvm
650) this.width=650; "Src=" https://s2.51cto.com/wyfs02/M02/8E/34/wKioL1i41L_AEfZfAACSh35loPY518.png-wh_500x0-wm_ 3-wmp_4-s_2352333374.png "title=" Clipboard.png "alt=" Wkiol1i41l_aefzfaacsh35lopy518.png-wh_50 "/>
650) this.width=650; "Src=" https://s5.51cto.com/wyfs02/M02/8E/34/wKioL1i41cDCgM4FAAEsj40wfh0906.png-wh_500x0-wm_ 3-wmp_4-s_3329602567.png "title=" clipboard (2). png "alt=" wkiol1i41cdcgm4faaesj40wfh0906.png-wh_50 "/>
650) this.width=650; "Src=" https://s4.51cto.com/wyfs02/M00/8E/36/wKiom1i41jOhKdvdAAOSyvd4IP4700.png-wh_500x0-wm_ 3-wmp_4-s_3902999659.png "title=" clipboard (3). png "alt=" wkiom1i41johkdvdaaosyvd4ip4700.png-wh_50 "/>
650) this.width=650; "Src=" https://s4.51cto.com/wyfs02/M00/8E/34/wKioL1i41luymCFaAAAgkLjps04096.png-wh_500x0-wm_ 3-wmp_4-s_207586743.png "title=" clipboard. png "alt=" wkiol1i41luymcfaaaagkljps04096.png-wh_50 "/>
VioStor
Vioserial
Netkvm
650) this.width=650; "Src=" https://s2.51cto.com/wyfs02/M00/8E/34/wKioL1i41wXQBycBAAEACJwXCbY467.png-wh_500x0-wm_ 3-wmp_4-s_1939286199.png "title=" clipboard (1). png "alt=" wkiol1i41wxqbycbaaeacjwxcby467.png-wh_50 "/>
650) this.width=650; "Src=" https://s2.51cto.com/wyfs02/M01/8E/34/wKioL1i41yyQD4vbAAEhM-1aanU762.png-wh_500x0-wm_ 3-wmp_4-s_2274020920.png "title=" clipboard (7). png "alt=" wkiol1i41yyqd4vbaaehm-1aanu762.png-wh_50 "/>
Although the disk has occurred, but also need to install the driver of the network card, continue
650) this.width=650; "Src=" https://s4.51cto.com/wyfs02/M02/8E/34/wKioL1i411_CM-rAAAD6uGeYD-g191.png-wh_500x0-wm_ 3-wmp_4-s_85126186.png "title=" clipboard (5). png "alt=" wkiol1i411_cm-raaad6ugeyd-g191.png-wh_50 "/>
650) this.width=650; "Src=" https://s2.51cto.com/wyfs02/M02/8E/34/wKioL1i4143xb_nDAAEYf-XkFF0938.png-wh_500x0-wm_ 3-wmp_4-s_1497558028.png "title=" clipboard (Ten). png "alt=" wkiol1i4143xb_ndaaeyf-xkff0938.png-wh_50 "/>
3. Continue to install the system
disconnecting virtios-win.iso----> Windows.iso
650) this.width=650; "Src=" https://s5.51cto.com/wyfs02/M02/8E/36/wKiom1i418_jgCSOAACSh35loPY938.png-wh_500x0-wm_ 3-wmp_4-s_719081804.png "title=" Clipboard.png "alt=" Wkiom1i418_jgcsoaacsh35lopy938.png-wh_50 "/>
650) this.width=650; "Src=" https://s1.51cto.com/wyfs02/M01/8E/34/wKioL1i42BqgReoUAAM3DG2ZH8g413.png-wh_500x0-wm_ 3-wmp_4-s_1648982840.png "title=" clipboard (9). png "alt=" wkiol1i42bqgreouaam3dg2zh8g413.png-wh_50 "/>
After installing the system, you need to activate the system , turn on the Remote Desktop , add a script to reset the password (install Python, python32), First change the password script , Install the Cloud-init package for these operations
=============================================================================================================== =============================================================================================================== ===================================================
The key is to pass this information in.
1. Set up a shared folder on the Windows system
2. Mount a shared folder on a Linux system (KVM Host) that changes to a Windows system
Mount// windows_ip /gx/data/gx/-o username=administrator,password= [email protected]
3. Copy the appropriate information to a Linux system (KVM host) to mount a Windows shared directory disk
4. Copy information complete
5. Put this information in the right place in Windows
6. Finally uninstall the Linux system mounted Windows shared folder
umount/data/gx/
7. Delete the shared folders in Windows (do not leave the information that should not be left in the system)
8. Activate the Windows system, install the incoming Python installer, and add Python to the system environment variable (execute python directly in CMD to see if it will go into the Pythonide interface), and finally install the "reset26 Reset password" service, I copied directly to the Python installation directory, then explained the cmd command into the Reset directory, execute the python reset26.py install installation Reset Service
Reset Password Script
The script will appear in the Windows Services service, a system service named Reset-administrator, note that he must be set to boot delay, or reset the password;
===========================================================================================
#!/usr/bin/env python#coding:utf8import osimport jsonimport urllibimport Win32serviceutilimport win32serviceimport win32eventdef get_data ():d ata = Urllib.urlopen ("Http://169.254.169.254/openstack/latest/meta_data.json"). Read (). Decode () Return datadef parse_data (data): json_data = json.loads (data) changepasswd = json_data.get ("meta"). Get ("changepasswd") if changepasswd:adminpass = json_data.get ("meta"). Get ("Admin_pass") Os.system ("Net user administrator /active:yes") Os.system ("net user administrator %s") % adminpass) Class reset (win32serviceutil. serviceframework):_svc_name_ = "reset" _svc_display_name_ = "Reset-administrator" def _ _init__ (Self, args): Win32serviceutil. serviceframework.__init__ (Self, args) self.hwaitstop = win32event. CreateEvent (None, 0, 0, none) def svcstop (self): self. ReportservicEstatus (Win32service. service_stop_pending) win32event. SetEvent (self.hwaitstop) Def svcdorun (self):p arse_data (Get_data ()) win32event. WaitForSingleObject (self.hwaitstop, win32event. INFINITE) if __name__== ' __main__ ': Win32serviceutil. Handlecommandline (reset)
===========================================================================================
Windows Add Environment variables
My Computer----> Properties----> Advanced system Settings----> System Properties----> Advanced----> Environment variables----> Add to Path OK
Do not understand self-Baidu, Google
CMD command line, execute services.msc into the system's service directory, view a service that has no reset-administrator, and modify the general startup type in the attribute to " automatic (delayed start)", and the first failure in recovery to the last failure is modified to restart the service.
9. Install the Cloud-init service,
650) this.width=650; "Src=" https://s2.51cto.com/wyfs02/M01/8E/36/wKiom1i42PqhgNnBAABhmw5cGpo019.png-wh_500x0-wm_ 3-wmp_4-s_847603232.png "title=" clipboard (4). png "alt=" wkiom1i42pqhgnnbaabhmw5cgpo019.png-wh_50 "/>
When the installation is complete, add the script to the
C:\Program Files\cloudbase solutions\cloudbase-init\localscripts\
Can
Modify Password Script
===========================================================================================
#-*-Coding:utf-8-*-import osimport jsonimport urllib.requestdef get_data ():d ata = Urllib.request.urlopen ("http/ 169.254.169.254/openstack/latest/meta_data.json "). Read () return datadef parse_data (data):d ata1 = str (data) Json_data = Json.loads (Data.decode ()) changepasswd = Json_data.get ("meta"). Get ("changepasswd") if changepasswd = = "True": AdminPass = Json_data.get ("meta"). Get ("Admin_pass") Os.system ("NET user Administrator/active:yes") Os.system ("net User Administrator%s "% adminpass) data = Get_data () parse_data (data)
===========================================================================================
650) this.width=650; "Src=" https://s4.51cto.com/wyfs02/M02/8E/36/wKiom1i42RaQcRGPAAJIEY0ih9E324.png-wh_500x0-wm_ 3-wmp_4-s_3399903962.png "title=" clipboard (one). png "alt=" wkiom1i42raqcrgpaajiey0ih9e324.png-wh_50 "/>
The last two hooks are OK, this service will automatically clean up the History command, MAC address, IP address, etc.
Finally remember to cloud-init this package delete, after clicking Finish, delete immediately ok
Show all virtual machines in KVM
Virsh List--all
Delete the virtual machine in KVM, delete the XML file only, do not delete the image file
Virsh undefine windows
Compress the image
qemu-img convert-c-o qcow2 compression before the path + name compression after the path + name
Reference Documentation: https://docs.openstack.org/image-guide/windows-image.html
Reference Documentation: http://www.cnblogs.com/eineseite/archive/2009/07/02/1515388.html
Reference Documentation: https://kurisu.love/index.php/archives/47/
Reference Documentation: http://www.bubuko.com/infodetail-705509.html
Reference Document:http://blog.csdn.net/ghostfromheaven/article/details/8604738
This article is from the "Rslinux" blog, make sure to keep this source http://readshlinux.blog.51cto.com/9322509/1902888
OpenStack mirrored windows (can reset password)