diff --git a/src/cobbler/bootup_dhcp.template.u b/src/cobbler/bootup_dhcp.template.u index a9a25555..8daa0b35 100644 --- a/src/cobbler/bootup_dhcp.template.u +++ b/src/cobbler/bootup_dhcp.template.u @@ -21,7 +21,6 @@ host __$HOSTFQDN__ { fixed-address __$IPADDRESS__; option host-name "__$HOSTNAME__"; filename "/pxelinux.0"; - option ntp-servers __$NTP_SERVER_LIST__; next-server __$IPADDRESS__; } diff --git a/src/server_mgr_main.py b/src/server_mgr_main.py index ee3b0513..c42a820e 100755 --- a/src/server_mgr_main.py +++ b/src/server_mgr_main.py @@ -479,7 +479,12 @@ def __init__(self, args_str=None): gevent.spawn(self._monitoring_base_plugin_obj.setup_keys, self._serverDb) #Generate the DHCP template for the SM host only such that cobbler works correctly + self._using_dhcp_management = False self._dhcp_template_obj = DHCPTemplateGenerator(self._serverDb) + dhcp_hosts = self._serverDb.get_dhcp_host() + dhcp_subnets = self._serverDb.get_dhcp_subnet() + if len(dhcp_hosts) > 1 and len(dhcp_subnets): + self._using_dhcp_management = True self._base_url = "http://%s:%s" % (self._args.listen_ip_addr, self._args.listen_port) @@ -1914,6 +1919,7 @@ def put_dhcp_host(self): msg = "Keys missing from the config sent: " + str(list(set(self._dhcp_host_key_list)-set(dhcp_host.keys()))) + "\n" self.log_and_raise_exception(msg) stanza = self._dhcp_template_obj.generate_dhcp_template() + self._using_dhcp_management = True # Sync the above information if self._smgr_cobbler: self._smgr_cobbler.sync() @@ -1970,6 +1976,7 @@ def put_dhcp_subnet(self): msg = "Keys missing from the config sent: " + str(set(self._dhcp_subnet_key_list)) + " " + str(set(dhcp_subnet.keys())) + "\n" self.log_and_raise_exception(msg) stanza = self._dhcp_template_obj.generate_dhcp_template() + self._using_dhcp_management = True except ServerMgrException as e: self._smgr_trans_log.log(bottle.request, self._smgr_trans_log.PUT_SMGR_CFG_SERVER, False) @@ -3251,8 +3258,8 @@ def reimage_server(self): if cluster and cluster[0]['parameters']: cluster_parameters = eval(cluster[0]['parameters']) - if 'ip_address' in server and server['ip_address']: - if server['ip_address'] not in valid_dhcp_ip_list: + if 'ip_address' in server and server['ip_address'] and self._using_dhcp_management: + if str(server['ip_address']) not in valid_dhcp_ip_list: msg = "The server with id %s cannot be reimaged. \ There is no cobbler DHCP configuration for the ip address of this server \ : %s" % (server['id'], server['ip_address']) @@ -3778,11 +3785,12 @@ def get_dhcp_ips(self): dhcp_ips = [] db_dhcp_hosts = self._serverDb.get_dhcp_host() for host in db_dhcp_hosts: - dhcp_ips.append(host['ip_address']) + dhcp_ips.append(str(host['ip_address'])) db_dhcp_subnets = self._serverDb.get_dhcp_subnet() for subnet in db_dhcp_subnets: subnet_cidr = self._serverDb.get_cidr(subnet['subnet_address'], subnet['subnet_mask']) - dhcp_ips.append(IPNetwork(str(subnet_cidr))) + subnet_ip_list = [str(x) for x in IPNetwork(str(subnet_cidr))] + dhcp_ips+=subnet_ip_list return set(dhcp_ips) # Function to get map server name to server ip