本文整理汇总了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)
}
示例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)
}
示例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)
}
示例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)
}
示例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)
}
示例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)
}
示例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)
}
示例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)
}
示例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)
}
示例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)
}
示例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)
}
示例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)
}
示例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)
}