summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael DeHaan <mdehaan@mdehaan.rdu.redhat.com>2007-09-13 13:40:06 -0400
committerMichael DeHaan <mdehaan@mdehaan.rdu.redhat.com>2007-09-13 13:40:06 -0400
commitbaec248f1bf62ec6ed099d1d29516cab917655a8 (patch)
tree3a44f2fcbadaad63bc1bd916bccbd0c469e5b20b
parentca35374f0faa564514c937430ee7deb1a3ffc01a (diff)
downloadthird_party-cobbler-baec248f1bf62ec6ed099d1d29516cab917655a8.zip
third_party-cobbler-baec248f1bf62ec6ed099d1d29516cab917655a8.tar.gz
third_party-cobbler-baec248f1bf62ec6ed099d1d29516cab917655a8.tar.xz
Adding ability to save/edit/add profiles to Web UI.
-rw-r--r--cobbler/webui/CobblerWeb.py54
-rw-r--r--webui_templates/profile_edit.tmpl9
2 files changed, 57 insertions, 6 deletions
diff --git a/cobbler/webui/CobblerWeb.py b/cobbler/webui/CobblerWeb.py
index 6bbb47b..827d263 100644
--- a/cobbler/webui/CobblerWeb.py
+++ b/cobbler/webui/CobblerWeb.py
@@ -138,7 +138,7 @@ class CobblerWeb(object):
} )
# FIXME: implement distro_save
- def distro_save(self):
+ def distro_save(self,name=None,kernel=None,initrd=None,kopts=None,ksmeta=None,breed=None,**args):
pass
@@ -250,8 +250,56 @@ class CobblerWeb(object):
} )
# FIXME: implement this function
- def profile_save(self):
- pass
+ 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):
+
+ self.__xmlrpc_setup()
+
+ # pre-command parameter checking
+ if name is None:
+ return self.error_page("name is required")
+ if distro is None:
+ return self.error_page("distro is required")
+
+ # grab a reference to the object
+ if new_or_edit == "edit":
+ try:
+ profile = self.remote.get_profile_handle( name, self.token )
+ except:
+ return self.error_page("Failed to lookup profile: %s" % name)
+ else:
+ profile = self.remote.new_profile(self.token)
+
+ try:
+ self.remote.modify_profile(profile, 'name', name, self.token)
+ self.remote.modify_profile(profile, 'distro', distro, self.token)
+ if kickstart:
+ self.remote.modify_profile(profile, 'kickstart', kickstart, self.token)
+ if kopts:
+ self.remote.modify_profile(profile, 'kopts', kopts, self.token)
+ if ksmeta:
+ self.remote.modify_profile(profile, 'ksmeta', ksmeta, self.token)
+ if virtfilesize:
+ self.remote.modify_profile(profile, 'virt-file-size', virtfilesize, self.token)
+ if virtram:
+ self.remote.modify_profile(profile, 'virt-ram', virtram, self.token)
+ if virttype:
+ self.remote.modify_profile(profile, 'virt-type', virttype, self.token)
+ if virtpath:
+ self.remote.modify_profile(profile, 'virt-path', virtpath, self.token)
+ if repos:
+ self.remote.modify_profile(profile, 'repos', repos, self.token)
+ if dhcptag:
+ self.remote.modify_profile(profile, 'dhcp-tag', dhcptag, self.token)
+ self.remote.save_profile(profile,self.token)
+ except Exception, e:
+ log_exc()
+ return self.error_page("Error while saving profile: %s" % str(e))
+
+ return self.profile_edit(name=name)
+
+
# ------------------------------------------------------------------------ #
# Kickstart files
diff --git a/webui_templates/profile_edit.tmpl b/webui_templates/profile_edit.tmpl
index eab13be..2dbeb7e 100644
--- a/webui_templates/profile_edit.tmpl
+++ b/webui_templates/profile_edit.tmpl
@@ -1,7 +1,7 @@
#extends cobbler.webui.master
#block body
-<form method="post" action="/profile_save">
+<form method="post" action="$base_url/profile_save">
<fieldset id="cform">
<legend>Edit a Profile</legend>
@@ -35,8 +35,8 @@
<!-- should allow freeform input but still show a list of choices? -->
<!-- probably should implement a combo box eventually -->
- <label for="ksfile">Kickstart File</label>
- <input type="text" size="128" style="width: 150px;" name="kopts" id="kopts"
+ <label for="kickstart">Kickstart File</label>
+ <input type="text" size="128" style="width: 150px;" name="kickstart" id="kickstart"
#if $profile
value="$profile.kickstart"
#end if
@@ -45,6 +45,9 @@
<label for="kopts">Kernel Options</label>
<input type="text" size="128" style="width: 150px;" name="kopts" id="kopts"
+ #if $profile
+ value="$profile.kernel_options"
+ #end if
/>
<br/>