summaryrefslogtreecommitdiffstats
path: root/cobbler/item_profile.py
diff options
context:
space:
mode:
authorMichael DeHaan <mdehaan@redhat.com>2006-05-08 18:34:42 -0400
committerJim Meyering <jim@meyering.net>2006-05-08 18:34:42 -0400
commit804a564ac24ff22cd46583fa98d8140a8b10f476 (patch)
treefadba99af49b4da97be1a5b7ab7af42cb780db39 /cobbler/item_profile.py
parentd4f71b4318fedf374844030095c6c8dd544f0e92 (diff)
downloadthird_party-cobbler-804a564ac24ff22cd46583fa98d8140a8b10f476.tar.gz
third_party-cobbler-804a564ac24ff22cd46583fa98d8140a8b10f476.tar.xz
third_party-cobbler-804a564ac24ff22cd46583fa98d8140a8b10f476.zip
Adding exception handling to remove the problem of propogating error codes all the way up the stack. Still not quite super-consistant, but getting there. Util functions still return true/false since they just ask questions, but API functions will throw errors to ensure they are being dealt with. Main CLI class needs to take advantage of this fact and become simpler. Tests are already modified to detect new exceptions with one exception :)
Diffstat (limited to 'cobbler/item_profile.py')
-rw-r--r--cobbler/item_profile.py22
1 files changed, 11 insertions, 11 deletions
diff --git a/cobbler/item_profile.py b/cobbler/item_profile.py
index c344fc3..33cd3a3 100644
--- a/cobbler/item_profile.py
+++ b/cobbler/item_profile.py
@@ -7,7 +7,7 @@ Michael DeHaan <mdehaan@redhat.com>
import utils
import item
-from cobbler_exception import CobblerException
+import cexceptions
class Profile(item.Item):
@@ -57,7 +57,7 @@ class Profile(item.Item):
if self.config.distros().find(distro_name):
self.distro = distro_name
return True
- raise CobblerException("no_distro")
+ raise cexceptions.CobblerException("no_distro")
def set_kickstart(self,kickstart):
"""
@@ -67,7 +67,7 @@ class Profile(item.Item):
if utils.find_kickstart(kickstart):
self.kickstart = kickstart
return True
- raise CobblerException("no_kickstart")
+ raise cexceptions.CobblerException("no_kickstart")
def set_xen_name(self,str):
"""
@@ -81,7 +81,7 @@ class Profile(item.Item):
# no slashes or wildcards
for bad in [ '/', '*', '?' ]:
if str.find(bad) != -1:
- return False
+ raise cexceptions.CobblerException("exc_xen_name")
self.xen_name = str
return True
@@ -98,13 +98,13 @@ class Profile(item.Item):
try:
inum = int(num)
if inum != float(num):
- return False
- self.xen_file_size = inum
+ return cexceptions.CobblerException("exc_xen_file")
if inum >= 0:
+ self.xen_file_size = inum
return True
- return False
+ return cexceptions.CobblerException("exc_xen_file")
except:
- return False
+ return cexceptions.CobblerException("exc_xen_file")
def set_xen_mac(self,mac):
"""
@@ -122,7 +122,7 @@ class Profile(item.Item):
self.xen_mac = mac
return True
else:
- return False
+ raise cexceptions.CobblerException("exc_xen_mac")
def set_xen_paravirt(self,truthiness):
"""
@@ -140,9 +140,9 @@ class Profile(item.Item):
elif (truthiness == True or truthiness.lower() == 'true'):
self.xen_paravirt = True
else:
- return False
+ return cexceptions.CobblerException("exc_xen_para")
except:
- return False
+ return cexceptions.CobblerException("exc_xen_para")
return True
def is_valid(self):