mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-09-19 10:46:58 +08:00
Merge pull request #11413 from swordqiu/hotfix/qj-support-windows-2003
fix: support windows 2003
This commit is contained in:
@@ -181,6 +181,19 @@ func init() {
|
||||
return nil
|
||||
})
|
||||
|
||||
R(&options.ResourceMetadataOptions{}, "server-set-metadata", "Set raw metadata of a server", func(s *mcclient.ClientSession, opts *options.ResourceMetadataOptions) error {
|
||||
params, err := opts.Params()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
result, err := modules.Servers.PerformAction(s, opts.ID, "metadata", params)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObject(result)
|
||||
return nil
|
||||
})
|
||||
|
||||
R(&options.ServerCreateFromInstanceSnapshot{}, "server-create-from-instance-snapshot", "server create from instance snapshot",
|
||||
func(s *mcclient.ClientSession, opts *options.ServerCreateFromInstanceSnapshot) error {
|
||||
params := &compute.ServerCreateInput{}
|
||||
|
||||
@@ -263,6 +263,8 @@ func ResizePartitionFs(fpath, fs string, raiseError bool) (error, bool) {
|
||||
{"umount", tmpPoint},
|
||||
{"sleep", "2"},
|
||||
{"rm", "-fr", tmpPoint}}
|
||||
} else if fs == "ntfs" {
|
||||
cmds = [][]string{{"ntfsresize", "-c", fpath}, {"ntfsresize", "-P", "-f", fpath}}
|
||||
}
|
||||
|
||||
if len(cmds) > 0 {
|
||||
|
||||
@@ -149,6 +149,14 @@ func (w *SWindowsRootFs) IsWindows10() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func (w *SWindowsRootFs) IsOldWindows() bool {
|
||||
info := w.GetReleaseInfo(nil)
|
||||
if info != nil && strings.HasPrefix(info.Version, "5.") {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func (w *SWindowsRootFs) GetOs() string {
|
||||
return "Windows"
|
||||
}
|
||||
@@ -332,6 +340,12 @@ func (w *SWindowsRootFs) CommitChanges(part IDiskPartition) error {
|
||||
tool := winutils.NewWinRegTool(confPath)
|
||||
tool.CheckPath()
|
||||
tool.EnableRdp()
|
||||
|
||||
if w.IsOldWindows() {
|
||||
// windows prior to windows 2003 should not try to commit changes
|
||||
return nil
|
||||
}
|
||||
|
||||
tool.InstallGpeditStartScript(WIN_BOOT_SCRIPT_PATH)
|
||||
|
||||
bootDir := path.Dir(BOOT_SCRIPT_PATH)
|
||||
|
||||
@@ -89,6 +89,22 @@ func (s *SKVMGuestInstance) getOsDistribution() string {
|
||||
return osDis
|
||||
}
|
||||
|
||||
func (s *SKVMGuestInstance) getOsVersion() string {
|
||||
osVer, _ := s.Desc.GetString("metadata", "os_version")
|
||||
return osVer
|
||||
}
|
||||
|
||||
// is windows prioer to windows server 2003
|
||||
func (s *SKVMGuestInstance) isOldWindows() bool {
|
||||
if s.getOsname() == OS_NAME_WINDOWS {
|
||||
ver := s.getOsVersion()
|
||||
if len(ver) > 1 && ver[0:2] == "5." {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func (s *SKVMGuestInstance) getMachine() string {
|
||||
machine, err := s.Desc.GetString("machine")
|
||||
if err != nil {
|
||||
@@ -527,13 +543,15 @@ function nic_mtu() {
|
||||
|
||||
cmd += " -device virtio-serial"
|
||||
cmd += " -usb"
|
||||
if !utils.IsInStringArray(s.getOsDistribution(), []string{OS_NAME_OPENWRT, OS_NAME_CIRROS}) && !s.disableUsbKbd() {
|
||||
if !utils.IsInStringArray(s.getOsDistribution(), []string{OS_NAME_OPENWRT, OS_NAME_CIRROS}) && !s.isOldWindows() && !s.disableUsbKbd() {
|
||||
cmd += " -device usb-kbd"
|
||||
}
|
||||
// # if osname == self.OS_NAME_ANDROID:
|
||||
// # cmd += " -device usb-mouse"
|
||||
// # else:
|
||||
cmd += " -device usb-tablet"
|
||||
if !s.isOldWindows() {
|
||||
cmd += " -device usb-tablet"
|
||||
}
|
||||
|
||||
if s.IsVdiSpice() {
|
||||
cmd += " -device qxl-vga,id=video0,ram_size=141557760,vram_size=141557760"
|
||||
|
||||
Reference in New Issue
Block a user