summaryrefslogtreecommitdiffstats
path: root/cobbler/remote.py
diff options
context:
space:
mode:
authorMichael DeHaan <mdehaan@mdehaan.rdu.redhat.com>2007-09-12 16:02:54 -0400
committerMichael DeHaan <mdehaan@mdehaan.rdu.redhat.com>2007-09-12 16:02:54 -0400
commit1d215c67c7404d37ca833acdcfe75b1bd515b592 (patch)
treed9483f546a650a9f696b41a3696a88af2bd0dbe0 /cobbler/remote.py
parent27e40ba1ab0412e7d47a8858193120d766841587 (diff)
downloadthird_party-cobbler-1d215c67c7404d37ca833acdcfe75b1bd515b592.tar.gz
third_party-cobbler-1d215c67c7404d37ca833acdcfe75b1bd515b592.tar.xz
third_party-cobbler-1d215c67c7404d37ca833acdcfe75b1bd515b592.zip
Adding additional exception handling and logging to WebUI.
Diffstat (limited to 'cobbler/remote.py')
-rw-r--r--cobbler/remote.py25
1 files changed, 15 insertions, 10 deletions
diff --git a/cobbler/remote.py b/cobbler/remote.py
index cca0df9..2673cb9 100644
--- a/cobbler/remote.py
+++ b/cobbler/remote.py
@@ -146,7 +146,7 @@ class CobblerXMLRPCInterface:
"""
return self.__get_all(self.api.repos())
- def __get_specific(self,collection,name):
+ def __get_specific(self,collection,name,flatten=False):
"""
Internal function to return a hash representation of a given object if it exists,
otherwise an empty hash will be returned.
@@ -155,31 +155,34 @@ class CobblerXMLRPCInterface:
item = collection.find(name=name)
if item is None:
return self._fix_none({})
- return self._fix_none(item.to_datastruct())
+ result = item.to_datastruct()
+ if flatten:
+ result = utils.flatten(result)
+ return self._fix_none(result)
- def get_distro(self,name,token=None):
+ def get_distro(self,name,flatten=False,token=None):
"""
Returns the distro named "name" as a hash.
"""
- return self.__get_specific(self.api.distros(),name)
+ return self.__get_specific(self.api.distros(),name,flatten=flatten)
- def get_profile(self,name,token=None):
+ def get_profile(self,name,flatten=False,token=None):
"""
Returns the profile named "name" as a hash.
"""
- return self.__get_specific(self.api.profiles(),name)
+ return self.__get_specific(self.api.profiles(),name,flatten=flatten)
- def get_system(self,name,token=None):
+ def get_system(self,name,flatten=False,token=None):
"""
Returns the system named "name" as a hash.
"""
- return self.__get_specific(self.api.systems(),name)
+ return self.__get_specific(self.api.systems(),name,flatten=flatten)
- def get_repo(self,name,token=None):
+ def get_repo(self,name,flatten=False,token=None):
"""
Returns the repo named "name" as a hash.
"""
- return self.__get_specific(self.api.repos(),name)
+ return self.__get_specific(self.api.repos(),name,flatten=flatten)
def get_distro_as_rendered(self,name,token=None):
"""
@@ -748,6 +751,8 @@ if __name__ == "__main__":
print remote.get_systems()
print remote.get_repos()
+ print remote.get_system("AA:BB:AA:BB:AA:BB",True) # flattened
+
# now simulate hitting a "sync" button in a WebUI
print remote.sync(token)