Skip to content

Commit

Permalink
Added new method
Browse files Browse the repository at this point in the history
  • Loading branch information
struegamer committed Jun 3, 2014
1 parent 3bc10e2 commit 37c1b94
Showing 1 changed file with 26 additions and 0 deletions.
Expand Up @@ -120,10 +120,36 @@ def dc2_dhcp_mgmt_write_config(ipspace=None):
'wb')
fp.write(rendered_template)
fp.close()
dc2_dhcp_mgmt_manage_include_file(
'add', '{0}'.format(str(ip.network)))
return True
else:
return False
except netaddr.core.AddrFormatError:
return False
else:
return False


def dc2_dhcp_mgmt_manage_include_file(action='add', filename_to_add=None):
dhcp_include_file = DHCP_MGMT_CONFIG['dhcp_include_file']
dhcp_store_directory = DHCP_MGMT_CONFIG['store_directory']

if action.lower() == 'add':
fp = open(dhcp_include_file, 'r+b')
contents = fp.readlines()
found = False
for line in contents:
if line.find('include "{0}/{1}";'.format(
dhcp_store_directory,
filename_to_add)) == -1:
found = False
else:
found = True
break
if found is False:
fp.write('include "{0}/{1}";'.format(
dhcp_store_directory, filename_to_add))
fp.close()
elif action.lower() == 'delete':
pass

0 comments on commit 37c1b94

Please sign in to comment.