package global import ( "time" "xg_auto_deploy/internal/config" "xg_auto_deploy/internal/logger" "xg_auto_deploy/internal/models" "github.com/sirupsen/logrus" "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 *logrus.Logger func InitNodeSetting() { XginiConfigMap = make(map[string]string) ClusterConfigMap = make(map[string]string) Logs = logger.Init("./logs/xg_autodeploy.log", "info") configTemp := config.InitNodeSetting(`./file/config.toml`) //获取配置文件里的[xugu]组内容 XginiConfigMap = configTemp.GetXuguini() ClusterConfigMap = configTemp.GetCluster() //ClusterInfo = config.ReadXgClusterConfig(ClusterConfigMap["local_file"]) var err error ClusterInfo, err = config.GetClusterConfig(ClusterConfigMap["local_file"]) if err != nil { Logs.Fatalf("config.GetClusterConfig 失败") } for key, value := range configTemp.GetNodeConfig() { //fmt.Println(key, value) 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: 10 * time.Second, HostKeyCallback: ssh.InsecureIgnoreHostKey(), // 不验证远程主机的身份,仅用于示例,请不要在生产环境中使用 }, } nodeTemp := models.ServerNodeConfig{ NodeId: key, ServerNodeInfo: value, SysInfo: sysInfo, AppInfo: appInfo, SSHInfo: sshInfo, } ServerNodeConfigs[key] = nodeTemp } }