Cobbler patch for sending DHCP option host-name based on system name

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



	Hi, for your consideration:

	Attached is a patch for allowing cobbler to set "option host-name
$SYSTEM_NAME" if the setting isc_set_host_name is set in
/var/lib/cobbler/settings

	What is intended for:

	At my network I've a generic:

	option
host-name=concat("equipo-",substring(binary-to-ascii(10,8,".",leased-address),9,3));

	To set host-names for non-registered computers, using this patch,
I can instruct my computers to use the name registered at cobbler by just
empyting hostname:

#raw
sed -i 's#^HOSTNAME=.*$##g' /etc/sysconfig/network
#end raw

	This way: if a system is registered, it will get cobbler hostname,
if not, will get a generic "equipo-$IP_LAST_BYTE"

	Regards
	Pablo


-- 
Pablo Iranzo Gómez
(http://Alufis35.uv.es/~iranzo/)
(PGPKey Available on http://www.uv.es/~iranzop/PGPKey.pgp)
                  --
Postulado de Boling sobre la Ley de Murphy:

Si se encuentra bien, no se preocupe. Se le pasará
diff --git a/cobbler/action_sync.py b/cobbler/action_sync.py
index 139066e..d6ea178 100644
--- a/cobbler/action_sync.py
+++ b/cobbler/action_sync.py
@@ -163,6 +163,8 @@ class BootSync:
                     # the label the entry after the hostname if possible
                     if host is not None and host != "":
                         systxt = "\nhost %s {\n" % host
+                        if self.settings.isc_set_host_name:
+                            systxt = systxt + "    option host-name = %s;\n" % host
                     else:
                         systxt = "\nhost generic%d {\n" % counter

diff --git a/cobbler/settings.py b/cobbler/settings.py
index 581403c..e89f254 100644
--- a/cobbler/settings.py
+++ b/cobbler/settings.py
@@ -39,6 +39,7 @@ DEFAULTS = {
     "dnsmasq_conf"                : "/etc/dnsmasq.conf",
     "httpd_bin"                   : "/usr/sbin/httpd",
     "http_port"                   : "80",
+    "isc_set_host_name"           : 0,
     "kerberos_realm"              : "example.org",
     "kernel_options"              : {
     "lang"                    : " ",

_______________________________________________
et-mgmt-tools mailing list
et-mgmt-tools@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/et-mgmt-tools

[Index of Archives]     [Fedora Users]     [Fedora Legacy List]     [Fedora Maintainers]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux