Beispiel #1
0
func (r *HostClient) UpdateUnDeployList(list *JSON.Type) error {
	db.Orm().Read(r.WebServer)
	newList := JSON.Extend(r.WebServer.UnDeployList, list)
	r.WebServer.UnDeployList = JSON.Stringify(newList)
	_, err := db.Orm().Update(r.WebServer, "UnDeployList")
	if err != nil {
		return err
	}
	return nil
}
Beispiel #2
0
//TODO 合并
func Find(client model.WebServer) (*model.WebServer, error) {
	err := db.Orm().Read(&client)
	if err != nil {
		return &client, err
	}
	return &client, nil
}
Beispiel #3
0
func (r *HostClient) GetUnDeployFiles() (JSON.Type, error) {
	c := model.WebServer{Id: r.Id}
	err := db.Orm().Read(&c)
	if err != nil {
		return nil, err
	}
	return JSON.Parse(c.UnDeployList), nil
}
Beispiel #4
0
func Del(client *model.WebServer) error {
	id := client.Id
	if _, err := db.Orm().Delete(client); err != nil {
		return err
	}
	delete(hostMap, id)
	return nil
}
Beispiel #5
0
func DeployMessage(message string) error {
	LastVersion.Comment = message
	if _, err := db.Orm().Update(&LastVersion, "Comment"); err != nil {
		fmt.Println("error", err)
		return err
	}
	return nil
}
Beispiel #6
0
//添加更新记录
func UpdateVersion(data *model.Version) error {
	if _, err := db.Orm().Insert(data); err != nil {
		return helper.NewError("save version error", err)
	}
	LastVersion = *data
	Version = LastVersion.Version
	return nil
}
Beispiel #7
0
//获取最新版本
func GetLastVersion() (model.Version, error) {
	LastVersion = model.Version{}
	if err := db.Orm().QueryTable("version").OrderBy("-id").Limit(1).One(&LastVersion); err != nil {
		return LastVersion, helper.NewError("SvnService.GetLastVersion", err)
	}
	Version = LastVersion.Version
	return LastVersion, nil
}
Beispiel #8
0
func Edit(client *model.WebServer, fields ...string) error {
	if _, err := db.Orm().Update(client, fields...); err != nil {
		return err
	}

	if c := FindFromCache(client.Id); c != nil {
		helper.ExtendStruct(c, client, fields...)
	}

	return nil
}
Beispiel #9
0
func Fetch() (HostMap, error) {
	var list []*model.WebServer
	hostMap = HostMap{}
	_, err := db.Orm().QueryTable("web_server").All(&list)
	if err == nil {
		for _, webServer := range list {
			hostMap[webServer.Id] = &HostClient{webServer, status.Die, &ProcStat{}, "", ""}
		}
	}
	return hostMap, err
}
Beispiel #10
0
func Active(client *model.WebServer) (int64, error) {
	created, id, err := db.Orm().ReadOrCreate(client, "Ip", "InternalIp", "Port")
	if err != nil {
		return id, err
	}
	if created || id > 0 {
		id = FindOrAppend(client)
		return id, nil
	}

	return id, helper.NewError(helper.AppendString("already exisits client, id: ", id))
}
Beispiel #11
0
func Fetch() (GroupMap, error) {
	var list []*model.Group
	groupMap = GroupMap{}
	_, err := db.Orm().QueryTable("group").All(&list)
	if err == nil {
		for _, group := range list {
			groupMap[group.Id] = group
		}
	}
	groupMap[0] = &model.Group{0, "Ungrouped", ""}
	return groupMap, err
}
Beispiel #12
0
func Add(rend render.Render, req *http.Request) {
	cfg := model.Config{
		Name: "hahaha",
		Content: JSON.Stringify(JSON.Type{
			"Name":    "languid",
			"XX":      "jeremy",
			"isTest":  true,
			"clients": []int{1, 2, 3, 4, 5},
		}),
	}

	if _, err := db.Orm().Insert(&cfg); err != nil {
		rend.JSON(200, helper.Error(err))
		return
	}

	result := JSON.Parse(cfg)
	result["Content"] = JSON.Parse(result["Content"])

	rend.JSON(200, helper.Success(result))
}
Beispiel #13
0
func Add(name string) (*model.Group, error) {
	var group model.Group
	group.Name = name
	_, err := db.Orm().Insert(&group)
	return &group, err
}