mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-09-01 15:07:17 +08:00
add ucloud vnc info
This commit is contained in:
@@ -80,7 +80,7 @@ type SVncInfo struct {
|
||||
VNCPassword string `json:"VncPassword"`
|
||||
UHostID string `json:"UHostId"`
|
||||
Action string `json:"Action"`
|
||||
VNCPort string `json:"VncPort"`
|
||||
VNCPort int64 `json:"VncPort"`
|
||||
}
|
||||
|
||||
func (self *SInstance) GetId() string {
|
||||
@@ -355,23 +355,6 @@ func (self *SInstance) GetSecurityGroups() ([]SSecurityGroup, error) {
|
||||
}
|
||||
|
||||
// https://docs.ucloud.cn/api/uhost-api/get_uhost_instance_vnc_info
|
||||
/*
|
||||
|
||||
type RemoteConsoleInfo struct {
|
||||
Host string `json:"host"`
|
||||
Port int64 `json:"port"`
|
||||
Protocol string `json:"protocol"`
|
||||
Id string `json:"id"`
|
||||
OsName string `json:"osName"`
|
||||
VncPassword string `json:"vncPassword"`
|
||||
|
||||
// used by aliyun server
|
||||
InstanceId string `json:"instance_id"`
|
||||
Url string `json:"url"`
|
||||
Password string `json:"password"`
|
||||
}
|
||||
|
||||
*/
|
||||
func (self *SRegion) GetInstanceVNCUrl(instanceId string) (jsonutils.JSONObject, error) {
|
||||
params := NewUcloudParams()
|
||||
params.Set("UHostId", instanceId)
|
||||
@@ -381,5 +364,11 @@ func (self *SRegion) GetInstanceVNCUrl(instanceId string) (jsonutils.JSONObject,
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return jsonutils.Marshal(&vnc), nil
|
||||
vncInfo := jsonutils.NewDict()
|
||||
vncInfo.Add(jsonutils.NewString(vnc.VNCIP), "host")
|
||||
vncInfo.Add(jsonutils.NewInt(vnc.VNCPort), "port")
|
||||
vncInfo.Add(jsonutils.NewString("vnc"), "protocol")
|
||||
vncInfo.Add(jsonutils.NewString(vnc.VNCPassword), "vncPassword")
|
||||
vncInfo.Add(jsonutils.NewString(vnc.VNCIP), "host")
|
||||
return vncInfo, nil
|
||||
}
|
||||
|
||||
@@ -33,12 +33,6 @@ type RemoteConsoleInfo struct {
|
||||
}
|
||||
|
||||
func NewRemoteConsoleInfoByCloud(s *mcclient.ClientSession, serverId string) (*RemoteConsoleInfo, error) {
|
||||
metadata, err := modules.Servers.GetSpecific(s, serverId, "metadata", nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
osName, _ := metadata.GetString("os_name")
|
||||
vncPasswd, _ := metadata.GetString("__vnc_password")
|
||||
ret, err := modules.Servers.GetSpecific(s, serverId, "vnc", nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -48,8 +42,18 @@ func NewRemoteConsoleInfoByCloud(s *mcclient.ClientSession, serverId string) (*R
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
vncInfo.OsName = osName
|
||||
vncInfo.VncPassword = vncPasswd
|
||||
|
||||
if len(vncInfo.OsName) == 0 || len(vncInfo.VncPassword) == 0{
|
||||
metadata, err := modules.Servers.GetSpecific(s, serverId, "metadata", nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
osName, _ := metadata.GetString("os_name")
|
||||
vncPasswd, _ := metadata.GetString("__vnc_password")
|
||||
vncInfo.OsName = osName
|
||||
vncInfo.VncPassword = vncPasswd
|
||||
}
|
||||
|
||||
return &vncInfo, nil
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user