summaryrefslogtreecommitdiffstats
path: root/cobbler
diff options
context:
space:
mode:
authorMichael DeHaan <mdehaan@redhat.com>2007-10-31 12:50:33 -0400
committerMichael DeHaan <mdehaan@redhat.com>2007-10-31 12:50:33 -0400
commit8c179cbc21dcafd91671404607f1c290f18aeb11 (patch)
tree74aa55b7b4a7805fb9b6cbc7615a0c7e5cddf46c /cobbler
parent4f6d730917ea7b3e1669fa72ca3fb36118a3f106 (diff)
downloadthird_party-cobbler-8c179cbc21dcafd91671404607f1c290f18aeb11.tar.gz
third_party-cobbler-8c179cbc21dcafd91671404607f1c290f18aeb11.tar.xz
third_party-cobbler-8c179cbc21dcafd91671404607f1c290f18aeb11.zip
Fix for cobbler's dhcp generation behavior with the new interface representation.
(Plus some unfinished work on paginating the WebUI).
Diffstat (limited to 'cobbler')
-rw-r--r--cobbler/action_sync.py12
-rw-r--r--cobbler/remote.py44
-rw-r--r--cobbler/webui/CobblerWeb.py12
3 files changed, 49 insertions, 19 deletions
diff --git a/cobbler/action_sync.py b/cobbler/action_sync.py
index 7efa0b5..4d07881 100644
--- a/cobbler/action_sync.py
+++ b/cobbler/action_sync.py
@@ -166,7 +166,7 @@ class BootSync:
if distro.arch == "ia64":
# can't use pxelinux.0 anymore
systxt = systxt + " filename \"/%s\";\n" % elilo
- systxt = systxt + " hardware ethernet %s;\n" % mac
+ systxt = systxt + " hardware ethernet %s;\n" % mac
if ip is not None and ip != "":
systxt = systxt + " fixed-address %s;\n" % ip
# not needed, as it's in the template.
@@ -187,9 +187,13 @@ class BootSync:
else:
systxt = ""
- if not system_definitions.has_key(interface["dhcp_tag"]):
- system_definitions[interface["dhcp_tag"]] = ""
- system_definitions[interface["dhcp_tag"]] = system_definitions[interface["dhcp_tag"]] + systxt
+ dhcp_tag = interface["dhcp_tag"]
+ if dhcp_tag == "":
+ dhcp_tag = "default"
+
+ if not system_definitions.has_key(dhcp_tag):
+ system_definitions[dhcp_tag] = ""
+ system_definitions[dhcp_tag] = system_definitions[dhcp_tag] + systxt
# we are now done with the looping through each interface of each system
diff --git a/cobbler/remote.py b/cobbler/remote.py
index 9cbff5c..a292dee 100644
--- a/cobbler/remote.py
+++ b/cobbler/remote.py
@@ -69,16 +69,36 @@ class CobblerXMLRPCInterface:
def ping(self):
return True
- def __get_all(self,collection_name,page=-1,results_per_page=50):
+ def get_size(self,collection_name):
+ """
+ Returns the number of entries in a collection (but not the actual
+ collection) for WUI/TUI interfaces that want to paginate the results.
+ """
+ data = self.__get_all(collection_name)
+ return len(data)
+
+ def __get_all(self,collection_name,page,results_per_page):
"""
Helper method to return all data to the WebUI or another caller
without going through the process of loading all the data into
- objects and recalculating. This does require that the cobbler
- data in the files is up-to-date in terms of serialized formats.
+ objects and recalculating.
+
+ Supports pagination for WUI or TUI based interfaces.
"""
- # FIXME: this method, and those that use it, need to allow page, and per_page
+ # FIXME: a global lock or module around data access loading
+ # would be useful for non-db backed storage
data = self.api.deserialize_raw(collection_name)
data.sort(self.__sorter)
+
+ if page is not None and results_per_page is not None:
+ if type(page) != int or page < 0:
+ return []
+ if type(results_per_page) != int or results_per_page <= 0:
+ return []
+ start_point = (results_per_page * page)
+ end_point = (results_per_page * page) + (results_per_page - 1)
+ data = data[start_point:end_point]
+
return self._fix_none(data)
def get_settings(self,token=None):
@@ -125,29 +145,29 @@ class CobblerXMLRPCInterface:
"""
return self.api.version()
- def get_distros(self,token=None):
+ def get_distros(self,token=None,page=None,results_per_page=None):
"""
Returns all cobbler distros as an array of hashes.
"""
- return self.__get_all("distro")
+ return self.__get_all("distro",page,results_per_page)
- def get_profiles(self,token=None):
+ def get_profiles(self,token=None,page=None,results_per_page=None):
"""
Returns all cobbler profiles as an array of hashes.
"""
- return self.__get_all("profile")
+ return self.__get_all("profile",page,results_per_page)
- def get_systems(self,token=None):
+ def get_systems(self,token=None,page=None,results_per_page=None):
"""
Returns all cobbler systems as an array of hashes.
"""
- return self.__get_all("system")
+ return self.__get_all("system",page,results_per_page)
- def get_repos(self,token=None):
+ def get_repos(self,token=None,page=None,results_per_page=None):
"""
Returns all cobbler repos as an array of hashes.
"""
- return self.__get_all("repo")
+ return self.__get_all("repo",page,results_per_page)
def __get_specific(self,collection_fn,name,flatten=False):
"""
diff --git a/cobbler/webui/CobblerWeb.py b/cobbler/webui/CobblerWeb.py
index 69c8e7f..075bc60 100644
--- a/cobbler/webui/CobblerWeb.py
+++ b/cobbler/webui/CobblerWeb.py
@@ -326,15 +326,21 @@ class CobblerWeb(object):
# if the system list is huge, this will probably need to use an
# iterator so the list doesn't get copied around
- def system_list(self):
+ def system_list(self,page=0,results_per_page=100):
if not self.__xmlrpc_setup():
return self.xmlrpc_auth_failure()
- systems = self.remote.get_systems()
+ systems_size = self.remote.get_size("systems")
+ pages = len(systems) / results_per_page
+ systems = self.remote.get_systems(page,results_per_page)
+
+
if len(systems) > 0:
return self.__render( 'system_list.tmpl', {
- 'systems': systems
+ 'systems' : systems,
+ 'pages' : pages,
+ 'page' : page
} )
else:
return self.__render('empty.tmpl',{})