當前位置: 首頁>>代碼示例>>Golang>>正文


Golang ltm.Loadbalancer函數代碼示例

本文整理匯總了Golang中github.com/zalando-techmonkeys/baboon-proxy/ltm.Loadbalancer函數的典型用法代碼示例。如果您正苦於以下問題:Golang Loadbalancer函數的具體用法?Golang Loadbalancer怎麽用?Golang Loadbalancer使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了Loadbalancer函數的13個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: LTMVirtualServerNameList

// LTMVirtualServerNameList show local traffic manager specific virtual server
func LTMVirtualServerNameList(c *gin.Context) {
	lbpair := c.Params.ByName("lbpair")
	vservername := c.Params.ByName("virtual")
	f5url, err := ltm.Loadbalancer(lbpair, conf.Ltmdevicenames)
	if err != nil {
		respondWithStatus(err.Status, vservername, nil, err.Message, conf.Documentation["ltmvirtualdocumentationuri"], c)
		return
	}
	res, virtualservernamelist, err := ltm.ShowLTMVirtualServerName(f5url, vservername)
	if err != nil {
		respondWithStatus(err.Status, vservername, nil, err.Message, conf.Documentation["ltmvirtualdocumentationuri"], c)
		return
	}
	json.Unmarshal([]byte(res.Body), &returnerror)
	u1 := new(url.URL)
	u1.Scheme = common.Protocol
	u1.Path = path.Join(c.Request.Host, c.Request.RequestURI, common.ProfilesURI)
	u2 := new(url.URL)
	u2.Scheme = common.Protocol
	u2.Path = path.Join(c.Request.Host, c.Request.RequestURI, common.FwURI)
	virtualservernamelist.ProfilesReference = u1.String()
	virtualservernamelist.FwRulesReference = u2.String()
	if len(virtualservernamelist.Pool) > 0 {
		u := new(url.URL)
		u.Scheme = common.Protocol
		u.Path = path.Join(c.Request.Host, "/api/ltms/", lbpair, common.PoolsURI, util.ReplaceCommon(virtualservernamelist.Pool))
		virtualservernamelist.PoolsReference = u.String()
	}
	respondWithStatus(res.Status, "", virtualservernamelist, returnerror.ErrorMessage(), conf.Documentation["ltmvirtualdocumentationuri"], c)
}
開發者ID:zalando,項目名稱:baboon-proxy,代碼行數:31,代碼來源:client.go

示例2: LTMBlockIPPatch

// LTMBlockIPPatch add ips which will be blocked
func LTMBlockIPPatch(c *gin.Context) {
	var blockips ltm.CreateAddresses

	f5url, err := ltm.Loadbalancer(c.Params.ByName("lbpair"), conf.Ltmdevicenames)
	if err != nil {
		respondWithStatus(err.Status, "", nil, err.Message, conf.Documentation["ltmaddresslistdocumentationuri"], c)
		return
	}
	f5url = util.ReplaceLTMUritoAddressListURI(f5url)
	if err := c.BindJSON(&blockips); err != nil {
		respondWithStatus(http.StatusBadRequest, "Invalid JSON data", "Block IPs",
			fmt.Sprintf("%s", err), conf.Documentation["ltmaddresslistdocumentationuri"], c)
		return
	}
	res, err := ltm.PatchLTMBlockAddresses(f5url, &blockips)
	if err != nil {
		respondWithStatus(err.Status, "", nil, err.Message, conf.Documentation["ltmaddresslistdocumentationuri"], c)
		return
	}
	json.Unmarshal([]byte(res.Body), &returnerror)
	if res.Status == http.StatusOK {
		res.Status = http.StatusCreated
	}
	respondWithStatus(res.Status, "IP(s) blocked successfully", blockips,
		returnerror.ErrorMessage(), conf.Documentation["ltmaddresslistdocumentationuri"], c)
}
開發者ID:zalando,項目名稱:baboon-proxy,代碼行數:27,代碼來源:client.go

示例3: LTMDataGroupItemPatch

