|
|
|
@@ -2885,3 +2885,46 @@ func getFlavorNameByFlavorCode(flavorCode string) string { |
|
|
|
"核" + strconv.Itoa(cardNum*256) + "GB" |
|
|
|
return cloudbrainTwoFlavorName |
|
|
|
} |
|
|
|
|
|
|
|
func GetLogFromModelDir(ctx *context.Context) { |
|
|
|
prefix := "/" + setting.CBCodePathPrefix + ctx.Cloudbrain.JobName |
|
|
|
files, err := storage.GetOneLevelAllObjectUnderDirMinio(setting.Attachment.Minio.Bucket, prefix, "") |
|
|
|
if err != nil { |
|
|
|
log.Error("query cloudbrain model failed: %v", err) |
|
|
|
return |
|
|
|
} |
|
|
|
startLine := ctx.QueryInt("startLine") |
|
|
|
endLine := ctx.QueryInt("endLine") |
|
|
|
re := "" |
|
|
|
for _, file := range files { |
|
|
|
if strings.HasSuffix(file.FileName, "log.txt") { |
|
|
|
reader, err := os.Open(storage.GetMinioPath(ctx.Cloudbrain.JobName, file.FileName)) |
|
|
|
defer reader.Close() |
|
|
|
if err == nil { |
|
|
|
r := bufio.NewReader(reader) |
|
|
|
for i := 0; i < endLine; i++ { |
|
|
|
line, error := r.ReadString('\n') |
|
|
|
if error == io.EOF { |
|
|
|
log.Info("read file completed.") |
|
|
|
break |
|
|
|
} |
|
|
|
if error != nil { |
|
|
|
log.Info("read file error." + error.Error()) |
|
|
|
break |
|
|
|
} |
|
|
|
if error == nil { |
|
|
|
if i >= startLine { |
|
|
|
re = re + line |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
break |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
ctx.JSON(http.StatusOK, map[string]interface{}{ |
|
|
|
"JobName": ctx.Cloudbrain.JobName, |
|
|
|
"Content": re, |
|
|
|
}) |
|
|
|
} |