Glasgow Cluster Database Schema

From GridPP Wiki
Jump to: navigation, search


Schema Description

Schema design is based on unique hostnames which are keys for the different database tables. The schema is created by this script:

#! /usr/bin/python
'''Create schema for cluster db'''

# $Id: mkclusterdb 224 2007-03-13 22:49:34Z graeme $

import os, sys, sqlite

from defaults import *
from altutil import *

mylog = loggingInit(logging.INFO)

try:
    con = sqlite.connect(clusterdb)
    cur = con.cursor()
    mylog.info('Creating hosts table.')
    cur.execute('create table hosts (hostname varchar(50) PRIMARY KEY, mac varchar(17) UNIQUE, ip varchar(15) UNIQUE)')
    mylog.info('Creating power table.')
    cur.execute('create table power (hostname varchar(50), power_bar varchar(20), power_socket varchar(20))')
    cur.execute('create index hostindex on power(hostname)')
    mylog.info('Creating etherport table.')
    cur.execute('create table etherport (hostname varchar(50) PRIMARY KEY, switch_number varchar(10), switch_port varchar(10))')
    mylog.info('Creating secret table.')
    cur.execute('create table secret (hostname varchar(50) PRIMARY KEY, start integer(12), end integer(12), nret int)')
    mylog.info('Creating ksclasses table.')
    cur.execute('create table ksclasses (hostname varchar(50) PRIMARY KEY, classes text)')
    con.commit()
    con.close()

except sqlite.DatabaseError, strError:
    print >>sys.stderr, "Failed to create table:", strError
    sys.exit(1)

Table: hosts

Maps hostname to MAC address and IP address. Note this is the FQDN associated with an interface on a machine, so dual homed machine will have two entries (the cluster headnode has 3!).

Table: power

Maps a hostname (usually the interal hostname) to an APC port on a power bar. This is used by the poweroff/poweron commands to switch the correct APC sockets. Note that machines with multiple power supplies will have multiple entries here.

Table: etherport

Maps a hostname to a switch port.

Table: secret

Table used by the server to determine if a host is allowed to recover secrets if it requests them. Triggering an install from the server will usually involve allowing a machine to recover secrets once when it first boots.

Table: ksclasses

Used by the kickstart PHP scripts to generate the kickstart file appropriate for this machine's role(s) and to copy the correct sets of skelton files.