installers

package
v0.6.2 Latest Latest
Warning

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

Go to latest
Published: Jan 10, 2023 License: BSD-3-Clause Imports: 27 Imported by: 0

Documentation

Index

Constants

View Source
const (
	UpgradeLimiterDuration          = 10          // node key expire time, by seconds
	UpgradeLimiterConcurrent        = 10          // 10 nodes
	UpgradeLimiterMaxBytesPerSecond = 5 * sizes.M // max bytes per second
)

Variables

View Source
var SharedDeployManager = NewDeployManager()
View Source
var SharedUpgradeLimiter = NewUpgradeLimiter()

Functions

func IsGrantError added in v0.5.3

func IsGrantError(err error) bool

Types

type BaseInstaller

type BaseInstaller struct {
	// contains filtered or unexported fields
}

func (*BaseInstaller) Close

func (this *BaseInstaller) Close() error

Close 关闭SSH服务

func (*BaseInstaller) InstallHelper

func (this *BaseInstaller) InstallHelper(targetDir string, role nodeconfigs.NodeRole) (env *Env, err error)

InstallHelper 上传安装助手

func (*BaseInstaller) Login

func (this *BaseInstaller) Login(credentials *Credentials) error

Login 登录SSH服务

func (*BaseInstaller) LookupLatestInstaller

func (this *BaseInstaller) LookupLatestInstaller(filePrefix string) (string, error)

LookupLatestInstaller 查找最新的版本的文件

type Credentials

type Credentials struct {
	Host       string
	Port       int
	Username   string
	Password   string
	PrivateKey string
	Passphrase string
	Method     string
	Sudo       bool
}

type DeployFile

type DeployFile struct {
	OS      string
	Arch    string
	Version string
	Path    string
}

DeployFile 部署文件描述

func (*DeployFile) Read

func (this *DeployFile) Read(offset int64) (data []byte, newOffset int64, err error)

Read 读取一个片段数据

func (*DeployFile) Sum

func (this *DeployFile) Sum() (string, error)

Sum 计算概要

type DeployManager

type DeployManager struct {
	// contains filtered or unexported fields
}

DeployManager 节点部署文件管理器 如果节点部署文件有变化,需要重启API节点以便于生效

func NewDeployManager

func NewDeployManager() *DeployManager

NewDeployManager 获取新节点部署文件管理器

func (*DeployManager) FindNSNodeFile

func (this *DeployManager) FindNSNodeFile(os string, arch string) *DeployFile

FindNSNodeFile 查找特别平台的NS节点安装文件

func (*DeployManager) FindNodeFile

func (this *DeployManager) FindNodeFile(os string, arch string) *DeployFile

FindNodeFile 查找特别平台的节点文件

func (*DeployManager) LoadNSNodeFiles

func (this *DeployManager) LoadNSNodeFiles() []*DeployFile

LoadNSNodeFiles 加载所有NS节点安装文件

func (*DeployManager) LoadNodeFiles

func (this *DeployManager) LoadNodeFiles() []*DeployFile

LoadNodeFiles 加载所有边缘节点文件

type Env

type Env struct {
	OS         string
	Arch       string
	HelperPath string
}

type GrantError added in v0.5.3

type GrantError struct {
	// contains filtered or unexported fields
}

func (*GrantError) Error added in v0.5.3

func (this *GrantError) Error() string

func (*GrantError) String added in v0.5.3

func (this *GrantError) String() string

type InstallerInterface

type InstallerInterface interface {
	// 登录SSH服务
	Login(credentials *Credentials) error

	// 安装
	Install(dir string, params interface{}, installStatus *models.NodeInstallStatus) error

	// 关闭连接的SSH服务
	Close() error
}

type NodeInstaller

type NodeInstaller struct {
	BaseInstaller
}

func (*NodeInstaller) Install

func (this *NodeInstaller) Install(dir string, params interface{}, installStatus *models.NodeInstallStatus) error

type NodeParams

type NodeParams struct {
	Endpoints   []string
	NodeId      string
	Secret      string
	IsUpgrading bool // 是否为升级
}

func (*NodeParams) QuoteEndpoints

func (this *NodeParams) QuoteEndpoints() string

func (*NodeParams) Validate

func (this *NodeParams) Validate() error

type NodeQueue

type NodeQueue struct {
}

func NewNodeQueue

func NewNodeQueue() *NodeQueue

func SharedNodeQueue

func SharedNodeQueue() *NodeQueue

func (*NodeQueue) InstallNode

func (this *NodeQueue) InstallNode(nodeId int64, installStatus *models.NodeInstallStatus, isUpgrading bool) error

InstallNode 安装边缘节点

func (*NodeQueue) InstallNodeProcess

func (this *NodeQueue) InstallNodeProcess(nodeId int64, isUpgrading bool) error

InstallNodeProcess 安装边缘节点流程控制

func (*NodeQueue) StartNode

func (this *NodeQueue) StartNode(nodeId int64) error

StartNode 启动边缘节点

func (*NodeQueue) StopNode

func (this *NodeQueue) StopNode(nodeId int64) error

StopNode 停止节点

type SSHClient

type SSHClient struct {
	// contains filtered or unexported fields
}

func NewSSHClient

func NewSSHClient(raw *ssh.Client) (*SSHClient, error)

func (*SSHClient) Chmod

func (this *SSHClient) Chmod(path string, mode os.FileMode) error

func (*SSHClient) Close

func (this *SSHClient) Close() error

func (*SSHClient) Copy

func (this *SSHClient) Copy(localPath string, remotePath string, mode os.FileMode) error

Copy 拷贝文件

func (*SSHClient) Dial

func (this *SSHClient) Dial(network string, addr string) (net.Conn, error)

func (*SSHClient) Exec

func (this *SSHClient) Exec(cmd string) (stdout string, stderr string, err error)

Exec 执行shell命令

func (*SSHClient) Listen

func (this *SSHClient) Listen(network string, addr string) (net.Listener, error)

func (*SSHClient) Mkdir

func (this *SSHClient) Mkdir(path string) error

func (*SSHClient) MkdirAll

func (this *SSHClient) MkdirAll(path string) error

func (*SSHClient) NewSession

func (this *SSHClient) NewSession() (*ssh.Session, error)

NewSession 获取新Session

func (*SSHClient) OpenFile

func (this *SSHClient) OpenFile(path string, flags int) (*sftp.File, error)

func (*SSHClient) ReadFile

func (this *SSHClient) ReadFile(path string) ([]byte, error)

ReadFile 读取文件内容

func (*SSHClient) Remove

func (this *SSHClient) Remove(path string) error

Remove 删除文件

func (*SSHClient) Stat

func (this *SSHClient) Stat(path string) (os.FileInfo, error)

func (*SSHClient) Sudo

func (this *SSHClient) Sudo(password string)

Sudo 设置使用Sudo

func (*SSHClient) User

func (this *SSHClient) User() string

User 用户名

func (*SSHClient) UserHome

func (this *SSHClient) UserHome() string

UserHome 用户地址

func (*SSHClient) WriteFile

func (this *SSHClient) WriteFile(path string, data []byte) (n int, err error)

WriteFile 写入文件内容

type UpgradeLimiter added in v0.4.9

type UpgradeLimiter struct {
	// contains filtered or unexported fields
}

UpgradeLimiter 升级流量管理器

func NewUpgradeLimiter added in v0.4.9

func NewUpgradeLimiter() *UpgradeLimiter

func (*UpgradeLimiter) CanUpgrade added in v0.4.9

func (this *UpgradeLimiter) CanUpgrade() bool

CanUpgrade 检查是否有新的升级

func (*UpgradeLimiter) UpdateNodeBytes added in v0.4.9

func (this *UpgradeLimiter) UpdateNodeBytes(nodeType nodeconfigs.NodeRole, nodeId int64, bytes int64)

UpdateNodeBytes 添加正在下载的节点流量

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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