2 # Functions for interacting with the boot_states table in the database
4 # Mark Huang <mlhuang@cs.princeton.edu>
5 # Copyright (C) 2006 The Trustees of Princeton University
8 from PLC.Faults import *
9 from PLC.Parameter import Parameter
10 from PLC.Table import Row, Table
14 Representation of a row in the boot_states table. To use,
15 instantiate with a dict of values.
18 table_name = 'boot_states'
19 primary_key = 'boot_state'
20 join_tables = ['nodes']
22 'boot_state': Parameter(str, "Boot state", max = 20),
25 def validate_boot_state(self, name):
26 # Make sure name is not blank
28 raise PLCInvalidArgument, "Boot state must be specified"
30 # Make sure boot state does not already exist
31 conflicts = BootStates(self.api, [name])
33 raise PLCInvalidArgument, "Boot state name already in use"
37 class BootStates(Table):
39 Representation of the boot_states table in the database.
42 def __init__(self, api, boot_states = None):
43 Table.__init__(self, api, BootState)
45 sql = "SELECT %s FROM boot_states" % \
46 ", ".join(BootState.fields)
49 sql += " WHERE boot_state IN (%s)" % ", ".join( [ api.db.quote (s) for s in boot_states ] )