// LTMDataGroupItemPatch add an item to a datagroup (ip or string) on a local traffic manager
func LTMDataGroupItemPatch(c *gin.Context) {
	var datagroupitemcreate ltm.CreateDataGroupItem
	direction := common.InternalDataGroup
	datagroupname := c.Params.ByName("datagroupname")

	f5url, err := ltm.Loadbalancer(c.Params.ByName("lbpair"), conf.Ltmdevicenames)
	if err != nil {
		respondWithStatus(err.Status, datagroupname, nil, err.Message, conf.Documentation["ltmdatagroupdocumentationuri"], c)
		return
	}

	if err := c.BindJSON(&datagroupitemcreate); err != nil {
		respondWithStatus(http.StatusBadRequest, "Invalid JSON data", "Create datagroup item",
			fmt.Sprintf("%s", err), conf.Documentation["ltmdatagroupdocumentationuri"], c)
		return
	}
	res, err := ltm.PatchLTMDataGroupItem(f5url, direction, datagroupname, &datagroupitemcreate)
	if err != nil {
		respondWithStatus(err.Status, datagroupname, nil, err.Message, conf.Documentation["ltmdatagroupdocumentationuri"], c)
		return
	}
	json.Unmarshal([]byte(res.Body), &returnerror)
	if res.Status == http.StatusOK {
		res.Status = http.StatusCreated
	}
	respondWithStatus(res.Status, "Datagroup item added in", datagroupname,
		returnerror.ErrorMessage(), conf.Documentation["ltmdatagroupdocumentationuri"], c)
}
開發者ID:zalando,項目名稱:baboon-proxy,代碼行數:29,代碼來源:client.go

示例4: LTMPoolMemberPost

// LTMPoolMemberPost add new members to a specific pool on a local traffic manager
func LTMPoolMemberPost(c *gin.Context) {
	var poolmembercreate ltm.CreatePoolMember

	pool := c.Params.ByName("pool")
	f5url, err := ltm.Loadbalancer(c.Params.ByName("lbpair"), conf.Ltmdevicenames)
	if err != nil {
		respondWithStatus(err.Status, "", nil, err.Message, conf.Documentation["ltmpoolmemberdocumentationuri"], c)
		return
	}

	if err := c.BindJSON(&poolmembercreate); err != nil {
		respondWithStatus(http.StatusBadRequest, "Invalid JSON data", "Create pool member",
			fmt.Sprintf("%s", err), conf.Documentation["ltmpoolmemberdocumentationuri"], c)
		return
	}
	res, err := ltm.PostLTMPoolMember(f5url, pool, &poolmembercreate)
	if err != nil {
		respondWithStatus(err.Status, "", nil, err.Message, conf.Documentation["ltmpoolmemberdocumentationuri"], c)
		return
	}
	json.Unmarshal([]byte(res.Body), &returnerror)

	if res.Status == http.StatusOK {
		res.Status = http.StatusCreated
	}
	respondWithStatus(res.Status, "Poolmember added", poolmembercreate.Name,
		returnerror.ErrorMessage(), conf.Documentation["ltmpoolmemberdocumentationuri"], c)
}
開發者ID:zalando,項目名稱:baboon-proxy,代碼行數:29,代碼來源:client.go

示例5: LTMDeviceList

// LTMDeviceList show local traffic manager devices
func LTMDeviceList(c *gin.Context) {
	f5url, err := ltm.Loadbalancer(c.Params.ByName("lbpair"), conf.Ltmdevicenames)
	if err != nil {
		respondWithStatus(err.Status, "", nil, err.Message, conf.Documentation["ltmdevicedocumentationuri"], c)
		return
	}
	res, devicelist, err := ltm.ShowLTMDevice(f5url)
	if err != nil {
		respondWithStatus(err.Status, "", nil, err.Message, conf.Documentation["ltmdevicedocumentationuri"], c)
		return
	}
	json.Unmarshal([]byte(res.Body), &returnerror)
	respondWithStatus(res.Status, "", devicelist, returnerror.ErrorMessage(), conf.Documentation["ltmdevicedocumentationuri"], c)
}
開發者ID:zalando,項目名稱:baboon-proxy,代碼行數:15,代碼來源:client.go

示例6: LTMDataGroupList

// LTMDataGroupList show local traffic manager internal data groups
func LTMDataGroupList(c *gin.Context) {
	direction := common.InternalDataGroup
	f5url, err := ltm.Loadbalancer(c.Params.ByName("lbpair"), conf.Ltmdevicenames)
	if err != nil {
		respondWithStatus(err.Status, "", nil, err.Message, conf.Documentation["ltmdatagroupdocumentationuri"], c)
		return
	}
	res, datagrouplist, err := ltm.ShowLTMDataGroup(f5url, direction)
	if err != nil {
		respondWithStatus(err.Status, "", nil, err.Message, conf.Documentation["ltmdatagroupdocumentationuri"], c)
		return
	}
	json.Unmarshal([]byte(res.Body), &returnerror)
	respondWithStatus(res.Status, "", datagrouplist, returnerror.ErrorMessage(), conf.Documentation["ltmdatagroupdocumentationuri"], c)
}
開發者ID:zalando,項目名稱:baboon-proxy,代碼行數:16,代碼來源:client.go

示例7: LTMFWRuleList

// LTMFWRuleList show local traffic manager iRules of a specific virtual server
func LTMFWRuleList(c *gin.Context) {
	vservername := c.Params.ByName("virtual")
	f5url, err := ltm.Loadbalancer(c.Params.ByName("lbpair"), conf.Ltmdevicenames)
	if err != nil {
		respondWithStatus(err.Status, vservername, nil, err.Message, conf.Documentation["ltmvirtualdocumentationuri"], c)
		return
	}
	res, rulelist, err := ltm.ShowLTMFWRules(f5url, vservername)
	if err != nil {
		respondWithStatus(err.Status, vservername, nil, err.Message, conf.Documentation["ltmvirtualdocumentationuri"], c)
		return
	}
	json.Unmarshal([]byte(res.Body), &returnerror)
	respondWithStatus(res.Status, "", rulelist, returnerror.ErrorMessage(), conf.Documentation["ltmvirtualdocumentationuri"], c)
}
開發者ID:zalando,項目名稱:baboon-proxy,代碼行數:16,代碼來源:client.go

示例8: LTMWhiteAddressList

// LTMWhiteAddressList show local traffic whitelisted ip addresses
func LTMWhiteAddressList(c *gin.Context) {
	lbpair := c.Params.ByName("lbpair")
	f5url, err := ltm.Loadbalancer(lbpair, conf.Ltmdevicenames)
	if err != nil {
		respondWithStatus(err.Status, "", nil, err.Message, conf.Documentation["ltmaddresslistdocumentationuri"], c)
		return
	}
	f5url = util.ReplaceLTMUritoAddressListURI(f5url)
	res, addresslist, err := ltm.ShowLTMAddressList(f5url, common.WhiteList)
	if err != nil {
		respondWithStatus(err.Status, "", nil, err.Message, conf.Documentation["ltmaddresslistdocumentationuri"], c)
		return
	}
	json.Unmarshal([]byte(res.Body), &returnerror)
	respondWithStatus(res.Status, "", addresslist, returnerror.ErrorMessage(), conf.Documentation["ltmaddresslistdocumentationuri"], c)
}
開發者ID:zalando,項目名稱:baboon-proxy,代碼行數:17,代碼來源:client.go

示例9: LTMPoolDelete

// LTMPoolDelete delete a pool on a local traffic manager
func LTMPoolDelete(c *gin.Context) {
	pool := c.Params.ByName("pool")
	f5url, err := ltm.Loadbalancer(c.Params.ByName("lbpair"), conf.Ltmdevicenames)
	if err != nil {
		respondWithStatus(err.Status, "", nil, err.Message, conf.Documentation["ltmpooldocumentationuri"], c)
		return
	}
	res, err := ltm.DeleteLTMPool(f5url, pool)
	if err != nil {
		respondWithStatus(err.Status, "", nil, err.Message, conf.Documentation["ltmpooldocumentationuri"], c)
		return
	}
	json.Unmarshal([]byte(res.Body), &returnerror)
	respondWithStatus(res.Status, "Pool deleted", pool,
		returnerror.ErrorMessage(), conf.Documentation["ltmpooldocumentationuri"], c)
}
開發者ID:zalando,項目名稱:baboon-proxy,代碼行數:17,代碼來源:client.go

示例10: LTMPoolNameList

// LTMPoolNameList show specific local traffic manager pool
func LTMPoolNameList(c *gin.Context) {
	f5url, err := ltm.Loadbalancer(c.Params.ByName("lbpair"), conf.Ltmdevicenames)
	if err != nil {
		respondWithStatus(err.Status, "", nil, err.Message, conf.Documentation["ltmpooldocumentationuri"], c)
		return
	}
	pool := c.Params.ByName("pool")
	res, poollist, err := ltm.ShowLTMPool(f5url, pool)
	if err != nil {
		respondWithStatus(err.Status, "", nil, err.Message, conf.Documentation["ltmpooldocumentationuri"], c)
		return
	}
	json.Unmarshal([]byte(res.Body), &returnerror)
	u := new(url.URL)
	u.Scheme = common.Protocol
	u.Path = path.Join(c.Request.Host, c.Request.RequestURI, common.MembersURI)
	poollist.MembersReference = u.String()
	respondWithStatus(res.Status, "", poollist, returnerror.ErrorMessage(), conf.Documentation["ltmpooldocumentationuri"], c)
}
開發者ID:zalando,項目名稱:baboon-proxy,代碼行數:20,代碼來源:client.go

示例11: LTMDataGroupDelete

