summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--cobbler/api.py47
-rw-r--r--tests/tests.py2
2 files changed, 16 insertions, 33 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()
+
diff --git a/tests/tests.py b/tests/tests.py
index 4d670ba..85ed0b9 100644
--- a/tests/tests.py
+++ b/tests/tests.py
@@ -43,7 +43,7 @@ class BootTest(unittest.TestCase):
self.fk_kernel2 = os.path.join(self.topdir, FAKE_KERNEL2)
self.fk_kernel3 = os.path.join(self.topdir, FAKE_KERNEL3)
- self.api = api.BootAPI(True) # contain_exceptions
+ self.api = api.BootAPI()
self.hostname = os.uname()[1]
create = [ self.fk_initrd, self.fk_initrd2, self.fk_initrd3,
self.fk_kernel, self.fk_kernel2, self.fk_kernel3 ]