Files
cloudpods/pkg/scheduler/handler/ping.go
T
Qiu Jian fcee2de326 修正:1. 由于系统盘大小设置单位未转换,导致阿里云创建主机失败 2.
伪删除阿里云主机后,detach了系统盘,导致主机恢复后无系统盘 3.
修正一些格式错误 4. 补充一些climc命令
2018-07-31 00:42:18 +08:00

53 lines
1.3 KiB
Go

package handler
import (
"fmt"
"net/http"
"gopkg.in/gin-gonic/gin.v1"
"github.com/yunionio/log"
o "github.com/yunionio/onecloud/cmd/scheduler/options"
schedman "github.com/yunionio/onecloud/pkg/scheduler/manager"
)
var counter = 0
func InstallPingHandler(r *gin.Engine) {
r.GET("/ping", pingHandler)
r.GET("/switch", switchHandler)
}
// pingHandler is a handler of ping-pong service that just for
// testing scheduler serevice.
func pingHandler(c *gin.Context) {
if !schedman.IsReady() {
c.AbortWithError(http.StatusBadRequest, fmt.Errorf("Global scheduler not init"))
return
}
log.Infof("%v", c.Request.Body)
c.JSON(http.StatusOK, "pong")
}
// switchHandler is a handler of switch service that just for
// testing scheduler serevice.
func switchHandler(c *gin.Context) {
if !schedman.IsReady() {
c.AbortWithError(http.StatusBadRequest, fmt.Errorf("Global scheduler not init"))
return
}
log.Infof("%v", c.Request.Body)
counter++
var result string
if counter%2 == 1 {
o.GetOptions().DisableBaremetalPredicates = true
result = fmt.Sprintf("ignore_baremetal_filter_switch is true")
} else {
o.GetOptions().DisableBaremetalPredicates = false
result = fmt.Sprintf("ignore_baremetal_filter_switch is false")
}
c.JSON(http.StatusOK, result)
}