diff options
author | Michael DeHaan <mdehaan@redhat.com> | 2007-11-12 13:25:23 -0500 |
---|---|---|
committer | Michael DeHaan <mdehaan@redhat.com> | 2007-11-12 13:25:23 -0500 |
commit | 57f449cc30b59970b97d7ee4d74cc02a98e07e30 (patch) | |
tree | 24b59435eba407c06645eecfeed882c0b31c240b /cobbler/serializer.py | |
parent | a4dcebbff2db26dc22aadcc0f84328c19d52e48d (diff) | |
download | third_party-cobbler-57f449cc30b59970b97d7ee4d74cc02a98e07e30.tar.gz third_party-cobbler-57f449cc30b59970b97d7ee4d74cc02a98e07e30.tar.xz third_party-cobbler-57f449cc30b59970b97d7ee4d74cc02a98e07e30.zip |
Abstract out the modules system to allow for other types of modules, and to also centralize configuration/loading/access some more.
Diffstat (limited to 'cobbler/serializer.py')
-rw-r--r-- | cobbler/serializer.py | 33 |
1 files changed, 16 insertions, 17 deletions
diff --git a/cobbler/serializer.py b/cobbler/serializer.py index f7904c1..8593aad 100644 --- a/cobbler/serializer.py +++ b/cobbler/serializer.py @@ -17,28 +17,22 @@ import errno import os from rhpl.translate import _, N_, textdomain, utf8 -import yaml # Howell-Clark version - from cexceptions import * import utils import api as cobbler_api -import modules.serializer_yaml as serializer_yaml -import ConfigParser - -MODULE_CACHE = {} -cp = ConfigParser.ConfigParser() -cp.read("/etc/cobbler/modules.conf") def serialize(obj): """ Save a collection to disk or other storage. """ - storage_module = __get_storage_module(obj.collection_type()) storage_module.serialize(obj) return True def serialize_item(collection, item): + """ + Save an item. + """ storage_module = __get_storage_module(collection.collection_type()) save_fn = getattr(storage_module, "serialize_item", None) if save_fn is None: @@ -49,6 +43,9 @@ def serialize_item(collection, item): return save_fn(collection,item) def serialize_delete(collection, item): + """ + Delete an object from a saved state. + """ storage_module = __get_storage_module(collection.collection_type()) delete_fn = getattr(storage_module, "serialize_delete", None) if delete_fn is None: @@ -67,17 +64,19 @@ def deserialize(obj,topological=False): return storage_module.deserialize(obj,topological) def deserialize_raw(collection_type): + """ + Return the datastructure corresponding to the serialized + disk state, without going through the Cobbler object system. + Much faster, when you don't need the objects. + """ storage_module = __get_storage_module(collection_type) return storage_module.deserialize_raw(collection_type) def __get_storage_module(collection_type): + """ + Look up serializer in /etc/cobbler/modules.conf + """ + capi = cobbler_api.BootAPI() + return capi.get_module_from_file("serializers",collection_type) - if not MODULE_CACHE.has_key(collection_type): - value = cp.get("serializers",collection_type) - module = cobbler_api.BootAPI().modules[value] - MODULE_CACHE[collection_type] = module - return module - else: - return MODULE_CACHE[collection_type] - |