Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to remove virtualserver configuration from other partitions? #44

Open
lefeck opened this issue Nov 15, 2022 · 0 comments
Open

How to remove virtualserver configuration from other partitions? #44

lefeck opened this issue Nov 15, 2022 · 0 comments

Comments

@lefeck
Copy link

lefeck commented Nov 15, 2022

Hi, I want to delete all the configurations in the virtualserver under partition, it doesn't seem to work, I don't know how to do it? My code is as follows:

package main

import (
	"fmt"
	"github.com/e-XpertSolutions/f5-rest-client/f5"
	"github.com/e-XpertSolutions/f5-rest-client/f5/ltm"
	"log"
	"sort"
	"time"
)

const Partition = "test"

//initiable f5 client
func NewF5Client() (*f5.Client, error) {
	//hosts := fmt.Sprintf("https://" + Host)
	//client, err := f5.NewBasicClient(hosts, Username, Password)
	client, err := f5.NewBasicClient("https://192.168.10.83", "admin", "admin")
	client.DisableCertCheck()

	client.SetTimeout(60 * time.Second)
	if err != nil {
		fmt.Println(err)
	}
	return client, nil
}

func DeleteVS(client *f5.Client) (err error) {
	tx, err := client.Begin()
	if err != nil {
		log.Fatalf("client open transaction: %s", err)
	}
	part := fmt.Sprintf("cd /%s", Partition)

	output, _ := tx.ExecTMSH(part)
	fmt.Println(output)
	cmd := fmt.Sprintf("delete ltm virtual all")

	outputs, _ := tx.ExecTMSH(cmd)
	fmt.Println(outputs)
	if err = tx.Commit(); err != nil {
		log.Fatalf("client commits transaction: %s", err)
	}
	return nil
}

func main() {
	client, _ := NewF5Client()
	DeleteVS(client)
}

As a result, only the virtualserver whose partition is common can be deleted, and the virtualserver configuration of other partitions cannot be deleted.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant