+from PLC.Faults import *
+from PLC.Parameter import Parameter
+from PLC.Table import Row, Table
+
+class BootState(Row):
+ """
+ Representation of a row in the boot_states table. To use,
+ instantiate with a dict of values.
+ """
+
+ table_name = 'boot_states'
+ primary_key = 'boot_state'
+ fields = {
+ 'boot_state': Parameter(str, "Boot state", max = 20),
+ }
+
+ def __init__(self, api, fields = {}):
+ Row.__init__(self, fields)
+ self.api = api
+
+ def validate_boot_state(self, name):
+ # Remove leading and trailing spaces
+ name = name.strip()
+
+ # Make sure name is not blank after we removed the spaces
+ if not name:
+ raise PLCInvalidArgument, "Boot state must be specified"
+
+ # Make sure boot state does not alredy exist
+ conflicts = BootStates(self.api, [name])
+ if conflicts:
+ raise PLCInvalidArgument, "Boot state name already in use"
+
+ return name
+
+ def delete(self, commit = True):
+ assert 'boot_state' in self
+
+ # Clean up miscellaneous join tables
+ for table in ['nodes', 'boot_states']:
+ self.api.db.do("DELETE FROM " + table + \
+ " WHERE boot_state = %(boot_state)s",
+ self)
+
+ if commit:
+ self.api.db.commit()
+
+class BootStates(Table):