12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879 |
- package global
- import (
- "time"
- "xg_auto_deploy/internal/config"
- "xg_auto_deploy/internal/logger"
- "xg_auto_deploy/internal/models"
- "golang.org/x/crypto/ssh"
- )
- var ServerNodeConfigs = make(map[string]models.ServerNodeConfig)
- var XginiConfigMap map[string]string
- var ClusterConfigMap map[string]string
- var ClusterInfo = &models.ClusterConfig{}
- var Logs = logger.Init("./logs/xg_autodeploy.log", "info")
- func InitNodeSetting(path string) {
- XginiConfigMap = make(map[string]string)
- ClusterConfigMap = make(map[string]string)
-
- configTemp := config.InitNodeSetting(path)
-
- XginiConfigMap = configTemp.GetXuguini()
- ClusterConfigMap = configTemp.GetCluster()
-
- var err error
- if ClusterConfigMap["local_file"] != "" {
- ClusterInfo, err = config.GetClusterConfig(ClusterConfigMap["local_file"])
- if err != nil {
- Logs.Fatalf("config.GetClusterConfig 失败")
- }
- }
- for key, value := range configTemp.GetNodeConfig() {
-
- sysInfo := &models.SysInfo{
- OsStackSize: "未检测",
- OsOpenFiles: "未检测",
- CoreWmemDefault: "未检测",
- CoreRmemDefault: "未检测",
- CoreRmemMax: "未检测",
- CoreWmemMax: "未检测",
- }
- appInfo := &models.AppInfo{
- Gcc: "未检测",
- Libaio: "未检测",
- Snmpd: "未检测",
- Ntpd: "未检测",
- }
- sshInfo := &models.SSHInfo{
- SSHClient: &ssh.ClientConfig{
- User: value.User,
- Auth: []ssh.AuthMethod{
- ssh.Password(value.Password),
- },
-
- ClientVersion: "",
- Timeout: 5 * time.Second,
- HostKeyCallback: ssh.InsecureIgnoreHostKey(),
- },
- }
- nodeTemp := models.ServerNodeConfig{
- NodeId: key,
- ServerNodeInfo: value,
- SysInfo: sysInfo,
- AppInfo: appInfo,
- SSHInfo: sshInfo,
- }
- ServerNodeConfigs[key] = nodeTemp
- }
- }
|