Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
06736db
Removing old test code for testing due to errors
agavran Dec 11, 2025
d993bf1
Implementing DB Variable support
agavran Dec 11, 2025
5878661
Implementing Mgmt Route Support
agavran Dec 11, 2025
a638f45
Implement Mgmt Firewall Rules support
agavran Dec 12, 2025
f0d5241
Implement Sys Auth Remote Roles support
agavran Dec 12, 2025
19a0b46
Implement Sys LDAP Auth support
agavran Dec 12, 2025
3da79d6
Implement Sys Auth Source support
agavran Dec 12, 2025
948d8ed
Implementing Sys Auth Remote User support
agavran Dec 15, 2025
a12e9ef
Implement Syslog support and old syslog code cleanup
agavran Dec 15, 2025
02c7d4e
Implementing hostname and GUI banner support
agavran Dec 15, 2025
ea86b7c
Implementing SSHD support
agavran Dec 15, 2025
371369a
Implementing HTTPD support
agavran Dec 15, 2025
91baa6b
Implementing SnmpConfig to support complete CRUD
agavran Dec 16, 2025
3d89364
Implementing SNMP Communities support
agavran Dec 16, 2025
27209f6
Implementing SNMP Access v3 support
agavran Dec 16, 2025
6eb6473
Implementing HA Group support
agavran Dec 16, 2025
33bcb1a
Expanding Route Domain support
agavran Dec 17, 2025
be7b997
Removing FipsCipherVersion from defaults (read-only attribute)
agavran Jan 2, 2026
d070402
SSHD - removing omitempty for attributes that can contain 0 value
agavran Jan 2, 2026
7dc25de
HTTPD - removing omitempty for attributes that can contain 0 value
agavran Jan 2, 2026
f296fd4
HTTPD - FipsCipherVersion removing omitempty for consistency
agavran Jan 2, 2026
0aef070
Adjusting type structures to support zero values and empty lists wher…
agavran Jan 7, 2026
c1b5d4e
Adding more verbosity for db_var resource
agavran Feb 17, 2026
6c7e5f0
Adding support for Device Name change and Self Device configuration
agavran Feb 17, 2026
f2dfaca
Allow zero values for db variables
agavran Feb 17, 2026
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
2,630 changes: 2,630 additions & 0 deletions db_vars.go

Large diffs are not rendered by default.

115 changes: 115 additions & 0 deletions device.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ package bigip

import (
"encoding/json"
"fmt"
)

// LIC contains device license for BIG-IP system.
Expand Down Expand Up @@ -365,3 +366,117 @@ func (b *BigIP) DevicegroupsDevices(name, rname string) (*Devicegroup, error) {

return &devicegroup, nil
}

//////////////////////////////////////////////////////////////////////////////////////
///////////////////// Device Self /////////////////
//////////////////////////////////////////////////////////////////////////////////////

type DeviceSelf struct {
Name string `json:"name,omitempty"`
MirrorIp string `json:"mirrorIp,omitempty"`
MirrorSecondaryIp string `json:"mirrorSecondaryIp,omitempty"`
ConfigsyncIp string `json:"configsyncIp,omitempty"`
MulticastInterface string `json:"multicastInterface"`
MulticastIp string `json:"multicastIp,omitempty"`
MulticastPort int `json:"multicastPort"`
UnicastAddress []UnicastAddress `json:"unicastAddress"`
}

func (b *BigIP) CreateDeviceSelf(config *DeviceSelf) error {
return b.patch(config, uriCm, uriDiv, config.Name)
}

func (b *BigIP) GetDeviceSelf(name string) (*DeviceSelf, error) {
var device DeviceSelf
err, _ := b.getForEntity(&device, uriCm, uriDiv, name)
if err != nil {
return nil, err
}
return &device, nil
}

func (b *BigIP) ModifyDeviceSelf(config *DeviceSelf) error {
return b.patch(config, uriCm, uriDiv, config.Name)
}

func (b *BigIP) DeleteDeviceSelf(name string) error {
defaultConfig := &DeviceSelf{
MirrorIp: "any6",
MirrorSecondaryIp: "any6",
ConfigsyncIp: "none",
MulticastInterface: "",
MulticastIp: "any6",
MulticastPort: 0,
UnicastAddress: []UnicastAddress{},
}
return b.patch(defaultConfig, uriCm, uriDiv, name)
}

//////////////////////////////////////////////////////////////////////////////////////
///////////////////// Device Name (Self) /////////////////
//////////////////////////////////////////////////////////////////////////////////////

