Skip to content

Commit

Permalink
Add an ability to update timezone
Browse files Browse the repository at this point in the history
Signed-off-by: Yevhen Fastiuk <yfastiuk@nvidia.com>
  • Loading branch information
fastiuk committed Apr 14, 2023
1 parent 2fdb64b commit cfd6dc1
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions scripts/hostcfgd
Original file line number Diff line number Diff line change
Expand Up @@ -1405,6 +1405,20 @@ class DeviceMetaCfg(object):
return
run_cmd(['sudo', 'monit', 'reload'])

def timezone_update(self, data):
"""
Apply timezone handler.
Run the following command in Linux: timedatectl set-timezone <timezone>
Args:
data: Read table's key's data.
"""
new_timezone = data.get('timezone')
syslog.syslog(syslog.LOG_DEBUG, f'DeviceMetaCfg: timezone update to {new_timezone}')

#run command will print out log error in case of error (no need to raise additional exception)
run_cmd(f'timedatectl set-timezone {new_timezone}', True, False)


class MgmtIfaceCfg(object):
"""
MgmtIfaceCfg Config Daemon
Expand Down Expand Up @@ -1741,6 +1755,7 @@ class HostConfigDaemon:
def device_metadata_handler(self, key, op, data):
syslog.syslog(syslog.LOG_INFO, 'DeviceMeta handler...')
self.devmetacfg.hostname_update(data)
self.devmetacfg.timezone_update(data)

def syslog_handler(self, key, op, data):
self.syslogcfg.syslog_update(data)
Expand Down

0 comments on commit cfd6dc1

Please sign in to comment.