Skip to content

Commit 4df60bd

Browse files
author
Viacheslav Kladov
committed
fix: add commands for images, hotfixes, volumes
1 parent cf5379c commit 4df60bd

File tree

1 file changed

+201
-0
lines changed

1 file changed

+201
-0
lines changed

sys.go

Lines changed: 201 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,89 @@ type TRAP struct {
185185
Version string `json:"version,omitempty"`
186186
}
187187

188+
type Volumes struct {
189+
Volumes []Volume `json:"items"`
190+
}
191+
192+
type Volume struct {
193+
Name string `json:"name,omitempty"`
194+
Fullpath string `json:"fullPath,omitempty"`
195+
Basebuild string `json:"basebuild,omitempty"`
196+
Build string `json:"build,omitempty"`
197+
Product string `json:"product,omitempty"`
198+
Status string `json:"status,omitempty"`
199+
Version string `json:"version,omitempty"`
200+
Media []struct {
201+
Defaultbootlocation bool `json:"defaultBootLocation,omitempty"`
202+
Name string `json:"name,omitempty"`
203+
Media string `json:"media,omitempty"`
204+
Size string `json:"size,omitempty"`
205+
}
206+
}
207+
208+
type Images struct {
209+
Images []Image `json:"items"`
210+
}
211+
212+
type Image struct {
213+
Name string `json:"name,omitempty"`
214+
Fullpath string `json:"fullPath,omitempty"`
215+
Basebuild string `json:"basebuild,omitempty"`
216+
Build string `json:"build,omitempty"`
217+
BuildDate string `json:"buildDate,omitempty"`
218+
Checksum string `json:"checksum,omitempty"`
219+
Product string `json:"product,omitempty"`
220+
Filesize string `json:"fileSize,omitempty"`
221+
Version string `json:"version,omitempty"`
222+
LastModified string `json:"lastModified,omitempty"`
223+
Verified string `json:"verified,omitempty"`
224+
}
225+
226+
type Hotfixes struct {
227+
Hotfixes []Hotfix `json:"items"`
228+
}
229+
230+
type Hotfix struct {
231+
Name string `json:"name,omitempty"`
232+
Fullpath string `json:"fullPath,omitempty"`
233+
Basebuild string `json:"basebuild,omitempty"`
234+
Build string `json:"build,omitempty"`
235+
BuildDate string `json:"buildDate,omitempty"`
236+
Checksum string `json:"checksum,omitempty"`
237+
Product string `json:"product,omitempty"`
238+
Filesize string `json:"fileSize,omitempty"`
239+
Version string `json:"version,omitempty"`
240+
LastModified string `json:"lastModified,omitempty"`
241+
Verified string `json:"verified,omitempty"`
242+
}
243+
244+
type Options interface {
245+
getOption() bool
246+
}
247+
248+
type OptionCreateVol struct {
249+
CreateVolume bool `json:"create-volume,omitempty"`
250+
}
251+
252+
type OptionReboot struct {
253+
Reboot bool `json:"reboot,omitempty"`
254+
}
255+
256+
func (o *OptionCreateVol) getOption() bool {
257+
return o.CreateVolume
258+
}
259+
260+
func (o *OptionReboot) getOption() bool {
261+
return o.Reboot
262+
}
263+
264+
type InstallConfig struct {
265+
Command string `json:"command"`
266+
Name string `json:"name"`
267+
Volume string `json:"volume"`
268+
Options []Options
269+
}
270+
188271
type Bigiplicenses struct {
189272
Bigiplicenses []Bigiplicense `json:"items"`
190273
}
@@ -256,6 +339,10 @@ const (
256339
uriUtil = "util"
257340
uriBash = "bash"
258341
uriVersion = "version"
342+
uriSoftware = "software"
343+
uriVolume = "volume"
344+
uriImage = "image"
345+
uriHotfix = "hotfix"
259346
uriNtp = "ntp"
260347
uriDNS = "dns"
261348
uriProvision = "provision"
@@ -867,3 +954,117 @@ func (b *BigIP) ModifyLogPublisher(r *LogPublisher) error {
867954
func (b *BigIP) DeleteLogPublisher(name string) error {
868955
return b.delete(uriSys, uriLogConfig, uriPublisher, name)
869956
}
957+
958+
func (b *BigIP) Volumes() (*Volumes, error) {
959+
var volumes Volumes
960+
err, _ := b.getForEntity(&volumes, uriSys, uriSoftware, uriVolume)
961+
962+
if err != nil {
963+
return nil, err
964+
}
965+
966+
return &volumes, nil
967+
}
968+
969+
func (b *BigIP) Volume(name string) (*Volume, error) {
970+
var volume Volume
971+
err, _ := b.getForEntity(&volume, uriSys, uriSoftware, uriVolume, name)
972+
973+
if err != nil {
974+
return nil, err
975+
}
976+
977+
return &volume, nil
978+
}
979+
980+
func (b *BigIP) DeleteVolume(name string) error {
981+
return b.delete(uriSys, uriSoftware, uriVolume, name)
982+
}
983+
984+
func (b *BigIP) Images() (*Images, error) {
985+
var images Images
986+
err, _ := b.getForEntity(&images, uriSys, uriSoftware, uriImage)
987+
988+
if err != nil {
989+
return nil, err
990+
}
991+
992+
return &images, nil
993+
}
994+
995+
func (b *BigIP) Image(name string) (*Image, error) {
996+
var image Image
997+
err, _ := b.getForEntity(&image, uriSys, uriSoftware, uriImage, name)
998+
999+
if err != nil {
1000+
return nil, err
1001+
}
1002+
1003+
return &image, nil
1004+
}
1005+
1006+
func (b *BigIP) InstallImage(name string,
1007+
volumename string,
1008+
reboot bool,
1009+
create_volume bool) error {
1010+
options := []Options{
1011+
&OptionCreateVol{CreateVolume: create_volume},
1012+
&OptionReboot{Reboot: reboot},
1013+
}
1014+
config := &InstallConfig{
1015+
Command: "install",
1016+
Name: name,
1017+
Volume: volumename,
1018+
Options: options,
1019+
}
1020+
1021+
return b.post(config, uriSys, uriSoftware, uriImage)
1022+
}
1023+
1024+
func (b *BigIP) DeleteImage(name string) error {
1025+
return b.delete(uriSys, uriSoftware, uriImage, name)
1026+
}
1027+
1028+
func (b *BigIP) Hotfixes() (*Hotfixes, error) {
1029+
var hotfixes Hotfixes
1030+
err, _ := b.getForEntity(&hotfixes, uriSys, uriSoftware, uriHotfix)
1031+
1032+
if err != nil {
1033+
return nil, err
1034+
}
1035+
1036+
return &hotfixes, nil
1037+
}
1038+
1039+
func (b *BigIP) Hotfix(name string) (*Hotfix, error) {
1040+
var hotfix Hotfix
1041+
err, _ := b.getForEntity(&hotfix, uriSys, uriSoftware, uriHotfix, name)
1042+
1043+
if err != nil {
1044+
return nil, err
1045+
}
1046+
1047+
return &hotfix, nil
1048+
}
1049+
1050+
func (b *BigIP) InstallHotfix(name string,
1051+
volume string,
1052+
reboot bool,
1053+
create_volume bool) error {
1054+
options := []Options{
1055+
&OptionCreateVol{CreateVolume: create_volume},
1056+
&OptionReboot{Reboot: reboot},
1057+
}
1058+
config := &InstallConfig{
1059+
Command: "install",
1060+
Name: name,
1061+
Volume: volume,
1062+
Options: options,
1063+
}
1064+
1065+
return b.post(config, uriSys, uriSoftware, uriHotfix)
1066+
}
1067+
1068+
func (b *BigIP) DeleteHotfix(name string) error {
1069+
return b.delete(uriSys, uriSoftware, uriHotfix, name)
1070+
}

0 commit comments

Comments
 (0)