summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael DeHaan <mdehaan@mdehaan.rdu.redhat.com>2007-04-19 15:24:08 -0400
committerMichael DeHaan <mdehaan@mdehaan.rdu.redhat.com>2007-04-19 15:24:08 -0400
commit8a46265453503a5dfe04bf10d3019368fb032cf5 (patch)
tree1f965e2948079ae60d3b56c6edaef8d6b59d9119
parentc9da67b5170b473895ce83feba2aa328cf5ec9f8 (diff)
downloadthird_party-cobbler-8a46265453503a5dfe04bf10d3019368fb032cf5.zip
third_party-cobbler-8a46265453503a5dfe04bf10d3019368fb032cf5.tar.gz
third_party-cobbler-8a46265453503a5dfe04bf10d3019368fb032cf5.tar.xz
Changes cobbler_syslogd to cobblerd, and this new daemon now offers koan
info over XMLRPC, allowing koan to stop needing to grok YAML. Older versions of koan will remain compatible over standard http://.
-rw-r--r--CHANGELOG1
-rw-r--r--MANIFEST.in7
-rw-r--r--cobbler.spec12
-rw-r--r--cobbler/cobblerd.py142
-rw-r--r--cobbler/settings.py1
-rw-r--r--cobbler/syslog_watcher.py52
-rw-r--r--config/cobbler.conf (renamed from templates/cobbler.conf)8
-rwxr-xr-xconfig/cobblerd (renamed from scripts/cobblersyslogd)11
-rw-r--r--config/rsync.exclude11
-rwxr-xr-xscripts/cobblerd (renamed from scripts/cobbler_syslogd)2
-rw-r--r--setup.py8
11 files changed, 179 insertions, 76 deletions
diff --git a/CHANGELOG b/CHANGELOG
index 9a72796..d48fab0 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -10,6 +10,7 @@ Cobbler CHANGELOG
- Teach cobbler to remove .olddata dirs, which can happen if createrepo crashes or is killed mid-process
- Default yum_core_repos_from_server to 0
- Implemented triggers for add/delete commands
+- BootAPI and Config object classes are now Borg patterned to prevent duplication of config info from the API.
* Thu Apr 05 2007 - 0.4.6
- Bind cobbler_syslogd to all addresses
diff --git a/MANIFEST.in b/MANIFEST.in
index 445e623..f6f8317 100644
--- a/MANIFEST.in
+++ b/MANIFEST.in
@@ -1,7 +1,7 @@
include loaders/COPYING_ELILO
include loaders/elilo-3.6-ia64.efi
include loaders/menu.c32
-include templates/cobbler.conf
+include config/cobbler.conf
include templates/dhcp.template
include templates/pxeprofile.template
include templates/pxedefault.template
@@ -13,6 +13,7 @@ include kickstarts/kickstart_fc6_domU.ks
include kickstarts/default.ks
include docs/cobbler.1.gz
include COPYING AUTHORS README CHANGELOG NEWS
-include templates/rsync.exclude
+include config/rsync.exclude
include scripts/watcher.py
-include scripts/cobblersyslogd
+include scripts/cobblerd
+include config/cobblerd
diff --git a/cobbler.spec b/cobbler.spec
index 271902d..fe278bf 100644
--- a/cobbler.spec
+++ b/cobbler.spec
@@ -46,18 +46,18 @@ test "x$RPM_BUILD_ROOT" != "x" && rm -rf $RPM_BUILD_ROOT
%{__python} setup.py install --optimize=1 --root=$RPM_BUILD_ROOT
%post
-/sbin/chkconfig --add cobblersyslogd
+/sbin/chkconfig --add cobblerd
%preun
if [ $1 = 0 ]; then
- /sbin/service cobblersyslogd stop >/dev/null 2>&1 || :
- chkconfig --del cobblersyslogd
+ /sbin/service cobblerd stop >/dev/null 2>&1 || :
+ chkconfig --del cobblerd
fi
%postun
if [ "$1" -ge "1" ]; then
- /sbin/service cobblersyslogd condrestart >/dev/null 2>&1 || :
+ /sbin/service cobblerd condrestart >/dev/null 2>&1 || :
fi
%clean
@@ -83,7 +83,7 @@ test "x$RPM_BUILD_ROOT" != "x" && rm -rf $RPM_BUILD_ROOT
%dir /tftpboot/pxelinux.cfg
%dir /tftpboot/images
%{_bindir}/cobbler
-%{_bindir}/cobbler_syslogd
+%{_bindir}/cobblerd
%dir /etc/cobbler
%config(noreplace) /etc/cobbler/default.ks
%config(noreplace) /etc/cobbler/kickstart_fc5.ks
@@ -100,7 +100,7 @@ test "x$RPM_BUILD_ROOT" != "x" && rm -rf $RPM_BUILD_ROOT
%{python_sitelib}/cobbler/*.py*
%{python_sitelib}/cobbler/yaml/*.py*
%{_mandir}/man1/cobbler.1.gz
-/etc/init.d/cobblersyslogd
+/etc/init.d/cobblerd
/etc/httpd/conf.d/cobbler.conf
%dir /var/log/cobbler/syslog
%defattr(2770,root,root)
diff --git a/cobbler/cobblerd.py b/cobbler/cobblerd.py
new file mode 100644
index 0000000..801f7f3
--- /dev/null
+++ b/cobbler/cobblerd.py
@@ -0,0 +1,142 @@
+# cobbler daemon for logging remote syslog traffic during kickstart
+#
+# Copyright 2007, Red Hat, Inc
+# Michael DeHaan <mdehaan@redhat.com>
+#
+# This software may be freely redistributed under the terms of the GNU
+# general public license.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+import socket
+import time
+import os
+import SimpleXMLRPCServer
+import yaml # Howell Clark version
+
+import api as cobbler_api
+
+def main():
+
+ bootapi = cobbler_api.BootAPI()
+ settings = bootapi.settings()
+ syslog_port = settings.syslog_port
+ xmlrpc_port = settings.xmlrpc_port
+
+ pid = os.fork()
+
+ if pid == 0:
+ do_xmlrpc(bootapi, settings, xmlrpc_port)
+ else:
+ do_syslog(bootapi, settings, syslog_port)
+
+def do_xmlrpc(bootapi, settings, port):
+
+ xinterface = CobblerXMLRPCInterface(bootapi)
+ server = CobblerXMLRPCServer(('', port))
+ server.register_instance(xinterface)
+ server.serve_forever()
+
+def do_syslog(bootapi, settings, port):
+
+ s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
+ s.bind(("0.0.0.0", port))
+
+ buf = 1024
+
+ while 1:
+ data, addr = s.recvfrom(buf)
+ (ip, port) = addr
+ if not data:
+ break
+ else:
+ logfile = open("/var/log/cobbler/syslog/%s" % ip, "a+")
+ t = time.localtime()
+ # write numeric time
+ seconds = str(time.mktime(t))
+ logfile.write(seconds)
+ logfile.write("\t")
+ # write string time
+ timestr = str(time.asctime(t))
+ logfile.write(timestr)
+ logfile.write("\t")
+ # write the IP address of the client
+ logfile.write(ip)
+ logfile.write("\t")
+ # write the data
+ logfile.write(data)
+ logfile.write("\n")
+ logfile.close()
+
+class CobblerXMLRPCInterface:
+
+ def __init__(self,api):
+ self.api = api
+
+ def __sorter(self,a,b):
+ return cmp(a["name"],b["name"])
+
+ def __get_all(self,collection):
+ data = collection.to_datastruct()
+ data.sort(self.__sorter)
+ return data
+
+ def get_distros(self):
+ return self.__get_all(self.api.distros())
+
+ def get_profiles(self):
+ return self.__get_all(self.api.profiles())
+
+ def get_systems(self):
+ return self.__get_all(self.api.systems())
+
+ def __get_specific(self,collection,name):
+ item = collection.find(name)
+ if item is None:
+ return {}
+ return item.to_datastruct()
+
+ def get_distro(self,name):
+ return self.__get_specific(self.api.distros(),name)
+
+ def get_profile(self,name):
+ return self.__get_specific(self.api.profiles(),name)
+
+ def get_system(self,name):
+ return self.__get_specific(self.api.systems(),name)
+
+ def get_repo(self,name):
+ return self.__get_specific(self.api.repos(),name)
+
+ def __get_for_koan(self,dir,name):
+ path = os.path.join("/var/www/cobbler/", dir, name)
+ if not os.path.exists(path):
+ return {}
+ fd = open(path)
+ data = fd.read()
+ datastruct = yaml.load(data).next()
+ fd.close()
+ return datastruct
+
+ def get_distro_for_koan(self,name):
+ return self.__get_for_koan("distros",name)
+
+ def get_profile_for_koan(self,name):
+ return self.__get_for_koan("profiles",name)
+
+ def get_system_for_koan(self,name):
+ return self.__get_for_koan("systems",name)
+
+class CobblerXMLRPCServer(SimpleXMLRPCServer.SimpleXMLRPCServer):
+
+ def __init__(self, args):
+ self.allow_reuse_address = True
+ SimpleXMLRPCServer.SimpleXMLRPCServer.__init__(self,args)
+
+
+if __name__ == "__main__":
+
+ main()
+
diff --git a/cobbler/settings.py b/cobbler/settings.py
index c4f3b36..2aa421b 100644
--- a/cobbler/settings.py
+++ b/cobbler/settings.py
@@ -40,6 +40,7 @@ DEFAULTS = {
"ia64" : "/var/lib/cobbler/elilo-3.6-ia64.efi"
},
"syslog_port" : 25150,
+ "xmlrpc_port" : 25151,
"minimize_syncs" : 1,
"yum_core_mirror_from_server" : 0
}
diff --git a/cobbler/syslog_watcher.py b/cobbler/syslog_watcher.py
deleted file mode 100644
index fc00b85..0000000
--- a/cobbler/syslog_watcher.py
+++ /dev/null
@@ -1,52 +0,0 @@
-# cobbler daemon for logging remote syslog traffic during kickstart
-#
-# Copyright 2007, Red Hat, Inc
-# Michael DeHaan <mdehaan@redhat.com>
-#
-# This software may be freely redistributed under the terms of the GNU
-# general public license.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-
-import socket
-import time
-
-import api as cobbler_api
-
-def main():
-
- bootapi = cobbler_api.BootAPI()
- settings = bootapi.settings()
- port = settings.syslog_port
-
- s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
- s.bind(("0.0.0.0", port))
-
- buf = 1024
-
- while 1:
- data, addr = s.recvfrom(buf)
- (ip, port) = addr
- if not data:
- break
- else:
- logfile = open("/var/log/cobbler/syslog/%s" % ip, "a+")
- t = time.localtime()
- # write numeric time
- seconds = str(time.mktime(t))
- logfile.write(seconds)
- logfile.write("\t")
- # write string time
- timestr = str(time.asctime(t))
- logfile.write(timestr)
- logfile.write("\t")
- # write the IP address of the client
- logfile.write(ip)
- logfile.write("\t")
- # write the data
- logfile.write(data)
- logfile.write("\n")
- logfile.close()
-
diff --git a/templates/cobbler.conf b/config/cobbler.conf
index 70a63e9..011760a 100644
--- a/templates/cobbler.conf
+++ b/config/cobbler.conf
@@ -1,11 +1,11 @@
# This configuration file allows cobbler data
# to be accessed over HTTP.
-AliasMatch ^/cobbler(/.*)?$ "/cobbler_webdir$1"
-AliasMatch ^/cobbler_track(/.*)?$ "/cobbler_webdir$1"
-AliasMatch ^/cblr(/.*)?$ "/cobbler_webdir$1"
+AliasMatch ^/cblr(.*)?$ "/var/www/cobbler$1"
+AliasMatch ^/cobbler_track(.*)?$ "/var/www/cobbler$1"
+AliasMatch ^/cobbler(.*)?$ "/var/www/cobbler$1"
-<Directory "/cobbler_webdir">
+<Directory "/var/www/cobbler">
Options Indexes FollowSymLinks
AllowOverride None
Order allow,deny
diff --git a/scripts/cobblersyslogd b/config/cobblerd
index b8bc3f7..756fa00 100755
--- a/scripts/cobblersyslogd
+++ b/config/cobblerd
@@ -3,9 +3,8 @@
# cobblersyslogd Cobbler kickstart status monitor
#
# chkconfig: 345 99 99
-# description: This is a daemon which monitors and logs remote syslog traffic \
-# from machines being provisioned from cobbler. \
-# See http://cobbler.et.redhat.com
+# description: This is a daemon that provides remote cobbler info to koan
+# clients and also logs installer syslog activitity.
#
# processname: /usr/bin/cobbler_syslogd
@@ -18,7 +17,7 @@
RETVAL=0
start() {
- echo -n $"Starting cobbler remote syslog monitor: "
+ echo -n $"Starting cobbler daemon: "
if test -f /var/lock/subsys/cobblersyslogd ; then
echo_failure
echo
@@ -34,7 +33,7 @@ start() {
stop() {
- echo -n $"Stopping cobbler remote syslog monitor: "
+ echo -n $"Stopping cobbler daemon: "
if ! test -f /var/lock/subsys/cobblersyslogd ; then
echo_failure
echo
@@ -50,7 +49,7 @@ stop() {
mystatus() {
if test -f /var/lock/subsys/cobblersyslogd ; then
- echo "cobbbler_syslogd is running..."
+ echo "cobbblerd is running..."
return 0
fi
echo "cobbler_syslogd is stopped"
diff --git a/config/rsync.exclude b/config/rsync.exclude
new file mode 100644
index 0000000..15c6993
--- /dev/null
+++ b/config/rsync.exclude
@@ -0,0 +1,11 @@
+### files to exclude from "cobbler import" commands that use
+### rsync mirrors. by default ISOs, PPC code, and debug
+### RPM's are not transferred. Some users may want to
+### re-enable debug RPM's.
+**/debug/**
+**/ppc/**
+**/source/**
+**/SRPMS/**
+**/*.iso
+**/openoffice.org-langpack**
+**/kde-i18n**
diff --git a/scripts/cobbler_syslogd b/scripts/cobblerd
index 86e77e1..409f738 100755
--- a/scripts/cobbler_syslogd
+++ b/scripts/cobblerd
@@ -16,7 +16,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
import sys
import os
-import cobbler.syslog_watcher as app
+import cobbler.cobblerd as app
if __name__ == "__main__":
diff --git a/setup.py b/setup.py
index d5bea99..9c685bd 100644
--- a/setup.py
+++ b/setup.py
@@ -45,9 +45,9 @@ if __name__ == "__main__":
"cobbler",
"cobbler/yaml"
],
- scripts = ["scripts/cobbler", "scripts/cobbler_syslogd"],
+ scripts = ["scripts/cobbler", "scripts/cobblerd"],
data_files = [
- (wwwconf, ['templates/cobbler.conf']),
+ (wwwconf, ['config/cobbler.conf']),
(cobpath, ['loaders/elilo-3.6-ia64.efi']),
(cobpath, ['loaders/menu.c32']),
(etcpath, ['kickstarts/kickstart_fc5.ks']),
@@ -60,8 +60,8 @@ if __name__ == "__main__":
(etcpath, ['templates/pxesystem_ia64.template']),
(etcpath, ['templates/pxeprofile.template']),
(manpath, ['docs/cobbler.1.gz']),
- (etcpath, ['templates/rsync.exclude']),
- (initpath, ['scripts/cobblersyslogd']),
+ (etcpath, ['config/rsync.exclude']),
+ (initpath, ['config/cobblerd']),
(logpath, []),
(logpath2, []),
(logpath3, []),