-
Notifications
You must be signed in to change notification settings - Fork 83
/
ntp_sync_cmd.go
53 lines (45 loc) · 1.39 KB
/
ntp_sync_cmd.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
package actions
import (
"github.com/go-openapi/swag"
"github.com/openshift/assisted-installer-agent/src/config"
"github.com/openshift/assisted-installer-agent/src/util"
"github.com/openshift/assisted-service/models"
"github.com/openshift/assisted-service/pkg/validations"
"github.com/pkg/errors"
)
type ntpSynchronizer struct {
args []string
agentConfig *config.AgentConfig
}
func (a *ntpSynchronizer) Validate() error {
var request models.NtpSynchronizationRequest
err := ValidateCommon("ntp synchronizer", 1, a.args, &request)
if err != nil {
return err
}
ntpSource := swag.StringValue(request.NtpSource)
if ntpSource != "" && !validations.ValidateAdditionalNTPSource(ntpSource) {
err = errors.Errorf("Invalid NTP source: %s", ntpSource)
return err
}
return nil
}
func (a *ntpSynchronizer) Run() (stdout, stderr string, exitCode int) {
return util.ExecutePrivileged(a.Command(), a.Args()...)
}
func (a *ntpSynchronizer) Command() string {
return podman
}
func (a *ntpSynchronizer) Args() []string {
podmanRunCmd := []string{
"run", "--privileged", "--net=host", "--rm",
"-v", "/usr/bin/chronyc:/usr/bin/chronyc",
"-v", "/var/log:/var/log",
"-v", "/run/systemd/journal/socket:/run/systemd/journal/socket",
"-v", "/var/run/chrony:/var/run/chrony",
a.agentConfig.AgentVersion,
"ntp_synchronizer",
}
podmanRunCmd = append(podmanRunCmd, a.args...)
return podmanRunCmd
}