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
11 from PLC.Faults import *
12 from PLC.Parameter import Parameter
13 from PLC.Table import Row, Table
17 Representation of a row in the boot_states table. To use,
18 instantiate with a dict of values.
21 table_name = 'boot_states'
22 primary_key = 'boot_state'
23 join_tables = ['nodes']
25 'boot_state': Parameter(str, "Boot state", max = 20),
28 def validate_boot_state(self, name):
29 # Make sure name is not blank
31 raise PLCInvalidArgument, "Boot state must be specified"
33 # Make sure boot state does not alredy exist
34 conflicts = BootStates(self.api, [name])
36 raise PLCInvalidArgument, "Boot state name already in use"
40 class BootStates(Table):
42 Representation of the boot_states table in the database.
45 def __init__(self, api, boot_states = None):
46 Table.__init__(self, api, BootState)
48 sql = "SELECT %s FROM boot_states" % \
49 ", ".join(BootState.fields)
52 sql += " WHERE boot_state IN (%s)" % ", ".join(map(api.db.quote, boot_states))