deployutils

package
v0.0.0-...-63ace11 Latest Latest
Warning

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

Go to latest
Published: Jun 3, 2022 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	YES_NO                    = []byte("(yes/no)? ")
	YES_NO_FINGERPRINT        = []byte("(yes/no/[fingerprint])? ")
	PASSWD                    = []byte("password: ")
	PASSWD_UPPER              = []byte("Password: ")
	SCP_PASSWD_WRONG          = []byte("Permission denied, please try again.")
	FILE_DIR_NOT_EXISTS       = []byte("No such file or directory")
	REDIS_CLUSTER_INIT_ACCEPT = []byte("(type 'yes' to accept): ")
	REDIS_CLUSTER_INIT_OK     = []byte("[OK] All 16384 slots covered.")
	REDIS_CLUSTER_INIT_ERR    = []byte("ERR")
	REDIS_MOVEING_SLOT        = []byte("Moving slot")
	REDIS_CLUSTER_DELETE_NODE = []byte(">>> Sending CLUSTER RESET SOFT to the deleted node.")
	REDIS_ADD_NODE_OK         = []byte("[OK] New node added correctly.")
	REDIS_SLAVEOF_OK          = []byte("OK")
	TAOS_SHELL                = []byte("taos> ")
	TAOS_OK                   = []byte("Query OK")
	TAOS_DNODE_READY          = "ready"
	TAOS_DNODE_DROPPING       = "dropping"
)

Functions

func AddLine

func AddLine(sshClient *SSHClient, context, confFile, logKey string, paasResult *result.ResultBean) bool

func AppendMultiLine

func AppendMultiLine(sshClient *SSHClient, oldValue, newValue, file, logKey string, paasResult *result.ResultBean) bool

func CD

func CD(sshClient *SSHClient, dir, logKey string, paasResult *result.ResultBean) bool

func ChMod

func ChMod(sshClient *SSHClient, fileName, mod, logKey string, paasResult *result.ResultBean) bool

func CheckBeforeDeploy

func CheckBeforeDeploy(serv *proto.PaasService, etcdNodeArr []map[string]interface{}, logKey string,
	paasResult *result.ResultBean) bool

func CheckInstanceDeployed

func CheckInstanceDeployed(instId, logKey string, paasResult *result.ResultBean) bool

func CheckInstanceNotDeployed

func CheckInstanceNotDeployed(instId, logKey string, paasResult *result.ResultBean) bool

func CheckPortDown

func CheckPortDown(sshClient *SSHClient, cmpt, instId, port, logKey string, paasResult *result.ResultBean) bool

func CheckPortUp

func CheckPortUp(sshClient *SSHClient, cmpt, instId, port, logKey string, paasResult *result.ResultBean) bool

func CheckPortUpPredeploy

func CheckPortUpPredeploy(sshClient *SSHClient, port, logKey string, paasResult *result.ResultBean) bool

func CheckPortsUp

func CheckPortsUp(sshClient *SSHClient, cmpt, instId string, ports []string, logKey string, paasResult *result.ResultBean) bool

func CheckPortsUpPredeploy

func CheckPortsUpPredeploy(sshClient *SSHClient, ports []string, logKey string, paasResult *result.ResultBean) bool

func ConnectSSH

func ConnectSSH(sshClient *SSHClient, logKey string, paasResult *result.ResultBean) bool

func CreateFile

func CreateFile(sshClient *SSHClient, fileName, fileContent, logKey string,
	paasResult *result.ResultBean) bool

func CreateShell

func CreateShell(sshClient *SSHClient, fileName, shell, logKey string, paasResult *result.ResultBean) bool

func DeployEtcdNode

func DeployEtcdNode(etcdNode map[string]interface{}, etcdFullAddr, etcdContainerInstId, logKey, magicKey string,
	paasResult *result.ResultBean) bool

func DeployGrafana

func DeployGrafana(grafana map[string]interface{}, version, logKey, magicKey string, paasResult *result.ResultBean) bool

func DeployZookeeper

func DeployZookeeper(zk map[string]interface{}, idx int, version, zkAddrList, logKey, magicKey string, paasResult *result.ResultBean) bool

func Dos2Unix

func Dos2Unix(sshClient *SSHClient, fileName, logKey string, paasResult *result.ResultBean) bool

func ExecSimpleCmd

func ExecSimpleCmd(sshClient *SSHClient, cmd, logKey string, paasResult *result.ResultBean) bool

func FetchAndExtractTgzDeployFile

