Exemple #1
0
func getCode(node string, dbMap *gorp.DbMap) (string, error) {
	length := len(strings.Split(node, "/"))
	id := strings.Split(node, "/")[length-1]
	code, err := dbMap.SelectStr("SELECT code FROM neo_map WHERE id ='" + id + "'")
	if err != nil {
		fmt.Println(err)
		return "", err
	}
	return code, nil
}
Exemple #2
0
func LookupUUID(db *gorp.DbMap, field map[string]interface{}) string {
	fields := []string{"name", "hostname"}

	if uuid, ok := field["uuid"]; ok == true {
		return uuid.(string)
	}

	for i := 0; i < len(fields); i++ {
		if val, ok := field[fields[i]]; ok == true {
			myuuid, err := db.SelectStr("select UUID from jail where "+fields[i]+" = ?", val)
			if err == nil {
				return myuuid
			}
		}
	}

	return ""
}