summaryrefslogtreecommitdiffstats
path: root/cobbler/api.py
diff options
context:
space:
mode:
authorMichael DeHaan <mdehaan@redhat.com>2006-05-12 10:28:25 -0400
committerJim Meyering <jim@meyering.net>2006-05-12 10:28:25 -0400
commit71bb8fbc7df46d7fa281e4399005b736f6a80826 (patch)
tree14f90d402480277f7f3ebf291d8cd3bb7b2763c3 /cobbler/api.py
parentfc2bae004b0c6763e7262090ee73a720bf8159cd (diff)
downloadthird_party-cobbler-71bb8fbc7df46d7fa281e4399005b736f6a80826.tar.gz
third_party-cobbler-71bb8fbc7df46d7fa281e4399005b736f6a80826.tar.xz
third_party-cobbler-71bb8fbc7df46d7fa281e4399005b736f6a80826.zip
Remove api_call indirection and exception handling layer since tests had already been modified to use failUnlessRaises.
Diffstat (limited to 'cobbler/api.py')
-rw-r--r--cobbler/api.py47
1 files changed, 15 insertions, 32 deletions
diff --git a/cobbler/api.py b/cobbler/api.py
index a4f04fe..3ce5038 100644
--- a/cobbler/api.py
+++ b/cobbler/api.py
@@ -23,84 +23,66 @@ import cexceptions
class BootAPI:
- def __init__(self,catch_exceptions=False):
+ def __init__(self):
"""
- The API can be invoked in two ways, depending on how it is constructed.
- The catch_exceptions mode will cause any API method to return false
- if any CobblerExceptions were thrown, along with setting 'last_error'.
- The other mode just lets the exceptions pass through, and is the way
- most apps should use the API. catch_exceptions was added for the test hooks,
- since they are coded to use True/False.
+ Constructor
"""
self._config = config.Config()
- self.catch_exceptions = catch_exceptions
- self.last_error = ""
self.deserialize()
-
- def __api_call(self,anonymous):
- if self.catch_exceptions:
- try:
- return anonymous()
- except cexceptions.CobblerException, cobexc:
- self.last_error = str(cobexc)
- return False
- else:
- return anonymous()
-
def clear(self):
"""
Forget about current list of profiles, distros, and systems
"""
- return self.__api_call(lambda: self._config.clear())
+ return self._config.clear()
def systems(self):
"""
Return the current list of systems
"""
- return self.__api_call(lambda: self._config.systems())
+ return self._config.systems()
def profiles(self):
"""
Return the current list of profiles
"""
- return self.__api_call(lambda: self._config.profiles())
+ return self._config.profiles()
def distros(self):
"""
Return the current list of distributions
"""
- return self.__api_call(lambda: self._config.distros())
+ return self._config.distros()
def settings(self):
"""
Return the application configuration
"""
- return self.__api_call(lambda: self._config.settings())
+ return self._config.settings()
def new_system(self):
"""
Return a blank, unconfigured system, unattached to a collection
"""
- return self.__api_call(lambda: self._config.new_system())
+ return self._config.new_system()
def new_distro(self):
"""
Create a blank, unconfigured distro, unattached to a collection.
"""
- return self.__api_call(lambda: self._config.new_distro())
+ return self._config.new_distro()
def new_profile(self):
"""
Create a blank, unconfigured profile, unattached to a collection
"""
- return self.__api_call(lambda: self._config.new_profile())
+ return self._config.new_profile()
def check(self):
"""
@@ -112,7 +94,7 @@ class BootAPI:
their TFTP servers for PXE, etc.
"""
check = action_check.BootCheck(self._config)
- return self.__api_call(lambda: check.run())
+ return check.run()
def sync(self,dryrun=True):
@@ -123,18 +105,19 @@ class BootAPI:
saved with serialize() will NOT be synchronized with this command.
"""
sync = action_sync.BootSync(self._config)
- return self.__api_call(lambda: sync.run(dryrun=dryrun))
+ return sync.run(dryrun=dryrun)
def serialize(self):
"""
Save the config file(s) to disk.
"""
- return self.__api_call(lambda: self._config.serialize())
+ return self._config.serialize()
def deserialize(self):
"""
Load the current configuration from config file(s)
"""
- return self.__api_call(lambda: self._config.deserialize())
+ return self._config.deserialize()
+