Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
gNMI Target
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
danet
gNMI Target
Commits
6959b092
Commit
6959b092
authored
3 years ago
by
istmxrein
Browse files
Options
Downloads
Patches
Plain Diff
implement system.Datetime and system.Boottime
parent
d9fc102d
No related branches found
No related tags found
1 merge request
!2
First working version that retrieves the real state from the device
Pipeline
#91113
passed
3 years ago
Stage: build
Stage: deploy
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
Dockerfile
+1
-1
1 addition, 1 deletion
Dockerfile
os_clients/ubuntu/ubuntu.go
+7
-16
7 additions, 16 deletions
os_clients/ubuntu/ubuntu.go
with
8 additions
and
17 deletions
Dockerfile
+
1
−
1
View file @
6959b092
...
...
@@ -9,7 +9,7 @@ COPY . .
RUN
GOOS
=
linux go build
-o
gnmi-target ./main.go
FROM
alpine:latest
RUN
apk add
--no-cache
git iproute2 iptables dumb-init coreutils
RUN
apk add
--no-cache
git iproute2 iptables dumb-init coreutils
bash
COPY
--from=builder /build/gnmi-target /usr/bin/gnmi-target
EXPOSE
7030
ENTRYPOINT
["dumb-init", "--"]
...
...
This diff is collapsed.
Click to expand it.
os_clients/ubuntu/ubuntu.go
+
7
−
16
View file @
6959b092
...
...
@@ -15,25 +15,11 @@ import (
)
type
OsclientUbuntu
struct
{
gt
*
gnmitargetygot
.
Gnmitarget
root
string
}
func
getHostPrefix
()
(
string
,
error
)
{
path
:=
"/host"
_
,
err
:=
os
.
Stat
(
path
)
if
err
==
nil
{
return
"/host"
,
nil
}
if
os
.
IsNotExist
(
err
)
{
return
""
,
nil
}
return
""
,
err
gt
*
gnmitargetygot
.
Gnmitarget
}
func
NewOsclientUbuntu
()
*
OsclientUbuntu
{
client
:=
new
(
OsclientUbuntu
)
client
.
root
,
_
=
getHostPrefix
()
return
client
}
...
...
@@ -95,10 +81,15 @@ func (ou *OsclientUbuntu) getSystemInformationen(gt *gnmitargetygot.Gnmitarget)
// Create Config
system
.
Hostname
=
ygot
.
String
(
name
)
system
.
CurrentDatetime
=
ygot
.
String
(
time
.
Now
()
.
Format
(
time
.
RFC3339
))
o
,
_
:=
os
.
Stat
(
"/proc/"
)
system
.
BootTime
=
ygot
.
Uint64
(
uint64
(
o
.
ModTime
()
.
UTC
()
.
UnixNano
()))
// Create Clock
system
.
Clock
=
system
.
GetOrCreateClock
()
zonename
,
_
:=
exec
.
Command
(
"realpath"
,
"--relative-to"
,
ou
.
root
+
"/usr/share/zoneinfo"
,
"/etc/localtime"
)
.
Output
()
output
,
_
:=
exec
.
Command
(
"realpath"
,
"--relative-to=/usr/share/zoneinfo"
,
"/etc/localtime"
)
.
Output
()
ss
:=
strings
.
Split
(
string
(
output
),
" "
)
zonename
:=
ss
[
len
(
ss
)
-
1
]
system
.
Clock
.
TimezoneName
=
ygot
.
String
(
strings
.
TrimSuffix
(
string
(
zonename
),
"
\n
"
))
//validate struct
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment