diff options
Diffstat (limited to 'cobbler/config.py')
-rw-r--r-- | cobbler/config.py | 31 |
1 files changed, 19 insertions, 12 deletions
diff --git a/cobbler/config.py b/cobbler/config.py index 27c33bd..bb2e454 100644 --- a/cobbler/config.py +++ b/cobbler/config.py @@ -1,15 +1,16 @@ """ Config.py is a repository of the Cobbler object model """ +import os import weakref -import distro -import profile -import system +import item_distro as distro +import item_profile as profile +import item_system as system -import distros -import profiles -import systems +import collection_distros as distros +import collection_profiles as profiles +import collection_systems as systems import settings import serializer @@ -17,22 +18,23 @@ import serializer class Config: def __init__(self): - # manage a definitive copy of all data collections with weakrefs + # manage a definitive copy of all data collections with weakrefs # back here so they can understand each other self._distros = distros.Distros(weakref.proxy(self)) self._profiles = profiles.Profiles(weakref.proxy(self)) self._systems = systems.Systems(weakref.proxy(self)) - self._settings = settings.Settings() # not a true collection + self._settings = settings.Settings() # not a true collection self._classes = [ self._distros, self._profiles, self._systems, self._settings, ] + self.file_check() def distros(self): return self._distros - + def profiles(self): return self._profiles @@ -40,14 +42,14 @@ class Config: return self._systems def settings(self): - return self._app_settings + return self._settings def new_distro(self): return distro.Distro(weakref.proxy(self)) def new_system(self): return system.System(weakref.proxy(self)) - + def new_profile(self): return profile.Profile(weakref.proxy(self)) @@ -55,6 +57,11 @@ class Config: for x in self._classes: x.clear() + def file_check(self): + for x in self._classes: + if not os.path.exists(x.filename()): + serializer.serialize(x) + def serialize(self): for x in self._classes: serializer.serialize(x) @@ -62,4 +69,4 @@ class Config: def deserialize(self): for x in self._classes: serializer.deserialize(x) - + |