summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael DeHaan <mdehaan@mdehaan.rdu.redhat.com>2007-09-13 18:28:28 -0400
committerMichael DeHaan <mdehaan@mdehaan.rdu.redhat.com>2007-09-13 18:28:28 -0400
commit30d26a3e234d3229e128c977b7aeefdc425ad910 (patch)
treeab53db2a8d30f88bdf91bfa00c345a6f2ac03d98
parentbaec248f1bf62ec6ed099d1d29516cab917655a8 (diff)
downloadthird_party-cobbler-30d26a3e234d3229e128c977b7aeefdc425ad910.zip
third_party-cobbler-30d26a3e234d3229e128c977b7aeefdc425ad910.tar.gz
third_party-cobbler-30d26a3e234d3229e128c977b7aeefdc425ad910.tar.xz
Adds edit capability to distro and profile objects, plus some random hacking on the WebUI.
Also adds delete checkboxes that are currently not implemented.
-rw-r--r--Makefile9
-rw-r--r--cobbler.spec1
-rw-r--r--cobbler/action_sync.py2
-rw-r--r--cobbler/webui/CobblerWeb.py121
-rw-r--r--cobbler/webui/master.py48
-rw-r--r--webui_templates/distro_edit.tmpl25
-rw-r--r--webui_templates/master.tmpl22
-rw-r--r--webui_templates/profile_edit.tmpl18
-rw-r--r--webui_templates/system_edit.tmpl15
9 files changed, 183 insertions, 78 deletions
diff --git a/Makefile b/Makefile
index 4d162f3..7a92fe9 100644
--- a/Makefile
+++ b/Makefile
@@ -17,13 +17,13 @@ test: install
python tests/tests.py
-rm -rf /tmp/_cobbler-*
-build: clean messages
+build: clean updatewui messages
python setup.py build -f
install: clean manpage
python setup.py install -f
-sdist: clean messages
+sdist: clean messages updatewui
python setup.py sdist
messages: cobbler/*.py
@@ -55,3 +55,8 @@ srpm: manpage sdist
--define "_sourcedir %{_topdir}" \
-bs --nodeps cobbler.spec
+updatewui:
+ cheetah-compile ./webui_templates/master.tmpl
+ -(rm ./webui_templates/*.bak)
+ mv ./webui_templates/master.py ./cobbler/webui
+
diff --git a/cobbler.spec b/cobbler.spec
index aed379a..e1db970 100644
--- a/cobbler.spec
+++ b/cobbler.spec
@@ -22,6 +22,7 @@ Requires(post): /sbin/chkconfig
Requires(preun): /sbin/chkconfig
Requires(preun): /sbin/service
BuildRequires: python-devel
+BuildRequires: python-cheetah
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-buildroot
BuildArch: noarch
ExcludeArch: ppc
diff --git a/cobbler/action_sync.py b/cobbler/action_sync.py
index 86aaa2f..0a0c263 100644
--- a/cobbler/action_sync.py
+++ b/cobbler/action_sync.py
@@ -613,7 +613,7 @@ class BootSync:
print _("Warning: Itanium system object (%s) needs an IP address to PXE") % system.name
- filename = "%s.conf" % self.utils_config_filename(system)
+ filename = "%s.conf" % utils.get_config_filename(system)
f2 = os.path.join(self.settings.tftpboot, filename)
f3 = os.path.join(self.settings.webdir, "systems", f1)
diff --git a/cobbler/webui/CobblerWeb.py b/cobbler/webui/CobblerWeb.py
index 827d263..3c1bcde 100644
--- a/cobbler/webui/CobblerWeb.py
+++ b/cobbler/webui/CobblerWeb.py
@@ -78,7 +78,6 @@ class CobblerWeb(object):
tmpl = Template( file=filepath, searchList=data )
return str(tmpl)
except:
- logger.error("An error has occurred.") # FIXME: remove
log_exc()
return self.error_page("Error while rendering page. See /var/log/cobbler/webui.log")
@@ -106,6 +105,10 @@ class CobblerWeb(object):
# Settings
# ------------------------------------------------------------------------ #
+ # FIXME: does it make sense to be able to edit settings? Probably not,
+ # as you could disable a lot of functionality if you aren't careful
+ # including your ability to fix it back.
+
def settings_view(self):
self.__xmlrpc_setup()
return self.__render( 'item.tmpl', {
@@ -117,30 +120,63 @@ class CobblerWeb(object):
# Distributions
# ------------------------------------------------------------------------ #
- #def distro_view(self, distribution):
- # self.__xmlrpc_setup()
- # return self.__render( 'item.tmpl', {
- # 'item_data': self.remote.get_distro(distribution,True),
- # 'caption': "Distribution \"%s\" Details" % distribution
- # } )
-
def distro_list(self):
self.__xmlrpc_setup()
return self.__render( 'distro_list.tmpl', {
'distros': self.remote.get_distros()
} )
-
- def distro_edit(self, name):
+ def distro_edit(self, name=None):
self.__xmlrpc_setup()
+
+ input_distro = None
+ if name is not None:
+ input_distro = self.remote.get_distro(name, True)
+
return self.__render( 'distro_edit.tmpl', {
- 'distro': self.remote.get_distro(name,True),
+ 'edit' : True,
+ 'distro': input_distro,
} )
- # FIXME: implement distro_save
- def distro_save(self,name=None,kernel=None,initrd=None,kopts=None,ksmeta=None,breed=None,**args):
- pass
+ # FIXME: implement handling of delete1, delete2 + renames
+ def distro_save(self,name=None,new_or_edit=None,kernel=None,initrd=None,kopts=None,ksmeta=None,arch=None,breed=None,**args):
+ self.__xmlrpc_setup()
+
+ # pre-command paramter checking
+ if name is None:
+ return self.error_page("name is required")
+ if kernel is None or not str(kernel).startswith("/"):
+ return self.error_page("kernel must be specified as an absolute path")
+ if initrd is None or not str(initrd).startswith("/"):
+ return self.error_page("initrd must be specified as an absolute path")
+ # grab a reference to the object
+ if new_or_edit == "edit":
+ try:
+ distro = self.remote.get_distro_handle( name, self.token)
+ except:
+ return self.error_page("Failed to lookup distro: %s" % name)
+ else:
+ distro = self.remote.new_distro(self.token)
+
+ try:
+ self.remote.modify_distro(distro, 'name', name, self.token)
+ self.remote.modify_distro(distro, 'kernel', kernel, self.token)
+ self.remote.modify_distro(distro, 'initrd', initrd, self.token)
+ if kopts:
+ self.remote.modify_distro(distro, 'kopts', kopts, self.token)
+ if ksmeta:
+ self.remote.modify_distro(distro, 'ksmeta', ksmeta, self.token)
+ if arch:
+ self.remote.modify_distro(distro, 'arch', arch, self.token)
+ if breed:
+ self.remote.modify_distro(distro, 'breed', breed, self.token)
+ self.remote.save_distro(distro, self.token)
+ except Exception, e:
+ log_exc()
+ return self.error_page("Error while saving distro: %s" % str(e))
+
+ return self.distro_edit(name=name)
# ------------------------------------------------------------------------ #
# Systems
@@ -154,22 +190,10 @@ class CobblerWeb(object):
'systems': self.remote.get_systems()
} )
- def system_add(self):
- self.__xmlrpc_setup()
- return self.__render( 'system_edit.tmpl', {
- 'system': None,
- 'profiles': self.remote.get_profiles()
- } )
-
- # FIXME: this should use the same template as system_edit
- #def system_view(self, name):
- # self.__xmlrpc_setup()
- # return self.__render( 'item.tmpl', {
- # 'item_data': self.remote.get_system(name,True),
- # 'caption': "Profile %s Settings" % name
- # } )
+ # FIXME: implement handling of delete1, delete2 + renames
+ def system_save(self, name=None, profile=None, new_or_edit=None, mac=None, ip=None, hostname=None,
+ kopts=None, ksmeta=None, netboot='n', dhcp_tag=None, **args):
- def system_save(self, name=None, profile=None, new_or_edit=None, mac=None, ip=None, hostname=None, kopts=None, ksmeta=None, netboot='n', dhcp_tag=None, **args):
self.__xmlrpc_setup()
# parameter checking
@@ -216,12 +240,19 @@ class CobblerWeb(object):
# FIXME: get the exact error message and display to the user.
log_exc()
return self.error_page("Error while saving system: %s" % str(e))
- return self.system_edit( name=name )
+ return self.system_edit( name=name)
+
+ def system_edit(self, name=None):
- def system_edit(self, name):
self.__xmlrpc_setup()
+
+ input_system = None
+ if name is not None:
+ input_system = self.remote.get_system(name,True)
+
return self.__render( 'system_edit.tmpl', {
- 'system': self.remote.get_system(name,True),
+ 'edit' : True,
+ 'system': input_system,
'profiles': self.remote.get_profiles()
} )
@@ -234,22 +265,22 @@ class CobblerWeb(object):
'profiles': self.remote.get_profiles()
} )
- def profile_add(self):
- self.__xmlrpc_setup()
- return self.__render( 'profile_edit.tmpl', {
- 'distros': self.remote.get_distros(),
- 'ksfiles': self.__ksfiles()
- } )
+ # FIXME: implement handling of delete1, delete2 + renames
+ def profile_edit(self, name=None):
- def profile_edit(self, name):
self.__xmlrpc_setup()
+
+ input_profile = None
+ if name is not None:
+ input_profile = self.remote.get_profile(name,True)
+
return self.__render( 'profile_edit.tmpl', {
- 'profile': self.remote.get_profile(name,True),
+ 'edit' : True,
+ 'profile': input_profile,
'distros': self.remote.get_distros(),
'ksfiles': self.__ksfiles()
} )
- # FIXME: implement this function
def profile_save(self,new_or_edit=None, name=None,distro=None,kickstart=None,kopts=None,
ksmeta=None,virtfilesize=None,virtram=None,virttype=None,
virtpath=None,repos=None,dhcptag=None,**args):
@@ -299,11 +330,16 @@ class CobblerWeb(object):
return self.profile_edit(name=name)
+ # ------------------------------------------------------------------------ #
+ # Repos
+ # ------------------------------------------------------------------------ #
+ # integrate repository adding/editing as with the other objects.
# ------------------------------------------------------------------------ #
# Kickstart files
# ------------------------------------------------------------------------ #
+
def ksfile_list(self):
return self.__render( 'ksfile_list.tmpl', {
'ksfiles': self.__ksfiles()
@@ -351,17 +387,14 @@ class CobblerWeb(object):
distro_edit.exposed = True
distro_list.exposed = True
distro_save.exposed = True
- #distro_view.exposed = True
profile_edit.exposed = True
profile_list.exposed = True
profile_save.exposed = True
- #profile_view.exposed = True
system_edit.exposed = True
system_list.exposed = True
system_save.exposed = True
- #system_view.exposed = True
settings_view.exposed = True
ksfile_view.exposed = True
diff --git a/cobbler/webui/master.py b/cobbler/webui/master.py
index 58b5047..c9ca4f4 100644
--- a/cobbler/webui/master.py
+++ b/cobbler/webui/master.py
@@ -33,10 +33,10 @@ VFN=valueForName
currentTime=time.time
__CHEETAH_version__ = '2.0rc8'
__CHEETAH_versionTuple__ = (2, 0, 0, 'candidate', 8)
-__CHEETAH_genTime__ = 1189393696.009383
-__CHEETAH_genTimestamp__ = 'Sun Sep 9 20:08:16 2007'
-__CHEETAH_src__ = 'master.tmpl'
-__CHEETAH_srcLastModified__ = 'Sun Sep 9 20:02:36 2007'
+__CHEETAH_genTime__ = 1189722444.76705
+__CHEETAH_genTimestamp__ = 'Thu Sep 13 18:27:24 2007'
+__CHEETAH_src__ = 'webui_templates/master.tmpl'
+__CHEETAH_srcLastModified__ = 'Thu Sep 13 18:27:18 2007'
__CHEETAH_docstring__ = 'Autogenerated by CHEETAH: The Python-Powered Template Engine'
if __CHEETAH_versionTuple__ < RequiredCheetahVersionTuple:
@@ -69,7 +69,7 @@ class master(Template):
- ## CHEETAH: generated from #block body at line 46, col 1.
+ ## CHEETAH: generated from #block body at line 53, col 1.
trans = KWS.get("trans")
if (not trans and not self._CHEETAH__isBuffering and not callable(self.transaction)):
trans = self.transaction # is None unless self.awake() was called
@@ -153,33 +153,43 @@ class master(Template):
<li><a href="''')
_v = VFFSL(SL,"base_url",True) # '$base_url' on line 33, col 22
if _v is not None: write(_filter(_v, rawExpr='$base_url')) # from line 33, col 22.
- write('''/settings_view" class="menu">Cobbler Settings</a></li>
+ write('''/settings_view" class="menu">Settings</a></li>
<li><hr/></li>
- <li><a href="''')
- _v = VFFSL(SL,"base_url",True) # '$base_url' on line 35, col 22
- if _v is not None: write(_filter(_v, rawExpr='$base_url')) # from line 35, col 22.
- write('''/profile_list" class="menu">List Profiles</a></li>
+ <li>LIST</li>
<li><a href="''')
_v = VFFSL(SL,"base_url",True) # '$base_url' on line 36, col 22
if _v is not None: write(_filter(_v, rawExpr='$base_url')) # from line 36, col 22.
- write('''/distro_list" class="menu">List Distros</a></li>
+ write('''/distro_list" class="menu">Distros</a></li>
<li><a href="''')
_v = VFFSL(SL,"base_url",True) # '$base_url' on line 37, col 22
if _v is not None: write(_filter(_v, rawExpr='$base_url')) # from line 37, col 22.
- write('''/system_list" class="menu">List Systems</a></li>
+ write('''/profile_list" class="menu">Profiles</a></li>
<li><a href="''')
_v = VFFSL(SL,"base_url",True) # '$base_url' on line 38, col 22
if _v is not None: write(_filter(_v, rawExpr='$base_url')) # from line 38, col 22.
- write('''/ksfile_list" class="menu">List KS Files</a></li>
+ write('''/system_list" class="menu">Systems</a></li>
+ <li><a href="''')
+ _v = VFFSL(SL,"base_url",True) # '$base_url' on line 39, col 22
+ if _v is not None: write(_filter(_v, rawExpr='$base_url')) # from line 39, col 22.
+ write('''/ksfile_list" class="menu">Kickstarts</a></li>
+ <li>(Pending: Repos)</li>
<li><hr/></li>
+ <li>ADD</li>
<li><a href="''')
- _v = VFFSL(SL,"base_url",True) # '$base_url' on line 40, col 22
- if _v is not None: write(_filter(_v, rawExpr='$base_url')) # from line 40, col 22.
- write('''/system_add" class="menu">Add System</a></li>
+ _v = VFFSL(SL,"base_url",True) # '$base_url' on line 43, col 22
+ if _v is not None: write(_filter(_v, rawExpr='$base_url')) # from line 43, col 22.
+ write('''/distro_edit" class="menu">Distro</a></li>
<li><a href="''')
- _v = VFFSL(SL,"base_url",True) # '$base_url' on line 41, col 22
- if _v is not None: write(_filter(_v, rawExpr='$base_url')) # from line 41, col 22.
- write('''/profile_add" class="menu">Add Profile</a></li>
+ _v = VFFSL(SL,"base_url",True) # '$base_url' on line 44, col 22
+ if _v is not None: write(_filter(_v, rawExpr='$base_url')) # from line 44, col 22.
+ write('''/profile_edit" class="menu">Profile</a></li>
+ <li><a href="''')
+ _v = VFFSL(SL,"base_url",True) # '$base_url' on line 45, col 22
+ if _v is not None: write(_filter(_v, rawExpr='$base_url')) # from line 45, col 22.
+ write('''/system_edit" class="menu">System</a></li>
+ <li>(Pending: Repo)</li>
+ <li><hr/></li>
+ <li>Sync</li>
</ul>
</div>
diff --git a/webui_templates/distro_edit.tmpl b/webui_templates/distro_edit.tmpl
index 2c32e3e..8b2b9c7 100644
--- a/webui_templates/distro_edit.tmpl
+++ b/webui_templates/distro_edit.tmpl
@@ -3,7 +3,14 @@
#block body
<form method="post" action="$base_url/distro_save">
<fieldset id="cform">
- <legend>Edit a Distro</legend>
+
+ #if $distro
+ <legend>Editing Distro</legend>
+ <input type="hidden" name="new_or_edit" value="edit"/>
+ #else
+ <legend>Adding a Distro</legend>
+ <input type="hidden" name="new_or_edit" value="new"/>
+ #end if
<label for="name">Name</label>
<input type="text" size="32" style="width: 150px;" name="name" id="name"
@@ -29,6 +36,14 @@
/>
<br/>
+ <label for="arch">Architecture</label>
+ <input type="text" size="32" style="width: 150px;" name="arch" id="arch"
+ #if $distro
+ value="$distro.arch"
+ #end if
+ />
+ <br/>
+
<label for="kopts">Kernel Options</label>
<input type="text" size="32" style="width: 150px;" name="kopts" id="kopts"
#if $distro
@@ -53,6 +68,14 @@
/>
<br/>
+ #if $distro
+ <label for="delete">Delete</label>
+ <input type="checkbox" name="delete1" value="delete1">Yes
+ <input type="checkbox" name="delete2" value="delete2">Really
+ <br/>
+ #end if
+
+
<input type="submit" name="submit" value="Save"/>
<input type="reset" name="reset" value="Reset"/>
</fieldset>
diff --git a/webui_templates/master.tmpl b/webui_templates/master.tmpl
index 84197e3..b856f6d 100644
--- a/webui_templates/master.tmpl
+++ b/webui_templates/master.tmpl
@@ -30,18 +30,20 @@
</select>
</li>
<li><hr/></li>
- <li><a href="$base_url/settings_view" class="menu">Cobbler Settings</a></li>
+ <li><a href="$base_url/settings_view" class="menu">Settings</a></li>
<li><hr/></li>
- <li><a href="$base_url/profile_list" class="menu">List Profiles</a></li>
- <li><a href="$base_url/distro_list" class="menu">List Distros</a></li>
- <li><a href="$base_url/system_list" class="menu">List Systems</a></li>
- <li><a href="$base_url/ksfile_list" class="menu">List Kickstarts</a></li>
- <li>List Repos</li>
+ <li>LIST</li>
+ <li><a href="$base_url/distro_list" class="menu">Distros</a></li>
+ <li><a href="$base_url/profile_list" class="menu">Profiles</a></li>
+ <li><a href="$base_url/system_list" class="menu">Systems</a></li>
+ <li><a href="$base_url/ksfile_list" class="menu">Kickstarts</a></li>
+ <li>(Pending: Repos)</li>
<li><hr/></li>
- <li><a href="$base_url/distro_edit" class="menu">Add Distro</a></li>
- <li><a href="$base_url/profile_edit" class="menu">Add Profile</a></li>
- <li><a href="$base_url/system_edit" class="menu">Add System</a></li>
- <li>Add Repo</li>
+ <li>ADD</li>
+ <li><a href="$base_url/distro_edit" class="menu">Distro</a></li>
+ <li><a href="$base_url/profile_edit" class="menu">Profile</a></li>
+ <li><a href="$base_url/system_edit" class="menu">System</a></li>
+ <li>(Pending: Repo)</li>
<li><hr/></li>
<li>Sync</li>
</ul>
diff --git a/webui_templates/profile_edit.tmpl b/webui_templates/profile_edit.tmpl
index 2dbeb7e..1fc3df8 100644
--- a/webui_templates/profile_edit.tmpl
+++ b/webui_templates/profile_edit.tmpl
@@ -3,7 +3,6 @@
#block body
<form method="post" action="$base_url/profile_save">
<fieldset id="cform">
- <legend>Edit a Profile</legend>
<!--
cobbler profile add -name=string -distro=string [-kickstart=url]
@@ -11,6 +10,15 @@
[-virt-ram=megabytes] [-virt-type=string] [-virt-path=string]
-->
+ #if $profile
+ <legend>Editing Profile</legend>
+ <input type="hidden" name="new_or_edit" value="edit"/>
+ #else
+ <legend>Adding a Profile</legend>
+ <input type="hidden" name="new_or_edit" value="new"/>
+ #end if
+
+
<label for="name">Profile Name</label>
<input type="text" size="32" style="width: 150px;" name="name" id="name"
#if $profile
@@ -107,6 +115,14 @@
/>
<br/>
+ #if $profile
+ <label for="delete">Delete</label>
+ <input type="checkbox" name="delete1" value="delete1">Yes
+ <input type="checkbox" name="delete2" value="delete2">Really
+ <br/>
+ #end if
+
+
<input type="submit" name="submit" value="Save"/>
<input type="reset" name="reset" value="Reset"/>
diff --git a/webui_templates/system_edit.tmpl b/webui_templates/system_edit.tmpl
index 3ba1c99..dfbb34c 100644
--- a/webui_templates/system_edit.tmpl
+++ b/webui_templates/system_edit.tmpl
@@ -3,6 +3,13 @@
#block body
<form method="post" action="$base_url/system_save">
<fieldset id="cform">
+
+ #if $system
+ <input type="hidden" name="new_or_edit" value="edit"/>
+ #else
+ <input type="hidden" name="new_or_edit" value="new"/>
+ #end if
+
<legend>Edit a System</legend>
<label for="name">System Name</label>
@@ -81,6 +88,14 @@
/>
<br/>
+ #if $system
+ <label for="delete">Delete</label>
+ <input type="checkbox" name="delete1" value="delete1">Yes
+ <input type="checkbox" name="delete2" value="delete2">Really
+ <br/>
+ #end if
+
+
<input type="submit" name="submit" value="Save"/>
<input type="reset" name="reset" value="Reset"/>
</fieldset>