From 7d9426dd6582d65de1c1a707dc40f03ef19d6c3b Mon Sep 17 00:00:00 2001 From: Joshua Boniface Date: Wed, 24 Oct 2018 01:04:04 -0400 Subject: [PATCH] Add NTP to dnsmasq DHCP; move mkdir of dnsmasq_hostsdir to init --- node-daemon/pvcd/VXNetworkInstance.py | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/node-daemon/pvcd/VXNetworkInstance.py b/node-daemon/pvcd/VXNetworkInstance.py index c18b2c15..f9a6c388 100644 --- a/node-daemon/pvcd/VXNetworkInstance.py +++ b/node-daemon/pvcd/VXNetworkInstance.py @@ -59,6 +59,13 @@ class VXNetworkInstance(object): self.dnsmasq_hostsdir = '{}/{}'.format(config['dnsmasq_dynamic_directory'], self.vni) self.dhcp_reservations = [] + # Create the network hostsdir + common.run_os_command( + '/bin/mkdir --parents {}'.format( + self.dnsmasq_hostsdir + ) + ) + self.firewall_rules_base = """# Rules for network {vxlannic} add chain inet filter {vxlannic}-in add chain inet filter {vxlannic}-out @@ -223,9 +230,9 @@ add rule inet filter input meta iifname {bridgenic} counter drop ) ) entry = '{},{}'.format(reservation, ipaddr) - outfile = open(filename, 'w') - outfile.write(entry) - outfile.close() + # Write the entry + with open(filename, 'w') as outfile: + outfile.write(entry) for reservation in old_reservations_list: if reservation not in new_reservations_list: @@ -354,12 +361,6 @@ add rule inet filter input meta iifname {bridgenic} counter drop prefix='VNI {}'.format(self.vni), state='o' ) - # Create the network hostsdir - common.run_os_command( - '/bin/mkdir --parents {}'.format( - self.dnsmasq_hostsdir - ) - ) # Recreate the environment we need for dnsmasq pvcd_config_file = os.environ['PVCD_CONFIG_FILE'] dhcp_environment = { @@ -386,6 +387,7 @@ add rule inet filter input meta iifname {bridgenic} counter drop '--dhcp-script={}/pvcd/dnsmasq-zookeeper-leases.py'.format(os.getcwd()), '--dhcp-range={},{},48h'.format(self.dhcp_start, self.dhcp_end), '--dhcp-hostsdir={}'.format(self.dnsmasq_hostsdir), + '--dhcp-option=option:ntp-server,224.0.0.1', '--log-facility=-', '--keep-in-foreground' ]