...
1
2
3 package hns
4
5 import (
6 "github.com/sirupsen/logrus"
7 )
8
9 type HNSSupportedFeatures struct {
10 Acl HNSAclFeatures `json:"ACL"`
11 }
12
13 type HNSAclFeatures struct {
14 AclAddressLists bool `json:"AclAddressLists"`
15 AclNoHostRulePriority bool `json:"AclHostRulePriority"`
16 AclPortRanges bool `json:"AclPortRanges"`
17 AclRuleId bool `json:"AclRuleId"`
18 }
19
20 func GetHNSSupportedFeatures() HNSSupportedFeatures {
21 var hnsFeatures HNSSupportedFeatures
22
23 globals, err := GetHNSGlobals()
24 if err != nil {
25
26 logrus.Debugf("Unable to obtain HNS globals: %s", err)
27 return hnsFeatures
28 }
29
30 hnsFeatures.Acl = HNSAclFeatures{
31 AclAddressLists: isHNSFeatureSupported(globals.Version, HNSVersion1803),
32 AclNoHostRulePriority: isHNSFeatureSupported(globals.Version, HNSVersion1803),
33 AclPortRanges: isHNSFeatureSupported(globals.Version, HNSVersion1803),
34 AclRuleId: isHNSFeatureSupported(globals.Version, HNSVersion1803),
35 }
36
37 return hnsFeatures
38 }
39
40 func isHNSFeatureSupported(currentVersion HNSVersion, minVersionSupported HNSVersion) bool {
41 if currentVersion.Major < minVersionSupported.Major {
42 return false
43 }
44 if currentVersion.Major > minVersionSupported.Major {
45 return true
46 }
47 if currentVersion.Minor < minVersionSupported.Minor {
48 return false
49 }
50 return true
51 }
52
View as plain text