Skip to content

Commit 52a6f23

Browse files
committed
[as3] display AS3 version on device connection
makes easier to see if AS3 is available on the device in case AS3 stops working.
1 parent d9fed03 commit 52a6f23

File tree

2 files changed

+43
-2
lines changed

2 files changed

+43
-2
lines changed

internal/agent/f5/as3/as3types.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,15 @@ type Tenant struct {
5656
Applications map[string]Application
5757
}
5858

59+
// AS3 Info
60+
61+
type AS3Info struct {
62+
Version string `json:"version"`
63+
Release string `json:"release"`
64+
SchemaCurrent string `json:"schemaCurrent"`
65+
SchemaMinimum string `json:"schemaMinimum"`
66+
}
67+
5968
func (t Tenant) MarshalJSON() ([]byte, error) {
6069
tenant, err := struct2map(t)
6170
if err != nil {

internal/agent/f5/bigip/bigip.go

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -401,6 +401,32 @@ func (b *BigIP) getDevice() (*bigip.Device, error) {
401401
return nil, fmt.Errorf("device %s not found", b.GetHostname())
402402
}
403403

404+
func (b *BigIP) getAS3Info() (*as3.AS3Info, error) {
405+
var as3info as3.AS3Info
406+
407+
req := &bigip.APIRequest{
408+
Method: "get",
409+
URL: "mgmt/shared/appsvcs/info",
410+
ContentType: "application/json",
411+
}
412+
resp, err := (*bigip.BigIP)(b).APICall(req)
413+
if err != nil {
414+
return nil, err
415+
}
416+
417+
var reqError bigip.RequestError
418+
if json.Unmarshal(resp, &reqError) == nil && reqError.Code != 0 {
419+
return nil, fmt.Errorf("%s\n%s", reqError.Error(), string(resp[:]))
420+
}
421+
422+
err = json.Unmarshal(resp, &as3info)
423+
if err != nil {
424+
return nil, err
425+
}
426+
427+
return &as3info, nil
428+
}
429+
404430
func NewSession(uri *url.URL) (*BigIP, error) {
405431
// check for user
406432
user := uri.User.Username()
@@ -439,7 +465,13 @@ func NewSession(uri *url.URL) (*BigIP, error) {
439465
return nil, fmt.Errorf("failed to get device information: %w", err)
440466
}
441467

442-
log.Infof("Connected to %s, %s (%s %s), %s", device.MarketingName, device.Name, device.Version,
443-
device.Edition, device.FailoverState)
468+
as3Version := "AS3 unavailable"
469+
if as3info, err := b.getAS3Info(); err == nil {
470+
as3Version = "AS3 " + as3info.Version
471+
}
472+
473+
log.Infof("Connected to %s, %s (%s %s), %s, %s", device.MarketingName, device.Name, device.Version,
474+
device.Edition, as3Version, device.FailoverState)
475+
444476
return b, nil
445477
}

0 commit comments

Comments
 (0)