// GetSelfDeviceName returns the name of the local BIG-IP device.
// It queries all devices and finds the one marked as selfDevice.
func (b *BigIP) GetSelfDeviceName() (string, error) {
devices, err := b.GetDevices()
if err != nil {
return "", err
}

for _, d := range devices {
if d.SelfDevice == "true" {
return d.Name, nil
}
}

return "", fmt.Errorf("no self device found")
}

// CreateDeviceName renames the BIG-IP device to the specified target name.
func (b *BigIP) CreateDeviceName(target string) error {
currentName, err := b.GetSelfDeviceName()
if err != nil {
return fmt.Errorf("unable to get current device name: %v", err)
}

config := &Devicename{
Command: "mv",
Name: currentName,
Target: target,
}

return b.post(config, uriCm, uriDiv)
}

// ModifyDeviceName renames the BIG-IP device to the specified target name.
func (b *BigIP) ModifyDeviceName(target string) error {
currentName, err := b.GetSelfDeviceName()
if err != nil {
return fmt.Errorf("unable to get current device name: %v", err)
}

config := &Devicename{
Command: "mv",
Name: currentName,
Target: target,
}

return b.post(config, uriCm, uriDiv)
}

// DeleteDeviceName resets the BIG-IP device name to the default "bigip1".
func (b *BigIP) DeleteDeviceName() error {
currentName, err := b.GetSelfDeviceName()
if err != nil {
return fmt.Errorf("unable to get current device name: %v", err)
}

config := &Devicename{
Command: "mv",
Name: currentName,
Target: "bigip1",
}

return b.post(config, uriCm, uriDiv)
}
41 changes: 41 additions & 0 deletions examples/db_vars/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package main

import (
"fmt"
"os"

"github.com/f5devcentral/go-bigip"
)

func main() {
// Connect to the BIG-IP system.
// Replace with your actual BIG-IP credentials and hostname
config := &bigip.Config{
//Address: "https://192.168.1.1",
Username: "admin",
//Password: "admin",
CertVerifyDisable: true, // Disable certificate verification for testing purposes
}

config.Address = os.Getenv("BIGIP_ADDRESS")
if config.Address != "" {
fmt.Println("BIGIP_ADDRESS:", config.Address)
} else {
fmt.Println("BIGIP_ADDRESS is not set.")
}

config.Password = os.Getenv("BIGIP_PASSWORD")
if config.Password != "" {
fmt.Println("BIGIP_PASSWORD:", config.Password)
} else {
fmt.Println("BIGIP_PASSWORD is not set.")
}

f5 := bigip.NewSession(config)

testDBVariableRead(f5)
testDBVariableCreation(f5)
testDBVariableUpdate(f5)
testDBVariableDelete(f5)

}
85 changes: 85 additions & 0 deletions examples/db_vars/test_db_var.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
package main

import (
"fmt"
"log"

"github.com/f5devcentral/go-bigip"
)

/////////////////////////////////////////////////////////////////////////////////
////////////// Database Variable Testing //////////////
/////////////////////////////////////////////////////////////////////////////////

func testDBVariableRead(f5 *bigip.BigIP) {
fmt.Println("\n=== Testing System DB Variable Read Operation ===")

// Test DB variable configuration
dbVar, err := f5.GetDBVariable("ui.advisory.enabled")
if err != nil {
log.Printf("Error getting Database Variable: %v", err)
return
}
if dbVar != nil {
fmt.Printf("Retrieved Database Variable:\n")
fmt.Printf(" Name: %s\n", dbVar.Name)
fmt.Printf(" Value: %s\n", dbVar.Value)
}
}

func testDBVariableCreation(f5 *bigip.BigIP) {
fmt.Println("\n=== Testing System DB Variable Creation Operation ===")

// Test DB variable configuration
dbVar := &bigip.DBVariable{
Name: "ui.advisory.enabled",
Value: "true",
}

// CREATE: Set DB Variable value
fmt.Println("Setting System DB Variable...")
err := f5.CreateDBVariable(dbVar)
if err != nil {
log.Printf("Error creating DB Variable: %v", err)
return
}
fmt.Printf("DB Variable ui.advisory.enabled changed successfully.\n")

}

func testDBVariableUpdate(f5 *bigip.BigIP) {
fmt.Println("\n=== Testing System DB Variable Modify Operation ===")

// Test DB variable configuration
dbVar := &bigip.DBVariable{
Name: "ui.advisory.color",
Value: "orange",
}

// CREATE: Set DB Variable value
fmt.Println("Modifying System DB Variable...")
err := f5.ModifyDBVariable(dbVar)
if err != nil {
log.Printf("Error modifying DB Variable: %v", err)
return
}
fmt.Printf("DB Variable ui.advisory.color changed successfully.\n")

}

