EmulabConstants.pm.in 26.5 KB
Newer Older
1 2
#!/usr/bin/perl -w
#
Leigh B Stoller's avatar
Leigh B Stoller committed
3
# Copyright (c) 2000-2015 University of Utah and the Flux Group.
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
# 
# {{{EMULAB-LICENSE
# 
# This file is part of the Emulab network testbed software.
# 
# This file is free software: you can redistribute it and/or modify it
# under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or (at
# your option) any later version.
# 
# This file 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 Affero General Public
# License for more details.
# 
# You should have received a copy of the GNU Affero General Public License
# along with this file.  If not, see <http://www.gnu.org/licenses/>.
# 
# }}}
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
#
# Emulab constants.
#

package EmulabConstants;
use strict;
use Exporter;
use SelfLoader;
use vars qw(@ISA @EXPORT);
@ISA = qw(Exporter SelfLoader);

@EXPORT =
    qw ( NODERELOADING_PID NODERELOADING_EID NODEDEAD_PID NODEDEAD_EID
	 OLDRESERVED_PID OLDRESERVED_EID NFREELOCKED_PID NFREELOCKED_EID 
	 NODEBOOTSTATUS_OKAY NODEBOOTSTATUS_FAILED NODEBOOTSTATUS_UNKNOWN
	 NODESTARTSTATUS_NOSTATUS PROJMEMBERTRUST_NONE PROJMEMBERTRUST_USER
	 PROJMEMBERTRUST_ROOT PROJMEMBERTRUST_GROUPROOT
	 PROJMEMBERTRUST_PROJROOT PROJMEMBERTRUST_LOCALROOT
41
	 NODEILL_PID NODEILL_EID VLAN_PID VLAN_EID
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60

	 TBOPSPID EXPTLOGNAME
	 PLABMOND_PID PLABMOND_EID PLABHOLDING_PID PLABHOLDING_EID
         PLABTESTING_PID PLABTESTING_EID PLABDOWN_PID PLABDOWN_EID

	 TBMinTrust TBTrustConvert

	 TB_NODEACCESS_READINFO TB_NODEACCESS_MODIFYINFO
	 TB_NODEACCESS_LOADIMAGE TB_NODEACCESS_REBOOT
	 TB_NODEACCESS_POWERCYCLE TB_NODEACCESS_MODIFYVLANS
	 TB_NODEACCESS_MIN TB_NODEACCESS_MAX

	 NODEFAILMODE_FATAL NODEFAILMODE_NONFATAL NODEFAILMODE_IGNORE

	 TB_USERINFO_READINFO TB_USERINFO_MODIFYINFO
	 TB_USERINFO_MIN TB_USERINFO_MAX

	 USERSTATUS_ACTIVE USERSTATUS_FROZEN
	 USERSTATUS_UNAPPROVED USERSTATUS_UNVERIFIED USERSTATUS_NEWUSER
61
	 USERSTATUS_ARCHIVED USERSTATUS_NONLOCAL
62 63 64 65 66 67 68 69 70 71

	 TB_EXPT_READINFO TB_EXPT_MODIFY TB_EXPT_DESTROY TB_EXPT_UPDATE
	 TB_EXPT_MIN TB_EXPT_MAX

	 TB_PROJECT_READINFO TB_PROJECT_MAKEGROUP
	 TB_PROJECT_EDITGROUP TB_PROJECT_DELGROUP
	 TB_PROJECT_GROUPGRABUSERS TB_PROJECT_BESTOWGROUPROOT
	 TB_PROJECT_LEADGROUP TB_PROJECT_ADDUSER
	 TB_PROJECT_DELUSER TB_PROJECT_MAKEOSID
	 TB_PROJECT_DELOSID TB_PROJECT_MAKEIMAGEID TB_PROJECT_DELIMAGEID
72
	 TB_PROJECT_CREATEEXPT TB_PROJECT_CREATELEASE
73
	 TB_PROJECT_MIN TB_PROJECT_MAX TB_PID_LEN
74 75 76 77 78

	 TB_OSID_READINFO TB_OSID_CREATE
	 TB_OSID_DESTROY TB_OSID_MIN TB_OSID_MAX
	 TB_OSID_OSIDLEN TB_OSID_OSNAMELEN TB_OSID_VERSLEN

79 80 81
         TB_TAINTSTATE_USERONLY TB_TAINTSTATE_BLACKBOX TB_TAINTSTATE_DANGEROUS 
         TB_TAINTSTATE_ALL

82
	 TB_IMAGEID_READINFO TB_IMAGEID_MODIFYINFO TB_IMAGEID_EXPORT
83 84 85 86
	 TB_IMAGEID_CREATE TB_IMAGEID_DESTROY
	 TB_IMAGEID_ACCESS TB_IMAGEID_MIN TB_IMAGEID_MAX
	 TB_IMAGEID_IMAGEIDLEN TB_IMAGEID_IMAGENAMELEN

87 88 89 90 91 92
         LEASE_ACCESS_READINFO LEASE_ACCESS_READ LEASE_ACCESS_MODIFY
         LEASE_ACCESS_DESTROY LEASE_ACCESS_MIN LEASE_ACCESS_MAX

         LEASE_STATE_VALID LEASE_STATE_UNAPPROVED LEASE_STATE_GRACE
         LEASE_STATE_LOCKED LEASE_STATE_EXPIRED

93
	 LEASE_ERROR_NONE LEASE_ERROR_FAILED LEASE_ERROR_BUSY
94
	 LEASE_ERROR_GONE
95

96 97 98
         GLOBAL_PERM_ANON_RO GLOBAL_PERM_USER_RO
         GLOBAL_PERM_ANON_RO_IDX GLOBAL_PERM_USER_RO_IDX

99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130
	 DBLIMIT_NSFILESIZE NODERELOADPENDING_EID

	 NODEREPOSITIONING_PID NODEREPOSITIONING_EID NODEREPOSPENDING_EID

	 EXPTSTATE_NEW EXPTSTATE_PRERUN EXPTSTATE_SWAPPED EXPTSTATE_SWAPPING
	 EXPTSTATE_ACTIVATING EXPTSTATE_ACTIVE EXPTSTATE_PANICED
	 EXPTSTATE_TERMINATING EXPTSTATE_TERMINATED EXPTSTATE_QUEUED
	 EXPTSTATE_MODIFY_PARSE EXPTSTATE_MODIFY_REPARSE EXPTSTATE_MODIFY_RESWAP
	 EXPTSTATE_RESTARTING
	 BATCHSTATE_LOCKED BATCHSTATE_UNLOCKED
	 EXPTCANCEL_CLEAR EXPTCANCEL_TERM EXPTCANCEL_SWAP EXPTCANCEL_DEQUEUE

	 TB_NODELOGTYPE_MISC TB_NODELOGTYPES TB_DEFAULT_NODELOGTYPE

	 TB_DEFAULT_RELOADTYPE TB_RELOADTYPE_FRISBEE TB_RELOADTYPE_NETDISK

	 TB_EXPTPRIORITY_LOW TB_EXPTPRIORITY_HIGH

	 TB_ASSIGN_TOOFEWNODES TB_OPSPID

	 TBDB_TBEVENT_NODESTATE TBDB_TBEVENT_NODEOPMODE TBDB_TBEVENT_CONTROL
	 TBDB_TBEVENT_COMMAND TBDB_TBEVENT_EXPTSTATE

	 TBDB_NODESTATE_ISUP TBDB_NODESTATE_REBOOTING TBDB_NODESTATE_REBOOTED
	 TBDB_NODESTATE_SHUTDOWN TBDB_NODESTATE_BOOTING TBDB_NODESTATE_TBSETUP
	 TBDB_NODESTATE_RELOADSETUP TBDB_NODESTATE_RELOADING
	 TBDB_NODESTATE_RELOADDONE TBDB_NODESTATE_RELOADDONE_V2
	 TBDB_NODESTATE_UNKNOWN
	 TBDB_NODESTATE_PXEWAIT TBDB_NODESTATE_PXEWAKEUP
	 TBDB_NODESTATE_PXEFAILED TBDB_NODESTATE_PXELIMBO
	 TBDB_NODESTATE_PXEBOOTING TBDB_NODESTATE_ALWAYSUP
	 TBDB_NODESTATE_MFSSETUP TBDB_NODESTATE_TBFAILED
Robert Ricci's avatar
Robert Ricci committed
131
	 TBDB_NODESTATE_POWEROFF TBDB_NODESTATE_SECVIOLATION
132
         TBDB_NODESTATE_GPXEBOOTING TBDB_NODESTATE_TPMSIGNOFF
133
	 TBDB_NODESTATE_VNODEBOOTSTART
134 135 136 137

	 TBDB_NODEOPMODE_NORMAL TBDB_NODEOPMODE_DELAYING
	 TBDB_NODEOPMODE_UNKNOWNOS TBDB_NODEOPMODE_RELOADING
	 TBDB_NODEOPMODE_NORMALv1 TBDB_NODEOPMODE_MINIMAL TBDB_NODEOPMODE_PCVM
Robert Ricci's avatar
Robert Ricci committed
138
	 TBDB_NODEOPMODE_RELOAD TBDB_NODEOPMODE_RELOADMOTE
David Johnson's avatar
David Johnson committed
139
	 TBDB_NODEOPMODE_RELOADPCVM TBDB_NODEOPMODE_RELOADPUSH
140
	 TBDB_NODEOPMODE_SECUREBOOT TBDB_NODEOPMODE_SECURELOAD
141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158
	 TBDB_NODEOPMODE_DELAY
	 TBDB_NODEOPMODE_BOOTWHAT
	 TBDB_NODEOPMODE_ANY
	 TBDB_NODEOPMODE_UNKNOWN

	 TBDB_COMMAND_REBOOT
	 TBDB_COMMAND_POWEROFF TBDB_COMMAND_POWERON TBDB_COMMAND_POWERCYCLE

	 TBDB_STATED_TIMEOUT_REBOOT TBDB_STATED_TIMEOUT_NOTIFY
	 TBDB_STATED_TIMEOUT_CMDRETRY

	 TBDB_ALLOCSTATE_FREE_CLEAN TBDB_ALLOCSTATE_FREE_DIRTY
	 TBDB_ALLOCSTATE_DOWN TBDB_ALLOCSTATE_RELOAD_TO_FREE
	 TBDB_ALLOCSTATE_RELOAD_PENDING TBDB_ALLOCSTATE_RES_RELOAD
	 TBDB_ALLOCSTATE_RES_INIT_DIRTY TBDB_ALLOCSTATE_RES_INIT_CLEAN
	 TBDB_ALLOCSTATE_RES_REBOOT_DIRTY TBDB_ALLOCSTATE_RES_REBOOT_CLEAN
	 TBDB_ALLOCSTATE_RES_READY TBDB_ALLOCSTATE_UNKNOWN
	 TBDB_ALLOCSTATE_RES_TEARDOWN TBDB_ALLOCSTATE_DEAD
159
	 TBDB_ALLOCSTATE_RES_RECONFIG TBDB_ALLOCSTATE_RES_REBOOT
160 161 162 163 164 165 166 167 168

	 TBDB_STATS_PRELOAD TBDB_STATS_START TBDB_STATS_TERMINATE
	 TBDB_STATS_SWAPIN TBDB_STATS_SWAPOUT TBDB_STATS_SWAPMODIFY
	 TBDB_STATS_FLAGS_IDLESWAP TBDB_STATS_FLAGS_PREMODIFY
	 TBDB_STATS_FLAGS_START TBDB_STATS_FLAGS_PRESWAPIN
	 TBDB_STATS_FLAGS_MODHOSED TBDB_STATS_SWAPUPDATE
	 TBDB_STATS_FLAGS_MODSWAPOUT

	 TBDB_JAILIPBASE TBDB_JAILIPMASK
169
	 TBDB_FRISBEEMCBASEADDR
170 171

	 TBDB_RSRVROLE_NODE TBDB_RSRVROLE_VIRTHOST TBDB_RSRVROLE_DELAYNODE
172
	 TBDB_RSRVROLE_SIMHOST TBDB_RSRVROLE_STORAGEHOST
173

174
	 TBDB_EXPT_WORKDIR TBDB_EXPT_INFODIR
175
	 TB_OSID_MBKERNEL TB_OSID_PATH_NFS
176
	 TB_OSID_FREEBSD_MFS TB_OSID_FRISBEE_MFS
177 178
	 TBDB_TBCONTROL_PXERESET TBDB_TBCONTROL_RESET
	 TBDB_TBCONTROL_RELOADDONE TBDB_TBCONTROL_RELOADDONE_V2
179 180 181 182 183 184 185 186 187 188
	 TBDB_TBCONTROL_TIMEOUT TBDB_NO_STATE_TIMEOUT
	 TBDB_TBCONTROL_PXEBOOT TBDB_TBCONTROL_BOOTING
	 TBDB_TBCONTROL_CHECKGENISUP

	 TBDB_LOWVPORT TBDB_MAXVPORT TBDB_PORTRANGE

	 TBDB_PHYSICAL_NODE_TABLES

	 TBDB_WIDEAREA_LOCALNODE

189 190 191 192 193
         TBDB_WIRETYPE_NODE TBDB_WIRETYPE_SERIAL TBDB_WIRETYPE_POWER
         TBDB_WIRETYPE_DNARD TBDB_WIRETYPE_CONTROL TBDB_WIRETYPE_TRUNK
         TBDB_WIRETYPE_OUTERCONTROL TBDB_WIRETYPE_UNUSED 
         TBDB_WIRETYPE_MANAGEMENT

194 195 196
	 TBDB_IFACEROLE_CONTROL TBDB_IFACEROLE_EXPERIMENT
	 TBDB_IFACEROLE_JAIL TBDB_IFACEROLE_FAKE TBDB_IFACEROLE_OTHER
	 TBDB_IFACEROLE_GW TBDB_IFACEROLE_OUTER_CONTROL
197
	 TBDB_IFACEROLE_MANAGEMENT
198 199 200 201 202 203 204 205 206 207

	 TBDB_ROUTERTYPE_NONE	TBDB_ROUTERTYPE_OSPF
	 TBDB_ROUTERTYPE_STATIC TBDB_ROUTERTYPE_MANUAL
	 TBDB_USER_INTERFACE_EMULAB TBDB_USER_INTERFACE_PLAB
	 TBDB_EVENTKEY TBDB_WEBKEY

	 TBDB_SECLEVEL_GREEN TBDB_SECLEVEL_BLUE TBDB_SECLEVEL_YELLOW
	 TBDB_SECLEVEL_ORANGE TBDB_SECLEVEL_RED TBDB_SECLEVEL_ZAPDISK

	 TB_NODEHISTORY_OP_FREE TB_NODEHISTORY_OP_ALLOC TB_NODEHISTORY_OP_MOVE
208
	 PROTOUSER TB_NODEHISTORY_OP_CREATE TB_NODEHISTORY_OP_DESTROY
209
	 PROTOGENI_SUPPORT PROTOGENI_GENIRACK
210 211 212
	 );

use English;
213
use vars qw($TB $TBOPS $TBOPSPID $EXPTLOGNAME $PROJROOT $MAINSITE $OURDOMAIN);
214 215 216 217 218 219 220

# Configure variables
$TB	     = "@prefix@";
$TBOPS       = "@TBOPSEMAIL@";
$TBOPSPID    = "emulab-ops";
$EXPTLOGNAME = "activity.log";
$PROJROOT    = "@PROJROOT_DIR@";
221
$MAINSITE    = @TBMAINSITE@;
222
$OURDOMAIN   = "@OURDOMAIN@";
223 224

1;
225
@SELFLOADER_DATA@
226 227 228 229 230

#
# Needs to be configured.
#
sub TBDB_EXPT_WORKDIR()		{ "/usr/testbed/expwork"; }
231
sub TBDB_EXPT_INFODIR()		{ "/usr/testbed/expinfo"; }
232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255

#
# Define exported "constants". Basically, these are just perl subroutines
# that look like constants cause you do not need to call a perl subroutine
# with parens. That is, FOO and FOO() are the same thing.
#
sub NODERELOADING_PID()		{ $TBOPSPID; }
sub NODERELOADING_EID()		{ "reloading"; }
sub NODERELOADPENDING_EID()	{ "reloadpending"; }
sub NODEREPOSITIONING_PID()	{ $TBOPSPID; }
sub NODEREPOSITIONING_EID()	{ "repositioning"; }
sub NODEREPOSPENDING_EID()	{ "repositionpending"; }
sub NODEDEAD_PID()		{ $TBOPSPID; }
sub NODEDEAD_EID()		{ "hwdown"; }
sub NODEILL_PID()		{ $TBOPSPID; }
sub NODEILL_EID()		{ "hwcheckup"; }
sub PLABMOND_PID()		{ $TBOPSPID; }
sub PLABMOND_EID()		{ "plab-monitor"; }
sub PLABTESTING_PID()		{ $TBOPSPID; }
sub PLABTESTING_EID()		{ "plab-testing"; }
sub PLABHOLDING_PID()		{ $TBOPSPID; }
sub PLABHOLDING_EID()		{ "plabnodes"; }
sub PLABDOWN_PID()		{ $TBOPSPID; }
sub PLABDOWN_EID()		{ "hwdown"; }
256 257
sub VLAN_PID()			{ $TBOPSPID; }
sub VLAN_EID()			{ "vlan-holding"; }
258 259 260 261 262 263
sub OLDRESERVED_PID()		{ $TBOPSPID; }
sub OLDRESERVED_EID()		{ "oldreserved"; }
sub NFREELOCKED_PID()		{ $TBOPSPID; }
sub NFREELOCKED_EID()		{ "nfree-locked"; }
sub TBOPSPID()			{ $TBOPSPID; }
sub EXPTLOGNAME()		{ $EXPTLOGNAME; }
264
sub PROTOUSER()			{ 'elabman'; }
265