// LTMDataGroupDelete delete a internal datagroup on a local traffic manager
func LTMDataGroupDelete(c *gin.Context) {
	var datagroupdelete ltm.RemoveDataGroup
	direction := common.InternalDataGroup
	f5url, err := ltm.Loadbalancer(c.Params.ByName("lbpair"), conf.Ltmdevicenames)
	if err != nil {
		respondWithStatus(err.Status, "", nil, err.Message, conf.Documentation["ltmdatagroupdocumentationuri"], c)
		return
	}
	if err := c.BindJSON(&datagroupdelete); err != nil {
		respondWithStatus(http.StatusBadRequest, "Invalid JSON data", "Delete datagroup item",
			fmt.Sprintf("%s", err), conf.Documentation["ltmdatagroupdocumentationuri"], c)
		return
	}
	res, err := ltm.DeleteLTMDataGroup(f5url, direction, datagroupdelete.Name)
	if err != nil {
		respondWithStatus(err.Status, "", nil, err.Message, conf.Documentation["ltmdatagroupdocumentationuri"], c)
		return
	}
	json.Unmarshal([]byte(res.Body), &returnerror)
	respondWithStatus(res.Status, "Datagroup deleted", datagroupdelete.Name,
		returnerror.ErrorMessage(), conf.Documentation["ltmdatagroupdocumentationuri"], c)
}
開發者ID:zalando,項目名稱:baboon-proxy,代碼行數:23,代碼來源:client.go

示例12: LTMPoolMemberPut

// LTMPoolMemberPut modify pool members on a local traffic manager (enabled, disabled, force-offline)
func LTMPoolMemberPut(c *gin.Context) {
	var poolmembermodify ltm.ModifyPoolMember
	pool := c.Params.ByName("pool")
	f5url, err := ltm.Loadbalancer(c.Params.ByName("lbpair"), conf.Ltmdevicenames)
	if err != nil {
		respondWithStatus(err.Status, pool, nil, err.Message, conf.Documentation["ltmpoolmemberdocumentationuri"], c)
		return
	}
	if err := c.BindJSON(&poolmembermodify); err != nil {
		respondWithStatus(http.StatusBadRequest, "Invalid JSON data", "Modify pool member",
			fmt.Sprintf("%s", err), conf.Documentation["ltmpoolmemberdocumentationuri"], c)
		return
	}
	res, err := ltm.PutLTMPoolMember(f5url, pool, poolmembermodify.Name, poolmembermodify.Status)
	if err != nil {
		respondWithStatus(err.Status, pool, nil, err.Message, conf.Documentation["ltmpoolmemberdocumentationuri"], c)
		return
	}
	json.Unmarshal([]byte(res.Body), &returnerror)
	respondWithStatus(res.Status, "Poolmember modified", poolmembermodify.Name,
		returnerror.ErrorMessage(), conf.Documentation["ltmpoolmemberdocumentationuri"], c)
}
開發者ID:zalando,項目名稱:baboon-proxy,代碼行數:23,代碼來源:client.go

示例13: LTMRemoveWhiteIPPatch

// LTMRemoveWhiteIPPatch remove ips which are currently whitelisted
func LTMRemoveWhiteIPPatch(c *gin.Context) {
	var removewhiteips ltm.DeleteAddresses

	f5url, err := ltm.Loadbalancer(c.Params.ByName("lbpair"), conf.Ltmdevicenames)
	if err != nil {
		respondWithStatus(err.Status, "", nil, err.Message, conf.Documentation["ltmaddresslistdocumentationuri"], c)
		return
	}
	f5url = util.ReplaceLTMUritoAddressListURI(f5url)
	if err := c.BindJSON(&removewhiteips); err != nil {
		respondWithStatus(http.StatusBadRequest, "Invalid JSON data", "Unblock IPs",
			fmt.Sprintf("%s", err), conf.Documentation["ltmaddresslistdocumentationuri"], c)
		return
	}
	res, err := ltm.DeleteLTMBlockAddresses(f5url, &removewhiteips, common.WhiteList)
	if err != nil {
		respondWithStatus(err.Status, "", nil, err.Message, conf.Documentation["ltmaddresslistdocumentationuri"], c)
		return
	}
	json.Unmarshal([]byte(res.Body), &returnerror)
	respondWithStatus(res.Status, "IP(s) removed successfully from whitelist", fmt.Sprintf("%+v", removewhiteips),
		returnerror.ErrorMessage(), conf.Documentation["ltmaddresslistdocumentationuri"], c)
}
開發者ID:zalando,項目名稱:baboon-proxy,代碼行數:24,代碼來源:client.go


注:本文中的github.com/zalando-techmonkeys/baboon-proxy/ltm.Loadbalancer函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。