summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBill Peck <bpeck@redhat.com>2009-06-19 13:53:22 -0400
committerBill Peck <bpeck@redhat.com>2009-06-19 13:53:22 -0400
commitbeb29a4c27ef56bc317f62c8dcb978db5e5bdf98 (patch)
tree47905a2f4da81a0a9804be0b2f536a3b485a0ffc
parent3d5f79fafa6ddfa6297b3507015b012a5b62785d (diff)
raise BeakerExceptions if we run into trouble
-rw-r--r--Server/beaker/server/bexceptions.py35
-rw-r--r--Server/beaker/server/controllers.py9
2 files changed, 40 insertions, 4 deletions
diff --git a/Server/beaker/server/bexceptions.py b/Server/beaker/server/bexceptions.py
new file mode 100644
index 0000000..ed1c4e1
--- /dev/null
+++ b/Server/beaker/server/bexceptions.py
@@ -0,0 +1,35 @@
+"""
+Custom exceptions for Beaker
+
+Copyright 2008-2009, Red Hat, Inc
+Bill Peck <bpeck@redhat.com>
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA
+"""
+
+import exceptions
+
+class BeakerException(exceptions.Exception):
+
+ def __init__(self, value, *args):
+ self.value = value % args
+
+ def __str__(self):
+ return repr(self.value)
+
+class BX(BeakerException):
+ pass
+
diff --git a/Server/beaker/server/controllers.py b/Server/beaker/server/controllers.py
index 48307e1..77964ad 100644
--- a/Server/beaker/server/controllers.py
+++ b/Server/beaker/server/controllers.py
@@ -36,6 +36,7 @@ from beaker.server.needpropertyxml import *
from beaker.server.helpers import *
from beaker.server.tools.init import dummy
from decimal import Decimal
+from bexceptions import *
from kid import Element
import cherrypy
@@ -114,16 +115,16 @@ class Netboot:
if distro_name:
distro = Distro.by_install_name(distro_name)
else:
- rc = -4
- result = "distro not defined"
+ raise BX(_("distro not defined"))
if hostname:
system = System.query().filter(System.fqdn == hostname).one()
rc, result = system.action_auto_provision(distro, ks_meta, bootargs, None, kickstart)
activity = SystemActivity(system.user, 'VIA %s' % None, 'Provision', 'Distro', "", "%s: %s" % (result, distro.install_name))
system.activity.append(activity)
else:
- rc = -3
- result = "hostname not defined"
+ raise BX(_("hostname not defined"))
+ if rc:
+ raise BX(_("Failed to auto_provision: %s" % result))
return rc
class Arches: