class DhcpdHost UserDict Describes dhcpd_hosts host entry def __init__

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
class DhcpdHost(UserDict):
""" Describes dhcpd_hosts host entry """
def __init__(self, entry_name=None, filename=dhcpd_hosts_path):
UserDict.__init__(self)
self.data = {}
self._filename = filename
self._hosts = get_dhcpd_contents(filename)
self.entry_name = entry_name
if entry_name is not None and self.host_exist():
self._set_host_info(entry_name)
def host_exist(self, entry_name):
""" Chack hosts exists or not """
for host in self._hosts:
if host['entry_name'] = entry_name:
return True
return Flase
def _set_host_info(self, entry_name):
""" Get host entry information """
for host in self._hosts:
if host['entry_name'] = entry_name:
self.data = host
break