session

package
v0.0.0-...-6410feb Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 25, 2024 License: Apache-2.0 Imports: 36 Imported by: 0

Documentation

Index

Constants

View Source
const (
	VNC        = api.VNC
	RDP        = api.RDP
	ALIYUN     = api.ALIYUN
	QCLOUD     = api.QCLOUD
	OPENSTACK  = api.OPENSTACK
	SPICE      = api.SPICE
	WMKS       = api.WMKS
	WS         = api.WS
	VMRC       = api.VMRC
	ZSTACK     = api.ZSTACK
	CTYUN      = api.CTYUN
	HUAWEI     = api.HUAWEI
	HCS        = api.HCS
	APSARA     = api.APSARA
	JDCLOUD    = api.JDCLOUD
	CLOUDPODS  = api.CLOUDPODS
	PROXMOX    = api.PROXMOX
	VOLCENGINE = api.VOLC_ENGINE
	SANGFOR    = api.SANGFOR
)

Variables

View Source
var (
	Manager        *SSessionManager
	AES_KEY        string
	AccessInterval time.Duration = 5 * time.Minute
)

Functions

func ResolveHostSSHIPPortById

func ResolveHostSSHIPPortById(ctx context.Context, s *mcclient.ClientSession, id string, ip string, port int) (string, int, *compute_api.HostDetails, error)

func ResolveServerSSHIPPortById

func ResolveServerSSHIPPortById(ctx context.Context, s *mcclient.ClientSession, id string, ip string, port int) (string, int, *compute_api.ServerDetails, error)

Types

type ISessionCommand

type ISessionCommand interface {
	command.ICommand

	GetInstanceName() string
	GetIPs() []string
}

type ISessionData

type ISessionData interface {
	command.ICommand
	IsNeedLogin() (bool, error)
	GetId() string
	GetDisplayInfo(ctx context.Context) (*SDisplayInfo, error)
}

type Pty

type Pty struct {
	Session *SSession
	Cmd     *exec.Cmd
	Pty     *os.File

	OriginSize *pty.Winsize
	Exit       bool
	// contains filtered or unexported fields
}

func NewPty

func NewPty(session *SSession) (p *Pty, err error)

func (*Pty) IsInShellMode

func (p *Pty) IsInShellMode() bool

func (*Pty) Read

func (p *Pty) Read() ([]byte, error)

func (*Pty) Resize

func (p *Pty) Resize(size *pty.Winsize)

func (*Pty) Stop

func (p *Pty) Stop() (err error)

type RandomSessionData

type RandomSessionData struct {
	command.ICommand
	// contains filtered or unexported fields
}

func WrapCommandSession

func WrapCommandSession(cmd command.ICommand) *RandomSessionData

func (*RandomSessionData) GetDisplayInfo

func (s *RandomSessionData) GetDisplayInfo(ctx context.Context) (*SDisplayInfo, error)

func (*RandomSessionData) GetId

func (s *RandomSessionData) GetId() string

func (*RandomSessionData) IsNeedLogin

func (s *RandomSessionData) IsNeedLogin() (bool, error)

type RemoteConsoleInfo

type RemoteConsoleInfo struct {
	cloudprovider.ServerVncOutput
	// contains filtered or unexported fields
}

func NewRemoteConsoleInfoByCloud

func NewRemoteConsoleInfoByCloud(s *mcclient.ClientSession, serverId string, query jsonutils.JSONObject) (*RemoteConsoleInfo, error)

func (*RemoteConsoleInfo) Cleanup

func (info *RemoteConsoleInfo) Cleanup() error

Cleanup implements ISessionData interface

func (*RemoteConsoleInfo) Connect

func (info *RemoteConsoleInfo) Connect() error

Connect implements ISessionData interface

func (*RemoteConsoleInfo) GetClientSession

func (info *RemoteConsoleInfo) GetClientSession() *mcclient.ClientSession

func (*RemoteConsoleInfo) GetCommand

func (info *RemoteConsoleInfo) GetCommand() *exec.Cmd

GetCommand implements ISessionData interface

func (*RemoteConsoleInfo) GetConnectParams

func (info *RemoteConsoleInfo) GetConnectParams() (string, error)

func (*RemoteConsoleInfo) GetDisplayInfo

func (info *RemoteConsoleInfo) GetDisplayInfo(ctx context.Context) (*SDisplayInfo, error)

func (*RemoteConsoleInfo) GetId

func (info *RemoteConsoleInfo) GetId() string

func (*RemoteConsoleInfo) GetPassword

func (info *RemoteConsoleInfo) GetPassword() string

func (*RemoteConsoleInfo) GetProtocol

func (info *RemoteConsoleInfo) GetProtocol() string

GetProtocol implements ISessionData interface

func (*RemoteConsoleInfo) GetRecordObject

func (info *RemoteConsoleInfo) GetRecordObject() *recorder.Object

func (*RemoteConsoleInfo) IsNeedLogin

func (info *RemoteConsoleInfo) IsNeedLogin() (bool, error)

IsNeedLogin implements ISessionData interface

func (*RemoteConsoleInfo) Scan

func (info *RemoteConsoleInfo) Scan(byte, func(string))

Scan implements ISessionData interface

type RemoteRDPConsoleInfo

