当前位置: 首页>>代码示例>>Golang>>正文


Golang logs.Normal函数代码示例

本文整理汇总了Golang中ssh_proxy_manage/logs.Normal函数的典型用法代码示例。如果您正苦于以下问题:Golang Normal函数的具体用法?Golang Normal怎么用?Golang Normal使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了Normal函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: DeleteContainerUserFromProxy

func DeleteContainerUserFromProxy(rulelist []SshRule, logid int64) error {
	logs.Normal("delete container from proxy:", rulelist, "logid:", logid)
	token := beego.AppConfig.String("proxy_url_token")
	//userdel
	for _, sshRuleOb := range rulelist {
		container := sshRuleOb.ContainerName
		proxyHost := sshRuleOb.ProxyHost
		//this url todo
		proxyDelUrl := proxyHost + ":9090/deleteContainer?container=" + container + "&logid=" + strconv.FormatInt(logid, 10) + "&token=" + token
		logs.Normal("curl delete container url:", proxyDelUrl, "logid:", logid)

		req := httplib.Get(proxyDelUrl)
		output := make(map[string]interface{})
		err := req.ToJson(&output)
		if err != nil {
			logs.Error("request from "+proxyDelUrl+" error:", err, logid)
			return err
		}

		if output["result"].(int) == 0 {
			logs.Normal(proxyDelUrl, "response ok!", logid)
			continue
		} else {
			logs.Error(proxyDelUrl+" error:", output["error"], logid)
		}
	}
	return nil
}
开发者ID:a4m,项目名称:bae_ssh_manage,代码行数:28,代码来源:util.go

示例2: Update

func (u *SshRuleManage) Update(conn *sql.DB, ruleOb SshRule, logid int64) error {
	tableName := u.TableName()
	if ruleOb.ContainerName == "" {
		return errors.New("ssh rule object is not good! miss primary key!")
	}
	param := make([]interface{}, 0)
	param = append(param, ruleOb.ContainerName)
	sqlu := "update " + tableName + " set containerName = '" + ruleOb.ContainerName + "'"
	if ruleOb.ProxyHost != "" {
		sqlu += " ,proxyHost='" + ruleOb.ProxyHost + "'"
		param = append(param, ruleOb.ProxyHost)
	}
	if ruleOb.PublicPort != 0 {
		portstr := strconv.Itoa(ruleOb.PublicPort)
		sqlu += " ,sshPort=" + portstr
		param = append(param, ruleOb.PublicPort)
	}
	if ruleOb.UiIpPort != "" {
		sqlu += " ,uiIpPort='" + ruleOb.UiIpPort + "'"
		param = append(param, ruleOb.UiIpPort)
	}

	uidstr := strconv.Itoa(ruleOb.Uid)
	sqlu += " where containerName = '" + ruleOb.ContainerName + "' and uid = " + uidstr
	logs.Normal("sql update:", sqlu, "logid:", logid)
	param = append(param, ruleOb.ContainerName)
	_, err := conn.Exec(sqlu)
	if err != nil {
		logs.Error("conn exec error:", err, "logid:", logid)
	}
	return err
}
开发者ID:a4m,项目名称:bae_ssh_manage,代码行数:32,代码来源:ssh_rules.go

示例3: Get

func (this *SshProxyServerController) Get() {
	host := this.Ctx.Input.Params[":objectId"]
	if host == "" {
		this.Ctx.Output.SetStatus(403)
		this.Ctx.Output.Body([]byte(`{"result":1,"error":"param error"}`))
		this.StopRun()
	}

	dbconn, err := models.InitDbConn(0)
	if err != nil {
		logs.Error("init db conn error:", err, "logid:", 0)
		this.Ctx.Output.SetStatus(500)
		this.Ctx.Output.Body([]byte(`{"result":1,"error":"init db conn error"}`))
		this.StopRun()
	}
	defer dbconn.Close()

	sshProxyM := new(models.SshProxyManage)
	sshProxyOb, err := sshProxyM.Query(dbconn, host, 0)
	if err != nil {
		logs.Error("ssh proxy query error:", err, "logid:", 0)
		this.Ctx.Output.SetStatus(500)
		this.Ctx.Output.Body([]byte(`{"result":1,"error":"` + err.Error() + `"}`))
		this.StopRun()
	}
	logs.Normal("ssh post ok!", sshProxyOb, "logid:", 0)
	this.Data["json"] = sshProxyOb
	this.ServeJson()
}
开发者ID:a4m,项目名称:bae_ssh_manage,代码行数:29,代码来源:sshProxyServerController.go

示例4: Post

//curl -i -X POST 'localhost:9090/sshPort' -d '{"port":2300,"host":"testinfo2","number":10,"avail":"true"}'
func (this *SshPortController) Post() {
	var sshPortOb models.SshPort
	requestBody := string(this.Ctx.Input.RequestBody)
	err := json.Unmarshal(this.Ctx.Input.RequestBody, &sshPortOb)
	if err != nil {
		this.Ctx.Output.SetStatus(403)
		this.Ctx.Output.Body([]byte(`{"result":1,"error":"param error"}`))
		this.StopRun()
	}
	logid, err := models.GetLogId(this.Ctx.Input.RequestBody)
	if err != nil {
		this.Ctx.Output.SetStatus(403)
		this.Ctx.Output.Body([]byte(`{"result":1,"error":"logid param error"}`))
		this.StopRun()
	}
	logs.Normal("post data:", requestBody, "logid:", logid)

	dbconn, err := models.InitDbConn(logid)
	if err != nil {
		logs.Error("init db conn error:", err, "logid:", logid)
		this.Ctx.Output.SetStatus(500)
		this.Ctx.Output.Body([]byte(`{"result":1,"error":"init db conn error"}`))
		this.StopRun()
	}
	defer dbconn.Close()

	dbconn.Exec("START TRANSACTION")
	logs.Normal("start transaction", "logid:", logid)

	sshPortM := new(models.SshPortManage)
	err = sshPortM.Insert(dbconn, sshPortOb, logid)
	if err != nil {
		dbconn.Exec("ROLLBACK")
		logs.Normal("ROLLBACK", "logid:", logid)
		logs.Error("ssh port insert error:", err, "logid:", logid)
		this.Ctx.Output.SetStatus(500)
		this.Ctx.Output.Body([]byte(`{"result":1,"error":` + err.Error() + `}`))
		this.StopRun()
	}
	dbconn.Exec("COMMIT")
	logs.Normal("COMMIT", "logid:", logid)
	logs.Normal("ssh post OK!", "logid:", logid)
	this.Ctx.Output.Body([]byte(`{"result":0}`))
}
开发者ID:a4m,项目名称:bae_ssh_manage,代码行数:45,代码来源:sshPortController.go

示例5: DeleteByUid

func (u *SshRuleManage) DeleteByUid(conn *sql.DB, uid string, logid int64) error {
	tableName := u.TableName()
	sqld := "delete from " + tableName + " where uid = " + uid
	logs.Normal("delete by uid sql:", sqld, "logid:", logid)
	if _, err := conn.Exec(sqld); err != nil {
		logs.Error("conn exec error:", err, "logid:", logid)
		return err
	}
	return nil
}
开发者ID:a4m,项目名称:bae_ssh_manage,代码行数:10,代码来源:ssh_rules.go

示例6: DeleteByKey

func (u *SshKeysManage) DeleteByKey(conn *sql.DB, uid string, key string, logid int64) error {
	tableName := u.TableName()
	sqld := "delete from " + tableName + " where uid = " + uid + " and keyName='" + key + "'"
	if _, err := conn.Exec(sqld); err != nil {
		logs.Error("sql deleteByKey error!", err, sqld, "logid:", logid)
		return err
	}
	logs.Normal("sql deleteByKey OK!", sqld, "logid:", logid)
	return nil
}
开发者ID:a4m,项目名称:bae_ssh_manage,代码行数:10,代码来源:ssh_keys.go

示例7: Delete

func (u *SshProxyManage) Delete(conn *sql.DB, host string, logid int64) error {
	tableName := u.TableName()
	sqld := "delete from " + tableName + " where machineHost = '" + host + "'"
	logs.Normal("sql delete:", sqld, "logid:", logid)
	if _, err := conn.Exec(sqld); err != nil {
		logs.Error("conn exec error:", err, "logid:", logid)
		return err
	}
	return nil
}
开发者ID:a4m,项目名称:bae_ssh_manage,代码行数:10,代码来源:ssh_proxy_machine.go

示例8: Delete

func (u *SshRuleManage) Delete(conn *sql.DB, uid, cname string, logid int64) error {
	tableName := u.TableName()
	sqld := "delete from " + tableName + " where uid= " + uid + " and containerName = '" + cname + "'"
	logs.Normal("delete sql:", sqld, "logid:", logid)
	if _, err := conn.Exec(sqld); err != nil {
		logs.Error("conn exec error:", err, "logid:", logid)
		return err
	}
	return nil
}
开发者ID:a4m,项目名称:bae_ssh_manage,代码行数:10,代码来源:ssh_rules.go

示例9: Delete

func (this *SshProxyServerController) Delete() {
	host := this.Ctx.Input.Params[":objectId"]
	if host == "" {
		this.Ctx.Output.SetStatus(403)
		this.Ctx.Output.Body([]byte(`{"result":1,"error":"param error"}`))
		this.StopRun()
	}
	logid, _ := this.GetInt("logid")
	if logid == 0 {
		this.Ctx.Output.SetStatus(403)
		this.Ctx.Output.Body([]byte(`{"result":1,"error":"logid param error"}`))
		this.StopRun()
	}
	logs.Normal("delete param:", "host:", host, "logid:", logid)
	dbconn, err := models.InitDbConn(logid)
	if err != nil {
		logs.Error("init db conn error:", err, "logid:", logid)
		this.Ctx.Output.SetStatus(500)
		this.Ctx.Output.Body([]byte(`{"result":1,"error":"init db conn error"}`))
		this.StopRun()
	}
	defer dbconn.Close()

	dbconn.Exec("START TRANSACTION")
	logs.Normal("start transaction", "logid:", logid)

	sshProxyM := new(models.SshProxyManage)
	err = sshProxyM.Delete(dbconn, host, logid)
	if err != nil {
		dbconn.Exec("ROLLBACK")
		logs.Normal("ROLLBACK", "logid:", logid)
		logs.Error("ssh proxy delete err:", err, "logid:", logid)
		this.Ctx.Output.SetStatus(500)
		this.Ctx.Output.Body([]byte(`{"result":1,"error":"` + err.Error() + `"}`))
		this.StopRun()
	}
	dbconn.Exec("COMMIT")
	logs.Normal("COMMIT", "logid:", logid)
	logs.Normal("ssh proxy delete OK!", "logid:", logid)
	this.Ctx.Output.Body([]byte(`{"result":0}`))
	this.StopRun()
}
开发者ID:a4m,项目名称:bae_ssh_manage,代码行数:42,代码来源:sshProxyServerController.go

示例10: reloadSshPublicKeys

func (this *SshKeysController) reloadSshPublicKeys(dbconn *sql.DB, uid string, logid int64) error {
	sshKeysM := new(models.SshKeysManage)
	pubSshKeyMap, errall := sshKeysM.GetAll(dbconn, uid, logid)
	logs.Normal("reloadSshPublicKeys get sshkey map:", pubSshKeyMap, "logid:", logid)
	if errall != nil {
		logs.Error("sshKeysM.GetAll error!", errall, " uid:", uid, "logid:", logid)
		return errall
	}
	//check ssh rules,if the rules is null,then only change ssh keys;
	// if the rules is not null,then change the proxy server
	sshRuleM := new(models.SshRuleManage)
	rulelist, err := sshRuleM.QueryByUid(dbconn, uid, logid)
	if err != nil {
		logs.Error("sshRuleM.QueryByUid error!", err, " uid:", uid, "logid:", logid)
		return err
	}
	logs.Normal("sshRuleM.QueryByUid get rule list:", rulelist, "logid:", logid)
	if len(rulelist) > 0 {
		err = models.UpdateRule(rulelist, pubSshKeyMap, logid)
	}
	return err
}
开发者ID:a4m,项目名称:bae_ssh_manage,代码行数:22,代码来源:sshKeysController.go

示例11: system

func (this *SshAgentController) system(s, logid string) (string, error) {
	cmd := exec.Command("/bin/sh", "-c", s)
	var out bytes.Buffer
	cmd.Stdout = &out
	err := cmd.Run()
	if err != nil {
		logs.Error("exec command error happened:", err, "the command is :", s, logid)
		return "", err
	}
	output := strings.TrimSpace(out.String())
	logs.Normal("exec command result is: ", output, "process state is :", cmd.ProcessState, logid)
	//fmt.Printf("%s\n", out.String(), cmd.ProcessState)
	return output, err
}
开发者ID:a4m,项目名称:bae_ssh_manage,代码行数:14,代码来源:sshagent.go

示例12: UpdateRule

func UpdateRule(rulelist []SshRule, keylist map[string]string, logid int64) error {
	logs.Normal("update rule list:", rulelist, "key list", keylist, "logid:", logid)
	token := beego.AppConfig.String("proxy_url_token")
	keylistStr, _ := json.Marshal(keylist)
	//useradd
	for _, sshRuleOb := range rulelist {
		container := sshRuleOb.ContainerName
		proxyHost := sshRuleOb.ProxyHost
		uiIpPort := sshRuleOb.UiIpPort
		uiArr := strings.Split(uiIpPort, ":")
		if len(uiArr) != 2 {
			logs.Error("update rule uiIpPort Error!", uiIpPort, container, proxyHost)
			continue
		}
		//this url todo
		proxyAddUrl := "http://" + proxyHost + ":9090/updateContainer?container=" + container + "&uiip=" + uiArr[0] + "&uiport=" + uiArr[1] + "&keylist=" + string(keylistStr) + "&logid=" + strconv.FormatInt(logid, 10) + "&token=" + token
		logs.Normal("curl add container url:", proxyAddUrl, "logid:", logid)

		req := httplib.Get(proxyAddUrl)
		output := make(map[string]interface{})
		err := req.ToJson(&output)
		if err != nil {
			logs.Error("request from "+proxyAddUrl+" error:", err, logid)
			return err
		}

		if output["result"].(int) == 0 {
			logs.Normal(proxyAddUrl, "response ok!", logid)
			continue
		} else {
			logs.Error(proxyAddUrl+" error:", output["error"], logid)
		}

	}
	return nil
}
开发者ID:a4m,项目名称:bae_ssh_manage,代码行数:36,代码来源:util.go

示例13: Insert

func (u *SshRuleManage) Insert(conn *sql.DB, sshRuleOb SshRule, logid int64) error {
	tableName := u.TableName()
	sqli := "INSERT INTO " + tableName + " (containerName,sshPort,proxyHost,uiIpPort,uid,addTime) VALUES (?,?,?,?,?,?)"
	logs.Normal("insert sql:", sqli, sshRuleOb, "logid:", logid)
	stmt, sterr := conn.Prepare(sqli)
	if sterr != nil {
		logs.Error("conn prepare error:", sterr, sqli, "logid:", logid)
		return sterr
	}
	if _, err := stmt.Exec(sshRuleOb.ContainerName, sshRuleOb.PublicPort, sshRuleOb.ProxyHost, sshRuleOb.UiIpPort, sshRuleOb.Uid, time.Now().Format("2006-01-02 15:04:05")); err != nil {
		logs.Error("sql exec error:", err, sqli, "logid:", logid)
		return err
	}
	return nil
}
开发者ID:a4m,项目名称:bae_ssh_manage,代码行数:15,代码来源:ssh_rules.go

示例14: Insert

func (u *SshKeysManage) Insert(conn *sql.DB, sshKeysOb SshKeys, logid int64) error {
	tableName := u.TableName()
	sqli := "INSERT INTO " + tableName + " (uid,keyName,publicKey,addTime) VALUES (?,?,?,?)"
	stmt, sterr := conn.Prepare(sqli)
	if sterr != nil {
		logs.Error("sql prepare error:", sterr, "logid:", logid)
		return sterr
	}
	if _, err := stmt.Exec(sshKeysOb.Uid, sshKeysOb.KeyName, sshKeysOb.PublicKey, time.Now().Format("2006-01-02 15:04:05")); err != nil {
		logs.Error("sql exec error:", sterr, " the sql is:", sqli, sshKeysOb, "logid:", logid)
		return err
	}
	logs.Normal("sql insert OK!", sqli, sshKeysOb, "logid:", logid)
	return nil
}
开发者ID:a4m,项目名称:bae_ssh_manage,代码行数:15,代码来源:ssh_keys.go

示例15: Insert

func (u *SshProxyManage) Insert(conn *sql.DB, sshProxyOb SshProxyMachine, logid int64) error {
	tableName := u.TableName()
	sqli := "INSERT INTO " + tableName + " (machineHost,userNumber,isAvail,addTime) VALUES (?,?,?,?)"
	logs.Normal("insert:", sqli, sshProxyOb, "logid:", logid)
	stmt, sterr := conn.Prepare(sqli)
	if sterr != nil {
		logs.Error("conn prepare error:", sterr, "logid:", logid)
		return sterr
	}
	if _, err := stmt.Exec(sshProxyOb.MachineHost, sshProxyOb.UserNumber, sshProxyOb.IsAvail, time.Now().Format("2006-01-02 15:04:05")); err != nil {
		logs.Error("stmt exec error:", err, "logid:", logid)
		return err
	}
	return nil
}
开发者ID:a4m,项目名称:bae_ssh_manage,代码行数:15,代码来源:ssh_proxy_machine.go


注:本文中的ssh_proxy_manage/logs.Normal函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。