func FetchAndExtractTgzDeployFile(sshClient *SSHClient, fileId int, subPath, version, logKey string, paasResult *result.ResultBean) bool

func FetchAndExtractZipDeployFile

func FetchAndExtractZipDeployFile(sshClient *SSHClient, fileId int, subPath, oldName, version, logKey string,
	paasResult *result.ResultBean) bool

func FetchFile

func FetchFile(sshClient *SSHClient, fileId int, logKey string, paasResult *result.ResultBean) bool

func GetCmptById

func GetCmptById(servInstID, instID string, cmptID int, paasResult *result.ResultBean) *proto.PaasMetaCmpt

func GetDeployFile

func GetDeployFile(fileId int, logKey string, paasResult *result.ResultBean) *proto.PaasDeployFile

func GetEtcdFullAddr

func GetEtcdFullAddr(etcdNodeArr []map[string]interface{}) string

func GetEtcdLongAddr

func GetEtcdLongAddr(etcdNodeArr []map[string]interface{}) string

func GetEtcdShortAddr

func GetEtcdShortAddr(etcdNodeArr []map[string]interface{}) string

func GetInstance

func GetInstance(instID string, logKey string, paasResult *result.ResultBean) (*proto.PaasInstance, bool)

func GetRealPort

func GetRealPort(item map[string]interface{}) string

func GetRealPortAsInt

func GetRealPortAsInt(item map[string]interface{}) int

func GetRedisClusterNode

func GetRedisClusterNode(sshClient *SSHClient, cmd, logKey string, paasResult *result.ResultBean) bool

func GetService

func GetService(instID string, logKey string, paasResult *result.ResultBean) (*proto.PaasService, bool)

func GetServiceTopo

func GetServiceTopo(servInstID, logKey string, paasResult *result.ResultBean) bool

func GetServiceVersion

func GetServiceVersion(servInstID, instID string) string

func GetSpecifiedBrokerArr

func GetSpecifiedBrokerArr(vbrokerArr []map[string]interface{}, instID string) []map[string]interface{}

func GetSpecifiedClickHouseItem

func GetSpecifiedClickHouseItem(jsonArr []map[string]interface{}, instID string) (map[string]interface{}, string)

func GetSpecifiedItem

func GetSpecifiedItem(jsonArr []map[string]interface{}, instID string) map[string]interface{}

func GetSpecifiedRocketMQBroker

func GetSpecifiedRocketMQBroker(vbrokerArr []map[string]interface{}, instID string) map[string]interface{}

func GetSpecifiedVBrokerId

func GetSpecifiedVBrokerId(vbrokerArr []map[string]interface{}, instID string) string

func GetStoreId

func GetStoreId(sshClient *SSHClient, pdIp, pdClientPort, ip, port, logKey string, paasResult *result.ResultBean) (int, bool)

func GetVersion

func GetVersion(servInstId, containerInstId, instId string) string

func GetVersionedFileName

func GetVersionedFileName(fileId int, version, logKey string, paasResult *result.ResultBean) string

func GetZKAddress

func GetZKAddress(zkArr []map[string]interface{}) string

func GetZKShortAddress

func GetZKShortAddress(zkArr []map[string]interface{}) string

func GetZkCluster

func GetZkCluster(zkArr []map[string]interface{}) string

func InitRedisCluster

func InitRedisCluster(sshClient *SSHClient, initCmd, logKey string, paasResult *result.ResultBean) bool

func IsDirExistInCurrPath

func IsDirExistInCurrPath(sshClient *SSHClient, fileDir, logKey string, paasResult *result.ResultBean) (bool, error)

func IsFileExist

func IsFileExist(sshClient *SSHClient, fileName string, isDir bool, logKey string, paasResult *result.ResultBean) bool

func IsInstanceDeployed

func IsInstanceDeployed(logKey string, inst *proto.PaasInstance, paasResult *result.ResultBean) bool

func IsInstanceNotDeployed

func IsInstanceNotDeployed(logKey string, inst *proto.PaasInstance, paasResult *result.ResultBean) bool

func IsPreEmbadded

func IsPreEmbadded(instId string) bool

func IsProcExist

func IsProcExist(sshClient *SSHClient, identify, logKey string, paasResult *result.ResultBean) bool

func IsSameSSH

func IsSameSSH(instID, nextInstID string) bool

func IsServiceDeployed

func IsServiceDeployed(logKey string, service *proto.PaasService, paasResult *result.ResultBean) bool

func IsServiceNotDeployed

func IsServiceNotDeployed(logKey string, service *proto.PaasService, paasResult *result.ResultBean) bool

func JoinRedisCluster

func JoinRedisCluster(sshClient *SSHClient, cmdJoin, logKey string, paasResult *result.ResultBean) bool

func LoadServTopo

func LoadServTopo(servInstID, logKey string, checkFlag bool, paasResult *result.ResultBean) (map[string]interface{}, string, bool)

func LoadServTopoForIncrDeploy

func LoadServTopoForIncrDeploy(servInstID, instID, logKey string, checkFlag bool,
	paasResult *result.ResultBean) (map[string]interface{}, string, bool)

func MV

func MV(sshClient *SSHClient, newName, oldName, logKey string, paasResult *result.ResultBean) bool

func MkDir

func MkDir(sshClient *SSHClient, dir, logKey string, paasResult *result.ResultBean) bool

func PWD

func PWD(sshClient *SSHClient, logKey string, paasResult *result.ResultBean) (string, error)

func PdctlDeleteTikvStore

func PdctlDeleteTikvStore(sshClient *SSHClient, pdIp, pdPort string,
	id int, logKey string, paasResult *result.ResultBean) bool

func PdctlGetStore

func PdctlGetStore(sshClient *SSHClient, ip, port, logKey string, paasResult *result.ResultBean) *proto.TikvStore

func PostDeployLog

func PostDeployLog(isOk bool, servInstID, logKey, flag string)

func PostProc

func PostProc(servInstID, deployFlag, logKey, magicKey string, paasResult *result.ResultBean) bool

func RM

func RM(sshClient *SSHClient, file, logKey string, paasResult *result.ResultBean) bool

func RedisSlaveOf

func RedisSlaveOf(sshClient *SSHClient, slaveCmd, logKey string, paasResult *result.ResultBean) bool

func RemoveRedisNodeFromCluster

func RemoveRedisNodeFromCluster(sshClient *SSHClient, ip, redisPort, selfId, logKey string, paasResult *result.ResultBean) bool

func ResetDBPwd

func ResetDBPwd(tidb map[string]interface{}, logKey string, paasResult *result.ResultBean) bool

func ReshardingRedisSlot

func ReshardingRedisSlot(sshClient *SSHClient, cmdMig, logKey string, paasResult *result.ResultBean) bool

func SED

func SED(sshClient *SSHClient, oldValue, newValue, file, logKey string, paasResult *result.ResultBean) bool

func Shutdown

func Shutdown(sshClient *SSHClient, instId, cmptName, stopCmd, deployDir, checkPort, deployFlag, logKey, magicKey string,
	paasResult *result.ResultBean) bool

func Startup

func Startup(sshClient *SSHClient, instId, cmptName, startCmd, checkPort, deployFlag, logKey, magicKey string,
	paasResult *result.ResultBean) bool

func StartupPreEmbadded

func StartupPreEmbadded(sshClient *SSHClient, instId, cmptName, logKey, magicKey string,
	paasResult *result.ResultBean) bool

func TAR

func TAR(sshClient *SSHClient, tarParams, srcFileName, desFileName, logKey string, paasResult *result.ResultBean) bool

func UnZip

func UnZip(sshClient *SSHClient, srcFileName, desFileName, logKey string, paasResult *result.ResultBean) bool

func UndeployEtcdNode

func UndeployEtcdNode(etcdNode map[string]interface{}, logKey, magicKey string, paasResult *result.ResultBean) bool

func UndeployGrafana

func UndeployGrafana(grafana map[string]interface{}, version, logKey, magicKey string, paasResult *result.ResultBean) bool

func UndeployPrometheus

func UndeployPrometheus(prometheus map[string]interface{}, version, logKey, magicKey string, paasResult *result.ResultBean) bool

func UndeployZookeeper

func UndeployZookeeper(zk map[string]interface{}, version, logKey, magicKey string, paasResult *result.ResultBean) bool

Types

type SSHClient

type SSHClient struct {
	Ip      string
	SshPort int
	User    string
	Passwd  string
	// contains filtered or unexported fields
}

func GetSshClient

func GetSshClient(sshId, logKey string, paasResult *result.ResultBean) (*SSHClient, *proto.PaasSsh, bool)

func NewSSHClient

func NewSSHClient(ip string, sshPort int, user string, passwd string) *SSHClient

func NewSSHClientBySSH

func NewSSHClientBySSH(ssh *proto.PaasSsh) *SSHClient

func (*SSHClient) CheckTaosNodeOffLine

func (h *SSHClient) CheckTaosNodeOffLine(cmd, node, logKey string, paasResult *result.ResultBean) bool

func (*SSHClient) CheckTaosNodeOnline

func (h *SSHClient) CheckTaosNodeOnline(cmd, node, logKey string, paasResult *result.ResultBean) bool

func (*SSHClient) Close

func (h *SSHClient) Close()

func (*SSHClient) Connect

func (h *SSHClient) Connect() bool

func (*SSHClient) CreateOrDropNode

func (h *SSHClient) CreateOrDropNode(cmd, logKey string, paasResult *result.ResultBean) bool

func (*SSHClient) Dos2Unix

func (h *SSHClient) Dos2Unix(cmd string) (string, error)

func (*SSHClient) ExecCmd

func (h *SSHClient) ExecCmd(cmd string) ([]byte, error)

func (*SSHClient) ExecInteractCmd

func (h *SSHClient) ExecInteractCmd(cmd string) error

需要交互式执行, 比如scp需要输入密码, 将执行与处理交互式部分分开

func (*SSHClient) GeneralCommand

func (h *SSHClient) GeneralCommand(cmd string) (string, error)

func (*SSHClient) InitRedisCluster

func (h *SSHClient) InitRedisCluster(cmd string) ([]byte, bool, error)

func (*SSHClient) IsFileExist

func (h *SSHClient) IsFileExist(fileName string, isDir bool) (bool, error)

func (*SSHClient) IsPortUsed

func (h *SSHClient) IsPortUsed(port string) (bool, error)

func (*SSHClient) IsProcExist

func (h *SSHClient) IsProcExist(identify, logKey string) (bool, error)

func (*SSHClient) JoinRedisCluster

func (h *SSHClient) JoinRedisCluster(cmd string) ([]byte, bool, error)

func (*SSHClient) LoginTaosShell

func (h *SSHClient) LoginTaosShell(cmd, logKey string, paasResult *result.ResultBean) bool

func (*SSHClient) MigrateRedisClusterSlot

func (h *SSHClient) MigrateRedisClusterSlot(cmd, logKey string, paasResult *result.ResultBean) bool

func (*SSHClient) ReadRedisDeleteNode

func (h *SSHClient) ReadRedisDeleteNode() ([]byte, error)

func (*SSHClient) ReadRedisInitAccept

func (h *SSHClient) ReadRedisInitAccept() ([]byte, error)

func (*SSHClient) ReadRedisInitOkOrErr

func (h *SSHClient) ReadRedisInitOkOrErr() ([]byte, error)

func (*SSHClient) ReadRedisJoinOkOrErr

func (h *SSHClient) ReadRedisJoinOkOrErr() ([]byte, bool, error)

func (*SSHClient) ReadRedisMigrateSlot

func (h *SSHClient) ReadRedisMigrateSlot() ([]byte, error)

func (*SSHClient) ReadRedisReshardingOkOrErr

func (h *SSHClient) ReadRedisReshardingOkOrErr() ([]byte, bool, error)

func (*SSHClient) ReadRedisSlaveOfOkOrErr

func (h *SSHClient) ReadRedisSlaveOfOkOrErr() ([]byte, bool, error)

func (*SSHClient) ReadScpOut

func (h *SSHClient) ReadScpOut() ([]byte, error)

func (*SSHClient) ReadTaosEnd

func (h *SSHClient) ReadTaosEnd() bool

func (*SSHClient) ReadTaosOK

func (h *SSHClient) ReadTaosOK() bool

func (*SSHClient) ReadToEof

func (h *SSHClient) ReadToEof() ([]byte, error)

func (*SSHClient) RedisSlaveOf

func (h *SSHClient) RedisSlaveOf(cmd string) ([]byte, bool, error)

func (*SSHClient) RemoveFromRedisCluster

func (h *SSHClient) RemoveFromRedisCluster(cmd, logKey string, paasResult *result.ResultBean) bool

func (*SSHClient) ReshardingRedisSlot

func (h *SSHClient) ReshardingRedisSlot(cmd string) ([]byte, bool, error)

func (*SSHClient) SCP

func (h *SSHClient) SCP(user, passwd, srcHost, sshPort, srcFile, desFile, logKey string,
	paasResult *result.ResultBean) bool

func (*SSHClient) Tail

func (h *SSHClient) Tail(file string, lines int) (string, error)

func (*SSHClient) Wait

func (h *SSHClient) Wait()

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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