func testDBVariableDelete(f5 *bigip.BigIP) {
fmt.Println("\n=== Testing DB Variable Removal/Reset-To-Defaults Operation ===")
// Test DB variable configuration
dbVar := &bigip.DBVariable{
Name: "ui.advisory.enabled",
}
// DELETE: Reset DB Variable to default
fmt.Println("Resetting DB Variable to default...")
err := f5.DeleteDBVariable(dbVar.Name)
if err != nil {
log.Printf("Error resetting DB Variable to defaults: %v", err)
return
}
fmt.Printf("DB Variable %s was set back to default value '%v' successfully.\n", dbVar.Name, bigip.DefaultDBValues[dbVar.Name])

}
58 changes: 58 additions & 0 deletions examples/device/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
package main

import (
"fmt"
"os"

"github.com/f5devcentral/go-bigip"
)

func main() {
// Connect to the BIG-IP system.
// Replace with your actual BIG-IP credentials and hostname
config := &bigip.Config{
//Address: "https://192.168.1.1",
Username: "admin",
//Password: "admin",
CertVerifyDisable: true, // Disable certificate verification for testing purposes
}

config.Address = os.Getenv("BIGIP_ADDRESS")
if config.Address != "" {
fmt.Println("BIGIP_ADDRESS:", config.Address)
} else {
fmt.Println("BIGIP_ADDRESS is not set.")
}

config.Password = os.Getenv("BIGIP_PASSWORD")
if config.Password != "" {
fmt.Println("BIGIP_PASSWORD:", config.Password)
} else {
fmt.Println("BIGIP_PASSWORD is not set.")
}

f5 := bigip.NewSession(config)

deviceSelfTesting := false
deviceNameTesting := true

if deviceSelfTesting {
testDeviceSelfRead(f5)
testDeviceSelfCreate(f5)
testDeviceSelfRead(f5)
testDeviceSelfUpdate(f5)
testDeviceSelfRead(f5)
testDeviceSelfDelete(f5)
testDeviceSelfRead(f5)
}
if deviceNameTesting {
testDeviceNameRead(f5)
testDeviceNameCreate(f5)
testDeviceNameRead(f5)
testDeviceNameUpdate(f5)
testDeviceNameRead(f5)
testDeviceNameDelete(f5)
testDeviceNameRead(f5)
}

}
80 changes: 80 additions & 0 deletions examples/device/test_device_name.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
package main

import (
"fmt"
"log"

"github.com/f5devcentral/go-bigip"
)

/////////////////////////////////////////////////////////////////////////////////
////////////// Device Name Testing /////////////////
/////////////////////////////////////////////////////////////////////////////////

func testDeviceNameRead(f5 *bigip.BigIP) {
fmt.Println("\n=== Testing Device Name Read Operation ===")

fmt.Println("Getting Device Name...")
name, err := f5.GetSelfDeviceName()
if err != nil {
log.Printf("Error getting Device Name: %v", err)
return
}

fmt.Printf(" Current Device Name: %s\n", name)
}

func testDeviceNameCreate(f5 *bigip.BigIP) {
fmt.Println("\n=== Testing Device Name Create Operation ===")

targetName := "ltm02.f5lab.com"

fmt.Printf("Renaming device to %s...\n", targetName)
err := f5.CreateDeviceName(targetName)
if err != nil {
log.Printf("Error creating Device Name: %v", err)
return
}
fmt.Printf("Device renamed successfully.\n")
}

func testDeviceNameUpdate(f5 *bigip.BigIP) {
fmt.Println("\n=== Testing Device Name Update Operation ===")

targetName := "ltm02-updated.f5lab.com"

fmt.Printf("Renaming device to %s...\n", targetName)
err := f5.ModifyDeviceName(targetName)
if err != nil {
log.Printf("Error updating Device Name: %v", err)
return
}
fmt.Printf("Device renamed successfully.\n")
}

func testDeviceNameDelete(f5 *bigip.BigIP) {
fmt.Println("\n=== Testing Device Name Delete Operation ===")

fmt.Println("Resetting device name to default (bigip1)...")
err := f5.DeleteDeviceName()
if err != nil {
log.Printf("Error deleting Device Name: %v", err)
return
}
fmt.Printf("Device name reset to default successfully.\n")

// Verify default name after reset
fmt.Println("\nVerifying default name after reset...")
name, err := f5.GetSelfDeviceName()
if err != nil {
log.Printf("Error getting Device Name after reset: %v", err)
return
}

fmt.Printf(" Device Name after reset: %s (expected: bigip1)\n", name)
if name == "bigip1" {
fmt.Println("Default name verified successfully.")
} else {
log.Println("Warning: Device name does not match expected default.")
}
}
Loading