dom0/qvm-sync-clock: use timestamp in RFC2822 format to avoid locale issues
This commit is contained in:
parent
d19a3cce99
commit
69354475bf
@ -71,18 +71,19 @@ def main():
|
|||||||
print >> sys.stderr, 'Time sync failed, aborting!'
|
print >> sys.stderr, 'Time sync failed, aborting!'
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
p = clock_vm.run('user:date -u', verbose=verbose, passio_popen=True, ignore_stderr=True)
|
# Use the date format based on RFC2822 to avoid localisation issues
|
||||||
|
p = clock_vm.run('user:date -u -R', verbose=verbose, passio_popen=True, ignore_stderr=True)
|
||||||
date_out = p.stdout.read(100)
|
date_out = p.stdout.read(100)
|
||||||
date_out = date_out.strip()
|
date_out = date_out.strip()
|
||||||
if not re.match(r'^[A-Za-z]* [A-Za-z]* [ 0-9][0-9] [0-9][0-9]:[0-9][0-9]:[0-9][0-9] [A-Z]* [0-9][0-9][0-9][0-9]$', date_out):
|
if not re.match(r'^[A-Za-z]+[,] [0-9][0-9] [A-Za-z]+ [0-9][0-9][0-9][0-9] [0-9][0-9]:[0-9][0-9]:[0-9][0-9] [+]0000$', date_out):
|
||||||
print >> sys.stderr, 'Invalid date output, aborting!'
|
print >> sys.stderr, date_out, 'Invalid date output, aborting!'
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
# Sync dom0 time
|
# Sync dom0 time
|
||||||
if verbose:
|
if verbose:
|
||||||
print >> sys.stderr, '--> Syncing dom0 clock.'
|
print >> sys.stderr, '--> Syncing dom0 clock.'
|
||||||
|
|
||||||
subprocess.check_call(['sudo', 'date', '-u', '-s', date_out])
|
subprocess.check_call(['sudo', 'date', '-u', '-R', '-s', date_out])
|
||||||
subprocess.check_call(['sudo', 'hwclock', '--systohc'])
|
subprocess.check_call(['sudo', 'hwclock', '--systohc'])
|
||||||
|
|
||||||
# Sync other VMs clock
|
# Sync other VMs clock
|
||||||
@ -91,7 +92,7 @@ def main():
|
|||||||
if verbose:
|
if verbose:
|
||||||
print >> sys.stderr, '--> Syncing \'%s\' clock.' % vm.name
|
print >> sys.stderr, '--> Syncing \'%s\' clock.' % vm.name
|
||||||
try:
|
try:
|
||||||
vm.run('root:date -u -s "%s"' % date_out, verbose=verbose)
|
vm.run('root:date -u -R -s "%s"' % date_out, verbose=verbose)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print >> sys.stderr, "ERROR syncing time in VM '%s': %s" % (vm.name, str(e))
|
print >> sys.stderr, "ERROR syncing time in VM '%s': %s" % (vm.name, str(e))
|
||||||
pass
|
pass
|
||||||
|
Loading…
Reference in New Issue
Block a user