fix: add password info to server vnc info (#14861)

Co-authored-by: Qiu Jian <qiujian@yunionyun.com>
This commit is contained in:
Jian Qiu
2022-08-29 18:08:51 +08:00
committed by GitHub
parent a4413b92e1
commit f3ecde64cf
3 changed files with 20 additions and 17 deletions

View File

@@ -303,29 +303,29 @@ type ServerVncInput struct {
// +onecloud:model-api-gen
type ServerVncOutput struct {
Id string
Id string `json:"id"`
// baremetal
HostId string
Zone string
HostId string `json:"host_id"`
Zone string `json:"zone"`
// kvm host ip
Host string
Protocol string
Port int64
Host string `json:"host"`
Protocol string `json:"protocol"`
Port int64 `json:"port"`
Url string
InstanceId string
InstanceName string
Password string
VncPassword string
Url string `json:"url"`
InstanceId string `json:"instance_id"`
InstanceName string `json:"instance_name"`
Password string `json:"password"`
VncPassword string `json:"vnc_password"`
OsName string
OsName string `json:"os_name"`
// cloudpods
ApiServer string
ConnectParams string
Session string
ApiServer string `json:"api_server"`
ConnectParams string `json:"connect_params"`
Session string `json:"session"`
Hypervisor string
Hypervisor string `json:"hypervisor"`
}

View File

@@ -204,11 +204,14 @@ func (self *SKVMGuestDriver) GetGuestVncInfo(ctx context.Context, userCred mccli
port = findVNCPort(results)
}
password := guest.GetMetadata(ctx, "__vnc_password", userCred)
result := &cloudprovider.ServerVncOutput{
Host: host.AccessIp,
Protocol: guest.GetVdi(),
Port: int64(port),
Hypervisor: api.HYPERVISOR_KVM,
Password: password,
}
return result, nil
}

View File

@@ -71,7 +71,7 @@ import (
func (self *SGuest) GetDetailsVnc(ctx context.Context, userCred mcclient.TokenCredential, input *cloudprovider.ServerVncInput) (*cloudprovider.ServerVncOutput, error) {
ret := &cloudprovider.ServerVncOutput{}
if utils.IsInStringArray(self.Status, []string{api.VM_RUNNING, api.VM_BLOCK_STREAM}) {
if utils.IsInStringArray(self.Status, []string{api.VM_RUNNING, api.VM_BLOCK_STREAM, api.VM_MIGRATING}) {
host, err := self.GetHost()
if err != nil {
return nil, httperrors.NewInternalServerError(errors.Wrapf(err, "GetHost").Error())