Skip to content

fix: add commands for images, hotfixes, volumes #52

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
3 changes: 2 additions & 1 deletion ltm.go
Original file line number Diff line number Diff line change
Expand Up @@ -2427,7 +2427,7 @@ func (b *BigIP) Monitors() ([]Monitor, error) {

// CreateMonitor adds a new monitor to the BIG-IP system. <parent> must be one of "http", "https",
// "icmp", "gateway icmp", or "tcp".
func (b *BigIP) CreateMonitor(name, parent, defaults_from string, interval, timeout int, send, receive, receive_disable, compatibility string) error {
func (b *BigIP) CreateMonitor(name, parent, defaults_from string, interval, timeout int, send, receive, receive_disable, compatibility string, destination string) error {
config := &Monitor{
Name: name,
ParentMonitor: parent,
Expand All @@ -2438,6 +2438,7 @@ func (b *BigIP) CreateMonitor(name, parent, defaults_from string, interval, time
ReceiveString: receive,
ReceiveDisable: receive_disable,
Compatibility: compatibility,
Destination: destination,
}

return b.AddMonitor(config)
Expand Down
202 changes: 202 additions & 0 deletions sys.go
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,90 @@ type TRAP struct {
Version string `json:"version,omitempty"`
}

type Volumes struct {
Volumes []Volume `json:"items"`
}

type Volume struct {
Name string `json:"name,omitempty"`
Fullpath string `json:"fullPath,omitempty"`
Basebuild string `json:"basebuild,omitempty"`
Build string `json:"build,omitempty"`
Product string `json:"product,omitempty"`
Status string `json:"status,omitempty"`
Version string `json:"version,omitempty"`
Active bool `json:"active,omitempty"`
Media []struct {
Defaultbootlocation bool `json:"defaultBootLocation,omitempty"`
Name string `json:"name,omitempty"`
Media string `json:"media,omitempty"`
Size string `json:"size,omitempty"`
}
}

type Images struct {
Images []Image `json:"items"`
}

type Image struct {
Name string `json:"name,omitempty"`
Fullpath string `json:"fullPath,omitempty"`
Build string `json:"build,omitempty"`
BuildDate string `json:"buildDate,omitempty"`
Checksum string `json:"checksum,omitempty"`
Product string `json:"product,omitempty"`
Filesize string `json:"fileSize,omitempty"`
Version string `json:"version,omitempty"`
LastModified string `json:"lastModified,omitempty"`
Verified string `json:"verified,omitempty"`
}

type Hotfixes struct {
Hotfixes []Hotfix `json:"items"`
}

type Hotfix struct {
Name string `json:"name,omitempty"`
Id string `json:"id,omitempty"`
Title string `json:"title,omitempty"`
Fullpath string `json:"fullPath,omitempty"`
Build string `json:"build,omitempty"`
BuildDate string `json:"buildDate,omitempty"`
Checksum string `json:"checksum,omitempty"`
Product string `json:"product,omitempty"`
Filesize string `json:"fileSize,omitempty"`
Version string `json:"version,omitempty"`
LastModified string `json:"lastModified,omitempty"`
Verified string `json:"verified,omitempty"`
}

type Options interface {
getOption() bool
}

type OptionCreateVol struct {
CreateVolume bool `json:"create-volume,omitempty"`
}

type OptionReboot struct {
Reboot bool `json:"reboot,omitempty"`
}

func (o *OptionCreateVol) getOption() bool {
return o.CreateVolume
}

func (o *OptionReboot) getOption() bool {
return o.Reboot
}

type InstallConfig struct {
Command string `json:"command"`
Name string `json:"name"`
Volume string `json:"volume"`
Options []Options `json:"options"`
}

type Bigiplicenses struct {
Bigiplicenses []Bigiplicense `json:"items"`
}
Expand Down Expand Up @@ -256,6 +340,10 @@ const (
uriUtil = "util"
uriBash = "bash"
uriVersion = "version"
uriSoftware = "software"
uriVolume = "volume"
uriImage = "image"
uriHotfix = "hotfix"
uriNtp = "ntp"
uriDNS = "dns"
uriProvision = "provision"
Expand Down Expand Up @@ -867,3 +955,117 @@ func (b *BigIP) ModifyLogPublisher(r *LogPublisher) error {
func (b *BigIP) DeleteLogPublisher(name string) error {
return b.delete(uriSys, uriLogConfig, uriPublisher, name)
}

func (b *BigIP) Volumes() (*Volumes, error) {
var volumes Volumes
err, _ := b.getForEntity(&volumes, uriSys, uriSoftware, uriVolume)

if err != nil {
return nil, err
}

return &volumes, nil
}

func (b *BigIP) Volume(name string) (*Volume, error) {
var volume Volume
err, _ := b.getForEntity(&volume, uriSys, uriSoftware, uriVolume, name)

if err != nil {
return nil, err
}

return &volume, nil
}

func (b *BigIP) DeleteVolume(name string) error {
return b.delete(uriSys, uriSoftware, uriVolume, name)
}

func (b *BigIP) Images() (*Images, error) {
var images Images
err, _ := b.getForEntity(&images, uriSys, uriSoftware, uriImage)

if err != nil {
return nil, err
}

return &images, nil
}

func (b *BigIP) Image(name string) (*Image, error) {
var image Image
err, _ := b.getForEntity(&image, uriSys, uriSoftware, uriImage, name)

if err != nil {
return nil, err
}

return &image, nil
}

func (b *BigIP) InstallImage(name string,
volumename string,
reboot bool,
create_volume bool) error {
options := []Options{
&OptionCreateVol{CreateVolume: create_volume},
&OptionReboot{Reboot: reboot},
}
config := &InstallConfig{
Command: "install",
Name: name,
Volume: volumename,
Options: options,
}

return b.post(config, uriSys, uriSoftware, uriImage)
}

func (b *BigIP) DeleteImage(name string) error {
return b.delete(uriSys, uriSoftware, uriImage, name)
}

func (b *BigIP) Hotfixes() (*Hotfixes, error) {
var hotfixes Hotfixes
err, _ := b.getForEntity(&hotfixes, uriSys, uriSoftware, uriHotfix)

if err != nil {
return nil, err
}

return &hotfixes, nil
}

func (b *BigIP) Hotfix(name string) (*Hotfix, error) {
var hotfix Hotfix
err, _ := b.getForEntity(&hotfix, uriSys, uriSoftware, uriHotfix, name)

if err != nil {
return nil, err
}

return &hotfix, nil
}

func (b *BigIP) InstallHotfix(name string,
volume string,
reboot bool,
create_volume bool) error {
options := []Options{
&OptionCreateVol{CreateVolume: create_volume},
&OptionReboot{Reboot: reboot},
}
config := &InstallConfig{
Command: "install",
Name: name,
Volume: volume,
Options: options,
}

return b.post(config, uriSys, uriSoftware, uriHotfix)
}

func (b *BigIP) DeleteHotfix(name string) error {
return b.delete(uriSys, uriSoftware, uriHotfix, name)
}