Beispiel #1
0
func (h *RpcClient) CheckDeployPath(r *http.Request, args *rpc.CheckDeployPathArgs, reply *rpc.RpcReply) error {
	if err := utils.PathEnable(args.Path); err != nil {
		reply.Response = err.Error()
	} else {
		reply.Response = true
	}
	return nil
}
Beispiel #2
0
func (h *RpcClient) Deploy(r *http.Request, args *rpc.SimpleArgs, reply *rpc.RpcReply) error {
	host.Active(args.Id)

	task.Trigger("host.Deploy")
	reply.Response = true
	return nil
}
Beispiel #3
0
func (h *RpcServer) DeployStatue(r *http.Request, args *rpc.SimpleArgs, reply *rpc.RpcReply) error {

	c := client.FindFromCache(args.Id)

	c.SetMessage(args.Message)
	webSocket.BroadCastAll(&webSocket.Message{
		Method: "deploy",
		Params: args,
	})

	switch args.What {
	case deployEnum.Error:
		c.SetError(args.Message)
		c.SetMessage()
		c.SetBusy(false)
		break
	case deployEnum.Finish:
		c.SetError()
		c.SetMessage()
		c.SetBusy(false)
		break
	}

	reply.Response = true
	return nil
}
Beispiel #4
0
func (h *RpcServer) ReportUsage(r *http.Request, args *rpc.UsageArgs, reply *rpc.RpcReply) error {
	if args.Id > 0 {
		client.UpdateUsage(args.Id, args.CPUPercent, args.MEMPercent)
	}
	reply.Response = true
	return nil
}
Beispiel #5
0
func (h *RpcServer) Status(r *http.Request, args *JSON.Type, reply *rpc.RpcReply) error {
	reply.Response = JSON.Type{
		"Ip":     "ok",
		"Status": "ok",
	}
	return nil
}
Beispiel #6
0
func (h *RpcClient) GetBackupList(r *http.Request, args *rpc.SimpleArgs, reply *rpc.RpcReply) error {
	host.Active(args.Id)
	result, err := host.GetBackupList()
	if err != nil {
		return err
	}
	reply.Response = result
	return nil
}
Beispiel #7
0
func (h *RpcClient) Revert(r *http.Request, args *rpc.SimpleArgs, reply *rpc.RpcReply) error {
	host.Active(args.Id)

	err := host.Revert(args.Message)
	if err != nil {
		return err
	}
	reply.Response = true
	return nil
}
Beispiel #8
0
//客户端启动通知,保存客户端入库
func (h *RpcServer) Active(r *http.Request, args *rpc.ActiveArgs, reply *rpc.RpcReply) error {
	id, err := client.Active(&model.WebServer{
		Ip:         args.Ip,
		InternalIp: args.InternalIp,
		Port:       args.Port,
	})
	if err != nil {
		return helper.NewError("add client error", err)
	}
	reply.Response = id
	return nil
}
Beispiel #9
0
func (h *RpcClient) ShowLog(r *http.Request, args *rpc.SimpleArgs, reply *rpc.RpcReply) error {
	host.Active(args.Id)
	output, err := host.ShowLog()
	reply.Response = output
	return err
}
Beispiel #10
0
func (h *RpcClient) Update(r *http.Request, args *rpc.UpdateArgs, reply *rpc.RpcReply) error {
	host.Active(args.Id)
	reply.Response = host.Update(args)
	return nil
}
Beispiel #11
0
func (h *RpcServer) BroadCastAll(r *http.Request, args *webSocket.Message, reply *rpc.RpcReply) error {
	webSocket.BroadCastAll(args)
	reply.Response = true
	return nil
}
Beispiel #12
0
func (h *RpcServer) Message(r *http.Request, args *JSON.Type, reply *rpc.RpcReply) error {
	reply.Response = args
	return nil
}