Skip to content

Commit 80746f4

Browse files
authored
Merge branch 'master' into fix/go-mod-tidy
2 parents d6580c1 + 61d8b07 commit 80746f4

File tree

4 files changed

+90
-3
lines changed

4 files changed

+90
-3
lines changed

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,4 +34,4 @@ require (
3434
google.golang.org/protobuf v1.21.0 // indirect
3535
)
3636

37-
go 1.19
37+
go 1.21

go.sum

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,6 @@ golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73r
109109
golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
110110
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
111111
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
112-
golang.org/x/net v0.0.0-20200301022130-244492dfa37a h1:GuSPYbZzB5/dcLNCwLQLsg3obCJtX9IJhpXkvY7kzk0=
113112
golang.org/x/net v0.0.0-20200301022130-244492dfa37a/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
114113
golang.org/x/net v0.0.0-20200813134508-3edf25e44fcc/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA=
115114
golang.org/x/net v0.0.0-20201021035429-f5854403a974 h1:IX6qOQeG5uLjB/hjjwjedwfjND0hgjPMMyO1RoIXQNI=
@@ -175,6 +174,5 @@ gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
175174
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
176175
honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
177176
honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
178-
inet.af v0.0.0-20181218191229-53da77bc832c h1:U3RoiyEF5b3Y1SVL6NNvpkgqUz2qS3a0OJh9kpSCN04=
179177
inet.af/netaddr v0.0.0-20230525184311-b8eac61e914a h1:1XCVEdxrvL6c0TGOhecLuB7U9zYNdxZEjvOqJreKZiM=
180178
inet.af/netaddr v0.0.0-20230525184311-b8eac61e914a/go.mod h1:e83i32mAQOW1LAqEIweALsuK2Uw4mhQadA5r7b0Wobo=

models/yang/annotations/openconfig-system-annot.yang

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ module openconfig-system-annot {
99
import sonic-extensions {prefix sonic-ext; }
1010
import openconfig-system-grpc { prefix oc-sys-grpc; }
1111
import gnsi-pathz { prefix gnsi-pathz; }
12+
import openconfig-gnsi-credentialz { prefix oc-gnsi-credz; }
1213

1314
deviation /oc-sys:system/oc-sys:ssh-server/oc-sys:state {
1415
deviate add {
@@ -24,6 +25,39 @@ module openconfig-system-annot {
2425
}
2526
}
2627

28+
deviation /oc-sys:system/oc-sys:aaa/oc-sys:authentication/oc-sys:glome/oc-sys:state {
29+
deviate add {
30+
sonic-ext:db-name "STATE_DB";
31+
sonic-ext:table-name "CREDENTIALS";
32+
sonic-ext:key-name "GLOME_CONFIG";
33+
}
34+
}
35+
36+
deviation /oc-sys:system/oc-sys:aaa/oc-sys:authentication/oc-sys:glome/oc-sys:state/oc-gnsi-credz:active-glome-key-version {
37+
deviate add {
38+
sonic-ext:field-name "key_version";
39+
}
40+
}
41+
42+
deviation /oc-sys:system/oc-sys:aaa/oc-sys:authentication/oc-sys:glome/oc-sys:state/oc-gnsi-credz:active-glome-key-created-on {
43+
deviate add {
44+
sonic-ext:field-name "last_updated";
45+
}
46+
}
47+
48+
deviation /oc-sys:system/oc-sys:aaa/oc-sys:authentication/oc-sys:glome/oc-sys:state/oc-gnsi-credz:enabled {
49+
deviate add {
50+
sonic-ext:field-name "enabled";
51+
}
52+
}
53+
54+
deviation /oc-sys:system/oc-gnsi-credz:console {
55+
deviate add {
56+
sonic-ext:db-name "STATE_DB";
57+
sonic-ext:subtree-transformer "console_counters_xfmr";
58+
}
59+
}
60+
2761
deviation /oc-sys:system/gnsi-pathz:gnmi-pathz-policies {
2862
deviate add {
2963
sonic-ext:key-transformer "pathz_policies_key_xfmr";

translib/transformer/xfmr_system.go

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,9 @@ const (
6666
PATHZ_WRITE_SUCCESS_TIMESTAMP = PATHZ_WRITES + "/last-access-accept"
6767
PATHZ_WRITE_FAILED = PATHZ_WRITES + "/access-rejects"
6868
PATHZ_WRITE_FAILED_TIMESTAMP = PATHZ_WRITES + "/last-access-reject"
69+
ACCOUNT_TBL = "CREDENTIALS|SSH_ACCOUNT"
70+
CONSOLE_TBL = "CREDENTIALS|CONSOLE_ACCOUNT"
71+
SSH_TBL = "CREDENTIALS|SSH_HOST"
6972
)
7073

7174
type sshState struct {
@@ -115,6 +118,8 @@ func init() {
115118
XlateFuncBind("DbToYang_pathz_policies_xfmr", DbToYang_pathz_policies_xfmr)
116119
XlateFuncBind("Subscribe_pathz_policies_xfmr", Subscribe_pathz_policies_xfmr)
117120
XlateFuncBind("DbToYang_pathz_policies_key_xfmr", DbToYang_pathz_policies_key_xfmr)
121+
XlateFuncBind("DbToYang_console_counters_xfmr", DbToYang_console_counters_xfmr)
122+
XlateFuncBind("Subscribe_console_counters_xfmr", Subscribe_console_counters_xfmr)
118123
}
119124

120125
type grpcState struct {
@@ -879,3 +884,53 @@ var Subscribe_pathz_policies_xfmr SubTreeXfmrSubscribe = func(inParams XfmrSubsc
879884
nOpts: &notificationOpts{mInterval: 0, pType: OnChange},
880885
}, nil
881886
}
887+
888+
var DbToYang_console_counters_xfmr SubTreeXfmrDbToYang = func(inParams XfmrParams) error {
889+
var counters accessCounters
890+
891+
table, err := inParams.dbs[inParams.curDb].GetEntry(&db.TableSpec{Name: "CREDENTIALS"}, db.Key{Comp: []string{"CONSOLE_METRICS"}})
892+
if err != nil {
893+
log.V(0).Infof("Failed to read from StateDB: %v", inParams.table)
894+
return err
895+
}
896+
897+
accepts := table.Get("access_accepts")
898+
if counters.accessAccepts, err = strconv.ParseUint(accepts, 10, 64); err != nil && accepts != "" {
899+
log.V(0).Infof("Couldn't find access_accepts: %v", err)
900+
}
901+
lastAccept := table.Get("last_access_accept")
902+
if counters.lastAccessAccept, err = strconv.ParseUint(lastAccept, 10, 64); err != nil && lastAccept != "" {
903+
log.V(0).Infof("Couldn't find last_access_accept: %v", err)
904+
}
905+
rejects := table.Get("access_rejects")
906+
if counters.accessRejects, err = strconv.ParseUint(rejects, 10, 64); err != nil && rejects != "" {
907+
log.V(0).Infof("Couldn't find access_rejects: %v", err)
908+
}
909+
lastReject := table.Get("last_access_reject")
910+
if counters.lastAccessReject, err = strconv.ParseUint(lastReject, 10, 64); err != nil && lastReject != "" {
911+
log.V(0).Infof("Couldn't find last_access_reject: %v", err)
912+
}
913+
914+
sysObj := getAppRootObject(inParams)
915+
ygot.BuildEmptyTree(sysObj)
916+
ygot.BuildEmptyTree(sysObj.Console)
917+
ygot.BuildEmptyTree(sysObj.Console.State)
918+
919+
sysObj.Console.State.Counters.AccessAccepts = &counters.accessAccepts
920+
sysObj.Console.State.Counters.AccessRejects = &counters.accessRejects
921+
sysObj.Console.State.Counters.LastAccessAccept = &counters.lastAccessAccept
922+
sysObj.Console.State.Counters.LastAccessReject = &counters.lastAccessReject
923+
924+
return nil
925+
}
926+
927+
var Subscribe_console_counters_xfmr SubTreeXfmrSubscribe = func(inParams XfmrSubscInParams) (XfmrSubscOutParams, error) {
928+
log.V(0).Infof("Subscribe_console_counters_xfmr:%s", inParams.requestURI)
929+
930+
return XfmrSubscOutParams{
931+
dbDataMap: RedisDbSubscribeMap{
932+
db.StateDB: {"CREDENTIALS": {"CONSOLE_METRICS": {}}}},
933+
onChange: OnchangeEnable,
934+
nOpts: &notificationOpts{mInterval: 0, pType: OnChange},
935+
}, nil
936+
}

0 commit comments

Comments
 (0)