f5-rest-client icon indicating copy to clipboard operation
f5-rest-client copied to clipboard

how to get pool member list, through the pool name of SourceAddressTranslation?

Open lefeck opened this issue 2 years ago • 0 comments

hi, I want to get its pool member list through the pool name of SourceAddressTranslation. I can't do it through the following code, and I haven't found the corresponding method. What should I do? code show as below:

package main

import (
	"fmt"
	"github.com/e-XpertSolutions/f5-rest-client/f5"
	"github.com/e-XpertSolutions/f5-rest-client/f5/ltm"
	"log"
	"net/url"
	"strings"
)

func main() {
	f5Client, err := f5.NewBasicClient("https://192.168.5.134", "admin", "admin")
	if err != nil {
		log.Fatal(err)
	}
	f5Client.DisableCertCheck()

	// Start new transaction.
	tx, err := f5Client.Begin()
	if err != nil {
		log.Fatal(err)
	}
	ltmClient := ltm.New(tx)

	params := url.Values{}
	params.Set("expandSubcollections", "true")

	vslist, _ := ltmClient.Virtual().ListAllWithParams(params)

	var test string
	for _, value := range vslist.Items {
		test = value.SourceAddressTranslation.Pool
		//fmt.Println(test)
	}
	satpoollist := StringSplitSubStrings(test)
	satPoolList, _ := ltmClient.PoolMembers().ListAll(satpoollist)
	for _, v := range satPoolList.Items {
		fmt.Println(v.Address)
	}
}

func StringSplitSubStrings(src string) (des string) {
	str := strings.SplitN(src, "/", -1)
	return str[len(str)-1]
}

lefeck avatar Jun 23 '22 04:06 lefeck