summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Makefile4
-rw-r--r--cobbler/action_sync.py12
-rw-r--r--cobbler/remote.py44
-rw-r--r--cobbler/webui/CobblerWeb.py12
-rw-r--r--webui_templates/system_list.tmpl20
5 files changed, 71 insertions, 21 deletions
diff --git a/Makefile b/Makefile
index 084b926..85d6715 100644
--- a/Makefile
+++ b/Makefile
@@ -39,12 +39,12 @@ devinstall:
cp /var/lib/cobbler/settings /tmp/cobbler_settings
cp /etc/cobbler/auth.conf /tmp/cobbler_auth.conf
cp /etc/cobbler/modules.conf /tmp/cobbler_modules.conf
- cp /var/www/cobbler/cgi-bin/.htpasswd /tmp/cobbler_htpasswd
+ -cp /var/www/cobbler/cgi-bin/.htpasswd /tmp/cobbler_htpasswd
make install
cp /tmp/cobbler_settings /var/lib/cobbler/settings
cp /tmp/cobbler_auth.conf /etc/cobbler/auth.conf
cp /tmp/cobbler_modules.conf /etc/cobbler/modules.conf
- cp /tmp/cobbler_htpasswd /var/www/cobbler/cgi-bin/.htpasswd
+ -cp /tmp/cobbler_htpasswd /var/www/cobbler/cgi-bin/.htpasswd
find /var/lib/cobbler/triggers | xargs chmod +x
chown -R apache /var/www/cobbler
chown -R apache /var/www/cgi-bin/cobbler
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',{})
diff --git a/webui_templates/system_list.tmpl b/webui_templates/system_list.tmpl
index e74f313..93f4602 100644
--- a/webui_templates/system_list.tmpl
+++ b/webui_templates/system_list.tmpl
@@ -1,7 +1,27 @@
#extends cobbler.webui.master
#block body
+
+ ## navigation for pages
+
+ Pages:&nbsp;
+ #if $page != 0
+ #set $previous_page = $page - 1
+ <A HREF="${base_url}/system_list?page=${previous_page}&results_per_page=${results_per_page}">&lt;</A>&nbsp;
+ #end
+
+ #for $this_page in $pages
+ <A HREF="${base_url}/system_list?page=${this_page}&results_per_page=${results_per_page}">$p</A>&nbsp;
+ #end
+
+ #if $page != $lastpage
+ #set $next_page = $page + 1
+ <A HREF="${base_url}/system_list?page=${next_page}&results_per_page=${results_per_page}">&rt;</A>
+ #end
+ </br>
+
<table class="sortable">
+
<thead>
<caption>Cobbler Systems</caption>
<tr>