From 5e2760ef13e12f222459ae808048de36f6bad120 Mon Sep 17 00:00:00 2001 From: Zexi Li Date: Thu, 21 Mar 2019 17:26:02 +0800 Subject: [PATCH 1/4] webconsole: append protocol params for each connParams --- cmd/climc/shell/webconsole.go | 1 - pkg/webconsole/session/remote_console.go | 18 +++++++++++++----- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/cmd/climc/shell/webconsole.go b/cmd/climc/shell/webconsole.go index 41696c5301..ce9c9f853b 100644 --- a/cmd/climc/shell/webconsole.go +++ b/cmd/climc/shell/webconsole.go @@ -25,7 +25,6 @@ func init() { if err != nil { return err } - u.Path = "index.html" u.RawQuery = connParams fmt.Println(u.String()) return nil diff --git a/pkg/webconsole/session/remote_console.go b/pkg/webconsole/session/remote_console.go index 20febea98f..3afe3b3d56 100644 --- a/pkg/webconsole/session/remote_console.go +++ b/pkg/webconsole/session/remote_console.go @@ -104,11 +104,21 @@ func (info *RemoteConsoleInfo) GetPassword() string { } func (info *RemoteConsoleInfo) getOpenStackURL() (string, error) { - return info.Url, nil + return info.getConnParamsURL(info.Url, nil), nil +} + +func (info *RemoteConsoleInfo) getConnParamsURL(baseURL string, params url.Values) string { + if params == nil { + params = url.Values{} + } + params.Set("protocol", info.Protocol) + queryURL := params.Encode() + return fmt.Sprintf("%s?%s", baseURL, queryURL) } func (info *RemoteConsoleInfo) getQcloudURL() (string, error) { - return "https://img.qcloud.com/qcloud/app/active_vnc/index.html?InstanceVncUrl=" + info.Url, nil + base := "https://img.qcloud.com/qcloud/app/active_vnc/index.html?InstanceVncUrl=" + info.Url + return info.getConnParamsURL(base, nil), nil } func (info *RemoteConsoleInfo) getAliyunURL() (string, error) { @@ -122,8 +132,6 @@ func (info *RemoteConsoleInfo) getAliyunURL() (string, error) { "instanceId": {info.InstanceId}, "isWindows": {isWindows}, "password": {info.Password}, - "protocol": {info.Protocol}, } - queryURL := params.Encode() - return fmt.Sprintf("%s?%s", base, queryURL), nil + return info.getConnParamsURL(base, params), nil } From a004e163a4edc7ad92787657818ed956d8427f63 Mon Sep 17 00:00:00 2001 From: wanyaoqi Date: Fri, 22 Mar 2019 10:34:52 +0800 Subject: [PATCH 2/4] fix deploy file --- pkg/cloudcommon/types/types.go | 2 +- pkg/hostman/guestfs/fsdriver/base.go | 7 +++++-- pkg/hostman/guestfs/kvmpart.go | 1 + pkg/hostman/guestfs/localfs.go | 3 +++ 4 files changed, 10 insertions(+), 3 deletions(-) diff --git a/pkg/cloudcommon/types/types.go b/pkg/cloudcommon/types/types.go index 44427cb54e..6165c3a941 100644 --- a/pkg/cloudcommon/types/types.go +++ b/pkg/cloudcommon/types/types.go @@ -4,7 +4,7 @@ import "net" type SSHConfig struct { Username string `json:"username,omitempty"` - RemoteIP string `json:"ip"` + RemoteIP string `json:"remote_ip"` Password string `json:"password"` } diff --git a/pkg/hostman/guestfs/fsdriver/base.go b/pkg/hostman/guestfs/fsdriver/base.go index abe4a062b5..b7176852ab 100644 --- a/pkg/hostman/guestfs/fsdriver/base.go +++ b/pkg/hostman/guestfs/fsdriver/base.go @@ -32,19 +32,22 @@ func (d *sGuestRootFsDriver) DeployFiles(deploys []jsonutils.JSONObject) error { } sPath, err := deploy.GetString("path") if err != nil { + log.Errorln(err) return err } dirname := filepath.Dir(sPath) - if !d.GetPartition().Exists(sPath, caseInsensitive) { + if !d.GetPartition().Exists(dirname, caseInsensitive) { modeRWXOwner := syscall.S_IRUSR | syscall.S_IWUSR | syscall.S_IXUSR err := d.GetPartition().Mkdir(dirname, modeRWXOwner, caseInsensitive) if err != nil { + log.Errorln(err) return err } } - if content, err := deploy.GetString("content"); err != nil { + if content, err := deploy.GetString("content"); err == nil { err := d.GetPartition().FilePutContents(sPath, content, modAppend, caseInsensitive) if err != nil { + log.Errorln(err) return err } } diff --git a/pkg/hostman/guestfs/kvmpart.go b/pkg/hostman/guestfs/kvmpart.go index 6f990897dd..cb31c6edf5 100644 --- a/pkg/hostman/guestfs/kvmpart.go +++ b/pkg/hostman/guestfs/kvmpart.go @@ -69,6 +69,7 @@ func (p *SKVMGuestDiskPartition) Mount() bool { func (p *SKVMGuestDiskPartition) mount(readonly bool) error { if _, err := procutils.NewCommand("mkdir", "-p", p.mountPath).Run(); err != nil { + log.Errorln(err) return err } var cmds = []string{"mount", "-t"} diff --git a/pkg/hostman/guestfs/localfs.go b/pkg/hostman/guestfs/localfs.go index 9f42835410..1572d864ca 100644 --- a/pkg/hostman/guestfs/localfs.go +++ b/pkg/hostman/guestfs/localfs.go @@ -28,6 +28,9 @@ func (f *SLocalGuestFS) SupportSerialPorts() bool { } func (f *SLocalGuestFS) GetLocalPath(sPath string, caseInsensitive bool) string { + if sPath == "." { + sPath = "" + } var fullPath = f.mountPath pathSegs := strings.Split(sPath, "/") for _, seg := range pathSegs { From e5b5a33c1e8a84415de9451dcb5e96c2214565a4 Mon Sep 17 00:00:00 2001 From: Zexi Li Date: Fri, 22 Mar 2019 12:12:11 +0800 Subject: [PATCH 3/4] =?UTF-8?q?=E4=BF=AE=E6=AD=A3:=20schedpolicies=20?= =?UTF-8?q?=E5=8A=A0=E5=85=A5=E7=9A=84=E6=A0=87=E7=AD=BE=E6=B2=A1=E6=9C=89?= =?UTF-8?q?=E4=BC=A0=E5=85=A5=20params=EF=BC=8C=E5=AF=BC=E8=87=B4=E5=8A=A8?= =?UTF-8?q?=E6=80=81=E6=A0=87=E7=AD=BE=E4=B8=8D=E7=94=9F=E6=95=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pkg/compute/models/schedpolicies.go | 1 + 1 file changed, 1 insertion(+) diff --git a/pkg/compute/models/schedpolicies.go b/pkg/compute/models/schedpolicies.go index 5f2c957342..4a69768d33 100644 --- a/pkg/compute/models/schedpolicies.go +++ b/pkg/compute/models/schedpolicies.go @@ -209,6 +209,7 @@ func ApplySchedPolicies(params *jsonutils.JSONDict) *jsonutils.JSONDict { newSchedtags := jsonutils.Marshal(schedtags) log.Infof("updated sched tag %s", newSchedtags) + params.Set("aggregate_strategy", newSchedtags) ret := jsonutils.NewDict() ret.Add(newSchedtags, "aggregate_strategy") From 837ae0cd16185fd7800cbfe67ef48da033772eb9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B1=88=E8=BD=A9?= Date: Fri, 22 Mar 2019 15:21:53 +0800 Subject: [PATCH 4/4] =?UTF-8?q?=E9=81=BF=E5=85=8Ddefault=20secgroup?= =?UTF-8?q?=E4=B8=8D=E8=83=BD=E9=87=8D=E8=AE=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pkg/compute/models/guest_actions.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/compute/models/guest_actions.go b/pkg/compute/models/guest_actions.go index 8e9192e232..7d0f075da8 100644 --- a/pkg/compute/models/guest_actions.go +++ b/pkg/compute/models/guest_actions.go @@ -802,7 +802,7 @@ func (self *SGuest) AllowPerformRevokeSecgroup(ctx context.Context, userCred mcc func (self *SGuest) saveDefaultSecgroupId(userCred mcclient.TokenCredential, secGrpId string) error { if secGrpId != self.SecgrpId { diff, err := db.Update(self, func() error { - self.SecgrpId = "default" + self.SecgrpId = secGrpId return nil }) if err != nil {