summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--cobbler/modules/serializer_shelver.py162
-rw-r--r--cobbler_register11
-rw-r--r--installer_templates/settings.template10
-rw-r--r--kickstarts/legacy.ks1
-rw-r--r--kickstarts/sample.ks1
-rw-r--r--kickstarts/sample_end.ks1
-rw-r--r--setup.py1
-rw-r--r--snippets/cobbler_register13
8 files changed, 32 insertions, 168 deletions
diff --git a/cobbler/modules/serializer_shelver.py b/cobbler/modules/serializer_shelver.py
deleted file mode 100644
index a46f4ebf..00000000
--- a/cobbler/modules/serializer_shelver.py
+++ /dev/null
@@ -1,162 +0,0 @@
-"""
-Serializer code for cobbler
-
-Copyright 2006-2008, Red Hat, Inc
-Michael DeHaan <mdehaan@redhat.com>
-
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-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., 51 Franklin Street, Fifth Floor, Boston, MA
-02110-1301 USA
-"""
-
-import distutils.sysconfig
-import os
-import sys
-import glob
-import traceback
-
-plib = distutils.sysconfig.get_python_lib()
-mod_path="%s/cobbler" % plib
-sys.path.insert(0, mod_path)
-
-from utils import _
-import utils
-import yaml # Howell-Clark version
-import cexceptions
-import os
-import shelve
-#import gdbm
-import dumbdbm
-
-#d = gdbm.open(FILENAME, 'c')
-#d.reorganize()
-#d.close()
-
-class DbInstance:
- __shared_state = {}
- __has_loaded = False
-
- def __init__(self):
- self.__dict__ = DbInstance.__shared_state
- if not DbInstance.__has_loaded:
- filename = "/var/lib/cobbler/config/shelf_db"
- if not os.path.exists(filename):
- db_pre = dumbdbm.open(filename, 'c')
- db_pre.close()
- self.db = shelve.open(filename, 'c', writeback=True)
-
-def __open():
- dbi = DbInstance()
- return dbi.db
-
-def __close(db):
- pass
-
-def register():
- """
- The mandatory cobbler module registration hook.
- """
- # FIXME: run only when used, not loaded
- db = __open()
- if not db.has_key("distro"):
- db["distro"] = {}
- if not db.has_key("profile"):
- db["profile"] = {}
- if not db.has_key("system"):
- db["system"] = {}
- if not db.has_key("repo"):
- db["repo"] = {}
- if not db.has_key("image"):
- db["image"] = {}
- if not db.has_key("ip_map"):
- db["ip_map"] = {}
- if not db.has_key("mac_map"):
- db["mac_map"] = {}
- __close(db)
- return "serializer"
-
-def serialize_item(obj, item, sync=True):
- datastruct = item.to_datastruct()
- db = __open()
- # print "serializing: %s, %s <- %s" % (item.TYPE_NAME, item.name, datastruct)
- db[item.TYPE_NAME][item.name] = datastruct
- if sync:
- db.sync()
- __close(db)
- return True
-
-def serialize_delete(obj, item):
- db = __open()
- # print "writing: %s" % item.TYPE_NAME
- del db[item.TYPE_NAME][name]
- db.sync()
- __close(db)
- return True
-
-def deserialize_item_raw(collection_type, item_name):
- db = __open()
- # print "reading raw: %s" % collection_type
- data = db[collection_type][item_name]
- __close(db)
- return data
-
-def serialize(obj):
- """
- Save an object to disk. Object must "implement" Serializable.
- FIXME: Return False on access/permission errors.
- This should NOT be used by API if serialize_item is available.
- """
- db = __open()
- if obj.collection_type() == "settings":
- return True
- for x in obj:
- serialize_item(obj,x,sync=False)
- db.sync()
- return True
-
-def deserialize_raw(collection_type):
- if collection_type == "settings":
- fd = open("/etc/cobbler/settings")
- datastruct = yaml.load(fd.read()).next()
- fd.close()
- return datastruct
- else:
- db = __open()
- # print "getting keys for: %s" % collection_type
- keys = db[collection_type].keys()
- results = []
- for k in keys:
- # print "found key: %s" % k
- results.append(db[collection_type][k])
- __close(db)
- return results
-
-def deserialize(obj,topological=True):
- """
- Populate an existing object with the contents of datastruct.
- Object must "implement" Serializable.
- """
- datastruct = deserialize_raw(obj.collection_type())
- if topological and type(datastruct) == list:
- datastruct.sort(__depth_cmp)
- obj.from_datastruct(datastruct)
- return True
-
-def __depth_cmp(item1, item2):
- d1 = item1.get("depth",1)
- d2 = item2.get("depth",1)
- return cmp(d1,d2)
-
-
-
diff --git a/cobbler_register b/cobbler_register
new file mode 100644
index 00000000..6a5dade5
--- /dev/null
+++ b/cobbler_register
@@ -0,0 +1,11 @@
+# begin cobbler registration for profiles only, if enabled
+#if $getVar('system_name','') == ''
+#set rnist = $getVar('register_new_installs','')
+#if $str(rnist).lower() in [ "1", "y", "yes", "true" ]
+if [ -f "/usr/bin/cobbler-register" ]; then
+ /usr/bin/cobbler-register --server=$server --profile=$profile_name --hostname='*FULLAUTO*'
+fi
+#end if
+#end if
+# end cobbler registration
+
diff --git a/installer_templates/settings.template b/installer_templates/settings.template
index 5ceb6be0..d97f32c8 100644
--- a/installer_templates/settings.template
+++ b/installer_templates/settings.template
@@ -296,12 +296,10 @@ redhat_management_permissive: 0
restart_dns: 1
restart_dhcp: 1
-# if set to 1, new systems doing profile based installations will
-# contact cobbler to have system records created for them containing
-# the mac address information that they have requested for install.
-# this effectively allows for registration of new hardware via PXE
-# without having to manually enter in all of the mac addresses for
-# every machine on your network
+# if set to 1, allows /usr/bin/cobbler-register (part of the koan package)
+# to be used to remotely add new cobbler system records to cobbler.
+# this effectively allows for registration of new hardware from system
+# records.
register_new_installs: 0
# install triggers are scripts in /var/lib/cobbler/triggers/install
diff --git a/kickstarts/legacy.ks b/kickstarts/legacy.ks
index a51ec6b7..70918985 100644
--- a/kickstarts/legacy.ks
+++ b/kickstarts/legacy.ks
@@ -53,6 +53,7 @@ $SNIPPET('post_install_network_config')
$SNIPPET('download_config_files')
$SNIPPET('koan_environment')
$SNIPPET('redhat_register')
+$SNIPPET('cobbler_register')
# Begin final steps
$kickstart_done
# End final steps
diff --git a/kickstarts/sample.ks b/kickstarts/sample.ks
index b253f8bd..f41470d9 100644
--- a/kickstarts/sample.ks
+++ b/kickstarts/sample.ks
@@ -60,6 +60,7 @@ $SNIPPET('func_register_if_enabled')
$SNIPPET('download_config_files')
$SNIPPET('koan_environment')
$SNIPPET('redhat_register')
+$SNIPPET('cobbler_register')
# Enable post-install boot notification
$SNIPPET('post_anamon')
# Start final steps
diff --git a/kickstarts/sample_end.ks b/kickstarts/sample_end.ks
index 0e318239..21148366 100644
--- a/kickstarts/sample_end.ks
+++ b/kickstarts/sample_end.ks
@@ -64,6 +64,7 @@ $SNIPPET('func_register_if_enabled')
$SNIPPET('download_config_files')
$SNIPPET('koan_environment')
$SNIPPET('redhat_register')
+$SNIPPET('cobbler_register')
# Enable post-install boot notification
$SNIPPET('post_anamon')
# Start final steps
diff --git a/setup.py b/setup.py
index bfbcbd03..c98c89ba 100644
--- a/setup.py
+++ b/setup.py
@@ -248,6 +248,7 @@ if __name__ == "__main__":
(snippetpath, ['snippets/post_anamon']),
(snippetpath, ['snippets/post_s390_reboot']),
(snippetpath, ['snippets/redhat_register']),
+ (snippetpath, ['snippets/cobbler_register']),
# documentation
(manpath, ['docs/cobbler.1.gz']),
diff --git a/snippets/cobbler_register b/snippets/cobbler_register
new file mode 100644
index 00000000..ea2b99af
--- /dev/null
+++ b/snippets/cobbler_register
@@ -0,0 +1,13 @@
+# Begin cobbler registration
+#if $getVar('system_name','') == ''
+#if $str($getVar('register_new_installs','')) in [ "1", "true", "yes", "y" ]
+if [ -f "/usr/bin/cobbler-register" ]; then
+ cobbler-register --server=$server --fqdn '*AUTO*' --profile=$profile_name
+fi
+#else
+# cobbler registration is disabled in /etc/cobbler/settings
+#end if
+#else
+# skipping for system-based installation
+#end if
+# End cobbler registration