Changeset 10654 in genesis for tools


Ignore:
Timestamp:
May 2, 2012, 10:29:52 PM (13 years ago)
Author:
rick
Message:

Provide an usefull ntp.conf template. Edge units have only external NTP
servers, Internal units has all the edge nodes configured as failback and the
pool as primary source.

Related-To: nodefactory#139

File:
1 edited

Legend:

Unmodified
Added
Removed
  • tools/gformat.py

    r10649 r10654  
    8484    'resolv.conf',
    8585    'motd',
     86    'ntp.conf',
    8687    'wleiden.yaml',
    8788    ]
     
    749750
    750751
     752def generate_ntp_conf(datadump):
     753  """ Generate configuration file '/etc/ntp.conf' """
     754  # XXX: This should properly going to be an datastructure soon
     755
     756  datadump['autogen_header'] = generate_header("#")
     757  datadump['autogen_ntp_servers'] = ''
     758  for host in get_proxylist():
     759    hostdump = get_yaml(host)
     760    datadump['autogen_ntp_servers'] += "server %(masterip)-15s iburst maxpoll 9 # %(autogen_realname)s\n" % hostdump
     761  for host in get_hybridlist():
     762    hostdump = get_yaml(host)
     763    if hostdump['service_proxy_ileiden'] or hostdump['service_proxy_normal']:
     764      datadump['autogen_ntp_servers'] += "server %(masterip)-15s iburst maxpoll 9 # %(autogen_realname)s\n" % hostdump
     765
     766  return Template("""\
     767{{ autogen_header }}
     768
     769{% if service_proxy_normal or service_proxy_ileiden or nodetype == 'Proxy' -%}
     770# Machine hooked to internet.
     771server 0.nl.pool.ntp.org iburst maxpoll 9
     772server 1.nl.pool.ntp.org iburst maxpoll 9
     773server 2.nl.pool.ntp.org iburst maxpoll 9
     774server 3.nl.pool.ntp.org iburst maxpoll 9
     775{% else -%}
     776# Local Wireless Leiden NTP Servers.
     777server 0.pool.ntp.wleiden.net iburst maxpoll 9
     778server 1.pool.ntp.wleiden.net iburst maxpoll 9
     779server 2.pool.ntp.wleiden.net iburst maxpoll 9
     780server 3.pool.ntp.wleiden.net iburst maxpoll 9
     781
     782# All the configured NTP servers
     783{{ autogen_ntp_servers }}
     784{% endif %}
     785
     786# If a server loses sync with all upstream servers, NTP clients
     787# no longer follow that server. The local clock can be configured
     788# to provide a time source when this happens, but it should usually
     789# be configured on just one server on a network. For more details see
     790# http://support.ntp.org/bin/view/Support/UndisciplinedLocalClock
     791# The use of Orphan Mode may be preferable.
     792#
     793server 127.127.1.0
     794fudge 127.127.1.0 stratum 10
     795""").render(datadump)
     796
     797
     798
    751799def generate_motd(datadump):
    752800  """ Generate configuration file '/etc/motd' """
     
    865913    elif config == 'resolv.conf':
    866914      output += generate_resolv_conf(datadump)
     915    elif config == 'ntp.conf':
     916      output += generate_ntp_conf(datadump)
    867917    elif config == 'motd':
    868918      output += generate_motd(datadump)
Note: See TracChangeset for help on using the changeset viewer.