fix(webconsole): pve vnc support (#18603)

This commit is contained in:
屈轩
2023-11-08 19:35:06 +08:00
committed by GitHub
parent 478e1844c9
commit c790883c29
6 changed files with 24 additions and 11 deletions
+1 -1
View File
@@ -83,7 +83,7 @@ require (
k8s.io/client-go v0.19.3
k8s.io/cluster-bootstrap v0.19.3
moul.io/http2curl/v2 v2.3.0
yunion.io/x/cloudmux v0.3.10-0-alpha.1.0.20231106041355-ad38cfeccb74
yunion.io/x/cloudmux v0.3.10-0-alpha.1.0.20231108093555-49a6b3a6f94e
yunion.io/x/executor v0.0.0-20230705125604-c5ac3141db32
yunion.io/x/jsonutils v1.0.1-0.20230613121553-0f3b41e2ef19
yunion.io/x/log v1.0.1-0.20230411060016-feb3f46ab361
+2 -2
View File
@@ -1179,8 +1179,8 @@ sigs.k8s.io/structured-merge-diff/v4 v4.0.1/go.mod h1:bJZC9H9iH24zzfZ/41RGcq60oK
sigs.k8s.io/yaml v1.1.0/go.mod h1:UJmg0vDUVViEyp3mgSv9WPwZCDxu4rQW1olrI1uml+o=
sigs.k8s.io/yaml v1.2.0 h1:kr/MCeFWJWTwyaHoR9c8EjH9OumOmoF9YGiZd7lFm/Q=
sigs.k8s.io/yaml v1.2.0/go.mod h1:yfXDCHCao9+ENCvLSE62v9VSji2MKu5jeNfTrofGhJc=
yunion.io/x/cloudmux v0.3.10-0-alpha.1.0.20231106041355-ad38cfeccb74 h1:149fOpxkgML65G80SulEFFXlFYy5GulPbK11xTZJ9mo=
yunion.io/x/cloudmux v0.3.10-0-alpha.1.0.20231106041355-ad38cfeccb74/go.mod h1:McRjoG2gaOUisB+Qa41kLCNZhr0lsCu4apEjTiphXVY=
yunion.io/x/cloudmux v0.3.10-0-alpha.1.0.20231108093555-49a6b3a6f94e h1:8+NOTuIa8sNN1sA3E9PZ0LexNIspxmE6E0c8RFKETdg=
yunion.io/x/cloudmux v0.3.10-0-alpha.1.0.20231108093555-49a6b3a6f94e/go.mod h1:McRjoG2gaOUisB+Qa41kLCNZhr0lsCu4apEjTiphXVY=
yunion.io/x/executor v0.0.0-20230705125604-c5ac3141db32 h1:v7POYkQwo1XzOxBoIoRVr/k0V9Y5JyjpshlIFa9raug=
yunion.io/x/executor v0.0.0-20230705125604-c5ac3141db32/go.mod h1:Uxuou9WQIeJXNpy7t2fPLL0BYLvLiMvGQwY7Qc6aSws=
yunion.io/x/jsonutils v0.0.0-20190625054549-a964e1e8a051/go.mod h1:4N0/RVzsYL3kH3WE/H1BjUQdFiWu50JGCFQuuy+Z634=
-1
View File
@@ -61,7 +61,6 @@ func (s *ConnectionServer) ServeHTTP(w http.ResponseWriter, req *http.Request) {
info := sessionObj.ISessionData.(*session.RemoteConsoleInfo)
if utils.IsInStringArray(info.Hypervisor, []string{
api.HYPERVISOR_OPENSTACK,
api.HYPERVISOR_PROXMOX,
api.HYPERVISOR_CTYUN,
}) {
srv, err = NewWebsocketProxyServer(sessionObj)
+1 -1
View File
@@ -1438,7 +1438,7 @@ sigs.k8s.io/structured-merge-diff/v4/value
# sigs.k8s.io/yaml v1.2.0
## explicit; go 1.12
sigs.k8s.io/yaml
# yunion.io/x/cloudmux v0.3.10-0-alpha.1.0.20231106041355-ad38cfeccb74
# yunion.io/x/cloudmux v0.3.10-0-alpha.1.0.20231108093555-49a6b3a6f94e
## explicit; go 1.18
yunion.io/x/cloudmux/pkg/apis
yunion.io/x/cloudmux/pkg/apis/billing
+12
View File
@@ -19,6 +19,7 @@ import (
"net/url"
"strconv"
"strings"
"time"
"yunion.io/x/jsonutils"
"yunion.io/x/pkg/errors"
@@ -233,6 +234,17 @@ func (self *SHost) CreateVM(opts *cloudprovider.SManagedVMCreateConfig) (cloudpr
}
vmIdRet := strconv.Itoa(vmId)
cloudprovider.Wait(time.Second*5, time.Minute, func() (bool, error) {
_, err := self.zone.region.GetInstance(vmIdRet)
if err != nil {
if errors.Cause(err) == cloudprovider.ErrNotFound {
return false, nil
}
return false, errors.Wrapf(err, "after created")
}
return true, nil
})
vm, err := self.zone.region.GetInstance(vmIdRet)
if err != nil {
return nil, err
+8 -6
View File
@@ -419,11 +419,10 @@ func (self *SInstance) GetVNCInfo(input *cloudprovider.ServerVncInput) (*cloudpr
return nil, err
}
ret := &cloudprovider.ServerVncOutput{}
params := url.Values{}
params.Set("port", fmt.Sprintf("%d", vnc.Port))
params.Set("vncticket", vnc.Ticket)
ret.Url = fmt.Sprintf("wss://%s:%d/api2/json/nodes/%s/qemu/%d/vncwebsocket?%s", self.host.zone.region.client.host, self.host.zone.region.client.port, self.Node, self.VmID, params.Encode())
ret.Protocol = "vnc"
ret.Host = self.host.zone.region.client.host
ret.Port = int64(vnc.Port)
ret.Password = vnc.Ticket
ret.Hypervisor = api.HYPERVISOR_PROXMOX
return ret, nil
}
@@ -839,7 +838,7 @@ func (self *SRegion) GetInstance(id string) (*SInstance, error) {
nodeName := ""
vmId, _ := strconv.Atoi(id)
if resource, ok := resources[vmId]; !ok {
return nil, errors.Errorf("failed get Instance id %s", id)
return nil, errors.Wrapf(cloudprovider.ErrNotFound, id)
} else {
nodeName = resource.Node
}
@@ -1010,7 +1009,10 @@ type InstanceVnc struct {
func (self *SRegion) GetVNCInfo(node string, vmId int) (*InstanceVnc, error) {
res := fmt.Sprintf("/nodes/%s/qemu/%d/vncproxy", node, vmId)
resp, err := self.post(res, map[string]interface{}{})
resp, err := self.post(res, map[string]interface{}{
"websocket": "1",
"generate-password": "0",
})
if err != nil {
return nil, err
}