summaryrefslogtreecommitdiffstats
path: root/cobbler/remote.py
diff options
context:
space:
mode:
authorMichael DeHaan <mdehaan@redhat.com>2008-04-24 13:46:04 -0400
committerMichael DeHaan <mdehaan@redhat.com>2008-04-24 13:46:04 -0400
commit9f314143b39edfa0943c68158d1ae954af4f4f86 (patch)
tree3216325d51476a00fe92f4fabac060f61d755cfa /cobbler/remote.py
parent7fe5d10a7387fb8f7d972567db54b3e0927081c5 (diff)
downloadthird_party-cobbler-9f314143b39edfa0943c68158d1ae954af4f4f86.tar.gz
third_party-cobbler-9f314143b39edfa0943c68158d1ae954af4f4f86.tar.xz
third_party-cobbler-9f314143b39edfa0943c68158d1ae954af4f4f86.zip
It's now possible to create new kickstart templates in /var/lib/cobbler/kickstarts/ from the WebUI, as well as delete ones that are no longer being used while on the edit page for that template.
Diffstat (limited to 'cobbler/remote.py')
-rw-r--r--cobbler/remote.py43
1 files changed, 40 insertions, 3 deletions
diff --git a/cobbler/remote.py b/cobbler/remote.py
index c25e700..a7e056b 100644
--- a/cobbler/remote.py
+++ b/cobbler/remote.py
@@ -24,6 +24,7 @@ import random
import base64
import string
import traceback
+import glob
import api as cobbler_api
import utils
@@ -158,6 +159,35 @@ class CobblerXMLRPCInterface:
return self._fix_none(data)
+ def get_kickstart_templates(self,token):
+ """
+ Returns all of the kickstarts that are in use by the system.
+ """
+ self.log("get_kickstart_templates",token=token)
+ self.check_access(token, "get_kickstart_templates")
+ files = {}
+ for x in self.api.profiles():
+ if x.kickstart is not None and x.kickstart != "" and x.kickstart != "<<inherit>>":
+ files[x.kickstart] = 1
+ for x in self.api.systems():
+ if x.kickstart is not None and x.kickstart != "" and x.kickstart != "<<inherit>>":
+ files[x.kickstart] = 1
+ for x in glob.glob("/var/lib/cobbler/kickstarts/*"):
+ files[x] = 1
+
+ return files.keys()
+
+ def is_kickstart_in_use(self,ks,token):
+ self.log("is_kickstart_in_use",token=token)
+ self.check_access(token, "is_kickstart_in_use")
+ for x in self.api.profiles():
+ if x.kickstart is not None and x.kickstart == ks:
+ return True
+ for x in self.api.systems():
+ if x.kickstart is not None and x.kickstart == ks:
+ return True
+ return False
+
def generate_kickstart(self,profile=None,system=None,REMOTE_ADDR=None,REMOTE_MAC=None):
self.log("generate_kickstart")
@@ -1042,9 +1072,16 @@ class CobblerReadWriteXMLRPCInterface(CobblerXMLRPCInterface):
fileh.close()
return data
else:
- fileh = open(kickstart_file,"w+")
- fileh.write(new_data)
- fileh.close()
+ if new_data == -1:
+ # delete requested
+ if not self.is_kickstart_in_use(kickstart_file,token):
+ os.remove(kickstart_file)
+ else:
+ raise CX(_("attempt to delete in-use file"))
+ else:
+ fileh = open(kickstart_file,"w+")
+ fileh.write(new_data)
+ fileh.close()
return True