266 267 268
sub PROTOGENI_SUPPORT()		{ @PROTOGENI_SUPPORT@; }
sub PROTOGENI_GENIRACK()	{ @PROTOGENI_GENIRACK@; }

269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308
sub NODEBOOTSTATUS_OKAY()	{ "okay" ; }
sub NODEBOOTSTATUS_FAILED()	{ "failed"; }
sub NODEBOOTSTATUS_UNKNOWN()	{ "unknown"; }
sub NODESTARTSTATUS_NOSTATUS()	{ "none"; }

sub NODEFAILMODE_FATAL()	{ "fatal"; }
sub NODEFAILMODE_NONFATAL()	{ "nonfatal"; }
sub NODEFAILMODE_IGNORE()	{ "ignore"; }

# Experiment states
sub EXPTSTATE_NEW()		{ "new"; }
sub EXPTSTATE_PRERUN()		{ "prerunning"; }
sub EXPTSTATE_SWAPPED()		{ "swapped"; }
sub EXPTSTATE_QUEUED()		{ "queued"; }
sub EXPTSTATE_SWAPPING()	{ "swapping"; }
sub EXPTSTATE_ACTIVATING()	{ "activating"; }
sub EXPTSTATE_ACTIVE()		{ "active"; }
sub EXPTSTATE_PANICED()		{ "paniced"; }
sub EXPTSTATE_TERMINATING()	{ "terminating"; }
sub EXPTSTATE_TERMINATED()	{ "ended"; }
sub EXPTSTATE_MODIFY_PARSE()	{ "modify_parse"; }
sub EXPTSTATE_MODIFY_REPARSE()	{ "modify_reparse"; }
sub EXPTSTATE_MODIFY_RESWAP()	{ "modify_reswap"; }
sub EXPTSTATE_RESTARTING()	{ "restarting"; }
# For the batch_daemon.
sub BATCHSTATE_LOCKED()		{ "locked";}
sub BATCHSTATE_UNLOCKED()	{ "unlocked";}

# Cancel flags
sub EXPTCANCEL_CLEAR()		{ 0 ;}
sub EXPTCANCEL_TERM()		{ 1 ;}
sub EXPTCANCEL_SWAP()		{ 2 ;}
sub EXPTCANCEL_DEQUEUE()	{ 3 ;}

sub USERSTATUS_ACTIVE()		{ "active"; }
sub USERSTATUS_FROZEN()		{ "frozen"; }
sub USERSTATUS_UNAPPROVED()	{ "unapproved"; }
sub USERSTATUS_UNVERIFIED()	{ "unverified"; }
sub USERSTATUS_NEWUSER()	{ "newuser"; }
sub USERSTATUS_ARCHIVED()	{ "archived"; }
309
sub USERSTATUS_NONLOCAL()	{ "nonlocal"; }
310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332

#
# We want valid project membership to be non-zero for easy membership
# testing. Specific trust levels are encoded thusly.
#
sub PROJMEMBERTRUST_NONE()	{ 0; }
sub PROJMEMBERTRUST_USER()	{ 1; }
sub PROJMEMBERTRUST_ROOT()	{ 2; }
sub PROJMEMBERTRUST_LOCALROOT()	{ 2; }
sub PROJMEMBERTRUST_GROUPROOT()	{ 3; }
sub PROJMEMBERTRUST_PROJROOT()	{ 4; }
sub PROJMEMBERTRUST_ADMIN()	{ 5; }

#
# Access types. Duplicated in the web interface. Make changes there too!
#
# Things you can do to a node.
sub TB_NODEACCESS_READINFO()	{ 1; }
sub TB_NODEACCESS_MODIFYINFO()	{ 2; }
sub TB_NODEACCESS_LOADIMAGE()	{ 3; }
sub TB_NODEACCESS_REBOOT()	{ 4; }
sub TB_NODEACCESS_POWERCYCLE()	{ 5; }
sub TB_NODEACCESS_MODIFYVLANS()	{ 6; }
Leigh B Stoller's avatar
Tweaks.  
Leigh B Stoller committed
333 334
sub TB_NODEACCESS_MIN()		{ TB_NODEACCESS_READINFO(); }
sub TB_NODEACCESS_MAX()		{ TB_NODEACCESS_MODIFYVLANS(); }
335 336 337 338

# User Info (modinfo web page, etc).
sub TB_USERINFO_READINFO()	{ 1; }
sub TB_USERINFO_MODIFYINFO()	{ 2; }
Leigh B Stoller's avatar
Tweaks.  
Leigh B Stoller committed
339 340
sub TB_USERINFO_MIN()		{ TB_USERINFO_READINFO(); }
sub TB_USERINFO_MAX()		{ TB_USERINFO_MODIFYINFO(); }
341 342 343 344 345 346

# Experiments.
sub TB_EXPT_READINFO()		{ 1; }
sub TB_EXPT_MODIFY()		{ 2; }
sub TB_EXPT_DESTROY()		{ 3; }
sub TB_EXPT_UPDATE()		{ 4; }
Leigh B Stoller's avatar
Tweaks.  
Leigh B Stoller committed
347 348
sub TB_EXPT_MIN()		{ TB_EXPT_READINFO(); }
sub TB_EXPT_MAX()		{ TB_EXPT_UPDATE(); }
349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364

# Projects.
sub TB_PROJECT_READINFO()	{ 1; }
sub TB_PROJECT_MAKEGROUP()	{ 2; }
sub TB_PROJECT_EDITGROUP()	{ 3; }
sub TB_PROJECT_GROUPGRABUSERS() { 4; }
sub TB_PROJECT_BESTOWGROUPROOT(){ 5; }
sub TB_PROJECT_DELGROUP()	{ 6; }
sub TB_PROJECT_LEADGROUP()	{ 7; }
sub TB_PROJECT_ADDUSER()	{ 8; }
sub TB_PROJECT_DELUSER()	{ 9; }
sub TB_PROJECT_MAKEOSID()	{ 10; }
sub TB_PROJECT_DELOSID()	{ 11; }
sub TB_PROJECT_MAKEIMAGEID()	{ 12; }
sub TB_PROJECT_DELIMAGEID()	{ 13; }
sub TB_PROJECT_CREATEEXPT()	{ 14; }
365
sub TB_PROJECT_CREATELEASE()	{ 15; }
Leigh B Stoller's avatar
Tweaks.  
Leigh B Stoller committed
366
sub TB_PROJECT_MIN()		{ TB_PROJECT_READINFO(); }
367
sub TB_PROJECT_MAX()		{ TB_PROJECT_CREATELEASE(); }
Leigh B Stoller's avatar
Leigh B Stoller committed
368
sub TB_PID_LEN()		{ 48; }
369 370 371 372 373

# OSIDs
sub TB_OSID_READINFO()		{ 1; }
sub TB_OSID_CREATE()		{ 2; }
sub TB_OSID_DESTROY()		{ 3; }
Leigh B Stoller's avatar
Tweaks.  
Leigh B Stoller committed
374 375
sub TB_OSID_MIN()		{ TB_OSID_READINFO(); }
sub TB_OSID_MAX()		{ TB_OSID_DESTROY(); }
376
sub TB_OSID_OSIDLEN()		{ 35; }
377
sub TB_OSID_OSNAMELEN()		{ 30; }
378 379 380 381 382
sub TB_OSID_VERSLEN()		{ 12; }

# Magic OSID constants
sub TB_OSID_MBKERNEL()          { "_KERNEL_"; } # multiboot kernel OSID

383 384 385
# Magic OSID path
sub TB_OSID_PATH_NFS()		{ "fs:/nfsroot" };

386 387 388 389
# Magic MFS constants
sub TB_OSID_FREEBSD_MFS()	{ "FREEBSD-MFS" };
sub TB_OSID_FRISBEE_MFS()	{ "FRISBEE-MFS" };

390 391 392 393 394 395 396 397
# OS/Node taint states
sub TB_TAINTSTATE_USERONLY()    { "useronly"; };
sub TB_TAINTSTATE_BLACKBOX()    { "blackbox"; };
sub TB_TAINTSTATE_DANGEROUS()   { "dangerous"; };
sub TB_TAINTSTATE_ALL()         { (TB_TAINTSTATE_USERONLY(),
				   TB_TAINTSTATE_BLACKBOX(),
				   TB_TAINTSTATE_DANGEROUS()); };

398 399 400 401 402 403 404 405 406 407
# ImageIDs
#
# Clarification:
# READINFO is read-only access to the image and its contents
# (This is what people get for shared images)
# ACCESS means complete power over the image and its [meta]data
sub TB_IMAGEID_READINFO()	{ 1; }
sub TB_IMAGEID_MODIFYINFO()	{ 2; }
sub TB_IMAGEID_CREATE()		{ 3; }
sub TB_IMAGEID_DESTROY()	{ 4; }
408 409
sub TB_IMAGEID_EXPORT()		{ 5; }
sub TB_IMAGEID_ACCESS()		{ 6; }
Leigh B Stoller's avatar
Tweaks.  
Leigh B Stoller committed
410 411
sub TB_IMAGEID_MIN()		{ TB_IMAGEID_READINFO(); }
sub TB_IMAGEID_MAX()		{ TB_IMAGEID_ACCESS(); }
412 413 414
sub TB_IMAGEID_IMAGEIDLEN()	{ 45; }
sub TB_IMAGEID_IMAGENAMELEN()	{ 30; }

415 416 417 418 419 420 421 422
# Lease Access Types
sub LEASE_ACCESS_READINFO()     { 1; }
sub LEASE_ACCESS_READ()         { 2; }
sub LEASE_ACCESS_MODIFY()       { 3; }
sub LEASE_ACCESS_DESTROY()      { 4; }
sub LEASE_ACCESS_MIN()          { LEASE_ACCESS_READINFO(); }
sub LEASE_ACCESS_MAX()          { LEASE_ACCESS_DESTROY(); }

423 424 425 426 427 428
# Lease States
sub LEASE_STATE_VALID()         { "valid"; }
sub LEASE_STATE_UNAPPROVED()    { "unapproved"; }
sub LEASE_STATE_GRACE()         { "grace"; }
sub LEASE_STATE_LOCKED()        { "locked"; }
sub LEASE_STATE_EXPIRED()       { "expired"; }
429
sub LEASE_STATE_INITIALIZING()  { "initializing"; }
430

431 432 433 434
# Lease Error returns
sub LEASE_ERROR_NONE()		{ 0; }
sub LEASE_ERROR_FAILED()	{ -1; }
sub LEASE_ERROR_BUSY()		{ -2; }
435
sub LEASE_ERROR_GONE()		{ -3; }
436

437 438 439 440 441 442
# Global permissions identifiers and indexes for *_permissions tables.
sub GLOBAL_PERM_ANON_RO         { "GLOBAL_ANON_RO"; }
sub GLOBAL_PERM_USER_RO         { "GLOBAL_USER_RO"; }
sub GLOBAL_PERM_ANON_RO_IDX     { 1; }
sub GLOBAL_PERM_USER_RO_IDX     { 2; }

443 444
# Node Log Types
sub TB_NODELOGTYPE_MISC		{ "misc"; }
Leigh B Stoller's avatar
Tweaks.  
Leigh B Stoller committed
445 446
sub TB_NODELOGTYPES()		{ ( TB_NODELOGTYPE_MISC() ) ; }
sub TB_DEFAULT_NODELOGTYPE()	{ TB_NODELOGTYPE_MISC(); }
447 448 449 450 451

# Node History Stuff.
sub TB_NODEHISTORY_OP_FREE	{ "free"; }
sub TB_NODEHISTORY_OP_ALLOC	{ "alloc"; }
sub TB_NODEHISTORY_OP_MOVE	{ "move"; }
452 453
sub TB_NODEHISTORY_OP_CREATE	{ "create"; }
sub TB_NODEHISTORY_OP_DESTROY	{ "destroy"; }
454 455 456 457

# Reload Types.
sub TB_RELOADTYPE_NETDISK()	{ "netdisk"; }
sub TB_RELOADTYPE_FRISBEE()	{ "frisbee"; }
Leigh B Stoller's avatar
Tweaks.  
Leigh B Stoller committed
458
sub TB_DEFAULT_RELOADTYPE()	{ TB_RELOADTYPE_FRISBEE(); }
459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501

# Experiment priorities.
sub TB_EXPTPRIORITY_LOW()	{ 0; }
sub TB_EXPTPRIORITY_HIGH()	{ 20; }

# Assign exit status for too few nodes.
sub TB_ASSIGN_TOOFEWNODES()	{ 2; }

# System PID.
sub TB_OPSPID()			{ $TBOPSPID; }

#
# Events we may want to send
#
sub TBDB_TBEVENT_NODESTATE	{ "TBNODESTATE"; }
sub TBDB_TBEVENT_NODEOPMODE	{ "TBNODEOPMODE"; }
sub TBDB_TBEVENT_CONTROL	{ "TBCONTROL"; }
sub TBDB_TBEVENT_COMMAND	{ "TBCOMMAND"; }
sub TBDB_TBEVENT_EXPTSTATE	{ "TBEXPTSTATE"; }

#
# For nodes, we use this set of events.
#
sub TBDB_NODESTATE_ISUP()	{ "ISUP"; }
sub TBDB_NODESTATE_ALWAYSUP()	{ "ALWAYSUP"; }
sub TBDB_NODESTATE_REBOOTED()	{ "REBOOTED"; }
sub TBDB_NODESTATE_REBOOTING()	{ "REBOOTING"; }
sub TBDB_NODESTATE_SHUTDOWN()	{ "SHUTDOWN"; }
sub TBDB_NODESTATE_BOOTING()	{ "BOOTING"; }
sub TBDB_NODESTATE_TBSETUP()	{ "TBSETUP"; }
sub TBDB_NODESTATE_RELOADSETUP(){ "RELOADSETUP"; }
sub TBDB_NODESTATE_MFSSETUP()   { "MFSSETUP"; }
sub TBDB_NODESTATE_TBFAILED()	{ "TBFAILED"; }
sub TBDB_NODESTATE_RELOADING()	{ "RELOADING"; }
sub TBDB_NODESTATE_RELOADDONE()	{ "RELOADDONE"; }
sub TBDB_NODESTATE_RELOADDONE_V2(){ "RELOADDONEV2"; }
sub TBDB_NODESTATE_UNKNOWN()	{ "UNKNOWN"; };
sub TBDB_NODESTATE_PXEWAIT()	{ "PXEWAIT"; }
sub TBDB_NODESTATE_PXELIMBO()	{ "PXELIMBO"; }
sub TBDB_NODESTATE_PXEWAKEUP()	{ "PXEWAKEUP"; }
sub TBDB_NODESTATE_PXEFAILED()	{ "PXEFAILED"; }
sub TBDB_NODESTATE_PXEBOOTING()	{ "PXEBOOTING"; }
sub TBDB_NODESTATE_POWEROFF()	{ "POWEROFF"; }
502
sub TBDB_NODESTATE_GPXEBOOTING(){ "GPXEBOOTING"; }
Robert Ricci's avatar
Robert Ricci committed
503 504 505
sub TBDB_NODESTATE_TPMSIGNOFF() { "TPMSIGNOFF"; }
sub TBDB_NODESTATE_SECVIOLATION(){ "SECVIOLATION"; }
sub TBDB_NODESTATE_MFSBOOTING() { "MFSBOOTING"; }
506
sub TBDB_NODESTATE_VNODEBOOTSTART() { "VNODEBOOTSTART"; }
507 508 509 510 511 512 513 514 515 516 517

sub TBDB_NODEOPMODE_ANY		{ "*"; } # A wildcard opmode
sub TBDB_NODEOPMODE_NORMAL	{ "NORMAL"; }
sub TBDB_NODEOPMODE_DELAYING	{ "DELAYING"; }
sub TBDB_NODEOPMODE_UNKNOWNOS	{ "UNKNOWNOS"; }
sub TBDB_NODEOPMODE_RELOADING	{ "RELOADING"; }
sub TBDB_NODEOPMODE_NORMALv1	{ "NORMALv1"; }
sub TBDB_NODEOPMODE_MINIMAL	{ "MINIMAL"; }
sub TBDB_NODEOPMODE_PCVM	{ "PCVM"; }
sub TBDB_NODEOPMODE_RELOAD	{ "RELOAD"; }
sub TBDB_NODEOPMODE_RELOADMOTE	{ "RELOAD-MOTE"; }
518
sub TBDB_NODEOPMODE_SECUREBOOT  { "SECUREBOOT"; }
Robert Ricci's avatar
Robert Ricci committed
519
sub TBDB_NODEOPMODE_SECURELOAD  { "SECURELOAD"; }
520
sub TBDB_NODEOPMODE_RELOADPCVM	{ "RELOAD-PCVM"; }
David Johnson's avatar
David Johnson committed
521
sub TBDB_NODEOPMODE_RELOADPUSH	{ "RELOAD-PUSH"; }
522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547
sub TBDB_NODEOPMODE_DELAY	{ "DELAY"; }
sub TBDB_NODEOPMODE_BOOTWHAT	{ "_BOOTWHAT_"; } # A redirection opmode
sub TBDB_NODEOPMODE_UNKNOWN	{ "UNKNOWN"; }

sub TBDB_COMMAND_REBOOT         { "REBOOT"; }
sub TBDB_COMMAND_POWEROFF       { "POWEROFF"; }
sub TBDB_COMMAND_POWERON        { "POWERON"; }
sub TBDB_COMMAND_POWERCYCLE     { "POWERCYCLE"; }

sub TBDB_STATED_TIMEOUT_REBOOT  { "REBOOT"; }
sub TBDB_STATED_TIMEOUT_NOTIFY  { "NOTIFY"; }
sub TBDB_STATED_TIMEOUT_CMDRETRY{ "CMDRETRY"; }

sub TBDB_ALLOCSTATE_FREE_CLEAN()       { "FREE_CLEAN"; }
sub TBDB_ALLOCSTATE_FREE_DIRTY()       { "FREE_DIRTY"; }
sub TBDB_ALLOCSTATE_DOWN()             { "DOWN"; }
sub TBDB_ALLOCSTATE_DEAD()             { "DEAD"; }
sub TBDB_ALLOCSTATE_RELOAD_TO_FREE()   { "RELOAD_TO_FREE"; }
sub TBDB_ALLOCSTATE_RELOAD_PENDING()   { "RELOAD_PENDING"; }
sub TBDB_ALLOCSTATE_RES_RELOAD()       { "RES_RELOAD"; }
sub TBDB_ALLOCSTATE_RES_REBOOT_DIRTY() { "RES_REBOOT_DIRTY"; }
sub TBDB_ALLOCSTATE_RES_REBOOT_CLEAN() { "RES_REBOOT_CLEAN"; }
sub TBDB_ALLOCSTATE_RES_INIT_DIRTY()   { "RES_INIT_DIRTY"; }
sub TBDB_ALLOCSTATE_RES_INIT_CLEAN()   { "RES_INIT_CLEAN"; }
sub TBDB_ALLOCSTATE_RES_READY()        { "RES_READY"; }
sub TBDB_ALLOCSTATE_RES_RECONFIG()     { "RES_RECONFIG"; }
548
sub TBDB_ALLOCSTATE_RES_REBOOT()       { "RES_REBOOT"; }
549 550 551
sub TBDB_ALLOCSTATE_RES_TEARDOWN()     { "RES_TEARDOWN"; }
sub TBDB_ALLOCSTATE_UNKNOWN()          { "UNKNOWN"; };

552
sub TBDB_TBCONTROL_PXERESET	{ "PXERESET"; }
553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607
sub TBDB_TBCONTROL_RESET	{ "RESET"; }
sub TBDB_TBCONTROL_RELOADDONE	{ "RELOADDONE"; }
sub TBDB_TBCONTROL_RELOADDONE_V2{ "RELOADDONEV2"; }
sub TBDB_TBCONTROL_TIMEOUT	{ "TIMEOUT"; }
sub TBDB_TBCONTROL_PXEBOOT	{ "PXEBOOT"; }
sub TBDB_TBCONTROL_BOOTING	{ "BOOTING"; }
sub TBDB_TBCONTROL_CHECKGENISUP	{ "CHECKGENISUP"; }

# Constant we use for the timeout field when there is no timeout for a state
sub TBDB_NO_STATE_TIMEOUT	{ 0; }

#
# Node name we use in the widearea_* tables to represent a generic local node.
# All local nodes are considered to have the same network characteristcs.
#
sub TBDB_WIDEAREA_LOCALNODE     { "boss"; }

#
# We should list all of the DB limits.
#
sub DBLIMIT_NSFILESIZE()	{ (2**24 - 1); }

#
# Virtual nodes must operate within a restricted port range. The range
# is effective across all virtual nodes in the experiment. When an
# experiment is swapped in, allocate a subrange from this and setup
# all the vnodes to allocate from that range. We tell the user this
# range so this they can set up their programs to operate in that range.
#
sub TBDB_LOWVPORT()		{ 30000; }
sub TBDB_MAXVPORT()		{ 60000; }
sub TBDB_PORTRANGE()		{ 256;   }

#
# STATS constants.
#
sub TBDB_STATS_PRELOAD()	{ "preload"; }
sub TBDB_STATS_START()		{ "start"; }
sub TBDB_STATS_TERMINATE()	{ "destroy"; }
sub TBDB_STATS_SWAPIN()		{ "swapin"; }
sub TBDB_STATS_SWAPOUT()	{ "swapout"; }
sub TBDB_STATS_SWAPMODIFY()	{ "swapmod"; }
sub TBDB_STATS_SWAPUPDATE()	{ "swapupdate"; }
sub TBDB_STATS_FLAGS_IDLESWAP()	{ 0x01; }
sub TBDB_STATS_FLAGS_PREMODIFY(){ 0x02; }
sub TBDB_STATS_FLAGS_START()    { 0x04; }
sub TBDB_STATS_FLAGS_PRESWAPIN(){ 0x08; }
sub TBDB_STATS_FLAGS_BATCHCTRL(){ 0x10; }
sub TBDB_STATS_FLAGS_MODHOSED() { 0x20; }
sub TBDB_STATS_FLAGS_MODSWAPOUT() { 0x40; }

# Jail.
sub TBDB_JAILIPBASE()		{ "@JAILIPBASE@"; }
sub TBDB_JAILIPMASK()		{ "@JAILIPMASK@"; }

608 609 610
# Frisbee.
sub TBDB_FRISBEEMCBASEADDR()	{ "@FRISEBEEMCASTADDR@:@FRISEBEEMCASTPORT@"; }

611 612 613 614 615
# Reserved node "roles"
sub TBDB_RSRVROLE_NODE()	{ "node"; }
sub TBDB_RSRVROLE_VIRTHOST()	{ "virthost"; }
sub TBDB_RSRVROLE_DELAYNODE()	{ "delaynode"; }
sub TBDB_RSRVROLE_SIMHOST()	{ "simhost"; }
616
sub TBDB_RSRVROLE_STORAGEHOST()	{ "storagehost"; }
617 618 619 620 621 622 623 624 625

# Interfaces roles.
sub TBDB_IFACEROLE_CONTROL()	{ "ctrl"; }
sub TBDB_IFACEROLE_EXPERIMENT()	{ "expt"; }
sub TBDB_IFACEROLE_JAIL()	{ "jail"; }
sub TBDB_IFACEROLE_FAKE()	{ "fake"; }
sub TBDB_IFACEROLE_GW()		{ "gw"; }
sub TBDB_IFACEROLE_OTHER()	{ "other"; }
sub TBDB_IFACEROLE_OUTER_CONTROL(){ "outer_ctrl"; }
626
sub TBDB_IFACEROLE_MANAGEMENT()	{ "mngmnt"; }
627

628
# Wire types.
629 630 631 632 633 634 635 636 637
sub TBDB_WIRETYPE_NODE()          { "Node"; }
sub TBDB_WIRETYPE_SERIAL()        { "Serial"; }
sub TBDB_WIRETYPE_POWER()         { "Power"; }
sub TBDB_WIRETYPE_DNARD()         { "Dnard"; }
sub TBDB_WIRETYPE_CONTROL()       { "Control"; }
sub TBDB_WIRETYPE_TRUNK()         { "Trunk"; }
sub TBDB_WIRETYPE_OUTERCONTROL()  { "OuterControl"; }
sub TBDB_WIRETYPE_UNUSED()        { "Unused"; }
sub TBDB_WIRETYPE_MANAGEMENT()    { "Management"; }
638

639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660
# Routertypes.
sub TBDB_ROUTERTYPE_NONE()	{ "none"; }
sub TBDB_ROUTERTYPE_OSPF()	{ "ospf"; }
sub TBDB_ROUTERTYPE_STATIC()	{ "static"; }
sub TBDB_ROUTERTYPE_MANUAL()	{ "manual"; }

# User Interface types.
sub TBDB_USER_INTERFACE_EMULAB(){ "emulab"; }
sub TBDB_USER_INTERFACE_PLAB()	{ "plab"; }

# Key Stuff
sub TBDB_EVENTKEY($$)	{ TBExptUserDir($_[0],$_[1]) . "/tbdata/eventkey"; }
sub TBDB_WEBKEY($$)	{ TBExptUserDir($_[0],$_[1]) . "/tbdata/webkey"; }

# Security Levels.
sub TBDB_SECLEVEL_GREEN()	{ 0; }
sub TBDB_SECLEVEL_BLUE()	{ 1; }
sub TBDB_SECLEVEL_YELLOW()	{ 2; }
sub TBDB_SECLEVEL_ORANGE()	{ 3; }
sub TBDB_SECLEVEL_RED()		{ 4; }

# This is the level at which we get extremely cautious when swapping out
Leigh B Stoller's avatar
Tweaks.  
Leigh B Stoller committed
661
sub TBDB_SECLEVEL_ZAPDISK()	{ TBDB_SECLEVEL_YELLOW(); }
662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680

#
# A hash of all tables that contain information about physical nodes - the
# value for each key is the list of columns that could contain the node's ID.
#
sub TBDB_PHYSICAL_NODE_TABLES() {
    return (
	'current_reloads'	=> [ 'node_id' ],
	'delays'		=> [ 'node_id' ],
	'iface_counters'	=> [ 'node_id' ],
	'interfaces'		=> [ 'node_id' ],
	'interface_settings'	=> [ 'node_id' ],
	'interface_state'	=> [ 'node_id' ],
	'last_reservation'	=> [ 'node_id' ],
	'linkdelays'		=> [ 'node_id' ],
	'location_info'		=> [ 'node_id' ],
	'next_reserve'		=> [ 'node_id' ],
	'node_activity'		=> [ 'node_id' ],
	'node_auxtypes'		=> [ 'node_id' ],
681
	'node_attributes'	=> [ 'node_id' ],
682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713
	'node_features'		=> [ 'node_id' ],
	'node_hostkeys'		=> [ 'node_id' ],
	'node_idlestats'	=> [ 'node_id' ],
	'node_status'   	=> [ 'node_id' ],
	'node_rusage'		=> [ 'node_id' ],
	'nodeipportnum'		=> [ 'node_id' ],
	'nodelog'		=> [ 'node_id' ],
	'nodes'			=> [ 'node_id', 'phys_nodeid' ],
	'nodeuidlastlogin'	=> [ 'node_id' ],
	'ntpinfo'		=> [ 'node_id' ],
	'outlets'		=> [ 'node_id' ],
	'outlets_remoteauth'	=> [ 'node_id' ],
	'partitions'		=> [ 'node_id' ],
	'plab_slice_nodes'	=> [ 'node_id' ],
	'port_counters'		=> [ 'node_id' ],
	'reserved'		=> [ 'node_id' ],
	'scheduled_reloads'	=> [ 'node_id' ],
	'state_triggers'	=> [ 'node_id' ],
	'switch_stacks'		=> [ 'node_id' ],
	'tiplines'		=> [ 'node_id' ],
	'tmcd_redirect'		=> [ 'node_id' ],
	'uidnodelastlogin'	=> [ 'node_id' ],
	'v2pmap'		=> [ 'node_id' ],
	'vinterfaces'		=> [ 'node_id' ],
	'widearea_nodeinfo'	=> [ 'node_id' ],
	'widearea_accounts'	=> [ 'node_id' ],
	'widearea_delays'	=> [ 'node_id1', 'node_id2' ],
	'widearea_recent'	=> [ 'node_id1', 'node_id2' ],
	'wires'			=> [ 'node_id1', 'node_id2' ],
	'node_startloc'		=> [ 'node_id' ],
	'node_history'		=> [ 'node_id' ],
	'node_bootlogs'		=> [ 'node_id' ],
714 715 716
	'plab_mapping'          => [ 'node_id' ],
	'node_utilization'      => [ 'node_id' ],
	'subbosses'		=> [ 'node_id' ],
717
	'node_licensekeys'	=> [ 'node_id' ],
718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780
    );
}

#
# Convert a trust string to the above numeric values.
#
sub TBTrustConvert($)
{
    my ($trust_string) = @_;
    my $trust_value = 0;

    #
    # Convert string to value. Perhaps the DB should have done it this way?
    #
    if ($trust_string eq "none") {
	$trust_value = PROJMEMBERTRUST_NONE();
    }
    elsif ($trust_string eq "user") {
	$trust_value = PROJMEMBERTRUST_USER();
    }
    elsif ($trust_string eq "local_root") {
	$trust_value = PROJMEMBERTRUST_LOCALROOT();
    }
    elsif ($trust_string eq "group_root") {
	$trust_value = PROJMEMBERTRUST_GROUPROOT();
    }
    elsif ($trust_string eq "project_root") {
	$trust_value = PROJMEMBERTRUST_PROJROOT();
    }
    elsif ($trust_string eq "admin") {
	$trust_value = PROJMEMBERTRUST_ADMIN();
    }
    else {
	    die("*** Invalid trust value $trust_string!");
    }

    return $trust_value;
}

#
# Return true if the given trust string is >= to the minimum required.
# The trust value can be either numeric or a string; if a string its
# first converted to the numeric equiv.
#
sub TBMinTrust($$)
{
    my ($trust_value, $minimum) = @_;

    if ($minimum < PROJMEMBERTRUST_NONE() ||
	$minimum > PROJMEMBERTRUST_ADMIN()) {
	    die("*** Invalid minimum trust $minimum!");
    }

    #
    # Sleazy? How do you do a typeof in perl?
    #
    if (length($trust_value) != 1) {
	$trust_value = TBTrustConvert($trust_value);
    }

    return $trust_value >= $minimum;
}

781
# _Always_ make sure that this 1 is at the end of the file...
782
1;