From c1aea64f02ae55d47c18269895717af99839ed0e Mon Sep 17 00:00:00 2001 From: Michael DeHaan Date: Fri, 5 May 2006 18:30:44 -0400 Subject: Interim commit during refactoring. Pretty broken as a result of some cleanup but it will get straightened out very soon. The main thing I'm doing here is to remove backreferences from the object tree and make the API simpler, so that folks using the API screw up less. This means making the CLI code simpler as well. The serializer has also been overhauled so it's not as much bolted on, although I have some fixing to do to make it work entirely correctly. Wanted to check all of this in case someone decided to patch something else, making diffing really complex in the interim. I'd recommend not patching anything else to this code as I'm not close to done, really. --- cobbler/api.py | 36 ++++++++++++++++++++++++++++++------ 1 file changed, 30 insertions(+), 6 deletions(-) (limited to 'cobbler/api.py') diff --git a/cobbler/api.py b/cobbler/api.py index 4d93da2..318dc51 100644 --- a/cobbler/api.py +++ b/cobbler/api.py @@ -13,7 +13,7 @@ import config import utils import sync import check - + _config = config.Config() class BootAPI: @@ -22,17 +22,19 @@ class BootAPI: def __init__(self): """ Constructor... - """ - + """ + self.debug = 1 # FIXME: deserializer/serializer error # handling probably not up to par yet - _config.deserialize() + self.deserialize() def clear(self): """ Forget about current list of profiles, distros, and systems """ + if self.debug: + print "BootAPI::clear" _config.clear() @@ -40,6 +42,8 @@ class BootAPI: """ Return the current list of systems """ + if self.debug: + print "BootAPI::systems" return _config.systems() @@ -47,6 +51,8 @@ class BootAPI: """ Return the current list of profiles """ + if self.debug: + print "BootAPI::profiles" return _config.profiles() @@ -54,6 +60,8 @@ class BootAPI: """ Return the current list of distributions """ + if self.debug: + print "BootAPI::distros" return _config.distros() @@ -61,6 +69,8 @@ class BootAPI: """ Return a blank, unconfigured system, unattached to a collection """ + if self.debug: + print "BootAPI::new_system" return _config.new_system() @@ -68,6 +78,8 @@ class BootAPI: """ Create a blank, unconfigured distro, unattached to a collection. """ + if self.debug: + print "BootAPI::new_distro" return _config.new_distro() @@ -75,6 +87,8 @@ class BootAPI: """ Create a blank, unconfigured profile, unattached to a collection """ + if self.debug: + print "BootAPI::new_profile" return _config.new_profile() def check(self): @@ -86,7 +100,9 @@ class BootAPI: for human admins, who may, for instance, forget to properly set up their TFTP servers for PXE, etc. """ - return check.bootcheck(_config).run() + if self.debug: + print "BootAPI::check" + return check.BootCheck(_config).run() def sync(self,dry_run=True): @@ -96,22 +112,30 @@ class BootAPI: /tftpboot. Any operations done in the API that have not been saved with serialize() will NOT be synchronized with this command. """ + if self.debug: + print "BootAPI::sync" # config.deserialize(); # neccessary? - return sync.bootsync(_config).sync(dry_run) + return sync.BootSync(_config).sync(dry_run) def serialize(self): """ Save the config file(s) to disk. """ + if self.debug: + print "BootAPI::serialize" _config.serialize() def deserialize(self): """ Load the current configuration from config file(s) """ + if self.debug: + print "BootAPI::deserialize" _config.deserialize() def last_error(self): + if self.debug: + print "BootAPI::last_error" return utils.last_error() -- cgit