type RemoteRDPConsoleInfo struct {
	Host         string
	Port         int
	Username     string
	Password     string
	ConnectionId string

	Width  int
	Height int
	Dpi    int
	// contains filtered or unexported fields
}

func NewRemoteRDPConsoleInfoByCloud

func NewRemoteRDPConsoleInfoByCloud(ctx context.Context, s *mcclient.ClientSession, serverId string, query jsonutils.JSONObject) (*RemoteRDPConsoleInfo, error)

func (*RemoteRDPConsoleInfo) Cleanup

func (info *RemoteRDPConsoleInfo) Cleanup() error

func (*RemoteRDPConsoleInfo) Connect

func (info *RemoteRDPConsoleInfo) Connect() error

func (*RemoteRDPConsoleInfo) GetClientSession

func (info *RemoteRDPConsoleInfo) GetClientSession() *mcclient.ClientSession

func (*RemoteRDPConsoleInfo) GetCommand

func (info *RemoteRDPConsoleInfo) GetCommand() *exec.Cmd

func (*RemoteRDPConsoleInfo) GetConnectParams

func (info *RemoteRDPConsoleInfo) GetConnectParams() (string, error)

func (*RemoteRDPConsoleInfo) GetDisplayInfo

func (info *RemoteRDPConsoleInfo) GetDisplayInfo(ctx context.Context) (*SDisplayInfo, error)

func (*RemoteRDPConsoleInfo) GetId

func (info *RemoteRDPConsoleInfo) GetId() string

func (*RemoteRDPConsoleInfo) GetPassword

func (info *RemoteRDPConsoleInfo) GetPassword() string

func (*RemoteRDPConsoleInfo) GetProtocol

func (info *RemoteRDPConsoleInfo) GetProtocol() string

func (*RemoteRDPConsoleInfo) GetRecordObject

func (info *RemoteRDPConsoleInfo) GetRecordObject() *recorder.Object

func (*RemoteRDPConsoleInfo) IsNeedLogin

func (info *RemoteRDPConsoleInfo) IsNeedLogin() (bool, error)

func (*RemoteRDPConsoleInfo) Scan

func (info *RemoteRDPConsoleInfo) Scan(byte, func(string))

type SDisplayInfo

type SDisplayInfo struct {
	WaterMark    string `json:"water_mark"`
	InstanceName string `json:"instance_name"`
	Ips          string `json:"ips"`

	Hypervisor     string `json:"hypervisor"`
	OsType         string `json:"os_type"`
	OsName         string `json:"os_name"`
	OsArch         string `json:"os_arch"`
	OsDistribution string `json:"os_distribution"`
	SecretLevel    string `json:"secret_level"`
}

type SSession

type SSession struct {
	ISessionData
	Id          string
	AccessToken string
	AccessedAt  time.Time
	// contains filtered or unexported fields
}

func (*SSession) Close

func (s *SSession) Close() error

func (*SSession) GetConnectParams

func (s *SSession) GetConnectParams(params url.Values, dispInfo *SDisplayInfo) (string, error)

func (*SSession) GetRecorder

func (s *SSession) GetRecorder() recorder.Recoder

func (*SSession) RegisterDuplicateHook

func (s *SSession) RegisterDuplicateHook(f func())

type SSessionManager

type SSessionManager struct {
	*sync.Map
}

func NewSessionManager

func NewSessionManager() *SSessionManager

func (*SSessionManager) Get

func (man *SSessionManager) Get(accessToken string) (*SSession, bool)

func (*SSessionManager) Save

func (man *SSessionManager) Save(data ISessionData) (*SSession, error)

type SSshConnectionInfo

type SSshConnectionInfo struct {
	IP           string `json:"ip"`
	Port         int    `json:"port"`
	Username     string `json:"username"`
	KeepUsername bool   `json:"keep_username"`
	Password     string `json:"password"`
	Name         string `json:"name"`
	ResourceType string `json:"resource_type" choices:"host|server"`

	GuestDetails *compute_api.ServerDetails
	HostDetails  *compute_api.HostDetails
}

type SSshSession

type SSshSession struct {
	Host string

	Port       int
	PrivateKey string
	Username   string
	// 保持原有 Username ,不实用 cloudroot 的同时使用 PrivateKey
	KeepUsername bool
	Password     string
	// contains filtered or unexported fields
}

func (*SSshSession) Cleanup

func (s *SSshSession) Cleanup() error

func (*SSshSession) GetClientSession

func (s *SSshSession) GetClientSession() *mcclient.ClientSession

func (*SSshSession) GetCommand

func (s *SSshSession) GetCommand() *exec.Cmd

func (*SSshSession) GetDisplayInfo

func (s *SSshSession) GetDisplayInfo(ctx context.Context) (*SDisplayInfo, error)

func (*SSshSession) GetId

func (s *SSshSession) GetId() string

func (*SSshSession) GetProtocol

func (s *SSshSession) GetProtocol() string

func (*SSshSession) GetRecordObject

func (s *SSshSession) GetRecordObject() *recorder.Object

func (*SSshSession) IsNeedLogin

func (s *SSshSession) IsNeedLogin() (bool, error)

func (*SSshSession) Scan

func (s *SSshSession) Scan(d byte, send func(msg string))

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL