-
Notifications
You must be signed in to change notification settings - Fork 5
/
agent.go
60 lines (51 loc) · 2.28 KB
/
agent.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
package illumioapi
import (
"encoding/json"
"fmt"
"net/url"
"strconv"
"time"
)
// CompatibilityReport is a compatibility report for a VEN in Idle status
type CompatibilityReport struct {
LastUpdatedAt time.Time `json:"last_updated_at"`
Results Results `json:"results"`
QualifyStatus string `json:"qualify_status"`
}
// QualifyTest is part of compatibility report
type QualifyTest struct {
Status *string `json:"status"`
IpsecServiceEnabled *string `json:"ipsec_service_enabled"` // Using a string to differentiate between false and empty
Ipv4ForwardingEnabled *string `json:"ipv4_forwarding_enabled"`
Ipv4ForwardingPktCnt *string `json:"ipv4_forwarding_pkt_cnt"`
IptablesRuleCnt *string `json:"iptables_rule_cnt"`
Ipv6GlobalScope *string `json:"ipv6_global_scope"`
Ipv6ActiveConnCnt *string `json:"ipv6_active_conn_cnt"`
IP6TablesRuleCnt *string `json:"ip6tables_rule_cnt"`
RoutingTableConflict *string `json:"routing_table_conflict"`
IPv6Enabled *string `json:"IPv6_enabled"`
UnwantedNics *string `json:"Unwanted_nics"`
GroupPolicy *string `json:"Group_policy"`
RequiredPackagesInstalled *string `json:"required_packages_installed"` // Using a string to differentiate between false and empty
RequiredPackagesMissing *[]string `json:"required_packages_missing"`
}
// Results are the list of qualify tests
type Results struct {
QualifyTests []QualifyTest `json:"qualify_tests"`
}
// GetCompatibilityReport returns the compatibility report for a VEN
func (p *PCE) GetCompatibilityReport(w Workload) (CompatibilityReport, APIResponse, error) {
// Build the API URL
apiURL, err := url.Parse("https://" + pceSanitization(p.FQDN) + ":" + strconv.Itoa(p.Port) + "/api/v2" + w.Agent.Href + "/compatibility_report")
if err != nil {
return CompatibilityReport{}, APIResponse{}, fmt.Errorf("get compatibility report - building URL - %s", err)
}
// Call the API
api, err := apicall("GET", apiURL.String(), *p, nil, false)
if err != nil {
return CompatibilityReport{}, APIResponse{}, fmt.Errorf("get compatibility report - calling API - %s", err)
}
var cr CompatibilityReport
json.Unmarshal([]byte(api.RespBody), &cr)
return cr, api, nil
}