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

Create LB/FW/IP temporary files under /tmp directory #27

Merged
merged 1 commit into from
Aug 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions cmd/get/get_firewall.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,15 +141,15 @@ func FWAPICall(restOptions *api.RESTOptions) (*http.Response, error) {

func FWdump(restOptions *api.RESTOptions, path string) (string, error) {
// File Open
fileP := []string{"FWconfig_", ".txt"}
fileP := []string{"/tmp/FWconfig_", ".txt"}
t := time.Now()
file := strings.Join(fileP, t.Local().Format("2006-01-02_15:04:05"))
f, err := os.Create(file)
if err != nil {
fmt.Printf("Can't create dump file\n")
os.Exit(1)
}
defer f.Close()
defer os.Remove(f.Name())

// API Call
client := api.NewLoxiClient(restOptions)
Expand Down
4 changes: 2 additions & 2 deletions cmd/get/get_loadbalancer.go
Original file line number Diff line number Diff line change
Expand Up @@ -225,15 +225,15 @@ func Lbdump(restOptions *api.RESTOptions, path string) (string, error) {
lbresp := api.LbRuleModGet{}
dresp := api.LbRuleModGet{}
// File Open
fileP := []string{"lbconfig_", ".txt"}
fileP := []string{"/tmp/lbconfig_", ".txt"}
t := time.Now()
file := strings.Join(fileP, t.Local().Format("2006-01-02_15:04:05"))
f, err := os.Create(file)
if err != nil {
fmt.Printf("Can't create dump file\n")
os.Exit(1)
}
defer f.Close()
defer os.Remove(f.Name())

// API Call
client := api.NewLoxiClient(restOptions)
Expand Down
8 changes: 5 additions & 3 deletions cmd/get/get_netlink.go
Original file line number Diff line number Diff line change
Expand Up @@ -514,7 +514,7 @@ func GetBonds() {
func Nlpdump(dpath string) (string, error) {
var ret int
var err error
fileP := []string{"ipconfig_", ".txt"}
fileP := []string{"/tmp/ipconfig_", ".txt"}
t := time.Now()
file := strings.Join(fileP, t.Local().Format("2006-01-02_15:04:05"))
f, err = os.Create(file)
Expand All @@ -523,9 +523,9 @@ func Nlpdump(dpath string) (string, error) {
os.Exit(1)
}

defer f.Close()
defer os.Remove(f.Name())

path = "ipconfig_" + t.Local().Format("2006-01-02_15:04:05") + "/"
path = "/tmp/" + "ipconfig_" + t.Local().Format("2006-01-02_15:04:05") + "/"
//fmt.Printf("Creating intf config dir : %s\n", path)
if _, err := os.Stat(path); errors.Is(err, os.ErrNotExist) {
err := os.Mkdir(path, os.ModePerm)
Expand All @@ -534,6 +534,8 @@ func Nlpdump(dpath string) (string, error) {
}
}

defer os.RemoveAll(path)

/*Get bridge info first */
GetBridges()
GetBonds()
Expand Down