Setting tag MyPLC-5.0-2 MyPLC-5.0-2
authorThierry Parmentelat <thierry.parmentelat@sophia.inria.fr>
Fri, 12 Mar 2010 17:59:02 +0000 (17:59 +0000)
committerThierry Parmentelat <thierry.parmentelat@sophia.inria.fr>
Fri, 12 Mar 2010 17:59:02 +0000 (17:59 +0000)
legacy scripts gen-sites-xml & gen-static-content back in (sigh)
new OMF category in the config
create the drl system slice

52 files changed:
Makefile
README-devel.txt [deleted file]
bashrc
bin/clean-empty-dirs.py [moved from clean-empty-dirs.py with 100% similarity]
bin/db-config [new file with mode: 0755]
bin/dns-config [moved from dns-config with 100% similarity]
bin/mtail.py [moved from mtail.py with 94% similarity]
bin/plc-check-ssl-peering.py [moved from check-ssl-peering.py with 100% similarity]
bin/plc-config [moved from plc-config with 100% similarity]
bin/plc-config-tty [new file with mode: 0755]
bin/plc-kml.py [moved from plc-kml.py with 93% similarity]
bin/plc-map.py [moved from plc-map.py with 100% similarity]
bin/plc-orphan-accounts.py [new file with mode: 0755]
bin/refresh-peer.py [moved from refresh-peer.py with 100% similarity]
bootstrap.xml [deleted file]
build-chroot.sh [deleted file]
build.functions [deleted file]
build.sh [deleted file]
db-config [deleted file]
db-config.d/040-init_scripts [new file with mode: 0644]
db-config.d/080-slice_netflow [new file with mode: 0644]
db-config.d/081-slice_sirius [new file with mode: 0644]
db-config.d/082-slice_sfacm [new file with mode: 0644]
db-config.d/083-slice_drl [new file with mode: 0644]
db-config.d/090-my_ops [new file with mode: 0644]
default_config.xml
host.init [deleted file]
myplc-chroot.spec [deleted file]
myplc-docs.spec
myplc-release.spec
myplc.spec
plc-config-tty [deleted file]
plc.d/api [deleted file]
plc.d/bootcd [deleted file]
plc.d/bootmanager [deleted file]
plc.d/crond [deleted file]
plc.d/db [deleted file]
plc.d/dns
plc.d/functions
plc.d/gpg
plc.d/httpd
plc.d/mail
plc.d/network
plc.d/packages [deleted file]
plc.d/postgresql [deleted file]
plc.d/ssh
plc.d/ssl
plc.d/syslog [deleted file]
plc.init [moved from guest.init with 96% similarity]
plc_config.py
support-scripts/gen-sites-xml.py [new file with mode: 0755]
support-scripts/gen-static-content.py [new file with mode: 0755]

index 752e747..82ae384 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -2,17 +2,28 @@
 # $Id$
 #
 
-BINARIES = plc-config plc-config-tty db-config dns-config plc-map.py plc-kml.py clean-empty-dirs.py mtail.py \
-       support-scripts/renew_reminder.py support-scripts/gen_aliases.py
-INIT_SCRIPTS = api bootcd bootmanager crond db dns functions gpg httpd mail network packages postgresql ssh ssl syslog
+##########
+tags:
+       find . -type f | egrep -v '.svn/|~$$' | xargs etags
+
+.PHONY: tags
+
+########## sync
+# 2 forms are supported
+# (*) if your plc root context has direct ssh access:
+# make sync PLC=private.one-lab.org
+# (*) otherwise, entering through the root context
+# make sync PLCHOST=testbox1.inria.fr GUEST=vplc03.inria.fr
 
-INITS=$(addprefix plc.d/,$(INIT_SCRIPTS))
+PLCHOST ?= testplc.onelab.eu
 
-########## make sync PLCHOST=hostname
-ifdef PLCHOST
 ifdef GUEST
-PLCSSH:=root@$(PLCHOST):/vservers/$(GUEST)
+SSHURL:=root@$(PLCHOST):/vservers/$(GUEST)
+SSHCOMMAND:=ssh root@$(PLCHOST) vserver $(GUEST)
 endif
+ifdef PLC
+SSHURL:=root@$(PLC):/
+SSHCOMMAND:=ssh root@$(PLC)
 endif
 
 LOCAL_RSYNC_EXCLUDES   := --exclude '*.pyc' 
@@ -21,21 +32,28 @@ RSYNC_COND_DRY_RUN  := $(if $(findstring n,$(MAKEFLAGS)),--dry-run,)
 RSYNC                  := rsync -a -v $(RSYNC_COND_DRY_RUN) $(RSYNC_EXCLUDES)
 
 sync:
-ifeq (,$(PLCSSH))
-       echo "sync: You must define PLCHOST and GUEST on the command line"
-       echo " e.g. make sync PLCHOST=private.one-lab.org GUEST=myplc01" ; exit 1
+ifeq (,$(SSHURL))
+       @echo "sync: You must define, either PLC, or PLCHOST & GUEST, on the command line"
+       @echo "  e.g. make sync PLC=private.one-lab.org"
+       @echo "  or   make sync PLCHOST=testbox1.inria.fr GUEST=vplc03.inria.fr"
+       @exit 1
 else
-       +$(RSYNC) guest.init $(PLCSSH)/etc/init.d/plc
-       +$(RSYNC) $(BINARIES) $(PLCSSH)/usr/bin
-       +$(RSYNC) $(INITS) $(PLCSSH)/etc/plc.d
-       +$(RSYNC) plc_config.py $(PLCSSH)/usr/lib/python2.4/site-packages/plc_config.py
-       +$(RSYNC) default_config.xml $(PLCSSH)/etc/planetlab/default_config.xml
-       @echo XXXXXXXX You might consider running the following command
-       @echo ssh $(PLCHOST) service plc start 
+       +$(RSYNC) plc.init $(SSHURL)/etc/init.d/plc
+       +$(RSYNC) bin/ $(SSHURL)/usr/bin/
+       +$(RSYNC) plc.d/ $(SSHURL)/etc/plc.d/
+       +$(RSYNC) db-config.d/ $(SSHURL)/etc/planetlab/db-config.d/
+       +$(RSYNC) plc_config.py $(SSHURL)/usr/lib/python2.5/site-packages/plc_config.py
+       +$(RSYNC) default_config.xml $(SSHURL)/etc/planetlab/default_config.xml
+       @echo XXXXXXXX you might need to run ssh root@$(PLC) service plc start 
 endif
 
+#################### convenience, for debugging only
+# make +foo : prints the value of $(foo)
+# make ++foo : idem but verbose, i.e. foo=$(foo)
+++%: varname=$(subst +,,$@)
+++%:
+       @echo "$(varname)=$($(varname))"
++%: varname=$(subst +,,$@)
++%:
+       @echo "$($(varname))"
 
-tags:
-       find . -type f | egrep -v '.svn/|~$$' | xargs etags
-
-.PHONY: tags
diff --git a/README-devel.txt b/README-devel.txt
deleted file mode 100644 (file)
index ad93523..0000000
+++ /dev/null
@@ -1,11 +0,0 @@
-Thierry Parmentelat, on November 30 2007
-we do not support myplc-devel anymore, see build/ for how to build the system in a vserver-based environment
-
-I am removing all files related to the former myplc-devel, they can be
-retrieved in revision 7249:
-
-D      plc_devel_config.xml
-D      build_devel.sh
-D      myplc-devel-native.spec
-D      myplc-devel.spec
-D      plc-devel.sysconfig
diff --git a/bashrc b/bashrc
index 41b27c6..0e92877 100644 (file)
--- a/bashrc
+++ b/bashrc
@@ -1,4 +1,6 @@
 # -*-sh-*-
+# $Id$
+# $URL$
 # this file defines a few convenience bash shorthands for managing myplc nodes
 # it is installed in /usr/share/myplc/aliases
 # you might wish to use it in your own bash startup files (.profile/.bashrc)
@@ -24,23 +26,27 @@ function node_dbg () {
     [[ -z "$@" ]] && { echo "Usage: $0 hostname [command]" ; return 1; }
     node_key /etc/planetlab/debug_ssh_key.rsa "$@"
 }
-function node_boot () {
-    [[ -z "$@" ]] && { echo "Usage: $0 hostname [command]" ; return 1; }
-    node_key /etc/planetlab/root_ssh_key.rsa "$@"
-}
-
 function nodes_dbg () {
     [[ -z "$@" ]] && { echo "Usage: $0 hosts_file [command]" ; return 1; }
     node_keys /etc/planetlab/debug_ssh_key.rsa "$@"
 }
-function nodes_boot () {
-    [[ -z "$@" ]] && { echo "Usage: $0 hosts_file [command]" ; return 1; }
-    nodes_key /etc/planetlab/root_ssh_key.rsa "$@"
-}
-
-function clear_keys () {
+function clear_known_hosts () {
     for hostname in "$@"; do   
         sed -i "/$hostname/d" ~/.ssh/known_hosts
     done
-}
-       
+}      
+
+# convenience 
+alias mtail=mtail.py
+
+# navigators - alphabetical
+alias gobmsource="cd /usr/share/bootmanager"
+alias goboot="cd /var/www/html/boot"
+alias godrupal="cd /var/www/html/planetlab"
+alias gohttplog="cd /var/log/httpd"
+alias goinit="cd /etc/plc.d"
+alias golog="cd /var/log/"
+alias goplcapi="cd /usr/share/plc_api"
+alias gosqllog="cd /var/lib/pgsql/data/pg_log"
+alias goyum="cd /var/www/html/install-rpms"
+
similarity index 100%
rename from clean-empty-dirs.py
rename to bin/clean-empty-dirs.py
diff --git a/bin/db-config b/bin/db-config
new file mode 100755 (executable)
index 0000000..f22e7f2
--- /dev/null
@@ -0,0 +1,115 @@
+#!/usr/bin/env /usr/bin/plcsh
+#
+# Bootstraps the PLC database with a default administrator account and
+# a default site, defines default slice attribute types, and
+# creates/updates default system slices.
+#
+# Mark Huang <mlhuang@cs.princeton.edu>
+# Copyright (C) 2006 The Trustees of Princeton University
+#
+# $Id$
+# $URL$
+
+import os,sys
+from optparse import OptionParser
+
+from plc_config import PLCConfiguration
+
+def GetSnippets(directory):
+    filenames = []
+    if os.path.exists(directory):
+        try:
+            filenames = os.listdir(directory)
+        except OSError, e:
+            raise Exception, "Error when opening %s (%s)" % \
+                  (os.path.join(dir, file), e)
+            
+    ignored = (".bak","~",".rpmsave",".rpmnew",".orig")
+    numberedfiles = {}
+    for filename in filenames:
+        shouldIgnore = False
+        for ignore in ignored:
+            if filename.endswith(ignore):
+                shouldIgnore = True
+                break
+
+        if not shouldIgnore:
+            parts = filename.split('-')
+            if len(parts)>=2:
+                name = '-'.join(parts)
+                try:
+                    number = int(parts[0])
+                    entry = numberedfiles.get(number,[])
+                    entry.append(name)
+                    numberedfiles[number]=entry
+                except ValueError:
+                    shouldIgnore = True
+            else:
+                shouldIgnore = True
+
+        if shouldIgnore:
+            print "db-config: ignoring %s snippet" % filename
+
+    filenames = []
+    keys = numberedfiles.keys()
+    keys.sort()
+    for k in keys:
+        for filename in numberedfiles[k]:
+            filenames.append(filename)
+    return filenames
+
+def main():
+    cfg = PLCConfiguration()
+    cfg.load()
+    variables = cfg.variables()
+
+    usage="%prog [-- options] [steps]"
+    release_url = "$URL$"
+    parser = OptionParser(usage=usage, version="%prog " + release_url )
+    parser.add_option("-l","--list",dest="list_steps",action="store_true",default=False,
+                      help="Lists available steps")
+    parser.add_option("-v","--verbose",dest="verbose",action="store_true",default=False,
+                      help="Run verbosely")
+
+    (options,steps) = parser.parse_args()
+    
+    # Load variables into dictionaries
+    for category_id, (category, variablelist) in variables.iteritems():
+        globals()[category_id] = dict(zip(variablelist.keys(),
+                                          [variable['value'] for variable in variablelist.values()]))
+
+    directory="/etc/planetlab/db-config.d"
+    snippets = GetSnippets(directory)
+
+    for snippet in snippets:
+        
+        selected=False
+        # no steps provided on the command-line : run them all
+        if not steps:
+            selected=True
+        else:
+            for step in steps:
+                if snippet.find (step)>=0 : selected=True
+        if not selected: 
+            continue
+        
+        if options.list_steps:
+            if not options.verbose: 
+                print snippet
+            else: 
+                print "Found step %s/%s"%(directory,snippet)
+                os.system("rpm -qf %s/%s"%(directory,snippet))
+            continue
+
+        fullpath = os.path.join(directory, snippet)
+        if options.verbose:
+            print "Running step %s"%fullpath
+        execfile(fullpath)
+
+if __name__ == '__main__':
+    main()
+
+# Local variables:
+# tab-width: 4
+# mode: python
+# End:
similarity index 100%
rename from dns-config
rename to bin/dns-config
similarity index 94%
rename from mtail.py
rename to bin/mtail.py
index 09e443f..954b1e5 100755 (executable)
--- a/mtail.py
@@ -34,7 +34,7 @@ example:
        parser.add_option("-p","--period", type="int", dest="tail_period", default=1,
                          help="Files check period in seconds")
        # rescan_period
-       parser.add_option("-d","--dir-period", type="int", dest="rescan_period", default=20,
+       parser.add_option("-d","--dir-period", type="int", dest="rescan_period", default=5,
                          help="Directories rescan period in seconds")
        # time format
        parser.add_option("-f","--format", dest="time_format", default=mtail.default_time_format,
@@ -55,7 +55,7 @@ example:
                          help="Run in verbose mode")
 
        (self.options, self.args) = parser.parse_args(args)
-       self.optparse = parser
+       self.option_parser = parser
 
        ### plc shortcuts
        if self.options.plc_mode:
@@ -73,7 +73,11 @@ example:
            print 'Arguments:',self.args
 
     def file_size (self,filename):
-       return os.stat(filename)[6]
+        try:
+            return os.stat(filename)[6]
+        except:
+            print "WARNING: file %s has vanished"%filename
+            return 0
                
     def number_files (self):
        return len(self.files)
@@ -168,7 +172,11 @@ example:
            print label,
 
     def show_file_end (self, filename, offset, size):
-       file = open(filename,"r")
+        try:
+            file = open(filename,"r")
+        # file has vanished
+        except:
+            return
        file.seek(offset)
        line=file.read(size-offset)
        self.show_now()
@@ -217,8 +225,8 @@ example:
 
     def run (self):
 
-       if self.number_files() == 0:
-           self.optparse.print_help()
+       if len(self.args) == 0:
+           self.option_parser.print_help()
            sys.exit(1)
        counter = 0
     
similarity index 100%
rename from plc-config
rename to bin/plc-config
diff --git a/bin/plc-config-tty b/bin/plc-config-tty
new file mode 100755 (executable)
index 0000000..26dfd82
--- /dev/null
@@ -0,0 +1,42 @@
+#!/bin/env python
+
+import sys
+import readline
+import plc_config
+
+def validator(validated_variables):
+    maint_user = validated_variables["PLC_API_MAINTENANCE_USER"]
+    root_user = validated_variables["PLC_ROOT_USER"]
+    if maint_user == root_user:
+        errStr="PLC_API_MAINTENANCE_USER=%s cannot be the same as PLC_ROOT_USER=%s"%(maint_user,root_user)
+        raise plc_config.ConfigurationException(errStr)
+
+usual_variables = [
+    "PLC_NAME",
+    "PLC_SHORTNAME",
+    "PLC_SLICE_PREFIX",
+    "PLC_ROOT_USER",
+    "PLC_ROOT_PASSWORD",
+    "PLC_MAIL_ENABLED",
+    "PLC_MAIL_SUPPORT_ADDRESS",
+    "PLC_DB_HOST",
+    "PLC_API_HOST",
+    "PLC_WWW_HOST",
+    "PLC_BOOT_HOST",
+    "PLC_NET_DNS1",
+    "PLC_NET_DNS2",
+    ]
+
+configuration={ \
+    'name':'plc',
+    'service':"plc",
+    'usual_variables':usual_variables,
+    'config_dir':"/etc/planetlab",
+    'validate_variables':{"PLC_API":"MAINTENANCE_USER","PLC":"ROOT_USER"},
+    'validator':validator,
+    }
+
+if __name__ == '__main__':
+    command=sys.argv[0]
+    argv = sys.argv[1:]
+    plc_config.main(command,argv,configuration)
similarity index 93%
rename from plc-kml.py
rename to bin/plc-kml.py
index 7cf6eb3..2a1ecf9 100755 (executable)
 
 import sys
 
-default_output       = "/var/www/html/sites/sites.kml"
-default_local_icon   = "sites/google-local.png"
-default_foreign_icon = "sites/google-foreign.png"
+default_output           = "/var/www/html/sites/sites.kml"
+default_local_icon       = "sites/google-local.png"
+default_foreign_icon     = "sites/google-foreign.png"
+default_local_builtin    = "palette-4.png"
+default_foreign_builtin  = "palette-3.png"
 
 class KmlMap:
 
@@ -34,16 +36,13 @@ class KmlMap:
     def write(self,string):
         self.output.write(string.encode("UTF-8"))
 
+    # mention local last 
     @staticmethod
     def site_compare (s1,s2):
-        n1=s1['name']
-        n2=s2['name']
-        if n1<n2:
-            return -1
-        elif n1>n2:
-            return 1
-        else:
-            return 0
+        p1 = p2 = 0
+        if s1['peer_id']: p1=s1['peer_id']
+        if s2['peer_id']: p2=s2['peer_id']
+        return p2-p1
 
     def refresh (self):
         self.open()
@@ -142,11 +141,11 @@ class KmlMap:
         if self.options.use_google_icons:
             if not peer_id:
                 # local sites
-                iconfile="palette-4.png"
+                iconfile=default_local_builtin
                 xyspec="<x>128</x><y>0</y><w>32</w><h>32</h>"
             else:
                 # remote
-                iconfile="palette-3.png"
+                iconfile=default_foreign_builtin
                 xyspec="<x>160</x><y>0</y><w>32</w><h>32</h>"
             iconurl="root://icons/%(iconfile)s"%locals()
         else:
similarity index 100%
rename from plc-map.py
rename to bin/plc-map.py
diff --git a/bin/plc-orphan-accounts.py b/bin/plc-orphan-accounts.py
new file mode 100755 (executable)
index 0000000..b8ce321
--- /dev/null
@@ -0,0 +1,166 @@
+#!/usr/bin/env plcsh
+#
+# $Id$
+#
+# searches and displays any local orphan account (not attached to a site)
+# remote accounts with identical emails are displayed as well
+
+import sys
+import time
+import readline
+from optparse import OptionParser
+
+logdir="/var/log/accounts"
+
+def run_in_log (options):
+    monthstring=time.strftime("%Y-%m")
+    if not os.path.isdir(logdir):
+        os.mkdir(logdir)
+    logname="%s/orphans-%s.log"%(logdir,monthstring)
+    sys.stdout=open(logname,'a')
+    sys.stderr=sys.stdout
+    run(options)
+    sys.stderr.close()
+    sys.stdout.close()
+
+# sort filters look broken
+def sort_email (p1,p2):
+    if p1['email'] == p2['email']: return 0
+    if p1['email'] < p2['email'] : return -1
+    return 1
+
+def get_orphans ():
+    orphans = [p for p in GetPersons({'peer_id':None,'-SORT':'email'}) if not p['site_ids'] ]
+    orphans.sort(sort_email)
+    return orphans
+
+def list_person (margin,p):
+    print margin,'%6d'%p['person_id'], time.asctime(time.gmtime(p['date_created'])),
+    if not p['peer_id']: print 'LOCAL',
+    else: print 'pr=',p['peer_id'],
+    if p['enabled']: print 'ENB',
+    else: print 'DIS',
+    print p['email']
+
+date_keys=['date_created','last_updated']
+def details_person (p):
+    keys=p.keys()
+    keys.sort()
+    for key in keys:
+        print key,'->',
+        value=p[key]
+        if key in date_keys:    print time.asctime(time.gmtime(value))
+        else:                   print value
+
+def get_related(email):
+    return GetPersons ({'email':email,'~peer_id':None})
+
+def header (message):
+    print '--------------------'
+    print GetPeerName(),
+    print time.asctime(time.gmtime())
+    print 'Listing orphan accounts and any similar remote'
+    print '--------------------'
+
+def delete_local (person,default_bool,options):
+    
+    # just in case
+    if person['peer_id'] != None:
+        print 'ERROR: cannot delete non-local person',person['email']
+        return
+
+    prompt = 'want to delete '+person['email']
+    if default_bool:    prompt += ' v(erbose)/[y]/n ? '
+    else:               prompt += ' v(erbose)y/[n] ? '
+
+    done=False
+
+    while not done:
+        done=True
+        try:
+            answer = raw_input(prompt).strip()
+        except EOFError :
+            print 'bailing out'
+            sys.exit(1)
+
+        if answer=='':
+            do_delete=default_bool
+        elif answer.lower()[0]=='y':
+            do_delete=True
+        elif answer.lower()[0]=='n':
+            do_delete=False
+        elif answer.lower()[0]=='v':
+            details_person(person)
+            done=False
+        else:
+            done=False
+    id=person['person_id']
+    email=person['email']
+    if options.dry_run:
+        if do_delete:                   print 'Would delete',id,'->',email
+        else:                           print 'Would preserve',id,'->',email
+    elif do_delete:
+        print 'Deleting',id,'->',email,
+        if DeletePerson(id) == 1:       print 'OK',id,'deleted'
+        else:                           print 'Deletion failed'
+
+def main_orphans (options):
+    orphans = get_orphans()
+    header ('Listing  %d  local accounts with no site - and similar remote accounts'%len(orphans))
+    index=0
+    for local in orphans:
+        index+=1
+        list_person ("%3d"%index,local)
+        for related in get_related(local['email']):
+            list_person("dup",related)
+        if options.delete:
+            delete_default = not local['enabled']
+            delete_local(local,delete_default,options)
+    
+def main_duplicates(options):
+
+    header ('Listing all duplicate accounts')
+    locals = GetPersons({'peer_id':None,'-SORT':'email'})
+    locals.sort(sort_email)
+    index=0
+    for local in locals:
+        remotes=GetPersons({'email':local['email'],'~peer_id':None})
+        if remotes:
+            index+=1
+            list_person('%3d'%index,local)
+            for remote in remotes:
+                list_person('dup',remote)
+            if options.delete:
+                delete_default = not local['enabled']
+                delete_local(local,delete_default,options)
+
+def run (options):
+    main_orphans(options)
+    main_duplicates(options)
+
+def main():
+
+    usage="%prog [ -- options]"
+
+    parser = OptionParser(usage=usage)
+    parser.add_option("-l","--log", dest="log", action="store_true",default=False,
+                      help="write current status in /var/log/accounts")
+    parser.add_option("-d","--delete", dest="delete", action="store_true",default=False,
+                      help="interactively delete extraneous accounts")
+    parser.add_option("-n","--dry-run", dest="dry_run", action="store_true",default=False,
+                      help="go through the delete prompting but does not delete")
+
+    (options,args) = parser.parse_args()
+    if len(args)!=0:
+        parser.error("Unexpected arguments",args)
+
+    if options.dry_run: options.delete=True
+    
+    if options.log:
+        options.delete=False
+        run_in_log(options)
+    else:
+        run(options)
+    
+if __name__ == '__main__':
+    main()
similarity index 100%
rename from refresh-peer.py
rename to bin/refresh-peer.py
diff --git a/bootstrap.xml b/bootstrap.xml
deleted file mode 100644 (file)
index b88e816..0000000
+++ /dev/null
@@ -1,53 +0,0 @@
-<?xml version="1.0"?>
-<!DOCTYPE configuration PUBLIC "-//PlanetLab Central//DTD PLC configuration//EN" "configuration.dtd">
-
-<configuration>
-
-  <!-- This overlay configuration file changes the DB, web, API, and
-       boot server ports to (hopefully unused) ports so that the
-       system can be bootstrapped on a build machine that may itself
-       be running such servers. -->
-
-  <variables>
-    <category id="plc_db">
-      <variablelist>
-       <variable id="port" type="int">
-         <value>15432</value>
-       </variable>
-      </variablelist>
-    </category>
-
-    <category id="plc_api">
-      <variablelist>
-       <variable id="port" type="int">
-         <value>10080</value>
-       </variable>
-      </variablelist>
-    </category>
-
-    <category id="plc_www">
-      <variablelist>
-       <variable id="port" type="int">
-         <value>10080</value>
-       </variable>
-
-       <variable id="ssl_port" type="int">
-         <value>10443</value>
-       </variable>
-      </variablelist>
-    </category>
-
-    <category id="plc_boot">
-      <variablelist>
-       <variable id="port" type="int">
-         <value>10080</value>
-       </variable>
-
-       <variable id="ssl_port" type="int">
-         <value>10443</value>
-       </variable>
-      </variablelist>
-    </category>
-  </variables>
-
-</configuration>
diff --git a/build-chroot.sh b/build-chroot.sh
deleted file mode 100755 (executable)
index 8e5d9b4..0000000
+++ /dev/null
@@ -1,139 +0,0 @@
-#!/bin/bash
-#
-# Builds MyPLC in the current host environment
-# This is for the so-called chroot installation mode, meaning that
-# the resulting rpm will install a full chroot image in /plc/root
-# that can be run through chroot /plc/root
-# This chroot mode is to be opposed to the native mode (see build-native.sh)
-# that can be used in the host's root context or within a vserver
-#
-# root.img (loopback image)
-# root/ (mount point)
-# data/ (various data files)
-# data/etc/planetlab/ (configuration files)
-# data/root (root's homedir)
-#
-# Mark Huang <mlhuang@cs.princeton.edu>
-# Copyright (C) 2006 The Trustees of Princeton University
-#
-# $Id$
-#
-
-. build.functions
-
-# pldistro expected as $1 - defaults to planetlab
-pldistro=$1 ; shift
-
-# These directories are allowed to grow to unspecified size, so they
-# are stored as symlinks to the /data partition. mkfedora and yum
-# expect some of them to be real directories, however.
-datadirs=(
-/etc/planetlab
-/root
-/var/lib/pgsql
-/var/www/html/alpina-logs
-/var/www/html/boot
-/var/www/html/download
-/var/www/html/download-${pldistro}-${pl_DISTRO_ARCH}
-/var/www/html/files
-/var/www/html/sites
-/var/www/html/generated
-/var/www/html/install-rpms
-/var/www/html/xml
-/tmp
-/usr/tmp
-/var/tmp
-/var/log
-)
-
-pl_fixdirs root "${datadirs[@]}"
-
-echo "* myplc: Installing base filesystem"
-mkdir -p root data
-
-pl_root_makedevs root
-pkgsfile=$(pl_locateDistroFile ../build/ ${pldistro} myplc.pkgs)
-pl_root_mkfedora root $pldistro $pkgsfile
-pl_root_tune_image root
-
-# Install configuration scripts
-echo "* myplc: Installing configuration scripts"
-install -D -m 755 plc_config.py root/tmp/plc_config.py
-chroot root sh -c 'cd /tmp; python plc_config.py build; python plc_config.py install'
-install -D -m 755 plc-config root/usr/bin/plc-config
-install -D -m 755 plc-config-tty root/usr/bin/plc-config-tty
-install -D -m 755 db-config root/usr/bin/db-config
-install -D -m 755 dns-config root/usr/bin/dns-config
-install -D -m 755 plc-map.py root/usr/bin/plc-map.py
-install -D -m 755 plc-kml.py root/usr/bin/plc-kml.py
-install -D -m 755 refresh-peer.py root/usr/bin/refresh-peer.py
-install -D -m 755 clean-empty-dirs.py root/usr/bin/clean-empty-dirs.py
-install -D -m 755 mtail.py root/usr/bin/mtail.py
-install -D -m 755 check-ssl-peering.py root/usr/bin/check-ssl-peering.py
-# Extra scripts (mostly for mail and dns) not installed by myplc by default.  Used in production
-mkdir root/etc/support-scripts
-cp support-scripts/* root/etc/support-scripts 
-# copy initscripts to etc/plc_sliceinitscripts
-mkdir root/etc/plc_sliceinitscripts
-cp plc_sliceinitscripts/* root/etc/plc_sliceinitscripts
-
-# Install initscripts
-echo "* myplc: Installing initscripts"
-find plc.d | cpio -p -d -u root/etc/
-install -D -m 755 guest.init root/etc/init.d/plc
-chroot root sh -c 'chkconfig --add plc; chkconfig plc on'
-
-# fetch the release stamp from the build if any
-# I could not come up with any more sensitive scheme 
-if [ -f ../../../myplc-release ] ; then
-  cp ../../../myplc-release myplc-release
-else
-  echo "Cannot find release information." > myplc-release
-  date >> myplc-release
-  echo "$HeadURL$" >> myplc-release
-fi
-# install it in /etc/myplc-release 
-install -m 444 myplc-release root/etc/myplc-release
-
-### Thierry Parmentelat - april 16 2007
-# fix the yum.conf as produced by mkfedora
-# so we can use the build's fc4 mirror for various installs/upgrades
-# within the chroot jail
-# yum_conf_to_build_host is defined in build.functions
-yum_conf_to_build_host ../build > root/etc/yum.conf
-
-### Thierry Parmentelat - may 8 2008
-# no doc built in this old-fashioned packaging anymore
-# use myplc-docs instead
-
-# Install configuration file
-echo "* myplc: Installing configuration file"
-install -D -m 444 default_config.xml data/etc/planetlab/default_config.xml
-install -D -m 444 plc_config.dtd data/etc/planetlab/plc_config.dtd
-
-# handle root's homedir and tweak root prompt
-echo "* myplc: root's homedir and prompt"
-roothome=data/root
-mkdir -p $roothome
-cat << EOF > $roothome/.profile
-export PS1="<plc> \$PS1"
-EOF
-chmod 644 $roothome/.profile
-
-# Move "data" directories out of the installation
-echo "* myplc: Moving data directories out of the installation"
-pl_move_dirs root data /data "${datadirs[@]}"
-
-# Fix permissions on tmp directories
-pl_fixtmp_permissions data
-
-# Remove generated bootmanager script
-rm -f data/var/www/html/boot/bootmanager.sh
-
-# yumgroups.xml and yum repo : let noderepo handle that
-
-# Make image out of directory
-echo "* myplc: Building loopback image"
-pl_make_image root root.img 100000000
-
-exit 0
diff --git a/build.functions b/build.functions
deleted file mode 100644 (file)
index a96e295..0000000
+++ /dev/null
@@ -1,82 +0,0 @@
-# -*-Shell-script-*-
-#
-# Common functions for MyPLC build scripts (build_devel.sh and
-# build.sh)
-#
-# Mark Huang <mlhuang@cs.princeton.edu>
-# Copyright (C) 2006 The Trustees of Princeton University
-#
-# $Id$
-#
-
-PATH=/sbin:/bin:/usr/sbin:/usr/bin
-
-# In both a normal CVS environment and a PlanetLab RPM
-# build environment, all of our dependencies are checked out into
-# directories at the same level as us.
-if [ -d ../build ] ; then
-    PATH=$PATH:../build
-    srcdir=..
-else
-    echo "Error: Could not find $(cd .. && pwd -P)/build/"
-    exit 1
-fi
-
-export PATH
-
-. build.common
-
-pl_process_fedora_options $@
-shiftcount=$?
-shift $shiftcount
-
-# XXX Backwards compatibility with old myplc-devel environment
-# We may be running inside a myplc-devel environment, which can
-# override these defaults.
-if [ -f /etc/planetlab/plc_config ] ; then
-    . /etc/planetlab/plc_config
-    [ ! -z "$PLC_DEVEL_FEDORA_RELEASE" ] && pl_FEDORA_RELEASE=$PLC_DEVEL_FEDORA_RELEASE
-    [ ! -z "$PLC_DEVEL_FEDORA_ARCH" ] && pl_FEDORA_ARCH=$PLC_DEVEL_FEDORA_ARCH
-    [ ! -z "$PLC_DEVEL_FEDORA_URL" ] && pl_FEDORA_URL=$PLC_DEVEL_FEDORA_URL
-fi
-
-# Do not tolerate errors
-set -e
-
-# Be verbose
-set -x
-
-# this is fragile, as the actual layout may vary from one mirror to the other
-# however this should be in line with the layouts obtained 
-# when running build/vbuild-fedora-mirror.sh
-
-function yum_conf_to_build_host () {
-    build_dir=$1; shift
-    BUILD_HOST=$(hostname)
-
-    cat <<EOF
-[main]
-cachedir=/var/cache/yum
-debuglevel=2
-logfile=/var/log/yum.log
-pkgpolicy=newest
-distroverpkg=redhat-release
-tolerant=1
-exactarch=1
-retries=10
-obsoletes=1
-gpgcheck=0
-# Prevent yum-2.4 from loading additional repository definitions
-# (e.g., from /etc/yum.repos.d/)
-reposdir=/dev/null
-
-EOF
-
-    template=$build_dir/mirroring/${pl_DISTRO_NAME}/yum.repos.d/building.repo.in
-    if [ ! -f $template ] ; then
-       echo "# MyPLC/$0: cannot find template $template"
-    else
-       sed -e s,@MIRRORURL@,http://${BUILD_HOST}/mirror/, $template
-    fi
-}
-
diff --git a/build.sh b/build.sh
deleted file mode 100755 (executable)
index 8ac4f25..0000000
--- a/build.sh
+++ /dev/null
@@ -1,59 +0,0 @@
-#!/bin/bash
-#
-# Builds MyPLC, either inside the MyPLC development environment in
-# devel/root (if PLC_DEVEL_BOOTSTRAP is true), or in the current host
-# environment (may be itself a MyPLC development environment or a
-# Fedora environment with the appropriate development packages
-# installed).
-#
-# Marc E. Fiuczynski <mef@cs.princeton.edu>
-# Copyright (C) 2007 The Trustees of Princeton University
-#
-# $Id$
-#
-
-. build.functions
-
-# XXX .spec file needs to have the appropriate set of requires statements
-
-# Install configuration scripts
-echo "* myplc-native: Installing configuration scripts"
-pldistro=$1; shift
-RPM_BUILD_ROOT=$1 ; shift
-rm -rf ${RPM_BUILD_ROOT}
-mkdir -p ${RPM_BUILD_ROOT}
-echo "* myplc-native: installing plc_config.py in /usr/share/myplc"
-install -D -m 755 plc_config.py ${RPM_BUILD_ROOT}/usr/share/myplc/plc_config.py
-install -D -m 644 bashrc ${RPM_BUILD_ROOT}/usr/share/myplc/bashrc
-echo "* myplc-native: installing scripts in /usr/bin"
-install -D -m 755 plc-config ${RPM_BUILD_ROOT}/usr/bin/plc-config
-install -D -m 755 plc-config-tty ${RPM_BUILD_ROOT}/usr/bin/plc-config-tty
-install -D -m 755 db-config ${RPM_BUILD_ROOT}/usr/bin/db-config
-install -D -m 755 dns-config ${RPM_BUILD_ROOT}/usr/bin/dns-config
-install -D -m 755 plc-map.py ${RPM_BUILD_ROOT}/usr/bin/plc-map.py
-install -D -m 755 plc-kml.py ${RPM_BUILD_ROOT}/usr/bin/plc-kml.py
-install -D -m 755 refresh-peer.py ${RPM_BUILD_ROOT}/usr/bin/refresh-peer.py
-install -D -m 755 clean-empty-dirs.py ${RPM_BUILD_ROOT}/usr/bin/clean-empty-dirs.py
-install -D -m 755 mtail.py ${RPM_BUILD_ROOT}/usr/bin/mtail.py
-install -D -m 755 check-ssl-peering.py ${RPM_BUILD_ROOT}/usr/bin/check-ssl-peering.py
-# Extra scripts (mostly for mail and dns) not installed by myplc by default.  Used in production
-echo "* myplc-native: installing scripts in /etc/support-scripts"
-mkdir -p ${RPM_BUILD_ROOT}/etc/support-scripts
-cp support-scripts/* ${RPM_BUILD_ROOT}/etc/support-scripts
-# copy initscripts to etc/plc_sliceinitscripts
-mkdir -p ${RPM_BUILD_ROOT}/etc/plc_sliceinitscripts
-cp plc_sliceinitscripts/* ${RPM_BUILD_ROOT}/etc/plc_sliceinitscripts
-
-# Install initscripts
-echo "* myplc-native: Installing initscripts"
-find plc.d | cpio -p -d -u ${RPM_BUILD_ROOT}/etc/
-install -D -m 755 guest.init ${RPM_BUILD_ROOT}/etc/init.d/plc
-
-# Install configuration file
-echo "* myplc: Installing configuration file"
-install -D -m 444 default_config.xml ${RPM_BUILD_ROOT}/etc/planetlab/default_config.xml
-install -D -m 444 plc_config.dtd ${RPM_BUILD_ROOT}/etc/planetlab/plc_config.dtd
-
-# yumgroups.xml and yum repo : let noderepo handle that
-
-exit 0
diff --git a/db-config b/db-config
deleted file mode 100755 (executable)
index 16c1366..0000000
--- a/db-config
+++ /dev/null
@@ -1,1125 +0,0 @@
-#!/usr/bin/env /usr/bin/plcsh
-#
-# Bootstraps the PLC database with a default administrator account and
-# a default site, defines default slice attribute types, and
-# creates/updates default system slices.
-#
-# Mark Huang <mlhuang@cs.princeton.edu>
-# Copyright (C) 2006 The Trustees of Princeton University
-#
-# $Id$
-# $HeadURL$
-
-from plc_config import PLCConfiguration
-import sys
-import resource
-
-def main():
-    cfg = PLCConfiguration()
-    cfg.load()
-    variables = cfg.variables()
-
-    # Load variables into dictionaries
-    for category_id, (category, variablelist) in variables.iteritems():
-        globals()[category_id] = dict(zip(variablelist.keys(),
-                                       [variable['value'] for variable in variablelist.values()]))
-
-    # Create/update the default administrator account (should be
-    # person_id 2).
-    admin = { 'person_id': 2,
-              'first_name': "Default",
-              'last_name': "Administrator",
-              'email': plc['root_user'],
-              'password': plc['root_password'] }
-    persons = GetPersons([admin['person_id']])
-    if not persons:
-        person_id = AddPerson(admin)
-        if person_id != admin['person_id']:
-            # Huh? Someone deleted the account manually from the database.
-            DeletePerson(person_id)
-            raise Exception, "Someone deleted the \"%s %s\" account from the database!" % \
-                  (admin['first_name'], admin['last_name'])
-        UpdatePerson(person_id, { 'enabled': True })
-    else:
-        person_id = persons[0]['person_id']
-        UpdatePerson(person_id, admin)
-
-    # Create/update the default site (should be site_id 1)
-    if plc_www['port'] == '80':
-        url = "http://" + plc_www['host'] + "/"
-    elif plc_www['port'] == '443':
-        url = "https://" + plc_www['host'] + "/"
-    else:
-        url = "http://" + plc_www['host'] + ":" + plc_www['port'] + "/"
-    site = { 'site_id': 1,
-             'name': plc['name'] + " Central",
-             'abbreviated_name': plc['name'],
-             'login_base': plc['slice_prefix'],
-             'is_public': False,
-             'url': url,
-             'max_slices': 100 }
-
-    sites = GetSites([site['site_id']])
-    if not sites:
-        site_id = AddSite(site['name'], site['abbreviated_name'], site['login_base'], site)
-        if site_id != site['site_id']:
-            DeleteSite(site_id)
-            raise Exception, "Someone deleted the \"%s\" site from the database!" % \
-                  site['name']
-        sites = [site]
-
-    # Must call UpdateSite() even after AddSite() to update max_slices
-    site_id = sites[0]['site_id']
-    UpdateSite(site_id, site)
-
-    # The default administrator account must be associated with a site
-    # in order to login.
-    AddPersonToSite(admin['person_id'], site['site_id'])
-    SetPersonPrimarySite(admin['person_id'], site['site_id'])
-
-    # Grant admin and PI roles to the default administrator account
-    AddRoleToPerson(10, admin['person_id'])
-    AddRoleToPerson(20, admin['person_id'])
-
-    #################### node tags
-    default_node_types = [
-        { 'tagname' : 'arch',
-          'description' : 'architecture name',
-          'category' : 'node/config', 
-          'min_role_id' : 40} ,
-        { 'tagname' : 'pldistro',
-          'description' : 'PlanetLab distribution',
-          'category' : 'node/config', 
-          'min_role_id' : 10} ,
-        { 'tagname' : 'deployment',
-          'description' : 'typically "alpha", "beta", or "production"',
-          'category' : 'node/operation', 
-          'min_role_id' : 10} ,
-        ]
-
-    #################### interface settings
-    # xxx this should move to PLC/Accessors
-
-    # Setup default slice attribute types
-    default_setting_types = [
-        {'category' : "interface/general",
-         'tagname' : "ifname",
-         'description': "Set interface name, instead of eth0 or the like",
-         'min_role_id' : 40},
-        {'category' : "interface/multihome",
-         'tagname' : "alias",
-         'description': "Specifies that the network is used for multihoming",
-         'min_role_id' : 40},
-
-        {'category' : "interface/hidden",
-         'tagname' : "backdoor",
-         'description': "For testing new settings",
-         'min_role_id' : 10},
-        ] + [
-        { 'category' : "interface/wifi",
-          'tagname' : x,
-          'description' : "802.11 %s -- see %s"%(y,z),
-          'min_role_id' : 40 } for (x,y,z) in [
-            ("mode","Mode","iwconfig"),
-            ("essid","ESSID","iwconfig"),
-            ("nw","Network Id","iwconfig"),
-            ("freq","Frequency","iwconfig"),
-            ("channel","Channel","iwconfig"),
-            ("sens","sensitivity threshold","iwconfig"),
-            ("rate","Rate","iwconfig"),
-            ("key","key","iwconfig key"),
-            ("key1","key1","iwconfig key [1]"),
-            ("key2","key2","iwconfig key [2]"),
-            ("key3","key3","iwconfig key [3]"),
-            ("key4","key4","iwconfig key [4]"),
-            ("securitymode","Security mode","iwconfig enc"),
-            ("iwconfig","Additional parameters to iwconfig","ifup-wireless"),
-            ("iwpriv","Additional parameters to iwpriv","ifup-wireless"),
-            ]
-        ]
-
-    #################### slice attributes
-    # xxx this should move to PLC/Accessors
-
-    # Setup default slice attribute types
-    default_attribute_types = [
-        # Slice type (only vserver is supported)
-        {'tagname': "type",
-         'description': "Type of slice (e.g. vserver)",
-         'category' : 'slice/general',
-         'min_role_id': 20},
-
-        # System slice
-        {'tagname': "system",
-         'description': "Is a default system slice (1) or not (0 or unset)",
-         'category' : 'slice/general',
-         'min_role_id': 10},
-
-        # Slice enabled (1) or suspended (0)
-        {'tagname': "enabled",
-         'description': "Slice enabled (1 or unset) or suspended (0)",
-         'category' : 'slice/general',
-         'min_role_id': 10},
-
-        # Slice reference image
-        {'tagname': "vref",
-         'description': "Reference image",
-         'category' : 'slice/config',
-         'min_role_id': 30},
-
-        # Slice initialization script
-        {'tagname': "initscript",
-         'description': "Slice initialization script",
-         'category' : 'slice/config',
-         'min_role_id': 10},
-
-        # CPU share
-        {'tagname': "cpu_pct",
-         'description': "Reserved CPU percent",
-         'category' : 'slice/rspec',
-         'min_role_id': 10},
-        {'tagname': "cpu_share",
-         'description': "Number of CPU shares",
-         'category' : 'slice/rspec',
-         'min_role_id': 10},
-
-        # Bandwidth limits
-        {'tagname': "net_min_rate",
-         'description': "Minimum bandwidth (kbps)",
-         'category' : 'slice/rspec',
-         'min_role_id': 10},
-        {'tagname': "net_max_rate",
-         'description': "Maximum bandwidth (kbps)",
-         'category' : 'slice/rspec',
-         'min_role_id': 10},
-        {'tagname': "net_i2_min_rate",
-         'description': "Minimum bandwidth over I2 routes (kbps)",
-         'category' : 'slice/rspec',
-         'min_role_id': 10},
-        {'tagname': "net_i2_max_rate",
-         'description': "Maximum bandwidth over I2 routes (kbps)",
-         'category' : 'slice/rspec',
-         'min_role_id': 10},
-        {'tagname': "net_max_kbyte",
-         'description': "Maximum daily network Tx KByte limit.",
-         'category' : 'slice/rspec',
-         'min_role_id': 10},
-        {'tagname': "net_thresh_kbyte",
-         'description': "KByte limit before warning and throttling.",
-         'category' : 'slice/rspec',
-         'min_role_id': 10},
-        {'tagname': "net_i2_max_kbyte",
-         'description': "Maximum daily network Tx KByte limit to I2 hosts.",
-         'category' : 'slice/rspec',
-         'min_role_id': 10},
-        {'tagname': "net_i2_thresh_kbyte",
-         'description': "KByte limit to I2 hosts before warning and throttling.",
-         'category' : 'slice/rspec',
-         'min_role_id': 10},
-        {'tagname': "net_share",
-         'description': "Number of bandwidth shares",
-         'category' : 'slice/rspec',
-         'min_role_id': 10},
-        {'tagname': "net_i2_share",
-         'description': "Number of bandwidth shares over I2 routes",
-         'category' : 'slice/rspec',
-         'min_role_id': 10},
-        # Disk quota
-        {'tagname': "disk_max",
-         'description': "Disk quota (1k disk blocks)",
-         'category' : 'slice/rspec',
-         'min_role_id': 10},
-
-        # Proper operations
-        {'tagname': "proper_op",
-         'description': "Proper operation (e.g. bind_socket)",
-         'category' : 'slice/rspec',
-         'min_role_id': 10},
-
-        # VServer capabilities 
-        {'tagname': "capabilities",
-         'description': "VServer bcapabilities (separate by commas)",
-         'category' : 'slice/rspec',
-         'min_role_id': 10},
-
-        # Vsys
-        {'tagname': "vsys",
-         'description': "Bind vsys script fd's to a slice's vsys directory.",
-         'category' : 'slice/rspec',
-         'min_role_id': 10},
-
-        # CoDemux
-        {'tagname': "codemux",
-         'description': "Demux HTTP between slices using localhost ports. Value in the form 'host, localhost port'.",
-         'category' : 'slice/rspec',
-         'min_role_id': 10},
-
-        # Delegation
-        {'tagname': "delegations",
-         'description': "Coma seperated list of slices to give delegation authority to.",
-         'category' : 'slice/rspec',
-         'min_role_id': 10}
-
-        ]
-
-    # add in the platform supported rlimits to the default_attribute_types
-    for entry in resource.__dict__.keys() + ["VLIMIT_OPENFD"]:
-        if entry.find("LIMIT_")==1:
-            rlim = entry[len("RLIMIT_"):]
-            rlim = rlim.lower()
-            for ty in ("min","soft","hard"):
-                attribute = {
-                    'tagname': "%s_%s"%(rlim,ty),
-                    'description': "Per sliver RLIMIT %s_%s."%(rlim,ty),
-                    'category': 'slice/limit',
-                    'min_role_id': 10 #admin
-                    }
-                default_attribute_types.append(attribute)
-
-    # Get list of existing tag types
-    known_tag_types = [tag_type['tagname'] for tag_type in GetTagTypes()]
-
-    all_default_types = default_node_types + default_setting_types + default_attribute_types
-    # Create/update default slice tag types
-    for default_tag_type in all_default_types:
-        if default_tag_type['tagname'] not in known_tag_types:
-            AddTagType(default_tag_type)
-        else:
-            UpdateTagType(default_tag_type['tagname'], default_tag_type)
-
-    #################### conf files
-
-    # Setup default PlanetLabConf entries
-    default_conf_files = [
-        # NTP configuration
-        {'enabled': True,
-         'source': 'PlanetLabConf/ntp.conf.php',
-         'dest': '/etc/ntp.conf',
-         'file_permissions': '644',
-         'file_owner': 'root',
-         'file_group': 'root',
-         'preinstall_cmd': '',
-         'postinstall_cmd': '/etc/rc.d/init.d/ntpd restart',
-         'error_cmd': '',
-         'ignore_cmd_errors': False,
-         'always_update': False},
-        {'enabled': True,
-         'source': 'PlanetLabConf/ntp/step-tickers.php',
-         'dest': '/etc/ntp/step-tickers',
-         'file_permissions': '644',
-         'file_owner': 'root',
-         'file_group': 'root',
-         'preinstall_cmd': '',
-         'postinstall_cmd': '/etc/rc.d/init.d/ntpd restart',
-         'error_cmd': '',
-         'ignore_cmd_errors': False,
-         'always_update': False},
-
-        # SSH server configuration
-        {'enabled': True,
-         'source': 'PlanetLabConf/sshd_config',
-         'dest': '/etc/ssh/sshd_config',
-         'file_permissions': '600',
-         'file_owner': 'root',
-         'file_group': 'root',
-         'preinstall_cmd': '',
-         'postinstall_cmd': '/etc/init.d/sshd restart',
-         'error_cmd': '',
-         'ignore_cmd_errors': False,
-         'always_update': False},
-
-        # Administrative SSH keys
-        {'enabled': True,
-         'source': 'PlanetLabConf/keys.php?root',
-         'dest': '/root/.ssh/authorized_keys',
-         'file_permissions': '644',
-         'file_owner': 'root',
-         'file_group': 'root',
-         'preinstall_cmd': '',
-         'postinstall_cmd': '/bin/chmod 700 /root/.ssh',
-         'error_cmd': '',
-         'ignore_cmd_errors': False,
-         'always_update': False},
-        {'enabled': True,
-         'source': 'PlanetLabConf/keys.php?site_admin',
-         'dest': '/home/site_admin/.ssh/authorized_keys',
-         'file_permissions': '644',
-         'file_owner': 'site_admin',
-         'file_group': 'site_admin',
-         'preinstall_cmd': 'grep -q site_admin /etc/passwd',
-         'postinstall_cmd': '/bin/chmod 700 /home/site_admin/.ssh',
-         'error_cmd': '',
-         'ignore_cmd_errors': False,
-         'always_update': False},
-        # Log rotation configuration
-        {'enabled': True,
-         'source': 'PlanetLabConf/logrotate.conf',
-         'dest': '/etc/logrotate.conf',
-         'file_permissions': '644',
-         'file_owner': 'root',
-         'file_group': 'root',
-         'preinstall_cmd': '',
-         'postinstall_cmd': '',
-         'error_cmd': '',
-         'ignore_cmd_errors': False,
-         'always_update': False},
-
-        # updatedb/locate nightly cron job
-        {'enabled': True,
-         'source': 'PlanetLabConf/slocate.cron',
-         'dest': '/etc/cron.daily/slocate.cron',
-         'file_permissions': '755',
-         'file_owner': 'root',
-         'file_group': 'root',
-         'preinstall_cmd': '',
-         'postinstall_cmd': '',
-         'error_cmd': '',
-         'ignore_cmd_errors': False,
-         'always_update': False},
-
-        # YUM configuration
-        {'enabled': True,
-         'source': 'yum/myplc.repo.php?gpgcheck=1',
-         'dest': '/etc/yum.myplc.d/myplc.repo',
-         'file_permissions': '644', 'file_owner': 'root', 'file_group': 'root',
-         'preinstall_cmd': '', 'postinstall_cmd': '', 'error_cmd': '',
-         'ignore_cmd_errors': False,
-         'always_update': False},
-        {'enabled': True,
-         'source': 'yum/yum.conf',
-         'dest': '/etc/yum.conf',
-         'file_permissions': '644', 'file_owner': 'root', 'file_group': 'root',
-         'preinstall_cmd': '', 'postinstall_cmd': '', 'error_cmd': '',
-         'ignore_cmd_errors': False,
-         'always_update': False},
-        {'enabled': True,
-         'source': 'yum/stock.repo',
-         'dest': '/etc/yum.myplc.d/stock.repo',
-         'file_permissions': '644', 'file_owner': 'root', 'file_group': 'root',
-         'preinstall_cmd': '', 'postinstall_cmd': '', 'error_cmd': '',
-         'ignore_cmd_errors': False,
-         'always_update': False},
-
-        {'enabled': True,
-         'source': 'PlanetLabConf/delete-rpm-list-production',
-         'dest': '/etc/planetlab/delete-rpm-list',
-         'file_permissions': '644',
-         'file_owner': 'root',
-         'file_group': 'root',
-         'preinstall_cmd': '',
-         'postinstall_cmd': '',
-         'error_cmd': '',
-         'ignore_cmd_errors': False,
-         'always_update': False},
-
-        # PLC configuration
-        {'enabled': True,
-         'source': 'PlanetLabConf/get_plc_config.php',
-         'dest': '/etc/planetlab/plc_config',
-         'file_permissions': '644',
-         'file_owner': 'root',
-         'file_group': 'root',
-         'preinstall_cmd': '',
-         'postinstall_cmd': '',
-         'error_cmd': '',
-         'ignore_cmd_errors': False,
-         'always_update': False},
-        {'enabled': True,
-         'source': 'PlanetLabConf/get_plc_config.php?python',
-         'dest': '/etc/planetlab/plc_config.py',
-         'file_permissions': '644',
-         'file_owner': 'root',
-         'file_group': 'root',
-         'preinstall_cmd': '',
-         'postinstall_cmd': '',
-         'error_cmd': '',
-         'ignore_cmd_errors': False,
-         'always_update': False},
-        {'enabled': True,
-         'source': 'PlanetLabConf/get_plc_config.php?perl',
-         'dest': '/etc/planetlab/plc_config.pl',
-         'file_permissions': '644',
-         'file_owner': 'root',
-         'file_group': 'root',
-         'preinstall_cmd': '',
-         'postinstall_cmd': '',
-         'error_cmd': '',
-         'ignore_cmd_errors': False,
-         'always_update': False},
-        {'enabled': True,
-         'source': 'PlanetLabConf/get_plc_config.php?php',
-         'dest': '/etc/planetlab/php/plc_config.php',
-         'file_permissions': '644',
-         'file_owner': 'root',
-         'file_group': 'root',
-         'preinstall_cmd': '',
-         'postinstall_cmd': '',
-         'error_cmd': '',
-         'ignore_cmd_errors': False,
-         'always_update': False},
-
-        # XXX Required for old Node Manager
-        # Proper configuration
-        {'enabled': True,
-         'source': 'PlanetLabConf/propd.conf',
-         'dest': '/etc/proper/propd.conf',
-         'file_permissions': '644',
-         'file_owner': 'root',
-         'file_group': 'root',
-         'preinstall_cmd': '',
-         'postinstall_cmd': '/etc/init.d/proper restart',
-         'error_cmd': '',
-         'ignore_cmd_errors': True,
-         'always_update': False},
-
-        # XXX Required for old Node Manager
-        # Bandwidth cap
-        {'enabled': True,
-         'source': 'PlanetLabConf/bwlimit.php',
-         'dest': '/etc/planetlab/bwcap',
-         'file_permissions': '644',
-         'file_owner': 'root',
-         'file_group': 'root',
-         'preinstall_cmd': '',
-         'postinstall_cmd': '',
-         'error_cmd': '',
-         'ignore_cmd_errors': True,
-         'always_update': False},
-
-        # Proxy ARP setup
-        {'enabled': True,
-         'source': 'PlanetLabConf/proxies.php',
-         'dest': '/etc/planetlab/proxies',
-         'file_permissions': '644',
-         'file_owner': 'root',
-         'file_group': 'root',
-         'preinstall_cmd': '',
-         'postinstall_cmd': '',
-         'error_cmd': '',
-         'ignore_cmd_errors': False,
-         'always_update': False},
-
-        # Firewall configuration
-        {'enabled': True,
-         'source': 'PlanetLabConf/blacklist.php',
-         'dest': '/etc/planetlab/blacklist',
-         'file_permissions': '600',
-         'file_owner': 'root',
-         'file_group': 'root',
-         'preinstall_cmd': '',
-         'postinstall_cmd': '/sbin/iptables-restore --noflush < /etc/planetlab/blacklist',
-         'error_cmd': '',
-         'ignore_cmd_errors': True,
-         'always_update': False},
-
-        # /etc/issue
-        {'enabled': True,
-         'source': 'PlanetLabConf/issue.php',
-         'dest': '/etc/issue',
-         'file_permissions': '644',
-         'file_owner': 'root',
-         'file_group': 'root',
-         'preinstall_cmd': '',
-         'postinstall_cmd': '',
-         'error_cmd': '',
-         'ignore_cmd_errors': False,
-         'always_update': False},
-
-        # Kernel parameters
-        {'enabled': True,
-         'source': 'PlanetLabConf/sysctl.php',
-         'dest': '/etc/sysctl.conf',
-         'file_permissions': '644',
-         'file_owner': 'root',
-         'file_group': 'root',
-         'preinstall_cmd': '',
-         'postinstall_cmd': '/sbin/sysctl -e -p /etc/sysctl.conf',
-         'error_cmd': '',
-         'ignore_cmd_errors': False,
-         'always_update': False},
-
-        # Sendmail configuration
-        {'enabled': True,
-         'source': 'PlanetLabConf/sendmail.mc',
-         'dest': '/etc/mail/sendmail.mc',
-         'file_permissions': '644',
-         'file_owner': 'root',
-         'file_group': 'root',
-         'preinstall_cmd': '',
-         'postinstall_cmd': '',
-         'error_cmd': '',
-         'ignore_cmd_errors': False,
-         'always_update': False},
-        {'enabled': True,
-         'source': 'PlanetLabConf/sendmail.cf',
-         'dest': '/etc/mail/sendmail.cf',
-         'file_permissions': '644',
-         'file_owner': 'root',
-         'file_group': 'root',
-         'preinstall_cmd': '',
-         'postinstall_cmd': 'service sendmail restart',
-         'error_cmd': '',
-         'ignore_cmd_errors': False,
-         'always_update': False},
-
-        # GPG signing keys
-        {'enabled': True,
-         'source': 'PlanetLabConf/RPM-GPG-KEY-fedora',
-         'dest': '/etc/pki/rpm-gpg/RPM-GPG-KEY-fedora',
-         'file_permissions': '644',
-         'file_owner': 'root',
-         'file_group': 'root',
-         'preinstall_cmd': '',
-         'postinstall_cmd': 'rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-fedora',
-         'error_cmd': '',
-         'ignore_cmd_errors': False,
-         'always_update': False},
-        {'enabled': True,
-         'source': 'PlanetLabConf/get_gpg_key.php',
-         'dest': '/etc/pki/rpm-gpg/RPM-GPG-KEY-planetlab',
-         'file_permissions': '644',
-         'file_owner': 'root',
-         'file_group': 'root',
-         'preinstall_cmd': '',
-         'postinstall_cmd': 'rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-planetlab',
-         'error_cmd': '',
-         'ignore_cmd_errors': False,
-         'always_update': False},
-
-        # Ping of death configuration
-        # the 'restart' postcommand doesn't work, b/c the pod script doesn't support it.
-        {'enabled': True,
-         'source': 'PlanetLabConf/ipod.conf.php',
-         'dest': '/etc/ipod.conf',
-         'file_permissions': '644',
-         'file_owner': 'root',
-         'file_group': 'root',
-         'preinstall_cmd': '',
-         'postinstall_cmd': '/etc/init.d/pod start',
-         'error_cmd': '',
-         'ignore_cmd_errors': False,
-         'always_update': False},
-
-        # sudo configuration
-        {'enabled': True,
-         'source': 'PlanetLabConf/sudoers.php',
-         'dest': '/etc/sudoers',
-         'file_permissions': '440',
-         'file_owner': 'root',
-         'file_group': 'root',
-         'preinstall_cmd': '',
-         'postinstall_cmd': '/usr/sbin/visudo -c',
-         'error_cmd': '',
-         'ignore_cmd_errors': False,
-         'always_update': False}
-        ]
-
-    # Get list of existing (enabled, global) files
-    conf_files = GetConfFiles()
-    conf_files = filter(lambda conf_file: conf_file['enabled'] and \
-                                          not conf_file['node_ids'] and \
-                                          not conf_file['nodegroup_ids'],
-                        conf_files)
-    dests = [conf_file['dest'] for conf_file in conf_files]
-    conf_files = dict(zip(dests, conf_files))
-
-    # Create/update default PlanetLabConf entries
-    for default_conf_file in default_conf_files:
-        if default_conf_file['dest'] not in dests:
-            AddConfFile(default_conf_file)
-        else:
-            conf_file = conf_files[default_conf_file['dest']]
-            UpdateConfFile(conf_file['conf_file_id'], default_conf_file)
-
-
-    #################### initscripts
-
-    # Default Initscripts
-    default_initscripts = []
-
-    # Find initscripts and add them to the db
-    for (root, dirs, files) in os.walk("/etc/plc_sliceinitscripts"):
-        for f in files:
-            # Read the file
-            file = open(root + "/" + f, "ro")
-            default_initscripts.append({"name": plc['slice_prefix'] + "_" + f,
-                                        "enabled": True,
-                                        "script": file.read().replace("@SITE@", url).replace("@PREFIX@", plc['slice_prefix'])})
-            file.close()
-
-    # Get list of existing initscripts
-    oldinitscripts = GetInitScripts()
-    oldinitscripts = [script['name'] for script in oldinitscripts]
-
-    for initscript in default_initscripts:
-        if initscript['name'] not in oldinitscripts:  AddInitScript(initscript)
-
-    # Create/update system slices
-    default_slices = [
-         # PlanetFlow
-        {'name': plc['slice_prefix'] + "_netflow",
-         'description': "PlanetFlow Traffic Auditing Service.  Logs, captured in the root context using fprobe-ulogd, are stored in a directory in the root context which is bind mounted to the planetflow slice.  The Planetflow Central service then periodically rsyncs these logs from the planetflow slice for aggregation.",
-         'url': url,
-         'instantiation': "plc-instantiated",
-         # Renew forever (minus one day, work around date conversion weirdness)
-         'expires': 0x7fffffff - (60 * 60 * 24),
-         'attributes': [('system', "1"),
-                        ('vref', "planetflow"),
-                        ('vsys', "pfmount")]},
-          # Sirius
-        {'name': plc['slice_prefix'] + "_sirius",
-         'description': 'The Sirius Calendar Service.\n\nSirius provides system-wide reservations of 25% CPU and 2Mb/s outgoing\nbandwidth.  Sign up for hour-long slots using the Web GUI at the\nPlanetLab website.\n\nThis slice should not generate traffic external to PlanetLab.\n',
-         'url': url + "db/sirius/index.php",
-         'instantiation': "plc-instantiated",
-         # Renew forever (minus one day, work around date conversion weirdness)
-         'expires': 0x7fffffff - (60 * 60 * 24),
-         'attributes': [('system', "1"),
-                        ('net_min_rate', "2000"),
-                        ('cpu_pct', "25"),
-                        ('initscript', plc['slice_prefix'] + "_sirius")]}
-        ]
-    
-    for default_slice in default_slices:
-        attributes=default_slice.pop('attributes')
-        slices = GetSlices([default_slice['name']])
-        if slices:
-            slice = slices[0]
-            UpdateSlice(slice['slice_id'], default_slice)
-        else:
-            AddSlice(default_slice)
-            slice = GetSlices([default_slice['name']])[0]
-
-        # Create/update all attributes
-        slice_tags = []
-        if slice['slice_tag_ids']:
-            # Delete unknown attributes
-            for slice_tag in GetSliceTags(slice['slice_tag_ids']):
-                if (slice_tag['tagname'], slice_tag['value']) \
-                   not in attributes:
-                    DeleteSliceTag(slice_tag['slice_tag_id'])
-                else:
-                    slice_tags.append((slice_tag['tagname'], slice_tag['value']))
-
-        for (name, value) in attributes:
-            if (name, value) not in slice_tags:
-                AddSliceTag(slice['name'], name, value)
-
-    
-    #################### body for messages
-
-    installfailed = """
-Once the node meets these requirements, please reinitiate the install
-by visiting:
-
-https://%(PLC_WWW_HOST)s:%(PLC_WWW_SSL_PORT)d/db/nodes/?id=%(node_id)d
-
-Update the BootState to 'Reinstall', then reboot the node.
-
-If you have already performed this step and are still receiving this
-message, please reply so that we may investigate the problem.
-"""
-
-    # Load default message templates
-    message_templates = [
-        {'message_id': 'Verify account',
-         'subject': "Verify account registration",
-         'template': """
-Please verify that you registered for a %(PLC_NAME)s account with the
-username %(email)s by visiting:
-
-https://%(PLC_WWW_HOST)s:%(PLC_WWW_SSL_PORT)d/db/persons/register.php?id=%(person_id)d&key=%(verification_key)s
-
-You must wait for this account to be approved before you can begin using it, please be patient.
-
-If you did not register for a %(PLC_NAME)s account, please ignore this
-message, or contact %(PLC_NAME)s Support <%(PLC_MAIL_SUPPORT_ADDRESS)s>.
-"""
-         },
-
-        {'message_id': 'New PI account',
-         'subject': "New PI account registration from %(first_name)s %(last_name)s <%(email)s> at %(site_name)s",
-         'template': """
-%(first_name)s %(last_name)s <%(email)s> has signed up for a new
-%(PLC_NAME)s account at %(site_name)s and has requested a PI role. PIs
-are responsible for enabling user accounts, creating slices, and
-ensuring that all users abide by the %(PLC_NAME)s Acceptable Use
-Policy.
-
-Only %(PLC_NAME)s administrators may enable new PI accounts. If you
-are a PI at %(site_name)s, please respond and indicate whether this
-registration is acceptable.
-
-To view the request, visit:
-
-https://%(PLC_WWW_HOST)s:%(PLC_WWW_SSL_PORT)d/db/persons/index.php?id=%(person_id)d
-"""
-         },
-
-        {'message_id': 'New account',
-         'subject': "New account registration from %(first_name)s %(last_name)s <%(email)s> at %(site_name)s",
-         'template': """
-%(first_name)s %(last_name)s <%(email)s> has signed up for a new
-%(PLC_NAME)s account at %(site_name)s and has requested the following
-roles: %(roles)s.
-
-To deny the request or enable the account, visit:
-
-https://%(PLC_WWW_HOST)s:%(PLC_WWW_SSL_PORT)d/db/persons/index.php?id=%(person_id)d
-"""
-         },
-
-        {'message_id': 'Password reset requested',
-         'subject': "Password reset requested",
-         'template': """
-Someone has requested that the password of your %(PLC_NAME)s account
-%(email)s be reset. If this person was you, you may continue with the
-reset by visiting:
-
-https://%(PLC_WWW_HOST)s:%(PLC_WWW_SSL_PORT)d/db/persons/reset_password.php?id=%(person_id)d&key=%(verification_key)s
-
-If you did not request that your password be reset, please contact
-%(PLC_NAME)s Support <%(PLC_MAIL_SUPPORT_ADDRESS)s>. Do not quote or
-otherwise include any of this text in any correspondence.
-"""
-         },
-
-        {'message_id': 'Password reset',
-         'subject': "Password reset",
-         'template': """
-The password of your %(PLC_NAME)s account %(email)s has been
-temporarily reset to:
-
-%(password)s
-
-Please change it at as soon as possible by visiting:
-
-https://%(PLC_WWW_HOST)s:%(PLC_WWW_SSL_PORT)d/db/persons/index.php?id=%(person_id)d
-
-If you did not request that your password be reset, please contact
-%(PLC_NAME)s Support <%(PLC_MAIL_SUPPORT_ADDRESS)s>. Do not quote or
-otherwise include any of this text in any correspondence.
-"""
-         },
-
-        # Boot Manager messages
-        {'message_id': "installfinished",
-         'subject': "%(hostname)s completed installation",
-         'template': """
-%(hostname)s just completed installation.
-
-The node should be usable in a couple of minutes if installation was
-successful.
-"""
-         },
-
-        {'message_id': "insufficientdisk",
-         'subject': "%(hostname)s does not have sufficient disk space",
-         'template': """
-%(hostname)s failed to boot because it does not have sufficent disk
-space, or because its disk controller was not recognized.
-
-Please replace the current disk or disk controller or install
-additional disks to meet the current hardware requirements.
-""" + installfailed
-         },
-
-        {'message_id': "insufficientmemory",
-         'subject': "%(hostname)s does not have sufficient memory",
-         'template': """
-%(hostname)s failed to boot because it does not have sufficent
-memory.
-
-Please install additional memory to meet the current hardware
-requirements.
-""" + installfailed
-         },
-
-        {'message_id': "authfail",
-         'subject': "%(hostname)s failed to authenticate",
-         'template':
-"""
-%(hostname)s failed to authenticate for the following reason:
-
-%(fault)s
-
-The most common reason for authentication failure is that the
-authentication key stored in the node configuration file, does not
-match the key on record. 
-
-There are two possible steps to resolve the problem.
-
-1. If you have used an All-in-one BootCD that includes the plnode.txt file,
-    then please check your machine for any old boot media, either in the
-    floppy drive, or on a USB stick.  It is likely that an old configuration
-    is being used instead of the new configuration stored on the BootCD.
-Or, 
-2. If you are using Generic BootCD image, then regenerate the node 
-    configuration file by visiting:
-
-    https://%(PLC_WWW_HOST)s:%(PLC_WWW_SSL_PORT)d/db/nodes/?id=%(node_id)d
-
-    Under 'Download', follow the 'Download plnode.txt file for %(hostname)s'
-    option, and save the downloaded file as plnode.txt on either a floppy 
-    disk or a USB flash drive.  Be sure the 'Boot State' is set to 'Boot', 
-    and, then reboot the node.
-
-If you have already performed this step and are still receiving this
-message, please reply so that we can help investigate the problem.
-"""
-         },
-
-        {'message_id': "notinstalled",
-         'subject': "%(hostname)s is not installed",
-         'template':
-"""
-%(hostname)s failed to boot because it has either never been
-installed, or the installation is corrupt.
-
-Please check if the hard drive has failed, and replace it if so. After
-doing so, visit:
-
-https://%(PLC_WWW_HOST)s:%(PLC_WWW_SSL_PORT)d/db/nodes/?id=%(node_id)d
-
-Change the 'Boot State' to 'Reinstall', and then reboot the node.
-
-If you have already performed this step and are still receiving this
-message, please reply so that we may investigate the problem.
-"""
-         },
-
-        {'message_id': "hostnamenotresolve",
-         'subject': "%(hostname)s does not resolve",
-         'template':
-"""
-%(hostname)s failed to boot because its hostname does not resolve, or
-does resolve but does not match its configured IP address.
-
-Please check the network settings for the node, especially its
-hostname, IP address, and DNS servers, by visiting:
-
-https://%(PLC_WWW_HOST)s:%(PLC_WWW_SSL_PORT)d/db/nodes/?id=%(node_id)d
-
-Correct any errors, and change the 'Boot State' to 'Reinstall', and then
-reboot the node.
-
-If you have already performed this step and are still receiving this
-message, please reply so that we may investigate the problem.
-"""
-         },
-
-        # XXX N.B. I don't think these are necessary, since there's no
-        # way that the Boot Manager would even be able to contact the
-        # API to send these messages.
-
-        {'message_id': "noconfig",
-         'subject': "%(hostname)s does not have a configuration file",
-         'template': """
-%(hostname)s failed to boot because it could not find a PlanetLab
-configuration file. To create this file, visit:
-
-https://%(PLC_WWW_HOST)s:%(PLC_WWW_SSL_PORT)d/db/nodes/?id=%(node_id)d
-
-Click the Configuration File link, and save the downloaded file as
-plnode.txt on either a floppy disk or a USB flash drive.  Change the 
-'Boot State' to 'Reinstall', and then reboot the node.
-
-If you have already performed this step and are still receiving this
-message, please reply so that we may investigate the problem.
-"""
-         },
-
-        {'message_id': "nodetectednetwork",
-         'subject': "%(hostname)s has unsupported network hardware",
-         'template':
-"""
-
-%(hostname)s failed to boot because it has network hardware that is
-unsupported by the current production kernel. If it has booted
-successfully in the past, please try re-installing it by visiting:
-
-https://%(PLC_WWW_HOST)s:%(PLC_WWW_SSL_PORT)d/db/nodes/?id=%(node_id)d
-
-Change the 'Boot State' to 'Reinstall', and then reboot the node.
-
-If you have already performed this step and are still receiving this
-message, please reply so that we may investigate the problem.
-"""
-         },
-        ]
-
-    for template in message_templates:
-        messages = GetMessages([template['message_id']])
-        if not messages:
-            AddMessage(template)
-
-    #################### PCUs
-    
-    ### Setup Initial PCU information
-    pcu_types = [{'model': 'AP79xx',
-          'name': 'APC AP79xx',
-          'pcu_protocol_types': [{ 'port': 80,
-                                  'protocol': 'APC79xxHttp',
-                                  'supported': False},
-                                 { 'port': 23,
-                                  'protocol': 'APC79xx',
-                                  'supported': True},
-                                 { 'port': 22,
-                                  'protocol': 'APC79xx',
-                                  'supported': True}],
-          },
-         {'model': 'Masterswitch',
-          'name': 'APC Masterswitch',
-          'pcu_protocol_types': [{ 'port': 80,
-                                  'protocol': 'APCMasterHttp',
-                                  'supported': False},
-                                 { 'port': 23,
-                                  'protocol': 'APCMaster',
-                                  'supported': True},
-                                 { 'port': 22,
-                                  'protocol': 'APCMaster',
-                                  'supported': True}],
-          },
-         {'model': 'DS4-RPC',
-          'name': 'BayTech DS4-RPC',
-          'pcu_protocol_types': [{ 'port': 80,
-                                  'protocol': 'BayTechHttp',
-                                  'supported': False},
-                                 { 'port': 23,
-                                  'protocol': 'BayTech',
-                                  'supported': True},
-                                 { 'port': 22,
-                                  'protocol': 'BayTech',
-                                  'supported': True}],
-          },
-         {'model': 'IP-41x_IP-81x',
-          'name': 'Dataprobe IP-41x & IP-81x',
-          'pcu_protocol_types': [ { 'port': 23,
-                                  'protocol': 'IPALTelnet',
-                                  'supported': True},
-                                  { 'port': 80,
-                                  'protocol': 'IPALHttp',
-                                  'supported': False}],
-          },
-         {'model': 'DRAC3',
-          'name': 'Dell RAC Version 3',
-          'pcu_protocol_types': [],
-          },
-         {'model': 'DRAC4',
-          'name': 'Dell RAC Version 4',
-          'pcu_protocol_types': [{ 'port': 443,
-                                  'protocol': 'DRACRacAdm',
-                                  'supported': True},
-                                 { 'port': 80,
-                                  'protocol': 'DRACRacAdm',
-                                  'supported': False},
-                                 { 'port': 22,
-                                  'protocol': 'DRAC',
-                                  'supported': True}],
-          },
-         {'model': 'ePowerSwitch',
-          'name': 'ePowerSwitch 1/4/8x',
-          'pcu_protocol_types': [{ 'port': 80,
-                                  'protocol': 'ePowerSwitch',
-                                  'supported': True}],
-          },
-         {'model': 'ilo2',
-          'name': 'HP iLO2 (Integrated Lights-Out)',
-          'pcu_protocol_types': [{ 'port': 443,
-                                  'protocol': 'HPiLOHttps',
-                                  'supported': True},
-                                 { 'port': 22,
-                                  'protocol': 'HPiLO',
-                                  'supported': True}],
-          },
-         {'model': 'ilo1',
-          'name': 'HP iLO version 1',
-          'pcu_protocol_types': [],
-          },
-         {'model': 'PM211-MIP',
-          'name': 'Infratec PM221-MIP',
-          'pcu_protocol_types': [],
-          },
-         {'model': 'AMT2.5',
-          'name': 'Intel AMT v2.5 (Active Management Technology)',
-          'pcu_protocol_types': [],
-          },
-         {'model': 'AMT3.0',
-          'name': 'Intel AMT v3.0 (Active Management Technology)',
-          'pcu_protocol_types': [],
-          },
-         {'model': 'WTI_IPS-4',
-          'name': 'Western Telematic (WTI IPS-4)',
-          'pcu_protocol_types': [],
-          },
-         {'model': 'unknown',
-          'name': 'Unknown Vendor or Model',
-          'pcu_protocol_types': [{ 'port': 443,
-                                  'protocol': 'UnknownPCU',
-                                  'supported': False},
-                                 { 'port': 80,
-                                  'protocol': 'UnknownPCU',
-                                  'supported': False},
-                                 { 'port': 23,
-                                  'protocol': 'UnknownPCU',
-                                  'supported': False},
-                                 { 'port': 22,
-                                  'protocol': 'UnknownPCU',
-                                  'supported': False}],
-          }]
-
-    # Get all model names
-    pcu_models = [type['model'] for type in GetPCUTypes()]
-    for type in pcu_types:
-        protocol_types = type['pcu_protocol_types']
-        # Take this value out of the struct.
-        del type['pcu_protocol_types']
-        if type['model'] not in pcu_models:
-            # Add the name/model info into DB
-            id = AddPCUType(type)
-            # for each protocol, also add this.
-            for ptype in protocol_types:
-                AddPCUProtocolType(id, ptype)
-
-    default_boot_states = [
-        'boot',
-        'failboot',
-        'safeboot',
-        'install',
-        'reinstall',
-        'disabled',
-    ]
-    current_boot_states = GetBootStates()
-    for state in default_boot_states:
-        if state not in current_boot_states:
-            AddBootState(state)
-
-    # TODO: Delete old boot states. 
-    # NOTE: Only do this if all federating peers have the new default boot states above.
-    #for state in current_boot_states:
-    #    if state not in default_boot_states:
-    #        DeleteBootState(state)
-
-    # Run local db-config snippets
-    files = []
-    dir = "/etc/planetlab/db-config.d"
-    try:
-        files = os.listdir(dir)
-    except:
-        pass
-
-    for file in files:
-        if (file.endswith(".bak") or file.endswith("~") or
-            file.endswith(".rpmsave") or file.endswith(".rpmnew") or
-            file.endswith(".orig")):
-            continue
-        execfile(os.path.join(dir, file))
-
-
-if __name__ == '__main__':
-    main()
-
-# Local variables:
-# tab-width: 4
-# mode: python
-# End:
diff --git a/db-config.d/040-init_scripts b/db-config.d/040-init_scripts
new file mode 100644 (file)
index 0000000..e86ec0f
--- /dev/null
@@ -0,0 +1,24 @@
+# -*-python-*-
+# $Id$
+# $URL$
+#################### initscripts
+# Default Initscripts
+default_initscripts = []
+
+# get the MyPLC url
+url = GetMyPLCURL()
+
+# Find initscripts and add them to the db
+for (root, dirs, files) in os.walk("/etc/plc_sliceinitscripts"):
+    for f in files:
+        # Read the file
+        file = open(root + "/" + f, "ro")
+        script = file.read()
+        script = script.replace("@SITE@", url)
+        script = script.replace("@PREFIX@", plc['slice_prefix'])
+        name = plc['slice_prefix'] + "_" + f
+        default_initscripts.append({"name":name,"enabled":True,"script":script})
+        file.close()
+
+for initscript in default_initscripts:
+       SetInitScript(initscript)
diff --git a/db-config.d/080-slice_netflow b/db-config.d/080-slice_netflow
new file mode 100644 (file)
index 0000000..7af59e0
--- /dev/null
@@ -0,0 +1,33 @@
+# -*-python-*-
+# $Id$
+# $URL$
+####################
+# Create/update system slices
+
+# get the MyPLC url
+url = GetMyPLCURL()
+
+description = """PlanetFlow Traffic Auditing Service.
+Logs, captured in the root context using fprobe-ulogd, are stored in a
+directory in the root context which is bind mounted to the planetflow
+slice.  The Planetflow Central service then periodically rsyncs these
+logs from the planetflow slice for aggregation."""
+
+slice = \
+{
+    'name': plc['slice_prefix'] + "_netflow",
+    'description': description,
+    'url': url,
+    'instantiation': "plc-instantiated",
+    # Renew forever (minus one day, work around date conversion weirdness)
+    'expires': 0x7fffffff - (60 * 60 * 24)
+}
+    
+tags = \
+[
+    ('system', "1"),
+    ('vref', "planetflow"),
+    ('vsys', "pfmount")
+]
+
+SetSlice(slice,tags)
diff --git a/db-config.d/081-slice_sirius b/db-config.d/081-slice_sirius
new file mode 100644 (file)
index 0000000..dca2399
--- /dev/null
@@ -0,0 +1,36 @@
+# -*-python-*-
+# $Id$
+# $URL$
+####################
+# Create/update system slices
+
+# get the MyPLC url
+url = GetMyPLCURL()
+
+descript = """The Sirius Calendar Service.
+
+Sirius provides system-wide reservations of CPU and outgoing
+bandwidth.  Sign up for hour-long slots using the Web GUI at the
+PlanetLab website.
+
+This slice should not generate traffic external to PlanetLab."""
+
+slice = \
+{
+    'name': plc['slice_prefix'] + "_sirius",
+    'description': description,
+    'url': url + "db/sirius/index.php",
+    'instantiation': "plc-instantiated",
+    # Renew forever (minus one day, work around date conversion weirdness)
+    'expires': 0x7fffffff - (60 * 60 * 24)
+}
+
+tags = \
+[
+    ('system', "1"),
+    ('net_min_rate', "2000"),
+    ('cpu_pct', "25"),
+    ('initscript', plc['slice_prefix'] + "_sirius")
+]
+
+SetSlice(slice,tags)
diff --git a/db-config.d/082-slice_sfacm b/db-config.d/082-slice_sfacm
new file mode 100644 (file)
index 0000000..eaf06fc
--- /dev/null
@@ -0,0 +1,30 @@
+# -*-python-*-
+# $Id$
+# $URL$
+####################
+# Create/update system slices
+
+# get the MyPLC url
+url = GetMyPLCURL()
+
+description = """Geni Component Manager Slice .
+This slice provides a backdoor to Node Manager and is used by the Geni/SFA
+Component Manger.
+"""
+
+slice = \
+{
+    'name': plc['slice_prefix'] + "_sfacm",
+    'description': description,
+    'url': url,
+    'instantiation': "plc-instantiated",
+    # Renew forever (minus one day, work around date conversion weirdness)
+    'expires': 0x7fffffff - (60 * 60 * 24)
+}
+    
+tags = \
+[
+    ('system', "1"),
+]
+
+SetSlice(slice,tags)
diff --git a/db-config.d/083-slice_drl b/db-config.d/083-slice_drl
new file mode 100644 (file)
index 0000000..488b893
--- /dev/null
@@ -0,0 +1,29 @@
+# Create/update system slices
+
+# get the MyPLC url
+url = GetMyPLCURL()
+
+description = """DistributedRateLimiting Service.
+Distributed rate limiting allows administrators to set a limit on the aggregate 
+outgoing traffic rate for a set of nodes without putting a single static limit 
+on any individual node. Given an aggregate rate limit, the participating nodes 
+each use a portion of the limit according to the current traffic demands at the nodes."""
+
+slice = \
+{
+    'name': plc['slice_prefix'] + "_drl",
+    'description': description,
+    'url': url,
+    'instantiation': "plc-instantiated",
+    # Renew forever (minus one day, work around date conversion weirdness)
+    'expires': 0x7fffffff - (60 * 60 * 24)
+}
+    
+tags = \
+[
+    ('system', "1"),
+    ('drl', "1"),
+    ('capabilities', "CAP_NET_ADMIN"),
+]
+
+SetSlice(slice,tags)
diff --git a/db-config.d/090-my_ops b/db-config.d/090-my_ops
new file mode 100644 (file)
index 0000000..75ae9fd
--- /dev/null
@@ -0,0 +1,32 @@
+# -*-python-*-
+# $Id$
+# $URL$
+########
+myops_node_tags = [
+    { 'tagname' : 'exempt_node_until',
+      'description' : 'Exclude this node from MyOps until given date (YYYYMMDD)',
+      'category' : 'node/myops', 
+      'min_role_id' : 10} ,
+]
+
+for node_type in myops_node_tags: SetTagType (node_type)
+
+########
+myops_site_tags = [
+    { 'tagname' : 'exempt_site_until',
+      'description' : 'Exclude this site from MyOps until given date (YYYYMMDD)',
+      'category' : 'site/myops', 
+      'min_role_id' : 10} ,
+]
+
+for site_type in myops_site_tags: SetTagType (site_type)
+########
+myops_person_tags = [
+    { 'tagname' : 'exempt_person_until',
+      'description' : 'Exclude this person from MyOps until given date (YYYYMMDD)',
+      'category' : 'person/myops', 
+      'min_role_id' : 10} ,
+]
+
+for person_type in myops_person_tags: SetTagType (person_type)
index 609b525..b8a2b66 100644 (file)
@@ -7,6 +7,7 @@ Mark Huang <mlhuang@cs.princeton.edu>
 Copyright (C) 2006 The Trustees of Princeton University
 
 $Id$
+$URL$
 -->
 
 <!DOCTYPE configuration PUBLIC "-//PlanetLab Central//DTD PLC configuration//EN" "plc_config.dtd">
@@ -115,6 +116,68 @@ $Id$
          <description>The SSH private key used to access the root
          account on your nodes.</description>
        </variable>
+
+      </variablelist>
+    </category>
+
+    <category id="plc_flavour">
+      <name>Flavours</name>
+      <description>Defaults for nodes and slices contents.</description>
+      
+      <variablelist>
+       <variable id="node_arch" type="string">
+         <name>arch for nodes</name>
+         <value>@ARCH@</value>
+         <description>The default 'arch' to use when installing nodes.
+         This is offered mostly for consistency with the rest of the
+         PLC_FLAVOUR category, but does not have much of a practical
+         interest. In any case, you need to have the corresponding
+         bootstrapfs images available for nodes.</description>
+       </variable>
+
+       <variable id="node_fcdistro" type="string">
+         <name>fcdistro for nodes</name>
+         <value>@FCDISTRO@</value>
+         <description>THIS CURRENTLY HAS NO EFFECT.
+          The default 'fcdistro' to use when installing
+         nodes.You need to have the corresponding bootstrapfs images
+         available for nodes. THIS CURRENTLY HAS NO EFFECT.</description>
+       </variable>
+
+       <variable id="node_pldistro" type="string">
+         <name>pldistro for nodes</name>
+         <value>@PLDISTRO@</value>
+         <description>The default 'pldistro' to use when installing
+         nodes. You need to have the corresponding bootstrapfs
+         images available for nodes.</description>
+       </variable>
+
+       <variable id="slice_arch" type="string">
+         <name>arch for slivers</name>
+         <value>@ARCH@</value>
+         <description>The default 'arch' to use for slivers. This is
+         useful if you have heterogeneous nodes (i686 and x86_64),
+         but want slivers to be homogeneous. You need to have the
+         corresponding vserver variant rpm available for
+         nodes.</description>
+       </variable>
+
+       <variable id="slice_fcdistro" type="string">
+         <name>fcdistro for slivers</name>
+         <value>@FCDISTRO@</value>
+         <description>The default 'fcdistro' to use for creating
+         slivers. You need to have the corresponding vserver variant
+         rpm available for nodes.</description>
+       </variable>
+
+       <variable id="slice_pldistro" type="string">
+         <name>pldistro for slivers</name>
+         <value>@PLDISTRO@</value>
+         <description>The default 'pldistro' to use for creating
+         slivers. You need to have the corresponding vserver variant
+         rpm available for nodes.</description>
+       </variable>
+
       </variablelist>
     </category>
 
@@ -160,6 +223,22 @@ $Id$
       </variablelist>
     </category>
 
+    <category id="plc_hosts">
+      <name>/etc/hosts</name>
+      <description>MyPLC can setup /etc/hosts with the hostnames and
+      IP addresses specified for *_NAME and *_IP, or look up the IP
+      addresses if they are not specified in this configuration.
+      </description>
+
+      <variablelist>
+        <variable id="enabled" type="boolean">
+          <name>Enable /etc/hosts configuration</name>
+          <value>true</value>
+          <description>Let PLC manage /etc/hosts</description>
+        </variable>
+      </variablelist>
+    </category>
+
     <category id="plc_mail">
       <name>Mail</name>
       <description>Many maintenance scripts, as well as the API and
@@ -553,6 +632,44 @@ $Id$
       </variablelist>
     </category>
 
+    <category id="plc_omf">
+      <name>Planetlab - OMF Integration</name>
+      <description>Planetlab - OMF integration</description>
+      <variablelist>
+        <variable id="enabled" type="boolean">
+          <name>OMF integration</name>
+          <value>false</value>
+          <description>Enable OMF integration.</description>
+        </variable>
+
+        <!-- xmpp server configuration -->
+        <variable id="xmpp_server" type="string">
+          <name>XMPP server</name>
+          <value>localhost.localdomain</value>
+          <description>The fully qualified hostname of the XMPP server.</description>
+        </variable>
+
+        <variable id="xmpp_user" type="string">
+          <name>XMPP username</name>
+          <value></value>
+          <description>XMPP username (which has admin rights).</description>
+        </variable>
+
+        <variable id="xmpp_password" type="string">
+          <name>XMPP password</name>
+          <value></value>
+          <description>The password of the XMPP user.</description>
+        </variable>
+
+        <!-- omf-slicemgr -->
+        <variable id="slicemgr_url" type="string">
+          <name>OMF Slicemgr URL</name>
+          <value>http://localhost.localdomain:5053/</value>
+          <description>.</description>
+        </variable>
+
+      </variablelist>
+    </category>
 
     <category id="plc_planetflow">
       <name>PlanetFlow Service Configuration</name>
@@ -566,6 +683,7 @@ $Id$
         </variable>
       </variablelist>
     </category>
+
     <category id="plc_monitor">
       <name>Monitoring Service</name>
       <description>The Monitor service that tracks node availablity and repair.</description>
@@ -585,16 +703,94 @@ $Id$
           <value></value>
           <description>The IP address of the monitor server.</description>
         </variable>
-        <variable id="email" type="email">
+        <variable id="from_email" type="email">
           <name>Monitor Email Address</name>
           <value>root+monitor@localhost.localdomain</value>
-          <description>The source address for all out-going messages from Monitor.</description>
+          <description>All messages from Monitor will appear to come from this address.</description>
+        </variable>
+        <variable id="cc_email" type="email">
+          <name>CC Email Address</name>
+          <value>root+monitor@localhost.localdomain</value>
+          <description>All messages from Monitor will be copied to this address.</description>
+        </variable>
+        <variable id="rt_queue" type="email">
+          <name>Queue Name in RT for new messages</name>
+          <value>support</value>
+          <description>All messages from Monitor will be copied to this address.</description>
         </variable>
         <variable id="dbpassword" type="password">
           <name>Database Password</name>
           <value></value>
           <description>The password to use when accessing the
           database, Monitor user account in the local PLC.</description>
+        </variable>
+
+           <variable id="ssl_key" type="file">
+                 <name>SSL Private Key</name>
+                 <value>/etc/planetlab/monitor_ssl.key</value>
+                 <description>The SSL private key to use for encrypting HTTPS
+                 traffic.</description>
+               </variable>
+
+               <variable id="ssl_crt" type="file">
+                 <name>SSL Public Certificate</name>
+                 <value>/etc/planetlab/monitor_ssl.crt</value>
+                 <description>The corresponding SSL public certificate for
+                 the HTTP server. By default, this certificate is
+                 self-signed. You may replace the certificate later with one
+                 signed by a root CA.</description>
+               </variable>
+
+               <variable id="ca_ssl_crt" type="file">
+                 <name>Root CA SSL Public Certificate</name>
+                 <value>/etc/planetlab/monitor_ca_ssl.crt</value>
+                 <description>The certificate of the root CA, if any, that
+                 signed your server certificate. If your server certificate is
+                 self-signed, then this file is the same as your server
+                 certificate.</description>
+               </variable>
+
+      </variablelist>
+    </category>
+    <category id="plc_rt">
+      <name>RT Configuration</name>
+      <description>RT</description>
+      <variablelist>
+        <variable id="enabled" type="boolean">
+          <name>Enabled</name>
+          <value>false</value>
+          <description>Enable on this machine.</description>
+        </variable>
+        <variable id="host" type="hostname">
+          <name>Hostname</name>
+          <value>localhost.localdomain</value>
+          <description>The fully qualified hostname.</description>
+        </variable>
+        <variable id="ip" type="ip">
+          <name>IP Address</name>
+          <value/>
+          <description>The IP address of the RT server.</description>
+        </variable>
+        <variable id="cc_address" type="email">
+          <name>CC Email Address</name>
+          <value>root+cclist@localhost.localdomain</value>
+          <description>All messages to and from PLCRT will be copied to this address.</description>
+        </variable>
+        <variable id="web_user" type="string">
+          <name>root</name>
+          <value>root</value>
+          <description>Username of a privileged user in RT who can create
+                 tickets for any RT Queue.</description>
+        </variable>
+        <variable id="web_password" type="password">
+          <name>password</name>
+          <value>password</value>
+          <description>Password for RT web user.</description>
+        </variable>
+        <variable id="dbpassword" type="password">
+          <name>Database Password</name>
+          <value></value>
+          <description>Password to use when accessing the RT database.</description>
         </variable>
       </variablelist>
     </category>
diff --git a/host.init b/host.init
deleted file mode 100755 (executable)
index 63dd1d6..0000000
--- a/host.init
+++ /dev/null
@@ -1,232 +0,0 @@
-#!/bin/bash
-#
-# plc  Manages all PLC services on this machine
-#
-# chkconfig: 2345 99 5
-#
-# description: Manages all PLC services on this machine
-#
-# $Id$
-#
-
-PATH=/sbin:/bin:/usr/bin:/usr/sbin
-
-# Source function library.
-if [ -f /etc/init.d/functions ] ; then
-    . /etc/init.d/functions
-fi
-
-# If success() or failure() are not defined
-if ! type -type success >/dev/null || ! type -type failure >/dev/null ; then
-    success() {
-       echo -ne "[  OK  ]\r"
-       return 0
-    }
-    failure() {
-       echo -ne "[FAILED]\r"
-       return 1
-    }
-fi
-
-# Source configuration
-SERVICE=$(basename $0)
-if [ ! -f /etc/sysconfig/$SERVICE ] ; then
-    SERVICE=plc
-fi
-if [ -f /etc/sysconfig/$SERVICE -a -z "${PLC_ROOT}${PLC_DATA}" ] ; then
-    . /etc/sysconfig/$SERVICE
-fi
-
-# Total number of errors
-ERRORS=0
-
-# Count the exit status of the last command
-check ()
-{
-    ERRORS=$(($ERRORS+$?))
-}
-
-mounted ()
-{
-    if cut -d' ' -f2 /proc/mounts | grep -q "$1" ; then
-       return 0
-    else
-       return 1
-    fi
-}
-
-mount_plc ()
-{
-    echo -n $"Mounting PLC: "
-
-    if ! mounted $PLC_ROOT ; then
-       if ! e2fsck -a $PLC_ROOT.img | logger -t "PLC" ; then
-           e2fsck $PLC_ROOT.img
-       fi
-       mount -o loop $PLC_ROOT.img $PLC_ROOT
-       check
-    fi
-    if ! mounted $PLC_ROOT/data ; then
-       mount -t none -o bind,rw $PLC_DATA $PLC_ROOT/data
-       check
-    fi
-    if ! mounted $PLC_ROOT/proc ; then
-       mount -t proc none $PLC_ROOT/proc
-       check
-    fi
-
-    [ $ERRORS -eq 0 ] && success $"PLC unmount" || failure $"PLC unmount"      
-    echo
-
-}
-
-start ()
-{
-    # Starting everything
-    if [ -z "$1" ] ; then
-       mount_plc 
-    fi
-
-    chroot $PLC_ROOT /sbin/service plc $PLC_OPTIONS start $*
-    check
-}
-
-umount_plc ()
-{
-    echo -n $"Unmounting PLC: "
-
-    for dir in $PLC_ROOT/proc $PLC_ROOT/data $PLC_ROOT ; do
-       if mounted $dir ; then
-           umount $dir
-           check
-       fi
-    done
-
-    [ $ERRORS -eq 0 ] && success $"PLC unmount" || failure $"PLC unmount"      
-    echo
-}
-
-stop ()
-{
-    if mounted $PLC_ROOT ; then
-       chroot $PLC_ROOT /sbin/service plc $PLC_OPTIONS stop $*
-       check
-    fi
-
-    # Stopped everything
-    if [ -z "$1" ] ; then
-       umount_plc
-    fi
-}
-
-mountstatus_plc ()
-{
-    for dir in $PLC_ROOT/proc $PLC_ROOT/data $PLC_ROOT ; do
-       if mounted $dir ; then
-           echo $dir
-       fi
-    done
-}
-
-# safestop : tries to stop normally; if that fails, kills processes that are still using /plc 
-# needs the lsof rpm in the root context (should be a dependency of the myplc spec)
-function check_command ()
-{
-    command=$1; shift
-    found=$(type -p $command)
-    if [ -z "$found" ] ; then
-        echo "$COMMAND : requires command $command, was not found - exiting"
-       exit 1
-    fi
-}
-
-
-### when process stil use /plc/root, we cannot umount it
-function kill_all ()
-{
-    [ -n "$DEBUG" ] && set -x
-    check_command lsof
-    
-    echo -n "Killing processes using $PLC_ROOT and $PLC_DATA: "
-    # initialize process list
-    former_process_list="unlikely"
-      
-    # we ignore unknown uids for now, since we run in the chroot jail anyway
-    # not too sure about that though, 
-    while true; do
-        # get the list of processes - collapse and remove empty lines
-       process_list=$(lsof -t +D $PLC_ROOT +D $PLC_DATA)
-       if [ -z "$process_list" ] ; then
-           # we are done, let's bail out
-           success "$PLC_ROOT clear" ; echo ; return
-       fi
-       if [ "$process_list" = "$former_process_list" ] ; then
-           # we are stuck, no progress since last time : exit on error
-           failure "$PLC_ROOT locked" ; echo ; return
-       fi
-       # record for next loop
-       former_process_list="$process_list"
-       # kill them
-       kill $process_list
-       sleep 2
-       # check there are dead
-       for pid in $process_list ; do
-           ps -o pid $pid &> /dev/null 
-           if [ "$?" = 0 ] ; then
-               [ -n "$DEBUG" ] && echo "$pid survived kill - forcing kill -9"
-               kill -9 $pid
-           fi
-       done
-    done
-}
-
-# Get command
-shift $(($OPTIND - 1))
-command=$1
-
-# Get step(s)
-shift 1
-
-case "$command" in
-    start|stop)
-       $command $*
-       ;;
-
-    restart)
-       stop $*
-       ERRORS=0
-       start $*
-       ;;
-
-    reload)
-       chroot $PLC_ROOT /sbin/service plc $PLC_OPTIONS reload $*
-       ;;      
-
-    mount|umount|mountstatus)
-        ${command}_plc
-       ;;
-
-   kill)
-        kill_all
-        ;;
-
-   safestop)
-        stop
-       ### Checking : we might need to run kill
-       mounted=$(mountstatus_plc)
-       if [ -n "$mounted" ] ; then
-           echo "Umount failed : killing remaining processes and trying again"
-           ERRORS=0
-           kill_all
-           ERRORS=0
-           stop
-       fi
-       ;;
-  
-    *)
-       echo "Usage: $0 {start|stop|restart|reload|mount|umount|mountstatus|kill|safestop}"
-       RETVAL=1
-       ;;
-esac
-
-exit $ERRORS
diff --git a/myplc-chroot.spec b/myplc-chroot.spec
deleted file mode 100644 (file)
index a8d38e7..0000000
+++ /dev/null
@@ -1,311 +0,0 @@
-#
-# $Id$
-#
-%define url $URL$
-
-%define name myplc-chroot
-%define version 5.0
-%define taglevel 2
-
-%define release %{taglevel}%{?pldistro:.%{pldistro}}%{?date:.%{date}}
-
-Summary: PlanetLab Central (PLC) Portable Installation
-Name: %{name}
-Version: %{version}
-Release: %{release}
-License: PlanetLab
-Group: Applications/Systems
-Source0: %{name}-%{version}.tar.gz
-BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root
-
-Vendor: PlanetLab
-Packager: PlanetLab Central <support@planet-lab.org>
-Distribution: PlanetLab %{plrelease}
-URL: %(echo %{url} | cut -d ' ' -f 2)
-
-Requires: tar
-
-Provides: myplc
-
-%define debug_package %{nil}
-
-%description
-MyPLC is a complete PlanetLab Central (PLC) portable installation
-contained within a chroot jail. The default installation consists of a
-web server, an XML-RPC API server, a boot server, and a database
-server: the core components of PLC. All PLC services are started up and
-shut down through a single System V init script installed in the host
-system. The related Web Interface is now separately packaged
-in the PLCWWW component. 
-
-%prep
-%setup -q
-
-%build
-pushd MyPLC
-./build-chroot.sh %{pldistro}
-popd
-
-%install
-rm -rf $RPM_BUILD_ROOT
-
-pushd MyPLC
-
-#
-# myplc
-#
-
-# Install host startup script and configuration file
-install -D -m 755 host.init $RPM_BUILD_ROOT/%{_sysconfdir}/init.d/plc
-install -D -m 644 plc.sysconfig $RPM_BUILD_ROOT/%{_sysconfdir}/sysconfig/plc
-
-# Create convenient symlink
-install -d -m 755 $RPM_BUILD_ROOT/%{_sysconfdir}
-ln -sf /plc/data/etc/planetlab $RPM_BUILD_ROOT/%{_sysconfdir}/planetlab
-
-# Install root filesystem
-install -d -m 755 $RPM_BUILD_ROOT/plc/root
-install -D -m 644 root.img $RPM_BUILD_ROOT/plc/root.img
-
-# Install data directory
-find data | cpio -p -d -u $RPM_BUILD_ROOT/plc/
-
-popd
-
-%clean
-rm -rf $RPM_BUILD_ROOT
-
-# If run under sudo
-if [ -n "$SUDO_USER" ] ; then
-    # Allow user to delete the build directory
-    chown -h -R $SUDO_USER .
-    # Some temporary cdroot files like /var/empty/sshd and
-    # /usr/bin/sudo get created with non-readable permissions.
-    find . -not -perm +0600 -exec chmod u+rw {} \;
-    # Allow user to delete the built RPM(s)
-    chown -h -R $SUDO_USER %{_rpmdir}/%{_arch}
-fi
-
-%pre
-if [ -x %{_sysconfdir}/init.d/plc ] ; then
-    %{_sysconfdir}/init.d/plc safestop
-fi
-
-# Old versions of myplc used to ship with a bootstrapped database and
-# /etc/planetlab directory. Including generated files in the manifest
-# was dangerous; if /plc/data/var/lib/pgsql/data/base/1/16676 changed
-# names from one RPM build to another, it would be rpmsaved and thus
-# effectively deleted. Now we do not include these files in the
-# manifest. However, to avoid deleting these files in the process of
-# upgrading from one of these old versions of myplc, we must back up
-# the database and /etc/planetlab and restore them after the old
-# version has been uninstalled in %triggerpostun (also in %post, in
-# case we are force upgrading to the same version).
-#
-# This code can be removed once all myplc-0.4-1 installations have
-# been upgraded to at least myplc-0.4-2.
-
-# 0 = install, 1 = upgrade
-if [ $1 -gt 0 ] ; then
-    for dir in /var/lib/pgsql/data /etc/planetlab ; do
-       if [ -d /plc/data/$dir ] ; then
-           echo "Preserving /plc/data/$dir"
-           mkdir -p /plc/data/$dir.rpmsave
-           tar -C /plc/data/$dir -cpf - . | \
-              tar -C /plc/data/$dir.rpmsave -xpf -
-
-           # Except for the default configuration file and DTD, which
-           # really should be considered for upgrade.
-           rm -f /plc/data/$dir.rpmsave/{default_config.xml,plc_config.dtd}
-       fi
-    done
-fi
-
-%post
-if [ -x /sbin/chkconfig ] ; then
-    /sbin/chkconfig --add plc
-    /sbin/chkconfig plc on
-fi
-
-%triggerpostun -- %{name}
-# 0 = erase, 1 = upgrade
-if [ $1 -gt 0 ] ; then
-    for dir in /var/lib/pgsql/data /etc/planetlab ; do
-       if [ -d /plc/data/$dir.rpmsave -a -d /plc/data/$dir ] ; then
-           echo "Merging /plc/data/$dir"
-           if tar -C /plc/data/$dir.rpmsave -cpf - . | \
-              tar -C /plc/data/$dir -xpf - ; then
-               rm -rf /plc/data/$dir.rpmsave
-           fi
-       fi
-    done
-fi    
-
-%preun
-# 0 = erase, 1 = upgrade
-if [ $1 -eq 0 ] ; then
-    %{_sysconfdir}/init.d/plc safestop
-    if [ -x /sbin/chkconfig ] ; then
-        /sbin/chkconfig plc off
-       /sbin/chkconfig --del plc
-    fi
-fi
-
-%files
-%defattr(-,root,root,-)
-# Host startup script and configuration file
-%{_sysconfdir}/init.d/plc
-%{_sysconfdir}/sysconfig/plc
-
-# Symlink to /etc/planetlab within data directory
-%{_sysconfdir}/planetlab
-
-# Root filesystem
-/plc/root.img
-/plc/root
-
-# Data directory
-%dir /plc/data
-%config(noreplace) /plc/data/*
-
-%changelog
-* Thu Jan 29 2009 Thierry Parmentelat <thierry.parmentelat@sophia.inria.fr> - MyPLC-5.0-2
-- rename myplc into myplc-chroot and myplc-native into myplc
-- new settings (shortname & hrn_root) for local peer
-
-* Wed Sep 10 2008 Thierry Parmentelat <thierry.parmentelat@sophia.inria.fr> - MyPLC-5.0-1
-- First iteration of new data model
-- Bunch of various fixes
-
-* Tue May 20 2008 Faiyaz Ahmed <faiyaza@cs.princeton.edu> - MyPLC-4.2-15
-- Removed proper ops from planetflow slice.
-
-* Wed May 14 2008 Thierry Parmentelat <thierry.parmentelat@sophia.inria.fr> - MyPLC-4.2-14
-- myplc-native requires myplc-docs
-- fixed doc build by locating locally installed DTDs at build-time
-
-* Sun May 11 2008 Thierry Parmentelat <thierry.parmentelat@sophia.inria.fr> - MyPLC-4.2-13
-- turn myplc-docs off for now
-
-* Sat May 10 2008 Thierry Parmentelat <thierry.parmentelat@sophia.inria.fr> - MyPLC-4.2-12
-- figures in doc package
-
-* Fri May 09 2008 Thierry Parmentelat <thierry.parmentelat@sophia.inria.fr> - MyPLC-4.2-11
-- no more doc packaged outside of myplc-docs - doc/ cleaned up 
-- chroot packaging does not have docs anymore
-- 'cvs' and 'dev' not required from myplc-native anymore
-- cosmetic change in kml output
-
-* Thu May 08 2008 Thierry Parmentelat <thierry.parmentelat@sophia.inria.fr> - MyPLC-4.2-10
-- defaults for *_IP conf vars now void, expect more accurate /etc/hosts
-- gethostbyname uses python rather than perl (hope this shrinks deps) 
-- doc: reviewed myplc doc - deprecated everything related to myplc-devel
-- doc: packaging doc in myplc-native (myplc&PLCAPI) & removed target files from svn
-- make sync now works towards vserver-based myplc only 
-
-* Mon May 05 2008 Stephen Soltesz <soltesz@cs.princeton.edu> - MyPLC-4.2-9
-- 
-- added vsys 'pfmount' script to the default netflow slice attributes.
-- 
-
-* Thu Apr 24 2008 Thierry Parmentelat <thierry.parmentelat@sophia.inria.fr> - MyPLC-4.2-8
-- plc.d/bootcd step altered for handling legacy bootcd smooth migration
-- to new bootcd packaging
-
-* Wed Apr 23 2008 Thierry Parmentelat <thierry.parmentelat@sophia.inria.fr> - MyPLC-4.2-7
-- changes needed for bootcd 4.2 : new, possible multiple, installation locations, and new rpm name
-
-* Tue Apr 22 2008 Thierry Parmentelat <thierry.parmentelat@sophia.inria.fr> - MyPLC-4.2-6
-- packaging of mplc-release in myplc-native
-- sudoers.php is new to PlanetLabConf (needs nodeconfig-4.2-4)
-- resolv file in /etc/resolv.conf, not plc_resolv.conf
-- improved sirius script
-- remove the 'driver' node-network-setting that was unused, and new 'Multihome' category
-- expires more properly set 
-
-* Mon Apr 07 2008 Stephen Soltesz <soltesz@cs.princeton.edu> - MyPLC-4.2-4 MyPLC-4.2-5
-- 
-
-* Wed Mar 26 2008 Thierry Parmentelat <thierry.parmentelat@sophia.inria.fr> - MyPLC-4.2-3 MyPLC-4.2-4
-- renew_reminder script moved to support-scripts/
-- gen-aliases script added in support-scripts/
-- sirius initscript moved to plc_sliceinitscripts (formerly inlined in db-config)
-- plc-map script : no javascript for googlemap anymore, see new plc-kml script instead
-- nodefamily-aware (creates legacy symlink /var/www/html/install-rpms/planetlab)
-- new native slice attributes 'capabilities', 'vsys' and 'codemux'
-- new setting 'Mom list address' for sending emails to a separate destination
-- starts rsyslogd/syslogd as appropriate
-- expects nodeconfig package (former PlanetLabConf/ dir from PLCWWW)
-- convenience generation of yum.conf in resulting image based on build/mirroring
-
-* Thu Feb 14 2008 Thierry Parmentelat <thierry.parmentelat@sophia.inria.fr> - myplc-4.2-2 myplc-4.2-3
-- refresh-peer.py removed (duplicate with PLCAPI)
-- plc.d/ scripts cleaned up
-- sirius initscript updated
-- slice auto renewal fixed
-
-* Thu Jan 31 2008 Thierry Parmentelat <thierry.parmentelat@sophia.inria.fr> - myplc-4.2-1 myplc-4.2-2
-- knows how to checkpoint and restore
-- packages step more robust, in particular with empty node repository
-- miscell tweaks for native packaging
-
-* Wed Jan 09 2008 Thierry Parmentelat <thierry.parmentelat@sophia.inria.fr> - myplc-4.0-15 myplc-4.2-0
-moving to 4.2 - no change
-
-* Fri Jan 19 2007 Mark Huang <mlhuang@CS.Princeton.EDU> - 0.5-3
-- Split off myplc-devel into separate spec file, so that it can be
-  built standalone.
-
-* Tue Aug 22 2006 Mark Huang <mlhuang@CS.Princeton.EDU> - 0.4-3, 0.5-3
-- MyPLC 0.4 RC3.
-- Fix upgrade path from RC1.
-- Always regenerate plc_config.xml at first startup
-- Upgrade kernel, iptables, vnet to 2.6.17-1.2142_FC4-3.planetlab
-- Minor PlanetFlow fixes
-- pl_mom/swapmon: Minor fixes
-- bootcd: Added Supermicro IPMI support
-- bootmanager: Cleanup, fixed check for new disks
-
-* Wed Aug 09 2006 Thierry Parmentelat <thierry.parmentelat@sophia.inria.fr>
-- introduces variable %{build_devel} to allow custom sites to skip building
-  the myplc-devel package.
-
-* Thu Jul 13 2006 Mark Huang <mlhuang@CS.Princeton.EDU> - 0.4-2, 0.5-2
-- MyPLC 0.4 RC2.
-- Fix many spec files (License replaces Copyright).
-- Fix kernel build under gcc32 (module verification bug).
-- Fix vnet build under gcc32
-- Fix PlanetFlow. MySQL RPM postinstall script no longer starts the
-  server. Also, get hostnames list from PLC_WWW_HOST, not
-  www.planet-lab.org.
-- Fix pl_mom/bwmon to use cached values if NM is unresponsive
-- Fix pl_mom/swapmon reset logic to avoid endless loops
-- Remove ksymoops, add kernel-smp to standard PlanetLab package group
-- Add kernel-smp boot support to bootmanager
-- Add badblock search support to bootmanager
-- Build development environment (myplc-devel). Add support for
-  building myplc itself inside myplc-devel.
-- Move step-specific initialization to appropriate plc.d scripts
-- Fix postgresql startup failure when bootstrapping
-- Allow CA to be configured for each SSL certificate set. Stop doing
-  root CA stuff, this is outside the scope of MyPLC. MyPLC now only
-  generates self-signed certificates, but supports replacement of the
-  self-signed certificates with real certifcates signed by another CA,
-  as long as the CA is specified.
-- Self-sign the MA/SA SSL certificate (and by extension, the MA/SA API
-  certificate).
-- pl_mom: Workarounds for when NM queries time out.
-- plc_api: Honor PLC_MAIL_ENABLED.
-
-* Wed Jul  6 2006 Mark Huang <mlhuang@CS.Princeton.EDU> - 0.4-1, 0.5-1
-- First stable release of MyPLC 0.4 RC1.
-
-* Wed Apr  5 2006 Mark Huang <mlhuang@CS.Princeton.EDU> - 0.2-1
-- Basic functionality complete. Consolidate into a single package
-  installed in /plc.
-
-* Fri Mar 17 2006 Mark Huang <mlhuang@CS.Princeton.EDU> - 0.1-1
-- Initial build.
-
-
-%define module_current_branch 4.2
index 07422c8..cc38548 100644 (file)
@@ -54,11 +54,19 @@ rm -f doc/NMAPI.html
 make -C doc NMAPI.html 
 popd
 
+pushd Monitor
+# beware that making the pdf file somehow overwrites the html
+make -C docs Monitor.pdf 
+rm -f docs/Monitor.html
+make -C docs Monitor.html 
+popd
+
 %install
 
 for ext in pdf html; do
     install -D -m 444 PLCAPI/doc/PLCAPI.$ext $RPM_BUILD_ROOT/var/www/html/planetlab/doc/PLCAPI.$ext
     install -D -m 444 NodeManager/doc/NMAPI.$ext $RPM_BUILD_ROOT/var/www/html/planetlab/doc/NMAPI.$ext
+    install -D -m 444 Monitor/docs/Monitor.$ext $RPM_BUILD_ROOT/var/www/html/planetlab/doc/Monitor.$ext
 done
 
 ./MyPLC/docbook2drupal.sh "PLC API Documentation (%{pldistro})" \
@@ -67,6 +75,9 @@ done
 ./MyPLC/docbook2drupal.sh "Node Manager API Documentation (%{pldistro})" \
     $RPM_BUILD_ROOT/var/www/html/planetlab/doc/NMAPI.html \
     $RPM_BUILD_ROOT/var/www/html/planetlab/doc/NMAPI.php 
+./MyPLC/docbook2drupal.sh "Monitor API Documentation (%{pldistro})" \
+    $RPM_BUILD_ROOT/var/www/html/planetlab/doc/Monitor.html \
+    $RPM_BUILD_ROOT/var/www/html/planetlab/doc/Monitor.php 
 
 %clean
 rm -rf $RPM_BUILD_ROOT
@@ -76,11 +87,174 @@ rm -rf $RPM_BUILD_ROOT
 /var/www/html/planetlab/doc/
 
 %changelog
-* Thu Jan 29 2009 Thierry Parmentelat <thierry.parmentelat@sophia.inria.fr> - MyPLC-5.0-2
+* Fri Mar 12 2010 Thierry Parmentelat <thierry.parmentelat@sophia.inria.fr> - MyPLC-5.0-2
+- legacy scripts gen-sites-xml & gen-static-content back in (sigh)
+- new OMF category in the config
+- create the drl system slice
+
+* Fri Jan 29 2010 Thierry Parmentelat <thierry.parmentelat@sophia.inria.fr> - MyPLC-5.0-1
+- first working version of 5.0:
+- pld.c/, db-config.d/ and nodeconfig/ scripts should now sit in the module they belong to
+- nodefamily is 3-fold with pldistro-fcdistro-arch
+- new PLC_FLAVOUR config category
+- reviewed module layout
+- cleaned up old chroot-related build stuff (does not need the build module when building anymore)
+
+* Sat Jan 09 2010 Thierry Parmentelat <thierry.parmentelat@sophia.inria.fr> - MyPLC-4.3-37
+- support for fedora 12
+- new package myplc-config for use by sfa
+- drupal user registration turned off
+
+* Thu Dec 31 2009 Marc Fiuczynski <mef@cs.princeton.edu> - MyPLC-4.3-36
+- - fix to make sure when API, BOOT, MONITOR are on the same
+- machine as WWW that the SSL key,cert for WWW takes precedence.
+- - Do proper setup for SSL CA certficate to be used as the server
+- chain.
+
+* Wed Dec 23 2009 Marc Fiuczynski <mef@cs.princeton.edu> - MyPLC-4.3-35
+- - Change sysctl.conf source to be PlanetLabConfsysctl.con rather than the php script.
+
+* Tue Dec 22 2009 Baris Metin <Talip-Baris.Metin@sophia.inria.fr> - MyPLC-4.3-34
+- depend on pcucontrol
+
+* Fri Dec 18 2009 Baris Metin <Talip-Baris.Metin@sophia.inria.fr> - MyPLC-4.3-33
+- * validate input according to type in plc_config
+- * added the _genicw system slice
+- * add tag types for sites and persons
+- * add new tags for nodes and slices for exemption from myops
+
+* Thu Nov 26 2009 Thierry Parmentelat <thierry.parmentelat@sophia.inria.fr> - MyPLC-4.3-32
+- turn off drupal on a box that acts as BOOT server but not as WWW server
+- cleanup some obsolete code for old chroot-jail packaging in the process
+- new bootcd-kernel script for keeping bootcd variants up2date
+
+* Mon Nov 09 2009 Daniel Hokka Zakrisson <daniel@hozac.com> - MyPLC-4.3-31
+- Make the /etc/hosts manipulation optional.
+
+* Thu Nov 05 2009 Daniel Hokka Zakrisson <daniel@hozac.com> - MyPLC-4.3-30
+- Fix SetRole.
+
+* Tue Nov 03 2009 Marc Fiuczynski <mef@cs.princeton.edu> - MyPLC-4.3-29
+- - Added "SetRole()" so that db-config.d/ scriplets can insert roles
+- into the DB.
+- - Added the root ssh key handling support back into plc.d/ssh and the
+- default xml file.  This should be identical to the way it was in
+- rc12.
+- - Added support in the db-config.d/01-init script to register the root
+- ssh public key with the default administrator.  In this way the root
+- ssh key will make it into the root account on the nodes by means of
+- NodeManager's specialaccounts plugin.
+
+* Tue Oct 20 2009 Thierry Parmentelat <thierry.parmentelat@sophia.inria.fr> - MyPLC-4.3-28
+- db-config ignores sliver tags
+- sirius's db-config script renamed (was sirious)
+
+* Tue Oct 13 2009 Thierry Parmentelat <thierry.parmentelat@sophia.inria.fr> - MyPLC-4.3-27
+- fix for silverauth - missing tag types now created at plc startup time
+
+* Fri Oct 09 2009 Thierry Parmentelat <thierry.parmentelat@sophia.inria.fr> - MyPLC-4.3-26
+- plc.d/ssl preserves SSL certificates when it thinkfs they're obsolete
+
+* Wed Oct 07 2009 Thierry Parmentelat <thierry.parmentelat@sophia.inria.fr> - MyPLC-4.3-25
+- companion to NM's specialaccounts plugin
+- do not generate /etc/planetlab/root_ssh_key* anymore
+- remove related config. variables and conf_files
+
+* Sun Sep 20 2009 Stephen Soltesz <soltesz@cs.princeton.edu> - MyPLC-4.3-24
+- clarified description text to refer only to plcrt and not other optional
+- packages.
+
+* Sat Sep 19 2009 Stephen Soltesz <soltesz@cs.princeton.edu> - MyPLC-4.3-23
+- fixed a bug setting slice multiple attributes with the same tag name
+
+* Mon Sep 07 2009 Thierry Parmentelat <thierry.parmentelat@sophia.inria.fr> - MyPLC-4.3-22
+- SSL setup for monitor box, and related new config variables
+- new conf_file for /etc/planetlab/extensions
+- various tweaks in db-config internals, about initscripts among others
+- also more messages defined in the db
+
+* Tue Jul 07 2009 Thierry Parmentelat <thierry.parmentelat@sophia.inria.fr> - MyPLC-4.3-21
+- create node tags, like e.g. 'arch', that were not handled with 4.3-20
+
+* Tue Jul 07 2009 Thierry Parmentelat <thierry.parmentelat@sophia.inria.fr> - MyPLC-4.3-20
+- bugfix in db-config, tag 4.3-19 would not fly
+
+* Mon Jul 06 2009 Marc Fiuczynski <mef@cs.princeton.edu> - MyPLC-4.3-19
+- Refactored db-config into snippets in db-config.d/.
+
+* Thu Jul 02 2009 Thierry Parmentelat <thierry.parmentelat@sophia.inria.fr> - MyPLC-4.3-18
+- oops, tag 4.3-17 was broken and would not work
+
+* Wed Jul 01 2009 Thierry Parmentelat <thierry.parmentelat@sophia.inria.fr> - MyPLC-4.3-17
+- bugfix - escape sequences inserted in xml configs
+
+* Fri Jun 26 2009 Marc Fiuczynski <mef@cs.princeton.edu> - MyPLC-4.3-16
+- Handle db-config.d files properly.
+
+* Tue Jun 23 2009 Marc Fiuczynski <mef@cs.princeton.edu> - MyPLC-4.3-15
+- - Fix /etc/init.d/plc to have command usage show up on the tty rather
+- than the log file
+- - Fix db-config to be a bit more cautious when
+- /etc/planetlab/db-config.d doesn't exist
+- - Clean up db-config approach to ignore .bak, *~, .rpm{save,new}, and
+- .orig files.
+- - Refactor generic plc-config-tty code into plc_config.py.
+- plc-config-tty now contains MyPLC specific paths, "usual" variables,
+- and the list of validated variables and the corresponding
+- validator() function. This refactoring lets one reuse plc_config.py
+- as a generic cmdline configuration tool for highly customer MyPLC
+- like software.
+
+* Mon Jun 15 2009 Stephen Soltesz <soltesz@cs.princeton.edu> - MyPLC-4.3-14
+- update PCU Type descriptions.
+- updates to init scripts
+
+* Wed Jun 03 2009 Thierry Parmentelat <thierry.parmentelat@sophia.inria.fr> - MyPLC-4.3-13
+- requires monitor-pcucontrol so register-wizard can work
+
+* Tue May 26 2009 Thierry Parmentelat <thierry.parmentelat@sophia.inria.fr> - MyPLC-4.3-12
+- cleaned up plc-config-tty, no more need to configure plc-devel
+
+* Tue May 19 2009 Thierry Parmentelat <thierry.parmentelat@sophia.inria.fr> - MyPLC-4.3-11
+- first draft of plc-orpha-accounts.py, and rename check-ssl-peering into plc-<>
+
+* Fri May 15 2009 Thierry Parmentelat <thierry.parmentelat@sophia.inria.fr> - MyPLC-4.3-10
+- tighter right permissions on site_admin's authorized keys for more robustness
+
+* Wed May 06 2009 Thierry Parmentelat <thierry.parmentelat@sophia.inria.fr> - MyPLC-4.3-9
+- fix issue in db-config that prevented correct operation
+
+* Wed May 06 2009 Thierry Parmentelat <thierry.parmentelat@sophia.inria.fr> - MyPLC-4.3-8
+- remove support for chroot-based packaging - no crond nor syslog step anymore
+- plc init script now named plc.init instead of former guest.init
+
+* Mon May 04 2009 Stephen Soltesz <soltesz@cs.princeton.edu> - MyPLC-4.3-7
+- add Monitor to docs build
+
+* Wed Apr 29 2009 Marc Fiuczynski <mef@cs.princeton.edu> - MyPLC-4.3-6
+- plc_config.py and plc-config-tty: generalized to work for more diverse
+- MyPLC configurations.
+- plc.d/httpd: only update httpd_conf with /data for chroot'ed MyPLC
+- deployments and increase the memory limits in php.ini
+- plc.d/crond: add --full option to vacuumdb
+
+* Tue Apr 07 2009 Thierry Parmentelat <thierry.parmentelat@sophia.inria.fr> - MyPLC-4.3-5
+- avoid generating ssl certificates for disabled services among www api boot
+
+* Mon Mar 30 2009 Thierry Parmentelat <thierry.parmentelat@sophia.inria.fr> - MyPLC-4.3-4
+- cleaned up old entries in db-config
+- mtail more robust
+
+* Tue Mar 24 2009 Thierry Parmentelat <thierry.parmentelat@sophia.inria.fr> - MyPLC-4.3-3
+- php include path tweaked for plekit includes
+- reviewed myplc (fka native) packaging dependencies
+- renumbered 4.3
+
+* Thu Jan 29 2009 Thierry Parmentelat <thierry.parmentelat@sophia.inria.fr> - MyPLC-4.3-2
 - rename myplc into myplc-chroot and myplc-native into myplc
 - new settings (shortname & hrn_root) for local peer
 
-* Wed Sep 10 2008 Thierry Parmentelat <thierry.parmentelat@sophia.inria.fr> - MyPLC-5.0-1
+* Wed Sep 10 2008 Thierry Parmentelat <thierry.parmentelat@sophia.inria.fr> - MyPLC-4.3-1
 - First iteration of new data model
 - Bunch of various fixes
 
@@ -104,4 +278,4 @@ rm -rf $RPM_BUILD_ROOT
 - cosmetic change in kml output
 
 
-%define module_current_branch 4.2
+%define module_current_branch 4.3
index 1551805..47d2777 100644 (file)
@@ -57,7 +57,172 @@ rm -rf $RPM_BUILD_ROOT
 /etc/myplc-release
 
 %changelog
-* Thu Jan 29 2009 Thierry Parmentelat <thierry.parmentelat@sophia.inria.fr> - MyPLC-5.0-2
+* Fri Mar 12 2010 Thierry Parmentelat <thierry.parmentelat@sophia.inria.fr> - MyPLC-5.0-2
+- legacy scripts gen-sites-xml & gen-static-content back in (sigh)
+- new OMF category in the config
+- create the drl system slice
+
+* Fri Jan 29 2010 Thierry Parmentelat <thierry.parmentelat@sophia.inria.fr> - MyPLC-5.0-1
+- first working version of 5.0:
+- pld.c/, db-config.d/ and nodeconfig/ scripts should now sit in the module they belong to
+- nodefamily is 3-fold with pldistro-fcdistro-arch
+- new PLC_FLAVOUR config category
+- reviewed module layout
+- cleaned up old chroot-related build stuff (does not need the build module when building anymore)
+
+* Sat Jan 09 2010 Thierry Parmentelat <thierry.parmentelat@sophia.inria.fr> - MyPLC-4.3-37
+- support for fedora 12
+- new package myplc-config for use by sfa
+- drupal user registration turned off
+
+* Thu Dec 31 2009 Marc Fiuczynski <mef@cs.princeton.edu> - MyPLC-4.3-36
+- - fix to make sure when API, BOOT, MONITOR are on the same
+- machine as WWW that the SSL key,cert for WWW takes precedence.
+- - Do proper setup for SSL CA certficate to be used as the server
+- chain.
+
+* Wed Dec 23 2009 Marc Fiuczynski <mef@cs.princeton.edu> - MyPLC-4.3-35
+- - Change sysctl.conf source to be PlanetLabConfsysctl.con rather than the php script.
+
+* Tue Dec 22 2009 Baris Metin <Talip-Baris.Metin@sophia.inria.fr> - MyPLC-4.3-34
+- depend on pcucontrol
+
+* Fri Dec 18 2009 Baris Metin <Talip-Baris.Metin@sophia.inria.fr> - MyPLC-4.3-33
+- * validate input according to type in plc_config
+- * added the _genicw system slice
+- * add tag types for sites and persons
+- * add new tags for nodes and slices for exemption from myops
+
+* Thu Nov 26 2009 Thierry Parmentelat <thierry.parmentelat@sophia.inria.fr> - MyPLC-4.3-32
+- turn off drupal on a box that acts as BOOT server but not as WWW server
+- cleanup some obsolete code for old chroot-jail packaging in the process
+- new bootcd-kernel script for keeping bootcd variants up2date
+
+* Mon Nov 09 2009 Daniel Hokka Zakrisson <daniel@hozac.com> - MyPLC-4.3-31
+- Make the /etc/hosts manipulation optional.
+
+* Thu Nov 05 2009 Daniel Hokka Zakrisson <daniel@hozac.com> - MyPLC-4.3-30
+- Fix SetRole.
+
+* Tue Nov 03 2009 Marc Fiuczynski <mef@cs.princeton.edu> - MyPLC-4.3-29
+- - Added "SetRole()" so that db-config.d/ scriplets can insert roles
+- into the DB.
+- - Added the root ssh key handling support back into plc.d/ssh and the
+- default xml file.  This should be identical to the way it was in
+- rc12.
+- - Added support in the db-config.d/01-init script to register the root
+- ssh public key with the default administrator.  In this way the root
+- ssh key will make it into the root account on the nodes by means of
+- NodeManager's specialaccounts plugin.
+
+* Tue Oct 20 2009 Thierry Parmentelat <thierry.parmentelat@sophia.inria.fr> - MyPLC-4.3-28
+- db-config ignores sliver tags
+- sirius's db-config script renamed (was sirious)
+
+* Tue Oct 13 2009 Thierry Parmentelat <thierry.parmentelat@sophia.inria.fr> - MyPLC-4.3-27
+- fix for silverauth - missing tag types now created at plc startup time
+
+* Fri Oct 09 2009 Thierry Parmentelat <thierry.parmentelat@sophia.inria.fr> - MyPLC-4.3-26
+- plc.d/ssl preserves SSL certificates when it thinkfs they're obsolete
+
+* Wed Oct 07 2009 Thierry Parmentelat <thierry.parmentelat@sophia.inria.fr> - MyPLC-4.3-25
+- companion to NM's specialaccounts plugin
+- do not generate /etc/planetlab/root_ssh_key* anymore
+- remove related config. variables and conf_files
+
+* Sun Sep 20 2009 Stephen Soltesz <soltesz@cs.princeton.edu> - MyPLC-4.3-24
+- clarified description text to refer only to plcrt and not other optional
+- packages.
+
+* Sat Sep 19 2009 Stephen Soltesz <soltesz@cs.princeton.edu> - MyPLC-4.3-23
+- fixed a bug setting slice multiple attributes with the same tag name
+
+* Mon Sep 07 2009 Thierry Parmentelat <thierry.parmentelat@sophia.inria.fr> - MyPLC-4.3-22
+- SSL setup for monitor box, and related new config variables
+- new conf_file for /etc/planetlab/extensions
+- various tweaks in db-config internals, about initscripts among others
+- also more messages defined in the db
+
+* Tue Jul 07 2009 Thierry Parmentelat <thierry.parmentelat@sophia.inria.fr> - MyPLC-4.3-21
+- create node tags, like e.g. 'arch', that were not handled with 4.3-20
+
+* Tue Jul 07 2009 Thierry Parmentelat <thierry.parmentelat@sophia.inria.fr> - MyPLC-4.3-20
+- bugfix in db-config, tag 4.3-19 would not fly
+
+* Mon Jul 06 2009 Marc Fiuczynski <mef@cs.princeton.edu> - MyPLC-4.3-19
+- Refactored db-config into snippets in db-config.d/.
+
+* Thu Jul 02 2009 Thierry Parmentelat <thierry.parmentelat@sophia.inria.fr> - MyPLC-4.3-18
+- oops, tag 4.3-17 was broken and would not work
+
+* Wed Jul 01 2009 Thierry Parmentelat <thierry.parmentelat@sophia.inria.fr> - MyPLC-4.3-17
+- bugfix - escape sequences inserted in xml configs
+
+* Fri Jun 26 2009 Marc Fiuczynski <mef@cs.princeton.edu> - MyPLC-4.3-16
+- Handle db-config.d files properly.
+
+* Tue Jun 23 2009 Marc Fiuczynski <mef@cs.princeton.edu> - MyPLC-4.3-15
+- - Fix /etc/init.d/plc to have command usage show up on the tty rather
+- than the log file
+- - Fix db-config to be a bit more cautious when
+- /etc/planetlab/db-config.d doesn't exist
+- - Clean up db-config approach to ignore .bak, *~, .rpm{save,new}, and
+- .orig files.
+- - Refactor generic plc-config-tty code into plc_config.py.
+- plc-config-tty now contains MyPLC specific paths, "usual" variables,
+- and the list of validated variables and the corresponding
+- validator() function. This refactoring lets one reuse plc_config.py
+- as a generic cmdline configuration tool for highly customer MyPLC
+- like software.
+
+* Mon Jun 15 2009 Stephen Soltesz <soltesz@cs.princeton.edu> - MyPLC-4.3-14
+- update PCU Type descriptions.
+- updates to init scripts
+
+* Wed Jun 03 2009 Thierry Parmentelat <thierry.parmentelat@sophia.inria.fr> - MyPLC-4.3-13
+- requires monitor-pcucontrol so register-wizard can work
+
+* Tue May 26 2009 Thierry Parmentelat <thierry.parmentelat@sophia.inria.fr> - MyPLC-4.3-12
+- cleaned up plc-config-tty, no more need to configure plc-devel
+
+* Tue May 19 2009 Thierry Parmentelat <thierry.parmentelat@sophia.inria.fr> - MyPLC-4.3-11
+- first draft of plc-orpha-accounts.py, and rename check-ssl-peering into plc-<>
+
+* Fri May 15 2009 Thierry Parmentelat <thierry.parmentelat@sophia.inria.fr> - MyPLC-4.3-10
+- tighter right permissions on site_admin's authorized keys for more robustness
+
+* Wed May 06 2009 Thierry Parmentelat <thierry.parmentelat@sophia.inria.fr> - MyPLC-4.3-9
+- fix issue in db-config that prevented correct operation
+
+* Wed May 06 2009 Thierry Parmentelat <thierry.parmentelat@sophia.inria.fr> - MyPLC-4.3-8
+- remove support for chroot-based packaging - no crond nor syslog step anymore
+- plc init script now named plc.init instead of former guest.init
+
+* Mon May 04 2009 Stephen Soltesz <soltesz@cs.princeton.edu> - MyPLC-4.3-7
+- add Monitor to docs build
+
+* Wed Apr 29 2009 Marc Fiuczynski <mef@cs.princeton.edu> - MyPLC-4.3-6
+- plc_config.py and plc-config-tty: generalized to work for more diverse
+- MyPLC configurations.
+- plc.d/httpd: only update httpd_conf with /data for chroot'ed MyPLC
+- deployments and increase the memory limits in php.ini
+- plc.d/crond: add --full option to vacuumdb
+
+* Tue Apr 07 2009 Thierry Parmentelat <thierry.parmentelat@sophia.inria.fr> - MyPLC-4.3-5
+- avoid generating ssl certificates for disabled services among www api boot
+
+* Mon Mar 30 2009 Thierry Parmentelat <thierry.parmentelat@sophia.inria.fr> - MyPLC-4.3-4
+- cleaned up old entries in db-config
+- mtail more robust
+
+* Tue Mar 24 2009 Thierry Parmentelat <thierry.parmentelat@sophia.inria.fr> - MyPLC-4.3-3
+- php include path tweaked for plekit includes
+- reviewed myplc (fka native) packaging dependencies
+- renumbered 4.3
+
+* Thu Jan 29 2009 Thierry Parmentelat <thierry.parmentelat@sophia.inria.fr> - MyPLC-4.3-2
 - rename myplc into myplc-chroot and myplc-native into myplc
 - new settings (shortname & hrn_root) for local peer
 
+
+%define module_current_branch 4.3
index ab03843..ccf8409 100644 (file)
@@ -1,6 +1,5 @@
 #
 # $Id$
-#
 %define url $URL$
 
 %define name myplc
@@ -8,13 +7,12 @@
 %define taglevel 2
 
 %define release %{taglevel}%{?pldistro:.%{pldistro}}%{?date:.%{date}}
+%global python_sitearch        %( python -c "from distutils.sysconfig import get_python_lib; print get_python_lib(1)" )
 
-Summary: PlanetLab Central (PLC) Portable Installation
 Name: %{name}
 Version: %{version}
 Release: %{release}
 License: PlanetLab
-Group: Applications/Systems
 Source0: %{name}-%{version}.tar.gz
 BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root
 BuildArch: noarch
@@ -24,59 +22,56 @@ Packager: PlanetLab Central <support@planet-lab.org>
 Distribution: PlanetLab %{plrelease}
 URL: %(echo %{url} | cut -d ' ' -f 2)
 
+%define nodefamily %{pldistro}-%{distroname}-%{_arch}
+
+####################### myplc
+Summary: PlanetLab Central (PLC) Portable Installation
+Group: Applications/Systems
+
+# as much as possible, requires should go in the subpackages specfile
 Requires: bzip2
-Requires: sendmail-cf
 Requires: tar 
 Requires: less
-Requires: perl-GD
+Requires: sendmail
+Requires: sendmail-cf
 Requires: openssl
-Requires: xmlsec1
-Requires: gd
 Requires: expect
 Requires: php-pgsql
 Requires: curl
-Requires: python-pycurl
-Requires: python-psycopg2
-Requires: httpd
 Requires: rsync
-Requires: mod_python
-Requires: mod_ssl
-Requires: bootmanager
 Requires: python-devel
-Requires: SOAPpy
-Requires: vixie-cron
 Requires: yum
-Requires: php-gd
 Requires: PyXML
-Requires: sendmail
-Requires: python >= 2.4
 Requires: createrepo
-Requires: postgresql-python
 Requires: cpio
-Requires: postgresql-server
 Requires: wget
 Requires: php
-Requires: xmlsec1-openssl
-Requires: postgresql
 Requires: openssh
-Requires: bootcd-%{pldistro}-%{_arch}
 Requires: dnsmasq
 Requires: diffutils
 Requires: gzip
 Requires: vim-minimal
 Requires: findutils
+Requires: xmlsec1
+Requires: xmlsec1-openssl
+%if "%{distro}" == "Fedora" && %{distrorelease} >= 10
+Requires: cronie
+%else
+Requires: vixie-cron
+%endif
 # planetlab stuff
+Requires: bootmanager
+Requires: bootcd-%{nodefamily}
+Requires: bootcd-initscripts
 Requires: PLCWWW
+Requires: www-register-wizard
 Requires: nodeconfig
+Requires: nodeyum
 Requires: PLCAPI
-Requires: bootstrapfs-%{pldistro}-%{_arch}
+Requires: bootstrapfs-%{nodefamily}
 Requires: myplc-docs
 Requires: myplc-release
-
-# argh - ugly - we might wish to use something from build/config.%{pldistro} instead
-%if "%{pldistro}" == "onelab"
-Requires: dummynet_image
-%endif
+Requires: myplc-config
 
 %define debug_package %{nil}
 
@@ -89,31 +84,77 @@ through a graphical interface. All PLC services are started up and
 shut down through a single System V init script installed in the host
 system.
 
+####################### myplc-config
+
+%package config
+
+Summary: PlanetLab Central (PLC) configuration python module
+Group: Applications/Systems
+Requires: python
+
+%description config
+This package provides the Python module to configure MyPLC.
+
+
 %prep
 %setup -q
 
 %build
 
 %install
-pushd MyPLC
 rm -rf $RPM_BUILD_ROOT
-./build.sh %{pldistro} $RPM_BUILD_ROOT
-popd
+
+# Install configuration scripts
+echo "* Installing plc_config.py in " ${PYTHON_SITEARCH}
+PYTHON_SITEARCH=`python -c 'from distutils.sysconfig import get_python_lib; print get_python_lib(1)'`
+install -D -m 755 plc_config.py ${RPM_BUILD_ROOT}/${PYTHON_SITEARCH}/plc_config.py
+
+echo "* Installing scripts in /usr/bin"
+mkdir -p ${RPM_BUILD_ROOT}/usr/bin
+rsync -av --exclude .svn bin/ ${RPM_BUILD_ROOT}/usr/bin/
+chmod 755 ${RPM_BUILD_ROOT}/usr/bin/*
+
+# Install initscript 
+echo "* Installing plc initscript"
+install -D -m 755 plc.init ${RPM_BUILD_ROOT}/etc/init.d/plc
+
+# Install initscripts
+echo "* Installing plc.d initscripts"
+find plc.d | cpio -p -d -u ${RPM_BUILD_ROOT}/etc/
+chmod 755 ${RPM_BUILD_ROOT}/etc/plc.d/*
+
+# Install db-config.d files
+echo "* Installing db-config.d files"
+mkdir -p ${RPM_BUILD_ROOT}/etc/planetlab/db-config.d
+cp db-config.d/* ${RPM_BUILD_ROOT}/etc/planetlab/db-config.d
+chmod 444 ${RPM_BUILD_ROOT}/etc/planetlab/db-config.d/*
+
+# Extra scripts (mostly for mail and dns) not installed by myplc by default.  Used in production
+echo "* Installing scripts in /etc/support-scripts"
+mkdir -p ${RPM_BUILD_ROOT}/etc/support-scripts
+cp support-scripts/* ${RPM_BUILD_ROOT}/etc/support-scripts
+chmod 444 ${RPM_BUILD_ROOT}/etc/support-scripts/*
+
+# copy initscripts to etc/plc_sliceinitscripts
+mkdir -p ${RPM_BUILD_ROOT}/etc/plc_sliceinitscripts
+cp plc_sliceinitscripts/* ${RPM_BUILD_ROOT}/etc/plc_sliceinitscripts
+chmod 444 ${RPM_BUILD_ROOT}/etc/plc_sliceinitscripts/*
+
+# Install configuration file
+echo "* myplc: Installing configuration file"
+install -D -m 444 plc_config.dtd ${RPM_BUILD_ROOT}/etc/planetlab/plc_config.dtd
+sed -e "s,@PLDISTRO@,%{pldistro},g" -e "s,@FCDISTRO@,%{distroname},g" -e "s,@ARCH@,%{_arch},g" \
+    default_config.xml > ${RPM_BUILD_ROOT}/etc/planetlab/default_config.xml
+chmod 444 ${RPM_BUILD_ROOT}/etc/planetlab/default_config.xml
+
+echo "* Installing bashrc convenience"
+install -D -m 644 bashrc ${RPM_BUILD_ROOT}/usr/share/myplc/bashrc
+
+# yumgroups.xml and yum repo : let noderepo handle that
 
 %clean
 rm -rf $RPM_BUILD_ROOT
 
-# If run under sudo
-if [ -n "$SUDO_USER" ] ; then
-    # Allow user to delete the build directory
-    chown -h -R $SUDO_USER .
-    # Some temporary cdroot files like /var/empty/sshd and
-    # /usr/bin/sudo get created with non-readable permissions.
-    find . -not -perm +0600 -exec chmod u+rw {} \;
-    # Allow user to delete the built RPM(s)
-    [ -d %{_rpmdir}/noarch ] && chown -h -R $SUDO_USER %{_rpmdir}/noarch
-fi
-
 %pre
 if [ -x %{_sysconfdir}/init.d/plc ] ; then
     %{_sysconfdir}/init.d/plc stop
@@ -154,10 +195,6 @@ if [ -x /sbin/chkconfig ] ; then
     /sbin/chkconfig --add plc
     /sbin/chkconfig plc on
 fi
-pushd /usr/share/myplc &> /dev/null
-python plc_config.py build
-python plc_config.py install
-popd &> /dev/null
 
 %triggerpostun -- %{name}
 # 0 = erase, 1 = upgrade
@@ -189,28 +226,183 @@ fi
 /etc/init.d/plc
 /etc/plc.d
 /etc/planetlab
-/etc/plc_sliceinitscripts/sirius
-/etc/support-scripts/gen_aliases.py*
-/etc/support-scripts/renew_reminder.py*
-/etc/support-scripts/renew_reminder_logrotate
+/etc/plc_sliceinitscripts
+/etc/support-scripts
+/usr/bin/
+/usr/share/myplc/bashrc
+
+%files config
+%defattr(-,root,root,-)
 /usr/bin/plc-config
-/usr/bin/plc-config-tty
-/usr/bin/db-config
-/usr/bin/dns-config
-/usr/bin/plc-map.py*
-/usr/bin/plc-kml.py*
-/usr/bin/refresh-peer.py*
-/usr/bin/clean-empty-dirs.py*
-/usr/bin/mtail.py*
-/usr/bin/check-ssl-peering.py*
-/usr/share/myplc
+%{python_sitearch}/plc_config.py*
+
 
 %changelog
-* Thu Jan 29 2009 Thierry Parmentelat <thierry.parmentelat@sophia.inria.fr> - MyPLC-5.0-2
+* Fri Mar 12 2010 Thierry Parmentelat <thierry.parmentelat@sophia.inria.fr> - MyPLC-5.0-2
+- legacy scripts gen-sites-xml & gen-static-content back in (sigh)
+- new OMF category in the config
+- create the drl system slice
+
+* Fri Jan 29 2010 Thierry Parmentelat <thierry.parmentelat@sophia.inria.fr> - MyPLC-5.0-1
+- first working version of 5.0:
+- pld.c/, db-config.d/ and nodeconfig/ scripts should now sit in the module they belong to
+- nodefamily is 3-fold with pldistro-fcdistro-arch
+- new PLC_FLAVOUR config category
+- reviewed module layout
+- cleaned up old chroot-related build stuff (does not need the build module when building anymore)
+
+* Sat Jan 09 2010 Thierry Parmentelat <thierry.parmentelat@sophia.inria.fr> - MyPLC-4.3-37
+- support for fedora 12
+- new package myplc-config for use by sfa
+- drupal user registration turned off
+
+* Thu Dec 31 2009 Marc Fiuczynski <mef@cs.princeton.edu> - MyPLC-4.3-36
+- - fix to make sure when API, BOOT, MONITOR are on the same
+- machine as WWW that the SSL key,cert for WWW takes precedence.
+- - Do proper setup for SSL CA certficate to be used as the server
+- chain.
+
+* Wed Dec 23 2009 Marc Fiuczynski <mef@cs.princeton.edu> - MyPLC-4.3-35
+- - Change sysctl.conf source to be PlanetLabConfsysctl.con rather than the php script.
+
+* Tue Dec 22 2009 Baris Metin <Talip-Baris.Metin@sophia.inria.fr> - MyPLC-4.3-34
+- depend on pcucontrol
+
+* Fri Dec 18 2009 Baris Metin <Talip-Baris.Metin@sophia.inria.fr> - MyPLC-4.3-33
+- * validate input according to type in plc_config
+- * added the _genicw system slice
+- * add tag types for sites and persons
+- * add new tags for nodes and slices for exemption from myops
+
+* Thu Nov 26 2009 Thierry Parmentelat <thierry.parmentelat@sophia.inria.fr> - MyPLC-4.3-32
+- turn off drupal on a box that acts as BOOT server but not as WWW server
+- cleanup some obsolete code for old chroot-jail packaging in the process
+- new bootcd-kernel script for keeping bootcd variants up2date
+
+* Mon Nov 09 2009 Daniel Hokka Zakrisson <daniel@hozac.com> - MyPLC-4.3-31
+- Make the /etc/hosts manipulation optional.
+
+* Thu Nov 05 2009 Daniel Hokka Zakrisson <daniel@hozac.com> - MyPLC-4.3-30
+- Fix SetRole.
+
+* Tue Nov 03 2009 Marc Fiuczynski <mef@cs.princeton.edu> - MyPLC-4.3-29
+- - Added "SetRole()" so that db-config.d/ scriplets can insert roles
+- into the DB.
+- - Added the root ssh key handling support back into plc.d/ssh and the
+- default xml file.  This should be identical to the way it was in
+- rc12.
+- - Added support in the db-config.d/01-init script to register the root
+- ssh public key with the default administrator.  In this way the root
+- ssh key will make it into the root account on the nodes by means of
+- NodeManager's specialaccounts plugin.
+
+* Tue Oct 20 2009 Thierry Parmentelat <thierry.parmentelat@sophia.inria.fr> - MyPLC-4.3-28
+- db-config ignores sliver tags
+- sirius's db-config script renamed (was sirious)
+
+* Tue Oct 13 2009 Thierry Parmentelat <thierry.parmentelat@sophia.inria.fr> - MyPLC-4.3-27
+- fix for silverauth - missing tag types now created at plc startup time
+
+* Fri Oct 09 2009 Thierry Parmentelat <thierry.parmentelat@sophia.inria.fr> - MyPLC-4.3-26
+- plc.d/ssl preserves SSL certificates when it thinkfs they're obsolete
+
+* Wed Oct 07 2009 Thierry Parmentelat <thierry.parmentelat@sophia.inria.fr> - MyPLC-4.3-25
+- companion to NM's specialaccounts plugin
+- do not generate /etc/planetlab/root_ssh_key* anymore
+- remove related config. variables and conf_files
+
+* Sun Sep 20 2009 Stephen Soltesz <soltesz@cs.princeton.edu> - MyPLC-4.3-24
+- clarified description text to refer only to plcrt and not other optional
+- packages.
+
+* Sat Sep 19 2009 Stephen Soltesz <soltesz@cs.princeton.edu> - MyPLC-4.3-23
+- fixed a bug setting slice multiple attributes with the same tag name
+
+* Mon Sep 07 2009 Thierry Parmentelat <thierry.parmentelat@sophia.inria.fr> - MyPLC-4.3-22
+- SSL setup for monitor box, and related new config variables
+- new conf_file for /etc/planetlab/extensions
+- various tweaks in db-config internals, about initscripts among others
+- also more messages defined in the db
+
+* Tue Jul 07 2009 Thierry Parmentelat <thierry.parmentelat@sophia.inria.fr> - MyPLC-4.3-21
+- create node tags, like e.g. 'arch', that were not handled with 4.3-20
+
+* Tue Jul 07 2009 Thierry Parmentelat <thierry.parmentelat@sophia.inria.fr> - MyPLC-4.3-20
+- bugfix in db-config, tag 4.3-19 would not fly
+
+* Mon Jul 06 2009 Marc Fiuczynski <mef@cs.princeton.edu> - MyPLC-4.3-19
+- Refactored db-config into snippets in db-config.d/.
+
+* Thu Jul 02 2009 Thierry Parmentelat <thierry.parmentelat@sophia.inria.fr> - MyPLC-4.3-18
+- oops, tag 4.3-17 was broken and would not work
+
+* Wed Jul 01 2009 Thierry Parmentelat <thierry.parmentelat@sophia.inria.fr> - MyPLC-4.3-17
+- bugfix - escape sequences inserted in xml configs
+
+* Fri Jun 26 2009 Marc Fiuczynski <mef@cs.princeton.edu> - MyPLC-4.3-16
+- Handle db-config.d files properly.
+
+* Tue Jun 23 2009 Marc Fiuczynski <mef@cs.princeton.edu> - MyPLC-4.3-15
+- - Fix /etc/init.d/plc to have command usage show up on the tty rather
+- than the log file
+- - Fix db-config to be a bit more cautious when
+- /etc/planetlab/db-config.d doesn''t exist
+- - Clean up db-config approach to ignore .bak, *~, .rpm{save,new}, and
+- .orig files.
+- - Refactor generic plc-config-tty code into plc_config.py.
+- plc-config-tty now contains MyPLC specific paths, "usual" variables,
+- and the list of validated variables and the corresponding
+- validator() function. This refactoring lets one reuse plc_config.py
+- as a generic cmdline configuration tool for highly customer MyPLC
+- like software.
+
+* Mon Jun 15 2009 Stephen Soltesz <soltesz@cs.princeton.edu> - MyPLC-4.3-14
+- update PCU Type descriptions.
+- updates to init scripts
+
+* Wed Jun 03 2009 Thierry Parmentelat <thierry.parmentelat@sophia.inria.fr> - MyPLC-4.3-13
+- requires monitor-pcucontrol so register-wizard can work
+
+* Tue May 26 2009 Thierry Parmentelat <thierry.parmentelat@sophia.inria.fr> - MyPLC-4.3-12
+- cleaned up plc-config-tty, no more need to configure plc-devel
+
+* Tue May 19 2009 Thierry Parmentelat <thierry.parmentelat@sophia.inria.fr> - MyPLC-4.3-11
+- first draft of plc-orpha-accounts.py, and rename check-ssl-peering into plc-<>
+
+* Wed May 06 2009 Thierry Parmentelat <thierry.parmentelat@sophia.inria.fr> - MyPLC-4.3-9
+- fix issue in db-config that prevented correct operation
+
+* Wed May 06 2009 Thierry Parmentelat <thierry.parmentelat@sophia.inria.fr> - MyPLC-4.3-8
+- remove support for chroot-based packaging - no crond nor syslog step anymore
+- plc init script now named plc.init instead of former guest.init
+
+* Mon May 04 2009 Stephen Soltesz <soltesz@cs.princeton.edu> - MyPLC-4.3-7
+- add Monitor to docs build
+
+* Wed Apr 29 2009 Marc Fiuczynski <mef@cs.princeton.edu> - MyPLC-4.3-6
+- plc_config.py and plc-config-tty: generalized to work for more diverse
+- MyPLC configurations.
+- plc.d/httpd: only update httpd_conf with /data for chroot-ed MyPLC
+- deployments and increase the memory limits in php.ini
+- plc.d/crond: add --full option to vacuumdb
+
+* Tue Apr 07 2009 Thierry Parmentelat <thierry.parmentelat@sophia.inria.fr> - MyPLC-4.3-5
+- avoid generating ssl certificates for disabled services among www api boot
+
+* Mon Mar 30 2009 Thierry Parmentelat <thierry.parmentelat@sophia.inria.fr> - MyPLC-4.3-4
+- cleaned up old entries in db-config
+- mtail more robust
+
+* Tue Mar 24 2009 Thierry Parmentelat <thierry.parmentelat@sophia.inria.fr> - MyPLC-4.3-3
+- php include path tweaked for plekit includes
+- reviewed myplc (fka native) packaging dependencies
+- renumbered 4.3
+
+* Thu Jan 29 2009 Thierry Parmentelat <thierry.parmentelat@sophia.inria.fr> - MyPLC-4.3-2
 - rename myplc into myplc-chroot and myplc-native into myplc
 - new settings (shortname & hrn_root) for local peer
 
-* Wed Sep 10 2008 Thierry Parmentelat <thierry.parmentelat@sophia.inria.fr> - MyPLC-5.0-1
+* Wed Sep 10 2008 Thierry Parmentelat <thierry.parmentelat@sophia.inria.fr> - MyPLC-4.3-1
 - First iteration of new data model
 - Bunch of various fixes
 
@@ -284,4 +476,4 @@ fi
 * Fri Aug 31 2007 Marc E. Fiuczynski <mef@CS.Princeton.EDU>
 - initial build.
 
-%define module_current_branch 4.2
+%define module_current_branch 4.3
diff --git a/plc-config-tty b/plc-config-tty
deleted file mode 100755 (executable)
index 1e07481..0000000
+++ /dev/null
@@ -1,486 +0,0 @@
-#!/usr/bin/python
-
-# Interactively prompts for variable values
-# expected arguments are
-# command -d [default-xml [custom-xml [ consolidated-xml ]]]
-#
-# -d is for the myplc-devel package
-
-# we use 3 instances of PLCConfiguration throughout:
-# cdef : models the defaults, from plc_default.xml
-# cread : merged from plc_default & configs/site.xml
-# cwrite : site.xml + pending changes
-
-import sys
-import os
-import re
-import readline
-import getopt
-
-from plc_config import PLCConfiguration
-from plc_config import ConfigurationException
-
-####################
-release_id = "$Id$"
-release_rev = "$Revision$"
-
-def init_flavour (flavour):
-    global service
-    global usual_variables
-    if (flavour == "devel"):
-        service="plc-devel"
-        usual_variables=("PLC_DEVEL_FEDORA_URL",
-                          "PLC_DEVEL_CVSROOT")
-        config_dir = "/plc/devel/data/etc/planetlab"
-    else:
-        service="plc"
-        usual_variables=("PLC_NAME",
-                         "PLC_SHORTNAME",
-                         "PLC_SLICE_PREFIX",
-                         "PLC_ROOT_USER",
-                         "PLC_ROOT_PASSWORD",
-                         "PLC_MAIL_ENABLED",
-                         "PLC_MAIL_SUPPORT_ADDRESS",
-                         "PLC_DB_HOST",
-                         "PLC_API_HOST",
-                         "PLC_WWW_HOST",
-                         "PLC_BOOT_HOST",
-                         "PLC_NET_DNS1",
-                         "PLC_NET_DNS2",
-                         )
-        config_dir = "/etc/planetlab"
-    global def_default_config
-    def_default_config= "%s/default_config.xml" % config_dir
-    global def_site_config
-    def_site_config = "%s/configs/site.xml" % config_dir
-    global def_consolidated_config
-    def_consolidated_config = "%s/plc_config.xml" % config_dir
-
-    global mainloop_usage
-    mainloop_usage= """Available commands:
- Uppercase versions give variables comments, when available
- u/U\t\t\tEdit usual variables
- w\t\t\tWrite & consolidate
- r\t\t\tRestart %s service
- q\t\t\tQuit (without saving)
- h/?\t\t\tThis help
----
- l/L [<cat>|<var>]\tShow Locally modified variables/values
- s/S [<cat>|<var>]\tShow variables/values (all, in category, single)
- e/E [<cat>|<var>]\tEdit variables (all, in category, single)
----
- c\t\t\tList categories
- v/V [<cat>|<var>]List Variables (all, in category, single)
----
-Typical usage involves: u, [l,] w, r, q
-""" % service
-
-def usage ():
-    command_usage="Usage: %s [-d] [-v] [default-xml [site-xml [consolidated-xml]]]"% sys.argv[0]
-    init_flavour ("boot")
-    command_usage +="""
-  -v shows version and exits
-\t default-xml defaults to %s
-\t site-xml defaults to %s
-\t consolidated-xml defaults to %s""" % (def_default_config,def_site_config, def_consolidated_config)
-    command_usage += """
-  Unless you specify the -d option, meaning you want to configure
-  myplc-devel instead of regular myplc, in which case""" 
-    init_flavour ("devel")
-    command_usage +="""
-\t default-xml defaults to %s
-\t site-xml defaults to %s
-\t consolidated-xml defaults to %s""" % (def_default_config,def_site_config, def_consolidated_config)
-    print(command_usage)
-    sys.exit(1)
-
-####################
-variable_usage= """Edit Commands :
-#\tShow variable comments
-.\tStops prompting, return to mainloop
-/\tCleans any site-defined value, reverts to default
-=\tShows default value
->\tSkips to next category
-?\tThis help
-"""
-
-####################
-def get_value (config,  category_id, variable_id):
-    (category, variable) = config.get (category_id, variable_id)
-    return variable['value']
-
-def get_current_value (cread, cwrite, category_id, variable_id):
-    # the value stored in cwrite, if present, is the one we want
-    try:
-        result=get_value (cwrite,category_id,variable_id)
-    except:
-        result=get_value (cread,category_id,variable_id)
-    return result
-
-# refrain from using plc_config's _sanitize 
-def get_varname (config,  category_id, variable_id):
-    (category, variable) = config.get (category_id, variable_id)
-    return (category_id+"_"+variable['id']).upper()
-
-# could not avoid using _sanitize here..
-def get_name_comments (config, cid, vid):
-    try:
-        (category, variable) = config.get (cid, vid)
-        (id, name, value, comments) = config._sanitize_variable (cid,variable)
-        return (name,comments)
-    except:
-        return (None,[])
-
-def print_name_comments (config, cid, vid):
-    (name,comments)=get_name_comments(config,cid,vid)
-    if name:
-        print "### %s" % name
-    if comments:
-        for line in comments:
-            print "# %s" % line
-    else:
-        print "!!! No comment associated to %s_%s" % (cid,vid)
-
-####################
-def list_categories (config):
-    result=[]
-    for (category_id, (category, variables)) in config.variables().iteritems():
-        result += [category_id]
-    return result
-
-def print_categories (config):
-    print "Known categories"
-    for cid in list_categories(config):
-        print "%s" % (cid.upper())
-
-####################
-def list_category (config, cid):
-    result=[]
-    for (category_id, (category, variables)) in config.variables().iteritems():
-        if (cid == category_id):
-            for variable in variables.values():
-                result += ["%s_%s" %(cid,variable['id'])]
-    return result
-    
-def print_category (config, cid, show_comments=True):
-    cid=cid.lower()
-    CID=cid.upper()
-    vids=list_category(config,cid)
-    if (len(vids) == 0):
-        print "%s : no such category"%CID
-    else:
-        print "Category %s contains" %(CID)
-        for vid in vids:
-            print vid.upper()
-
-####################
-def consolidate (default_config, site_config, consolidated_config):
-    try:
-        conso = PLCConfiguration (default_config)
-        conso.load (site_config)
-        conso.save (consolidated_config)
-    except Exception, inst:
-        print "Could not consolidate, %s" % (str(inst))
-        return
-    print ("Merged\n\t%s\nand\t%s\ninto\t%s"%(default_config,site_config,
-                                              consolidated_config))
-    os.system("set -x ; service plc reload")
-        
-####################
-def restart_plc ():
-    print ("==================== Stopping %s" % service)
-    os.system("service %s stop" % service)
-    print ("==================== Starting %s" % service)
-    os.system("service %s start" % service)
-
-####################
-def prompt_variable (cdef, cread, cwrite, category, variable,
-                     show_comments, support_next=False):
-
-    assert category.has_key('id')
-    assert variable.has_key('id')
-
-    category_id = category ['id']
-    variable_id = variable['id']
-
-    while True:
-        default_value = get_value(cdef,category_id,variable_id)
-        current_value = get_current_value(cread,cwrite,category_id, variable_id)
-        varname = get_varname (cread,category_id, variable_id)
-        
-        if show_comments :
-            print_name_comments (cdef, category_id, variable_id)
-        prompt = "== %s : [%s] " % (varname,current_value)
-        try:
-            answer = raw_input(prompt).strip()
-        except EOFError :
-            raise Exception ('BailOut')
-
-        # no change
-        if (answer == "") or (answer == current_value):
-            return None
-        elif (answer == "."):
-            raise Exception ('BailOut')
-        elif (answer == "#"):
-            print_name_comments(cread,category_id,variable_id)
-        elif (answer == "?"):
-            print variable_usage.strip()
-        elif (answer == "="):
-            print ("%s defaults to %s" %(varname,default_value))
-        # revert to default : remove from cwrite (i.e. site-config)
-        elif (answer == "/"):
-            cwrite.delete(category_id,variable_id)
-            print ("%s reverted to %s" %(varname,default_value))
-            return
-        elif (answer == ">"):
-            if support_next:
-                raise Exception ('NextCategory')
-            else:
-                print "No support for next category"
-        else:
-            variable['value'] = answer
-            cwrite.set(category,variable)
-            return
-
-def prompt_variables_all (cdef, cread, cwrite, show_comments):
-    try:
-        for (category_id, (category, variables)) in cread.variables().iteritems():
-            print ("========== Category = %s" % category_id.upper())
-            for variable in variables.values():
-                try:
-                    newvar = prompt_variable (cdef, cread, cwrite, category, variable,
-                                              show_comments, True)
-                except Exception, inst:
-                    if (str(inst) == 'NextCategory'): break
-                    else: raise
-                    
-    except Exception, inst:
-        if (str(inst) == 'BailOut'): return
-        else: raise
-
-def prompt_variables_category (cdef, cread, cwrite, cid, show_comments):
-    cid=cid.lower()
-    CID=cid.upper()
-    try:
-        print ("========== Category = %s" % CID)
-        for vid in list_category(cdef,cid):
-            (category,variable) = cdef.locate_varname(vid.upper())
-            newvar = prompt_variable (cdef, cread, cwrite, category, variable,
-                                      show_comments, False)
-    except Exception, inst:
-        if (str(inst) == 'BailOut'): return
-        else: raise
-
-####################
-def show_variable (cdef, cread, cwrite,
-                   category, variable,show_value,show_comments):
-    assert category.has_key('id')
-    assert variable.has_key('id')
-
-    category_id = category ['id']
-    variable_id = variable['id']
-
-    default_value = get_value(cdef,category_id,variable_id)
-    current_value = get_current_value(cread,cwrite,category_id,variable_id)
-    varname = get_varname (cread,category_id, variable_id)
-    if show_comments :
-        print_name_comments (cdef, category_id, variable_id)
-    if show_value:
-        print "%s = %s" % (varname,current_value)
-    else:
-        print "%s" % (varname)
-
-def show_variables_all (cdef, cread, cwrite, show_value, show_comments):
-    for (category_id, (category, variables)) in cread.variables().iteritems():
-        print ("========== Category = %s" % category_id.upper())
-        for variable in variables.values():
-            show_variable (cdef, cread, cwrite,
-                           category, variable,show_value,show_comments)
-
-def show_variables_category (cdef, cread, cwrite, cid, show_value,show_comments):
-    cid=cid.lower()
-    CID=cid.upper()
-    print ("========== Category = %s" % CID)
-    for vid in list_category(cdef,cid):
-        (category,variable) = cdef.locate_varname(vid.upper())
-        show_variable (cdef, cread, cwrite, category, variable,
-                       show_value,show_comments)
-
-####################
-re_mainloop_0arg="^(?P<command>[uUwrqlLsSeEcvVhH\?])[ \t]*$"
-re_mainloop_1arg="^(?P<command>[sSeEvV])[ \t]+(?P<arg>\w+)$"
-matcher_mainloop_0arg=re.compile(re_mainloop_0arg)
-matcher_mainloop_1arg=re.compile(re_mainloop_1arg)
-
-def mainloop (cdef, cread, cwrite, default_config, site_config, consolidated_config):
-    while True:
-        try:
-            answer = raw_input("Enter command (u for usual changes, w to save, ? for help) ").strip()
-        except EOFError:
-            answer =""
-        if (answer == "") or (answer in "?hH"):
-            print mainloop_usage
-            continue
-        groups_parse = matcher_mainloop_0arg.match(answer)
-        command=None
-        if (groups_parse):
-            command = groups_parse.group('command')
-            arg=None
-        else:
-            groups_parse = matcher_mainloop_1arg.match(answer)
-            if (groups_parse):
-                command = groups_parse.group('command')
-                arg=groups_parse.group('arg')
-        if not command:
-            print ("Unknown command >%s< -- use h for help" % answer)
-            continue
-
-        show_comments=command.isupper()
-        command=command.lower()
-
-        mode='ALL'
-        if arg:
-            mode=None
-            arg=arg.lower()
-            variables=list_category (cdef,arg)
-            if len(variables):
-                # category_id as the category name
-                # variables as the list of variable names
-                mode='CATEGORY'
-                category_id=arg
-            arg=arg.upper()
-            (category,variable)=cdef.locate_varname(arg)
-            if variable:
-                # category/variable as output by locate_varname
-                mode='VARIABLE'
-            if not mode:
-                print "%s: no such category or variable" % arg
-                continue
-
-        if (command in "qQ"):
-            # todo check confirmation
-            return
-        elif (command in "wW"):
-            try:
-                # Confirm that various constraints are met before saving file.
-                cwrite.verify(cdef, cread)
-                cwrite.save(site_config)
-            except ConfigurationException, e:
-                print "Save failed due to a configuration exception: %s" % e
-                break;
-            except:
-                import traceback; print traceback.print_exc()
-                print ("Could not save -- fix write access on %s" % site_config)
-                break
-            print ("Wrote %s" % site_config)
-            consolidate(default_config, site_config, consolidated_config)
-            print ("You might want to type 'r' (restart plc) or 'q' (quit)")
-        elif (command == "u"):
-            try:
-                for varname in usual_variables:
-                    (category,variable) = cdef.locate_varname(varname)
-                    prompt_variable(cdef, cread, cwrite, category, variable, False)
-            except Exception, inst:
-                if (str(inst) != 'BailOut'):
-                    raise
-        elif (command == "r"):
-            restart_plc()
-        elif (command == "c"):
-            print_categories(cread)
-        elif (command in "eE"):
-            if mode == 'ALL':
-                prompt_variables_all(cdef, cread, cwrite,show_comments)
-            elif mode == 'CATEGORY':
-                prompt_variables_category(cdef,cread,cwrite,category_id,show_comments)
-            elif mode == 'VARIABLE':
-                try:
-                    prompt_variable (cdef,cread,cwrite,category,variable,
-                                     show_comments,False)
-                except Exception, inst:
-                    if (str(inst) != 'BailOut'):
-                        raise
-        elif (command in "vVsSlL"):
-            show_value=(command in "sSlL")
-            (c1,c2,c3) = (cdef, cread, cwrite)
-            if (command in "lL"):
-                (c1,c2,c3) = (cwrite,cwrite,cwrite)
-            if mode == 'ALL':
-                show_variables_all(c1,c2,c3,show_value,show_comments)
-            elif mode == 'CATEGORY':
-                show_variables_category(c1,c2,c3,category_id,show_value,show_comments)
-            elif mode == 'VARIABLE':
-                show_variable (c1,c2,c3,category,variable,show_value,show_comments)
-        else:
-            print ("Unknown command >%s< -- use h for help" % answer)
-
-####################
-# creates directory for file if not yet existing
-def check_dir (config_file):
-    dirname = os.path.dirname (config_file)
-    if (not os.path.exists (dirname)):
-        os.makedirs(dirname,0755)
-        if (not os.path.exists (dirname)):
-            print "Cannot create dir %s - exiting" % dirname
-            sys.exit(1)
-        else:
-            print "Created directory %s" % dirname
-                
-####################
-def main ():
-
-    command=sys.argv[0]
-    argv = sys.argv[1:]
-
-    save = True
-    # default is myplc (non -devel) unless -d is specified
-    init_flavour("boot")
-    optlist,list = getopt.getopt(argv,":dhv")
-    for opt in optlist:
-        if opt[0] == "-h":
-            usage()
-        if opt[0] == "-v":
-            print ("This is %s - %s" %(command,release_rev))
-            sys.exit(1)
-        if opt[0] == "-d":
-            init_flavour("devel")
-            argv=argv[1:]
-
-    if len(argv) == 0:
-        (default_config,site_config,consolidated_config) = (def_default_config, def_site_config, def_consolidated_config)
-    elif len(argv) == 1:
-        (default_config,site_config,consolidated_config) = (argv[0], def_site_config, def_consolidated_config)
-    elif len(argv) == 2:
-        (default_config, site_config,consolidated_config)  = (argv[0], argv[1], def_consolidated_config)
-    elif len(argv) == 3:
-        (default_config, site_config,consolidated_config)  = argv
-    else:
-        usage()
-
-    for c in (default_config,site_config,consolidated_config):
-        check_dir (c)
-
-    try:
-        # the default settings only - read only
-        cdef = PLCConfiguration(default_config)
-
-        # in effect : default settings + local settings - read only
-        cread = PLCConfiguration(default_config)
-
-    except:
-        print ("default config files not found, is myplc installed ?")
-        return 1
-
-    # local settings only, will be modified & saved
-    cwrite=PLCConfiguration()
-    
-    try:
-        cread.load(site_config)
-        cwrite.load(site_config)
-    except:
-        cwrite = PLCConfiguration()
-
-    mainloop (cdef, cread, cwrite,default_config, site_config, consolidated_config)
-    return 0
-
-if __name__ == '__main__':
-    main()
diff --git a/plc.d/api b/plc.d/api
deleted file mode 100755 (executable)
index c64937d..0000000
--- a/plc.d/api
+++ /dev/null
@@ -1,58 +0,0 @@
-#!/bin/bash
-#
-# priority: 450
-#
-# Configure the API. Must be done after SSL certificates are generated
-# and before the API web server is brought up.
-#
-# Mark Huang <mlhuang@cs.princeton.edu>
-# Copyright (C) 2006 The Trustees of Princeton University
-#
-# $Id$
-#
-
-# Source function library and configuration
-. /etc/plc.d/functions
-. /etc/planetlab/plc_config
-local_config=/etc/planetlab/configs/site.xml
-
-# Be verbose
-set -x
-
-case "$1" in
-    start)
-       if [ "$PLC_API_ENABLED" != "1" ] ; then
-           exit 0
-       fi
-
-       MESSAGE=$"Configuring the API"
-       dialog "$MESSAGE"
-
-       # Make sure that the API maintenance account is protected by a
-       # password.
-       if [ -z "$PLC_API_MAINTENANCE_PASSWORD" ] ; then
-           PLC_API_MAINTENANCE_PASSWORD=$(uuidgen)
-           plc-config --category=plc_api --variable=maintenance_password --value="$PLC_API_MAINTENANCE_PASSWORD" --save=$local_config $local_config
-           service plc reload
-       fi
-
-       # Make sure that all PLC servers are allowed to access the API
-       # through the maintenance account.
-       PLC_API_MAINTENANCE_SOURCES=($((
-           for ip in $PLC_API_MAINTENANCE_SOURCES ; do
-               echo $ip
-           done
-           for server in API BOOT WWW ; do
-               hostname=PLC_${server}_HOST
-               gethostbyname ${!hostname}
-           done
-        ) | sort -u))
-       PLC_API_MAINTENANCE_SOURCES=${PLC_API_MAINTENANCE_SOURCES[*]}
-       plc-config --category=plc_api --variable=maintenance_sources --value="$PLC_API_MAINTENANCE_SOURCES" --save=$local_config $local_config
-       service plc reload
-
-       result "$MESSAGE"
-       ;;
-esac
-
-exit $ERRORS
diff --git a/plc.d/bootcd b/plc.d/bootcd
deleted file mode 100755 (executable)
index e628dd7..0000000
+++ /dev/null
@@ -1,71 +0,0 @@
-#!/bin/bash
-#
-# priority: 1000
-#
-# Rebuild the Boot CD
-#
-# Mark Huang <mlhuang@cs.princeton.edu>
-# Copyright (C) 2006 The Trustees of Princeton University
-#
-# $Id$
-#
-
-# Source function library and configuration
-. /etc/plc.d/functions
-. /etc/planetlab/plc_config
-
-# Be verbose
-set -x
-
-case "$1" in
-    start)
-       if [ "$PLC_BOOT_ENABLED" != "1" -a \
-            "$PLC_WWW_ENABLED" != "1" ] ; then
-           exit 0
-       fi
-
-       MESSAGE=$"Rebuilding Boot CD"
-       dialog "$MESSAGE"
-
-       ########## legacy myplcs - temporary code
-       # create /etc/planetlab/nodefamily if missing
-       [ -f /etc/planetlab/nodefamily ] || { mkdir -p /etc/planetlab ; echo "planetlab-i386" > /etc/planetlab/nodefamily ; }
-       # move if plain directories
-       for legacydir in /usr/share/bootcd /var/www/html/download ; do
-           if [ -d "${legacydir}" ] && [ ! -h ${legacydir} ] ; then
-               rm -rf ${legacydir}-legacy
-               mv -f ${legacydir} ${legacydir}-legacy
-           fi
-       done
-       ########## end
-
-       # get the default nodefamily
-       def_nodefamily=$(cat /etc/planetlab/nodefamily)
-       
-       # Customize the Boot CD : run build.sh on all available bootcd's
-       shopt -s nullglob
-       for bootcd in /usr/share/bootcd-* ; do
-           name=$(basename $bootcd)
-           nodefamily=$(echo $name | sed -e s,bootcd-,,)
-           download=/var/www/html/download-${nodefamily}
-           [ -d ${download} ] || mkdir -p ${download}
-
-           pushd ${download}
-           ${bootcd}/build.sh ${PLC_BUILD_ALL_BOOTCDS:+-a}
-           check
-           popd
-       
-           # the default: create symlinks to the actual locations
-           if [ "${nodefamily}" == "${def_nodefamily}" ] ; then
-               rm -rf /usr/share/bootcd
-               ln -s /usr/share/bootcd-${nodefamily} /usr/share/bootcd
-               rm -rf /var/www/html/download
-               ln -s /var/www/html/download-${nodefamily} /var/www/html/download
-           fi
-       done
-
-       result "$MESSAGE"
-       ;;
-esac
-
-exit $ERRORS
diff --git a/plc.d/bootmanager b/plc.d/bootmanager
deleted file mode 100755 (executable)
index bdc05bc..0000000
+++ /dev/null
@@ -1,52 +0,0 @@
-#!/bin/bash
-#
-# priority: 1100
-#
-# Rebuild the Boot Manager
-#
-# Mark Huang <mlhuang@cs.princeton.edu>
-# Copyright (C) 2006 The Trustees of Princeton University
-#
-# $Id$
-#
-
-# Source function library and configuration
-. /etc/plc.d/functions
-. /etc/planetlab/plc_config
-
-# Be verbose
-set -x
-
-case "$1" in
-    start)
-       if [ "$PLC_BOOT_ENABLED" != "1" -a \
-            "$PLC_WWW_ENABLED" != "1" ] ; then
-           exit 0
-       fi
-
-       MESSAGE=$"Rebuilding Boot Manager"
-       dialog "$MESSAGE"
-
-       # Customize the Boot Manager
-       pushd /var/www/html/boot
-       /usr/share/bootmanager/build.sh
-       check
-
-       dirlist="" 
-       for i in `ls`; do 
-               if [ -d $i ]; then 
-                       dirlist="$dirlist $i" 
-               fi
-       done
-       for dir in $dirlist ; do 
-               echo -n " $dir"
-               /usr/share/bootmanager/build.sh $dir
-               check
-       done
-       popd
-
-       result "$MESSAGE"
-       ;;
-esac
-
-exit $ERRORS
diff --git a/plc.d/crond b/plc.d/crond
deleted file mode 100755 (executable)
index 024615c..0000000
+++ /dev/null
@@ -1,86 +0,0 @@
-#!/bin/bash
-#
-# priority: 900
-#
-# Configure cron jobs
-#
-# Mark Huang <mlhuang@cs.princeton.edu>
-# Copyright (C) 2006 The Trustees of Princeton University
-#
-# $Id$
-#
-
-# Source function library and configuration
-. /etc/plc.d/functions
-. /etc/planetlab/plc_config
-
-# Be verbose
-set -x
-
-# Export so that we do not have to specify -p to psql invocations
-export PGPORT=$PLC_DB_PORT
-
-case "$1" in
-    start)
-       MESSAGE=$"Starting crond"
-       dialog "$MESSAGE"
-
-       if [ "$PLC_MAIL_ENABLED" = "1" ] ; then
-           MAILTO=$PLC_MAIL_SUPPORT_ADDRESS
-       else
-           MAILTO=
-       fi
-
-       cat >/etc/cron.d/plc.cron <<EOF
-SHELL=/bin/bash
-PATH=/sbin:/bin:/usr/sbin:/usr/bin
-MAILTO=$MAILTO
-HOME=/
-#
-# minute hour day-of-month month day-of-week user command
-EOF
-
-        # Run all jobs once at startup
-
-       if [ "$PLC_WWW_ENABLED" = "1" ] ; then
-           echo "00 * * * * wget -O - -q http://localhost/cron.php" >>/etc/cron.d/plc.cron
-           wget -O - -q http://localhost/cron.php
-           check
-       fi
-
-       if [ "$PLC_DNS_ENABLED" = "1" ] ; then
-           echo "*/15 * * * * root dns-config" >>/etc/cron.d/plc.cron
-           dns-config
-           check
-       fi
-
-       if [ "$PLC_DB_ENABLED" = "1" ] ; then
-           echo "5 5 * * * root vacuumdb -U postgres --all --analyze --quiet" >>/etc/cron.d/plc.cron
-           vacuumdb -U postgres --all --analyze --quiet
-           check
-       fi
-
-       if [ "$PLC_WWW_ENABLED" = "1" ] ; then
-         echo "*/15 * * * * root clean-empty-dirs.py /var/tmp/bootmedium" >> /etc/cron.d/plc.cron
-         clean-empty-dirs.py /var/tmp/bootmedium
-         check
-       fi
-
-       plc_daemon crond
-       check
-
-       result "$MESSAGE"       
-       ;;
-
-    stop)
-       MESSAGE=$"Stopping crond"
-       dialog "$MESSAGE"
-
-       killproc plc_crond
-       check
-
-       result "$MESSAGE"       
-       ;;
-esac
-
-exit $ERRORS
diff --git a/plc.d/db b/plc.d/db
deleted file mode 100755 (executable)
index 3f0f8fd..0000000
--- a/plc.d/db
+++ /dev/null
@@ -1,188 +0,0 @@
-#!/bin/bash
-#
-# priority: 800
-#
-# Bootstrap the database
-#
-# Mark Huang <mlhuang@cs.princeton.edu>
-# Copyright (C) 2006 The Trustees of Princeton University
-#
-# $Id$
-#
-
-# Source function library and configuration
-. /etc/plc.d/functions
-. /etc/planetlab/plc_config
-
-# Be verbose
-set -x
-
-# Export so that we do not have to specify -p to psql invocations
-export PGPORT=$PLC_DB_PORT
-
-# Updates the database by applying all migration scripts in
-# /usr/share/plc_api/migrations/N-up-*, where N is greater than the
-# current subversion. At least one of the migration scripts with the
-# same N must update plc_db_version.subversion.
-function migrate_db()
-{
-    subversion=$(psql -U $PLC_DB_USER --quiet --tuples-only --no-align -c \
-                "SELECT subversion FROM plc_db_version LIMIT 1" \
-                $PLC_DB_NAME 2>/dev/null || echo 0)
-    shopt -s nullglob
-    for file in /usr/share/plc_api/migrations/[0-9]*-up-* ; do
-       script=$(basename $file)
-       index=${script%-up*}
-       extension=${script##*.}
-       if [ $index -gt $subversion ] ; then
-           if [ "$extension" = "sql" ] ; then
-               dialog " - $script (dbdumped)"
-               dump_planetlab_db "before-$script"
-               psql -U $PLC_DB_USER -f $file $PLC_DB_NAME
-           elif [ -x $file ] ; then
-               dialog " - $script (dbdumped)"
-               dump_planetlab_db "before-$script"
-               $file
-           else
-               dialog "\nWarning: migration $file not executable"
-           fi
-           check
-       fi
-    done
-}
-
-function checkpoint_planetlab_db()
-{
-    dumpfile=$1
-    pg_dump -U $PLC_DB_USER $PLC_DB_NAME > $dumpfile
-    check
-}
-
-function restore_planetlab_db()
-{
-    dumpfile=$1
-    if [ -n "$dumpfile" ] ; then 
-       [ -f "$dumpfile" ] && psql -a -U $PLC_DB_USER $PLC_DB_NAME < $dumpfile
-       check
-    fi
-}
-
-# use a single date of this script invocation for the dump_*_db functions.
-DATE=$(date +"%Y-%m-%d-%H-%M-%S")
-
-# Dumps the database - optional argument to specify filename suffix
-function dump_planetlab_db()
-{
-    if [ -n "$1" ] ; then suffix="-$1" ; else suffix="" ; fi
-    dumpfile=/var/lib/pgsql/backups/$(date +"${PLC_DB_NAME}.${DATE}${suffix}.sql")
-    checkpoint_planetlab_db $dumpfile
-}
-
-function restore_drupal_db()
-{
-    dumpfile=$1
-    if [ -n "$dumpfile" ] ; then 
-       [ -f "$dumpfile" ] && psql -a -U $PLC_DB_USER drupal < $1
-       check
-    fi
-}
-
-function checkpoint_drupal_db()
-{
-    dumpfile=$1
-    pg_dump -U $PLC_DB_USER drupal > $dumpfile
-    check
-}
-
-function dump_drupal_db()
-{
-    dumpfile=/var/lib/pgsql/backups/$(date +"drupal.${DATE}.sql")
-    checkpoint_drupal_db $dumpfile
-    check
-}
-
-# Clean up old backups
-function clean_dumps()
-{
-    find /var/lib/pgsql/backups '(' -name "$PLC_DB_NAME.*.sql" -o -name "drupal.*.sql" ')' -a -atime +15 | xargs rm -f
-    check
-}
-
-[ $PLC_DB_ENABLED -ne 1 ] && exit 0
-case "$1" in
-    start)
-       MESSAGE=$"Bootstrapping the database"
-       dialog "$MESSAGE"
-
-       # Apply schema updates
-       migrate_db
-
-       # Update the maintenance account username. This can't be
-       # done through the api-config script since it uses the
-       # maintenance account to access the API. The maintenance
-       # account should be person_id 1 since it is created by the
-       # DB schema itself.
-       psql -U $PLC_DB_USER -c "UPDATE persons SET email='$PLC_API_MAINTENANCE_USER' WHERE person_id=1" $PLC_DB_NAME
-
-       # Update the Drupal site_name variable
-       psql -U $PLC_DB_USER drupal <<EOF
-DELETE FROM variable WHERE name = 'site_name';
-INSERT INTO variable (name, value) VALUES ('site_name', 's:${#PLC_NAME}:"$PLC_NAME";');
-EOF
-
-       # Bootstrap the DB
-       db-config
-       check
-
-       result "$MESSAGE"
-       ;;
-
-    migrate)
-       MESSAGE=$"Migrating the database"
-       dialog "$MESSAGE"
-
-       migrate_db
-       result "$MESSAGE"
-       ;;
-
-    dump)
-       MESSAGE=$"Dumping the databases in /var/lib/pgsql/backups"
-       dialog "$MESSAGE"
-
-       dump_planetlab_db
-       dump_drupal_db
-       result "$MESSAGE"
-       ;;
-
-    checkpoint)
-       MESSAGE=$"Checkpointing the databases"
-       checkpoint_planetlab_db $2
-       checkpoint_drupal_db $3
-       ;;
-
-    restore)
-       MESSAGE=$"Restoring the databases from checkpoint files"
-       restore_planetlab_db $2
-       restore_drupal_db $3
-       ;;
-
-    clean-dump)
-       MESSAGE=$"Cleaning old database dumps"
-       dialog "$MESSAGE"
-
-       clean_dumps
-       result "$MESSAGE"
-       ;;
-
-    stop)
-       MESSAGE=$"Ignoring request to stop myplc databases"
-       result "$MESSAGE"
-       ;;
-
-    *)
-        echo "Usage: $0 [start|migrate|dump|checkpoint|restore|clean-dump|stop]"
-       exit 1
-       ;;
-esac
-
-exit $ERRORS
index b195809..aea50f7 100755 (executable)
--- a/plc.d/dns
+++ b/plc.d/dns
@@ -1,6 +1,8 @@
 #!/bin/bash
+# $Id$
+# $URL$
 #
-# priority: 850
+# priority: 950
 #
 # Start local DNS server to provide minimal DNS forward resolution for
 # ourselves and our nodes.
@@ -8,8 +10,6 @@
 # Mark Huang <mlhuang@cs.princeton.edu>
 # Copyright (C) 2006 The Trustees of Princeton University
 #
-# $Id$
-#
 
 # Source function library and configuration
 . /etc/plc.d/functions
@@ -23,7 +23,7 @@ set -x
 case "$1" in
     start)
        if [ $PLC_DNS_ENABLED -eq 1 ] ; then
-           MESSAGE=$"Starting DNS server"
+           MESSAGE="Starting DNS server"
            dialog "$MESSAGE"
 
            dns-config
@@ -32,7 +32,7 @@ case "$1" in
 
        # Set up nameservers
        if [ -n "$PLC_NET_DNS1" -o -n "$PLC_NET_DNS2" ] ; then
-           MESSAGE=$"Configuring resolv.conf"
+           MESSAGE="Configuring resolv.conf"
            dialog "$MESSAGE"
 
            rfile=$(mktemp)
@@ -63,9 +63,9 @@ case "$1" in
        ;;
 
     stop)
-       MESSAGE=$"Reverting /etc/resolv.conf and /etc/hosts"
-       dialog "$MESSAGE"
        if [ $PLC_DNS_ENABLED -eq 1 ] ; then
+           MESSAGE=$"Reverting /etc/resolv.conf"
+           dialog "$MESSAGE"
            if [ -f "/etc/plc_resolv.conf" ] ; then
                ourfile=$(grep "$SIGNATURE" /etc/plc_resolv.conf| wc -l)
                if [ $ourfile -ne 0 ] ; then 
@@ -73,21 +73,28 @@ case "$1" in
                fi
                mv -f /etc/plc_resolv.conf /etc/resolv.conf
            fi
+           check
+           result ""
+           MESSAGE=$"Removing /etc/plc_hosts"
+           dialog "$MESSAGE"
            [ -f "/etc/plc_hosts" ] && rm -f /etc/plc_hosts
+           result ""
        fi
        if [ $PLC_DNS_ENABLED -eq 0 -a -f "/etc/resolv_plc.backup" ] ; then
+           MESSAGE="Restoring /etc/resolv.conf"
+           dialog "$MESSAGE"
            mv -f /etc/resolv_plc.backup /etc/resolv.conf
+           result ""
        fi
 
        if [ $PLC_DNS_ENABLED -eq 1 ] ; then
-           MESSAGE=$"Stopping DNS server"
+           MESSAGE="Stopping DNS server"
            dialog "$MESSAGE"
-
            killproc plc_dnsmasq
            check
+           result ""
        fi
 
-       result "$MESSAGE"
        ;;
 esac
 
index 29c5881..e2e128c 100644 (file)
@@ -1,12 +1,12 @@
 # -*-Shell-script-*-
+# $Id$
+# $URL$
 #
 # Common functions for PLC startup/shutdown scripts
 #
 # Mark Huang <mlhuang@cs.princeton.edu>
 # Copyright (C) 2006 The Trustees of Princeton University
 #
-# $Id$
-#
 
 export PATH=/sbin:/bin:/usr/bin:/usr/sbin
 
index 5fd3923..2342885 100755 (executable)
--- a/plc.d/gpg
+++ b/plc.d/gpg
@@ -1,14 +1,14 @@
 #!/bin/bash
+# $Id$
+# $URL$
 #
-# priority: 500
+# priority: 400
 #
 # Generate GPG keys
 #
 # Mark Huang <mlhuang@cs.princeton.edu>
 # Copyright (C) 2006 The Trustees of Princeton University
 #
-# $Id$
-#
 
 # Source function library and configuration
 . /etc/plc.d/functions
@@ -113,7 +113,12 @@ EOF
            rpm --allmatches -e gpg-pubkey
            check
        fi
-       rpm --import /etc/pki/rpm-gpg/*
+       # starting with rpm-4.6, this fails when run a second time
+       # it would be complex to do this properly based on the filename, 
+       # as /etc/pki/rpm-gpg/ typically has many symlinks to the same file
+       # see also http://fedoranews.org/tchung/gpg/
+       # so just ignore the result
+       rpm --import /etc/pki/rpm-gpg/* || :
        check
 
        # Make GPG key readable by apache so that the API can sign peer requests
index 5078c0e..f62c66c 100755 (executable)
@@ -1,14 +1,14 @@
 #!/bin/bash
+# $Id$
+# $URL$
 #
-# priority: 700
+# priority: 600
 #
 # Configure Apache web server
 #
 # Mark Huang <mlhuang@cs.princeton.edu>
 # Copyright (C) 2006 The Trustees of Princeton University
 #
-# $Id$
-#
 
 # Source function library and configuration
 . /etc/plc.d/functions
@@ -24,6 +24,15 @@ httpd_conf=/etc/httpd/conf/httpd.conf
 ssl_conf=/etc/httpd/conf.d/ssl.conf
 plc_conf=/etc/httpd/conf.d/plc.conf
 
+function disable_file () {
+    file=$1; shift
+    [ -f $file ] && mv -f $file $file.disabled
+}
+function enable_file () {
+    file=$1; shift
+    [ ! -f $file ] && mv -f $file.disabled $file
+}
+
 case "$1" in
     start)
        if [ "$PLC_API_ENABLED" != "1" -a \
@@ -35,19 +44,18 @@ case "$1" in
        MESSAGE=$"Starting web server"
        dialog "$MESSAGE"
 
-       # Set the document root to /data/var/www/html (static files
-       # and PlanetLabConf only, no Drupal or admin pages) if the web
-       # server should not run on this machine.
+       # set document root - not really useful on fedora but just in case
+       sed -i -e "s@^DocumentRoot.*@DocumentRoot \"$DocumentRoot\"@" $httpd_conf
+       # whether WWW is enabled or not : 
        if [ "$PLC_WWW_ENABLED" != "1" ] ; then
-           sed -i -e "s@^DocumentRoot.*@DocumentRoot \"/data$DocumentRoot\"@" $httpd_conf
-           ln -nsf $DocumentRoot/PlanetLabConf /data$DocumentRoot/PlanetLabConf
+           # avoid hitting drupal, that would try to connect to the db and create noise
+           disable_file $DocumentRoot/index.php
        else
-           sed -i -e "s@^DocumentRoot.*@DocumentRoot \"$DocumentRoot\"@" $httpd_conf
-           rm -f /data$DocumentRoot/PlanetLabConf
+           enable_file $DocumentRoot/index.php
        fi
 
        # Set the default include path
-       include_path=".:$DocumentRoot/planetlab/includes:$DocumentRoot/generated:/etc/planetlab/php:/usr/share/plc_api/php"
+       include_path=".:$DocumentRoot/planetlab/includes:$DocumentRoot/plekit/php:$DocumentRoot/generated:/etc/planetlab/php:/usr/share/plc_api/php"
        sed -i -e "s@[;]*include_path = \"\.:.*\"@include_path = \"$include_path\"@" $php_ini
 
        # Disable default Listen directive
@@ -197,7 +205,7 @@ EOF
 
        ## patch php.ini
        # memory limit
-       sed -i -e 's,^memory_limit = 8M *;,memory_limit = 24M ; patch myplc -- ,' $php_ini 
+       sed -i -e 's,^memory_limit = 32M *;,memory_limit = 80M ; patch myplc -- ,' $php_ini 
        # log_errors : is On by default
        # error_log
        if ! grep '^error_log *=' $php_ini > /dev/null ; then
index fba0973..2adfc97 100755 (executable)
@@ -1,14 +1,14 @@
 #!/bin/bash
+# $Id$
+# $URL$
 #
-# priority: 250
+# priority: 200
 #
 # Start local mail server.
 #
 # Mark Huang <mlhuang@cs.princeton.edu>
 # Copyright (C) 2006 The Trustees of Princeton University
 #
-# $Id$
-#
 
 # Source function library and configuration
 . /etc/plc.d/functions
@@ -28,7 +28,10 @@ case "$1" in
 
        # Add apache to list of users that can send mail as others
        # without a warning, so that the API can send out mail.
-       echo "apache" >/etc/mail/trusted-users
+       count=$(grep ^apache /etc/mail/trusted-users|wc -l)
+       if [ $count -eq 0 ] ; then
+               echo "apache" >>/etc/mail/trusted-users
+       fi
 
        (exec 3>&- 4>&- ; service sendmail start)
        check
index 39d44e9..782f3d7 100755 (executable)
@@ -1,4 +1,6 @@
 #!/bin/bash
+# $Id$
+# $URL$
 #
 # priority: 100
 #
@@ -7,8 +9,6 @@
 # Mark Huang <mlhuang@cs.princeton.edu>
 # Copyright (C) 2006 The Trustees of Princeton University
 #
-# $Id$
-#
 
 # Source function library and configuration
 . /etc/plc.d/functions
@@ -17,6 +17,8 @@
 # Be verbose
 set -x
 
+[ "$PLC_HOSTS_ENABLED" -ne 1 ] && exit 0
+
 case "$1" in
     start)
        MESSAGE=$"Generating network files"
@@ -51,6 +53,7 @@ case "$1" in
        if [ -f /etc/hosts_plc.backup ] ; then
            mv -f /etc/hosts_plc.backup /etc/hosts
        fi
+       dialog "$MESSAGE"
        result "$MESSAGE"
        ;;
 esac
diff --git a/plc.d/packages b/plc.d/packages
deleted file mode 100755 (executable)
index be99234..0000000
+++ /dev/null
@@ -1,131 +0,0 @@
-#!/bin/bash
-#
-# priority: 1200
-#
-# Update node package repository metadata and sign packages
-#
-# Mark Huang <mlhuang@cs.princeton.edu>
-# Copyright (C) 2006 The Trustees of Princeton University
-#
-# $Id$
-#
-
-# Source function library and configuration
-. /etc/plc.d/functions
-. /etc/planetlab/plc_config
-
-# Be verbose
-set -x
-
-case "$1" in
-    start)
-       if [ "$PLC_BOOT_ENABLED" != "1" ] ; then
-           exit 0
-       fi
-
-       MESSAGE=$"Signing and indexing node packages"
-       dialog "$MESSAGE"
-
-       shopt -s nullglob
-
-       shift
-       if [[ -z "$@" ]] ; then
-           # use all subdirs in install-rpms by default
-           repositories=/var/www/html/install-rpms/*
-       else
-           # else use argv
-           repositories="$@"
-       fi
-
-       ### availability of repo indexing tools
-       # old one - might be needed for old-style nodes
-       type -p yum-arch > /dev/null && have_yum_arch="true"
-       # new one
-       type -p createrepo > /dev/null && have_createrepo="true"
-
-       for repository in $repositories ; do
-           # the rpms that need signing
-           new_rpms=
-           # and the corresponding stamps
-           new_stamps=
-           # is there a need to refresh yum metadata
-           need_yum_arch=
-           need_createrepo=
-
-           # right after installation, no package is present
-           # but we still need to create index 
-           [ -n "$have_yum_arch" -a ! -f $repository/headers/header.info ] && need_yum_arch=true
-           [ -n "$have_createrepo" -a ! -f $repository/repodata/repomd.xml ] && need_createrepo=true
-           
-           for package in $(find $repository/ -name '*.rpm') ; do
-               stamp=$repository/signed-stamps/$(basename $package).signed
-               # If package is newer than signature stamp
-               if [ $package -nt $stamp ] ; then
-                   new_rpms="$new_rpms $package"
-                   new_stamps="$new_stamps $stamp"
-               fi
-               # Or than yum-arch headers
-               [ -n "$have_yum_arch" ] && [ $package -nt $repository/headers/header.info ] && need_yum_arch=true
-               # Or than createrepo database
-               [ -n "$have_createrepo" ] && [ $package -nt $repository/repodata/repomd.xml ] && need_createrepo=true
-           done
-
-           if [ -n "$new_rpms" ] ; then
-               # Create a stamp once the package gets signed
-               mkdir $repository/signed-stamps 2> /dev/null
-
-               # Sign RPMS. setsid detaches rpm from the terminal,
-                # allowing the (hopefully blank) GPG password to be
-                # entered from stdin instead of /dev/tty.
-               echo | setsid rpm \
-                   --define "_signature gpg" \
-                   --define "_gpg_path /etc/planetlab" \
-                   --define "_gpg_name $PLC_MAIL_SUPPORT_ADDRESS" \
-                   --resign $new_rpms && touch $new_stamps
-               check
-           fi
-
-           # Update repository index / yum metadata. 
-
-           if [ -n "$need_yum_arch" ] ; then
-               # yum-arch sometimes leaves behind
-               # .oldheaders and .olddata directories accidentally.
-               rm -rf $repository/{.oldheaders,.olddata}
-               yum-arch $repository 
-               check
-           fi
-
-           if [ -n "$need_createrepo" ] ; then
-               if [ -f $repository/yumgroups.xml ] ; then
-                   createrepo --quiet -g yumgroups.xml $repository 
-               else
-                   createrepo --quiet $repository
-               fi
-               check
-           fi
-       done
-
-       result "$MESSAGE"
-       ;;
-    clean)
-       shift
-       if [[ -z "$@" ]] ; then
-           # use all subdirs in install-rpms by default
-           repositories=/var/www/html/install-rpms/*
-       else
-           # else use argv
-           repositories=$@
-       fi
-
-       for repository in $repositories ; do
-           rm -rf $repository/signed-stamps
-           rm -rf $repository/repodata
-           rm -rf $repository/headers
-       done
-       ;;
-    *)
-        echo "Usage: $0 start|clean [repo ..]"
-       ;;
-esac
-
-exit $ERRORS
diff --git a/plc.d/postgresql b/plc.d/postgresql
deleted file mode 100755 (executable)
index f4c2093..0000000
+++ /dev/null
@@ -1,196 +0,0 @@
-#!/bin/bash
-#
-# priority: 300
-#
-# Manage the PostgreSQL database server
-#
-# Mark Huang <mlhuang@cs.princeton.edu>
-# Copyright (C) 2006 The Trustees of Princeton University
-#
-# $Id$
-#
-
-# Source function library and configuration
-. /etc/plc.d/functions
-. /etc/planetlab/plc_config
-local_config=/etc/planetlab/configs/site.xml
-
-# Be verbose
-set -x
-
-# Default locations
-PGDATA=/var/lib/pgsql/data
-postgresql_conf=$PGDATA/postgresql.conf
-pghba_conf=$PGDATA/pg_hba.conf
-
-# Export so that we do not have to specify -p to psql invocations
-export PGPORT=$PLC_DB_PORT
-
-# /etc/init.d/postgresql always returns 0, even on failure
-postgresql_start ()
-{
-    # start() always returns 0
-    (exec 3>&- 4>&- ; service postgresql start)
-
-    # status() will still return 0 even while still initializing
-    if status postmaster && [ -f /var/lock/subsys/postgresql ] ; then
-       # The only way we can be sure is if we can access it
-       for i in $(seq 1 10) ; do
-           # Must do this as the postgres user initially (before we
-           # fix pg_hba.conf to passwordless localhost access).
-           su -c 'psql -U postgres -c "" template1' postgres && return 0
-           sleep 1
-       done
-    fi
-
-    return 1
-}
-
-postgresql_init ()
-{
-    service postgresql initdb &> /dev/null || :
-    postgresql_start
-}
-
-case "$1" in
-    start)
-       if [ "$PLC_DB_ENABLED" != "1" ] ; then
-           exit 0
-       fi
-
-       MESSAGE=$"Starting PostgreSQL server"
-       dialog "$MESSAGE"
-
-       # Set data directory and redirect startup output to /var/log/pgsql
-       mkdir -p /etc/sysconfig/pgsql
-       (
-           echo "PGDATA=$PGDATA"
-           echo "PGLOG=/var/log/pgsql"
-           echo "PGPORT=$PLC_DB_PORT"
-       ) >>/etc/sysconfig/pgsql/postgresql
-
-       # Fix ownership (rpm installation may have changed it)
-       chown -R -H postgres:postgres $(dirname $PGDATA)
-
-       # PostgreSQL must be started at least once to bootstrap
-       # /var/lib/pgsql/data
-       if [ ! -f $postgresql_conf ] ; then
-           postgresql_init
-           check
-           service postgresql stop
-           check
-       fi
-
-       # Enable DB server. PostgreSQL >=8.0 defines listen_addresses,
-       # PostgreSQL 7.x uses tcpip_socket.
-       if grep -q listen_addresses $postgresql_conf ; then
-           sed -i -e '/^listen_addresses/d' $postgresql_conf
-           echo "listen_addresses = '*'" >>$postgresql_conf
-       elif grep -q tcpip_socket $postgresql_conf ; then
-           sed -i -e '/^tcpip_socket/d' $postgresql_conf
-           echo "tcpip_socket = true" >>$postgresql_conf
-       fi
-
-       # Disable access to all DBs from all hosts
-       sed -i -e '/^\(host\|local\)/d' $pghba_conf
-
-       # Enable passwordless localhost access
-       echo "local all all trust" >>$pghba_conf
-
-       # Enable access from the API, boot, and web servers
-       PLC_API_IP=$(gethostbyname $PLC_API_HOST)
-       PLC_BOOT_IP=$(gethostbyname $PLC_BOOT_HOST)
-       PLC_WWW_IP=$(gethostbyname $PLC_WWW_HOST)
-       ip_failure=0
-       if [ -z "$PLC_API_IP" ] ; then
-           MESSAGE=$"PLC_API_IP is not set"
-           dialog "$MESSAGE"
-           ip_failure=1
-       fi
-       if [ -z "$PLC_BOOT_IP" ] ; then
-           MESSAGE=$"PLC_BOOT_IP is not set"
-           dialog "$MESSAGE"
-           ip_failure=1
-       fi
-       if [ -z "$PLC_WWW_IP" ] ; then
-           MESSAGE=$"PLC_WWW_IP is not set"
-           dialog "$MESSAGE"
-           ip_failure=1
-       fi
-       if [ $ip_failure -eq 1 ] ; then
-           /bin/false
-           check
-       fi
-
-       (
-           echo "host $PLC_DB_NAME $PLC_DB_USER 127.0.0.1/32 password"
-           echo "host $PLC_DB_NAME $PLC_DB_USER $PLC_API_IP/32 password"
-           echo "host $PLC_DB_NAME $PLC_DB_USER $PLC_BOOT_IP/32 password"
-           echo "host $PLC_DB_NAME $PLC_DB_USER $PLC_WWW_IP/32 password"
-           # Drupal also uses PostgreSQL
-           echo "host drupal $PLC_DB_USER 127.0.0.1/32 password"
-           echo "host drupal $PLC_DB_USER $PLC_WWW_IP/32 password"
-       ) >>$pghba_conf
-
-       # Append site-specific access rules
-       for file in $pghba_conf.d/*.conf ; do
-           cat "$file" >>$pghba_conf
-       done
-
-       # Fix ownership (sed -i changes it)
-       chown postgres:postgres $postgresql_conf $pghba_conf
-
-       # Start up the server
-       postgresql_start
-       check
-
-       # Create/update the unprivileged database user and password
-       if [ -z "$PLC_DB_PASSWORD" ] ; then
-           PLC_DB_PASSWORD=$(uuidgen)
-           plc-config --category=plc_db --variable=password --value="$PLC_DB_PASSWORD" --save=$local_config $local_config
-           service plc reload
-       fi
-       if ! psql -U $PLC_DB_USER -c "" template1 >/dev/null 2>&1 ; then
-           psql -U postgres -c "CREATE USER $PLC_DB_USER PASSWORD '$PLC_DB_PASSWORD'" template1
-       else
-           psql -U postgres -c "ALTER USER $PLC_DB_USER WITH PASSWORD '$PLC_DB_PASSWORD'" template1
-       fi
-       check
-
-       # Create the databases if necessary
-       if ! psql -U $PLC_DB_USER -c "" $PLC_DB_NAME >/dev/null 2>&1 ; then
-           createdb -U postgres --encoding=UNICODE --owner=$PLC_DB_USER $PLC_DB_NAME
-           psql -U $PLC_DB_USER -f /usr/share/plc_api/$PLC_DB_NAME.sql $PLC_DB_NAME
-       fi
-       check
-       if ! psql -U $PLC_DB_USER -c "" drupal >/dev/null 2>&1 ; then
-           createdb -U postgres --encoding=UNICODE --owner=$PLC_DB_USER drupal
-            psql -U $PLC_DB_USER -f /var/www/html/database/database.pgsql drupal 
-       fi
-       check
-
-       result "$MESSAGE"
-       ;;
-
-    stop)
-       MESSAGE=$"Stopping PostgreSQL server"
-       dialog "$MESSAGE"
-
-       # Drop the current user in case the username changes
-       psql -U postgres -c "DROP USER $PLC_DB_USER" template1
-
-       # WARNING: If the DB name changes, the old DB will be left
-       # intact and a new one will be created. If it changes
-       # back, the old DB will not be re-created.
-
-       # Shut down the server
-       service postgresql stop
-
-       # /etc/init.d/postgresql fails if it is not running
-       [ "$PLC_DB_ENABLED" = 1 ] && check
-
-       result "$MESSAGE"
-       ;;
-esac
-
-exit $ERRORS
index 9b6b1c3..907c851 100755 (executable)
--- a/plc.d/ssh
+++ b/plc.d/ssh
@@ -1,14 +1,14 @@
 #!/bin/bash
+# $Id$
+# $URL$
 #
-# priority: 600
+# priority: 500
 #
 # Generate SSH keys
 #
 # Mark Huang <mlhuang@cs.princeton.edu>
 # Copyright (C) 2006 The Trustees of Princeton University
 #
-# $Id$
-#
 
 # Source function library and configuration
 . /etc/plc.d/functions
index a9d22c7..e7e3278 100755 (executable)
--- a/plc.d/ssl
+++ b/plc.d/ssl
@@ -1,14 +1,14 @@
 #!/bin/bash
+# $Id$
+# $URL$
 #
-# priority: 400
+# priority: 300
 #
 # Generate SSL certificates
 #
 # Mark Huang <mlhuang@cs.princeton.edu>
 # Copyright (C) 2006 The Trustees of Princeton University
 #
-# $Id$
-#
 
 # Source function library and configuration
 . /etc/plc.d/functions
@@ -25,6 +25,14 @@ ssl_cname ()
        lower
 }
 
+backup_file ()
+{
+    filepath=$1
+    filename=$(basename ${filepath})
+    dir=$(dirname ${filepath})
+    mv -f ${filepath} ${dir}/${filename}-`date +%Y-%m-%d-%H-%M-%S`.bak
+}
+
 # Verify a certificate. If invalid, generate a new self-signed
 # certificate.
 verify_or_generate_certificate() {
@@ -42,10 +50,11 @@ verify_or_generate_certificate() {
     if [ -f $crt ] ; then
        # Check if certificate is valid
        verify=$(openssl verify -CAfile $ca $crt)
-       # Delete if invalid or if the subject has changed
+       # Backup if invalid or if the subject has changed
        if grep -q "error" <<<$verify || \
            [ "$(ssl_cname $crt)" != "$cname" ] ; then
-           rm -f $crt $ca
+            backup_file $crt
+            backup_file $ca
        fi
     fi
 
@@ -73,22 +82,30 @@ verify_or_generate_certificate() {
 
 case "$1" in
     start)
-       MESSAGE=$"Generating SSL certificates"
-       dialog "$MESSAGE"
 
        # Generate HTTPS certificates if necessary. We generate a
        # certificate for each enabled server with a different
        # hostname. These self-signed certificates may be overridden
        # later.
-       for server in WWW API BOOT ; do
-           ssl_key=PLC_${server}_SSL_KEY
+        MESSAGE=$"Generating SSL certificates for"
+        dialog "$MESSAGE"
+
+       for server in WWW API BOOT MONITOR; do
+           eval "a=\$PLC_${server}_ENABLED"
+            echo $a
+            if [ "$a" -ne 1 ] ; then
+               echo "Skipping"
+                continue
+            fi
+           dialog "$server"
+            ssl_key=PLC_${server}_SSL_KEY
            ssl_crt=PLC_${server}_SSL_CRT
            ca_ssl_crt=PLC_${server}_CA_SSL_CRT
            hostname=PLC_${server}_HOST
 
            # Check if we have already generated a certificate for
            # the same hostname.
-           for previous_server in WWW API BOOT ; do
+           for previous_server in WWW API BOOT MONITOR; do
                if [ "$server" = "$previous_server" ] ; then
                    break
                fi
@@ -115,20 +132,27 @@ case "$1" in
        # 4) and /etc/httpd/conf (Fedora Core 2). If the API, boot,
        # and web servers are all running on the same machine, the web
        # server certificate takes precedence.
-       for server in API BOOT WWW ; do
+       for server in API BOOT MONITOR WWW; do
            enabled=PLC_${server}_ENABLED
            if [ "${!enabled}" != "1" ] ; then
                continue
            fi
            ssl_key=PLC_${server}_SSL_KEY
            ssl_crt=PLC_${server}_SSL_CRT
+           ssl_ca_crt=PLC_${server}_CA_SSL_CRT
 
            symlink ${!ssl_crt} /etc/pki/tls/certs/localhost.crt
            symlink ${!ssl_key} /etc/pki/tls/private/localhost.key
+           symlink ${!ssl_ca_crt} /etc/pki/tls/certs/server-chain.crt
            symlink ${!ssl_crt} /etc/httpd/conf/ssl.crt/server.crt
            symlink ${!ssl_key} /etc/httpd/conf/ssl.key/server.key
        done
 
+       # Ensure that the server-chain gets used, as it is off by
+       # default.
+       sed -i -e 's/^#SSLCertificateChainFile /SSLCertificateChainFile /' \
+           /etc/httpd/conf.d/ssl.conf
+
        result "$MESSAGE"
        ;;
 esac
diff --git a/plc.d/syslog b/plc.d/syslog
deleted file mode 100755 (executable)
index e58cf18..0000000
+++ /dev/null
@@ -1,52 +0,0 @@
-#!/bin/bash
-#
-# priority: 200
-#
-# Do not use the standard syslog initscript. It will start up a
-# (probably duplicate) copy of klogd, and on shutdown, if a pidfile is
-# not found, will (probably) kill the host syslogd and klogd instances
-# as well.
-#
-# Mark Huang <mlhuang@cs.princeton.edu>
-# Copyright (C) 2006 The Trustees of Princeton University
-#
-# $Id$
-#
-
-# Source function library and configuration
-. /etc/plc.d/functions
-. /etc/planetlab/plc_config
-
-# Be verbose
-set -x
-
-# fedora 8 comes with a new name for the binary
-if type rsyslogd &> /dev/null ; then
-    syslogname=rsyslogd
-else
-    syslogname=syslogd
-fi
-
-case "$1" in
-    start)
-       MESSAGE=$"Starting system logger"
-       dialog "$MESSAGE"
-
-       plc_daemon $syslogname -m 0
-       check
-
-       result "$MESSAGE"
-       ;;
-
-    stop)
-       MESSAGE=$"Shutting down system logger"
-       dialog "$MESSAGE"
-
-       killproc plc_$syslogname
-       check
-
-       result "$MESSAGE"
-       ;;
-esac
-
-exit $ERRORS
similarity index 96%
rename from guest.init
rename to plc.init
index 309523e..fc93b7e 100755 (executable)
+++ b/plc.init
@@ -7,6 +7,7 @@
 # description: Manages all PLC services on this machine
 #
 # $Id$
+# $URL$
 #
 
 # Source function library and configuration
@@ -34,10 +35,11 @@ verbose=0
 # but that's maybe a good thing, that all is done at first start
 ###
 
+# do not consider files that contain '.', '~' or 'functions' in the name
 steps=($(
 for step in /etc/plc.d/* ; do
     stepname=$(basename $step)
-    plainstepname=$(echo $stepname | sed -e 's,\.,,' -e 's,~,,')
+    plainstepname=$(echo $stepname | sed -e 's,\.,,' -e 's,~,,' -e 's,functions,,' )
     if [ -f $step -a -x $step -a "$stepname" = "$plainstepname" ] ; then
        priority=$(sed -ne 's/# priority: \(.*\)/\1/p' $step)
        echo $priority $stepname
@@ -133,7 +135,7 @@ fi
 # Get command
 shift $(($OPTIND - 1))
 if [ -z "$1" ] ; then
-    usage
+    usage >&3
 fi
 command=$1
 
index b40918c..fcab1f6 100644 (file)
 # $Id$
 #
 
-import xml.dom.minidom
-from StringIO import StringIO
-import time
-import re
-import textwrap
 import codecs
 import os
+import re
+import sys
+import textwrap
+import time
+import traceback
 import types
-
+import xml.dom.minidom
+from xml.parsers.expat import ExpatError
+from StringIO import StringIO
+from optparse import OptionParser
 
 class ConfigurationException(Exception): pass
 
@@ -189,7 +192,11 @@ class PLCConfiguration:
         Merge file into configuration store.
         """
 
-        dom = xml.dom.minidom.parse(file)
+        try:
+            dom = xml.dom.minidom.parse(file)
+        except ExpatError, e:
+            raise ConfigurationException, e
+
         if type(file) in types.StringTypes:
             self._files.append(os.path.abspath(file))
 
@@ -237,46 +244,44 @@ class PLCConfiguration:
 
         fileobj.close()
 
-    def verify(self, default, read):
-        """ Confirm that the existing configuration is consistent according to
-        the checks below.
+    def verify(self, default, read, verify_variables={}):
+        """ Confirm that the existing configuration is consistent
+            according to the checks below.
 
             It looks for filled-in values in the order of, local object (self),
             followed by cread (read values), and finally default values.
 
         Arguments: 
 
-            None
+            default configuration
+            site configuration
+            list of category/variable tuples to validate in these configurations
 
         Returns:
 
-            None.  If an exception is found, ConfigurationException is raised.
+            dict of values for the category/variables passed in
+            If an exception is found, ConfigurationException is raised.
 
         """
 
-        (category,maint_user) = self.get('plc_api', 'maintenance_user')
-        if maint_user == None:
-            (category, maint_user) = read.get('plc_api', 'maintenance_user')
-        if maint_user == None:
-            (category,maint_user) = default.get('plc_api', 'maintenance_user')
-        if maint_user == None:
-            raise ConfigurationException("Cannot find PLC_API_MAINTENANCE_USER")
-
-        (category,root_user) = self.get('plc', 'root_user')
-        if root_user == None:
-            (category,root_user) = read.get('plc', 'root_user')
-        if root_user == None:
-            root_user = default.get('plc', 'root_user')
-        if root_user == None:
-            raise ConfigurationException("Cannot find PLC_ROOT_USER")
-
-        muser= maint_user['value']
-        ruser= root_user['value']
-
-        if muser == ruser:
-            raise ConfigurationException("The Maintenance Account email address cannot be the same as the Root User email address")
-        return
-
+        validated_variables = {}
+        for category_id, variable_id in verify_variables.iteritems():
+            category_id = category_id.lower()
+            variable_id = variable_id.lower()
+            variable_value = None
+            sources = (self, read, default)
+            for source in sources:
+                (category_value, variable_value) = source.get(category_id,variable_id)
+                if variable_value <> None:
+                    entry = validated_variables.get(category_id,[])
+                    entry.append(variable_value['value'])
+                    validated_variables["%s_%s"%(category_id.upper(),variable_id.upper())]=entry
+                    break
+            if variable_value == None:
+                raise ConfigurationException("Cannot find %s_%s)" % \
+                                             (category_id.upper(),
+                                              variable_id.upper()))
+        return validated_variables
 
     def get(self, category_id, variable_id):
         """
@@ -823,6 +828,28 @@ DO NOT EDIT. This file was automatically generated at
 
         return buf.getvalue()
 
+    def validate_type(self, variable_type, value):
+
+        # ideally we should use the "validate_*" methods in PLCAPI or
+        # even declare some checks along with the default
+        # configuration (using RELAX NG?) but this shall work for now.
+        def ip_validator(val):
+            import socket
+            try:
+                socket.inet_aton(val)
+                return True
+            except: return False
+
+        validators = {
+            'email' : lambda val: re.match('\A[a-zA-Z0-9._%+\-]+@[a-zA-Z0-9._\-]+\.[a-zA-Z]+\Z', val),
+            'ip': ip_validator
+            }
+
+        # validate it if not a know type.
+        validator = validators.get(variable_type, lambda x: True)
+        return validator(value)
+
+
 
 # xml.dom.minidom.Text.writexml adds surrounding whitespace to textual
 # data when pretty-printing. Override this behavior.
@@ -838,6 +865,499 @@ class TrimTextElement(xml.dom.minidom.Element):
         writer.write(newl)
 
 
+####################
+# GLOBAL VARIABLES
+#
+release_id = "$Id$"
+release_rev = "$Revision$"
+release_url = "$URL$"
+
+g_configuration=None
+usual_variables=None
+config_dir=None
+service=None
+
+def noop_validator(validated_variables):
+    pass
+
+
+# historically we could also configure the devel pkg....
+def init_configuration ():
+    global g_configuration
+    global usual_variables, config_dir, service
+
+    usual_variables=g_configuration["usual_variables"]
+    config_dir=g_configuration["config_dir"]
+    service=g_configuration["service"]
+
+    global def_default_config, def_site_config, def_consolidated_config
+    def_default_config= "%s/default_config.xml" % config_dir
+    def_site_config = "%s/configs/site.xml" % config_dir
+    def_consolidated_config = "%s/%s_config.xml" % (config_dir, service)
+
+    global mainloop_usage
+    mainloop_usage= """Available commands:
+ Uppercase versions give variables comments, when available
+ u/U\t\t\tEdit usual variables
+ w\t\t\tWrite
+ r\t\t\tRestart %(service)s service
+ R\t\t\tReload %(service)s service (rebuild config files for sh, python....)
+ q\t\t\tQuit (without saving)
+ h/?\t\t\tThis help
+---
+ l/L [<cat>|<var>]\tShow Locally modified variables/values
+ s/S [<cat>|<var>]\tShow variables/values (all, in category, single)
+ e/E [<cat>|<var>]\tEdit variables (all, in category, single)
+---
+ c\t\t\tList categories
+ v/V [<cat>|<var>]\tList Variables (all, in category, single)
+---
+Typical usage involves: u, [l,] w, r, q
+""" % globals()
+
+def usage ():
+    command_usage="%prog [options] [default-xml [site-xml [consolidated-xml]]]"
+    init_configuration ()
+    command_usage +="""
+\t default-xml defaults to %s
+\t site-xml defaults to %s
+\t consolidated-xml defaults to %s""" % (def_default_config,def_site_config, def_consolidated_config)
+    return command_usage
+
+####################
+variable_usage= """Edit Commands :
+#\tShow variable comments
+.\tStops prompting, return to mainloop
+/\tCleans any site-defined value, reverts to default
+=\tShows default value
+>\tSkips to next category
+?\tThis help
+"""
+
+####################
+def get_value (config,  category_id, variable_id):
+    (category, variable) = config.get (category_id, variable_id)
+    return variable['value']
+
+def get_type (config, category_id, variable_id):
+    (category, variable) = config.get (category_id, variable_id)
+    return variable['type']
+
+def get_current_value (cread, cwrite, category_id, variable_id):
+    # the value stored in cwrite, if present, is the one we want
+    try:
+        result=get_value (cwrite,category_id,variable_id)
+    except:
+        result=get_value (cread,category_id,variable_id)
+    return result
+
+# refrain from using plc_config's _sanitize 
+def get_varname (config,  category_id, variable_id):
+    (category, variable) = config.get (category_id, variable_id)
+    return (category_id+"_"+variable['id']).upper()
+
+# could not avoid using _sanitize here..
+def get_name_comments (config, cid, vid):
+    try:
+        (category, variable) = config.get (cid, vid)
+        (id, name, value, comments) = config._sanitize_variable (cid,variable)
+        return (name,comments)
+    except:
+        return (None,[])
+
+def print_name_comments (config, cid, vid):
+    (name,comments)=get_name_comments(config,cid,vid)
+    if name:
+        print "### %s" % name
+    if comments:
+        for line in comments:
+            print "# %s" % line
+    else:
+        print "!!! No comment associated to %s_%s" % (cid,vid)
+
+####################
+def list_categories (config):
+    result=[]
+    for (category_id, (category, variables)) in config.variables().iteritems():
+        result += [category_id]
+    return result
+
+def print_categories (config):
+    print "Known categories"
+    for cid in list_categories(config):
+        print "%s" % (cid.upper())
+
+####################
+def list_category (config, cid):
+    result=[]
+    for (category_id, (category, variables)) in config.variables().iteritems():
+        if (cid == category_id):
+            for variable in variables.values():
+                result += ["%s_%s" %(cid,variable['id'])]
+    return result
+    
+def print_category (config, cid, show_comments=True):
+    cid=cid.lower()
+    CID=cid.upper()
+    vids=list_category(config,cid)
+    if (len(vids) == 0):
+        print "%s : no such category"%CID
+    else:
+        print "Category %s contains" %(CID)
+        for vid in vids:
+            print vid.upper()
+
+####################
+def consolidate (default_config, site_config, consolidated_config):
+    global service
+    try:
+        conso = PLCConfiguration (default_config)
+        conso.load (site_config)
+        conso.save (consolidated_config)
+    except Exception, inst:
+        print "Could not consolidate, %s" % (str(inst))
+        return
+    print ("Merged\n\t%s\nand\t%s\ninto\t%s"%(default_config,site_config,
+                                              consolidated_config))
+
+def reload_service ():
+    global service
+    os.system("set -x ; service %s reload" % service)
+        
+####################
+def restart_service ():
+    global service
+    print ("==================== Stopping %s" % service)
+    os.system("service %s stop" % service)
+    print ("==================== Starting %s" % service)
+    os.system("service %s start" % service)
+
+####################
+def prompt_variable (cdef, cread, cwrite, category, variable,
+                     show_comments, support_next=False):
+
+    assert category.has_key('id')
+    assert variable.has_key('id')
+
+    category_id = category ['id']
+    variable_id = variable['id']
+
+    while True:
+        default_value = get_value(cdef,category_id,variable_id)
+        variable_type = get_type(cdef,category_id,variable_id)
+        current_value = get_current_value(cread,cwrite,category_id, variable_id)
+        varname = get_varname (cread,category_id, variable_id)
+        
+        if show_comments :
+            print_name_comments (cdef, category_id, variable_id)
+        prompt = "== %s : [%s] " % (varname,current_value)
+        try:
+            answer = raw_input(prompt).strip()
+        except EOFError :
+            raise Exception ('BailOut')
+        except KeyboardInterrupt:
+            print "\n"
+            raise Exception ('BailOut')
+
+        # no change
+        if (answer == "") or (answer == current_value):
+            return None
+        elif (answer == "."):
+            raise Exception ('BailOut')
+        elif (answer == "#"):
+            print_name_comments(cread,category_id,variable_id)
+        elif (answer == "?"):
+            print variable_usage.strip()
+        elif (answer == "="):
+            print ("%s defaults to %s" %(varname,default_value))
+        # revert to default : remove from cwrite (i.e. site-config)
+        elif (answer == "/"):
+            cwrite.delete(category_id,variable_id)
+            print ("%s reverted to %s" %(varname,default_value))
+            return
+        elif (answer == ">"):
+            if support_next:
+                raise Exception ('NextCategory')
+            else:
+                print "No support for next category"
+        else:
+            if cdef.validate_type(variable_type, answer):
+                variable['value'] = answer
+                cwrite.set(category,variable)
+                return
+            else:
+                print "Not a valid value"
+
+def prompt_variables_all (cdef, cread, cwrite, show_comments):
+    try:
+        for (category_id, (category, variables)) in cread.variables().iteritems():
+            print ("========== Category = %s" % category_id.upper())
+            for variable in variables.values():
+                try:
+                    newvar = prompt_variable (cdef, cread, cwrite, category, variable,
+                                              show_comments, True)
+                except Exception, inst:
+                    if (str(inst) == 'NextCategory'): break
+                    else: raise
+                    
+    except Exception, inst:
+        if (str(inst) == 'BailOut'): return
+        else: raise
+
+def prompt_variables_category (cdef, cread, cwrite, cid, show_comments):
+    cid=cid.lower()
+    CID=cid.upper()
+    try:
+        print ("========== Category = %s" % CID)
+        for vid in list_category(cdef,cid):
+            (category,variable) = cdef.locate_varname(vid.upper())
+            newvar = prompt_variable (cdef, cread, cwrite, category, variable,
+                                      show_comments, False)
+    except Exception, inst:
+        if (str(inst) == 'BailOut'): return
+        else: raise
+
+####################
+def show_variable (cdef, cread, cwrite,
+                   category, variable,show_value,show_comments):
+    assert category.has_key('id')
+    assert variable.has_key('id')
+
+    category_id = category ['id']
+    variable_id = variable['id']
+
+    default_value = get_value(cdef,category_id,variable_id)
+    current_value = get_current_value(cread,cwrite,category_id,variable_id)
+    varname = get_varname (cread,category_id, variable_id)
+    if show_comments :
+        print_name_comments (cdef, category_id, variable_id)
+    if show_value:
+        print "%s = %s" % (varname,current_value)
+    else:
+        print "%s" % (varname)
+
+def show_variables_all (cdef, cread, cwrite, show_value, show_comments):
+    for (category_id, (category, variables)) in cread.variables().iteritems():
+        print ("========== Category = %s" % category_id.upper())
+        for variable in variables.values():
+            show_variable (cdef, cread, cwrite,
+                           category, variable,show_value,show_comments)
+
+def show_variables_category (cdef, cread, cwrite, cid, show_value,show_comments):
+    cid=cid.lower()
+    CID=cid.upper()
+    print ("========== Category = %s" % CID)
+    for vid in list_category(cdef,cid):
+        (category,variable) = cdef.locate_varname(vid.upper())
+        show_variable (cdef, cread, cwrite, category, variable,
+                       show_value,show_comments)
+
+####################
+re_mainloop_0arg="^(?P<command>[uUwrRqlLsSeEcvVhH\?])[ \t]*$"
+re_mainloop_1arg="^(?P<command>[sSeEvV])[ \t]+(?P<arg>\w+)$"
+matcher_mainloop_0arg=re.compile(re_mainloop_0arg)
+matcher_mainloop_1arg=re.compile(re_mainloop_1arg)
+
+def mainloop (cdef, cread, cwrite, default_config, site_config, consolidated_config):
+    global service
+    while True:
+        try:
+            answer = raw_input("Enter command (u for usual changes, w to save, ? for help) ").strip()
+        except EOFError:
+            answer =""
+        except KeyboardInterrupt:
+            print "\nBye"
+            sys.exit()
+
+        if (answer == "") or (answer in "?hH"):
+            print mainloop_usage
+            continue
+        groups_parse = matcher_mainloop_0arg.match(answer)
+        command=None
+        if (groups_parse):
+            command = groups_parse.group('command')
+            arg=None
+        else:
+            groups_parse = matcher_mainloop_1arg.match(answer)
+            if (groups_parse):
+                command = groups_parse.group('command')
+                arg=groups_parse.group('arg')
+        if not command:
+            print ("Unknown command >%s< -- use h for help" % answer)
+            continue
+
+        show_comments=command.isupper()
+
+        mode='ALL'
+        if arg:
+            mode=None
+            arg=arg.lower()
+            variables=list_category (cdef,arg)
+            if len(variables):
+                # category_id as the category name
+                # variables as the list of variable names
+                mode='CATEGORY'
+                category_id=arg
+            arg=arg.upper()
+            (category,variable)=cdef.locate_varname(arg)
+            if variable:
+                # category/variable as output by locate_varname
+                mode='VARIABLE'
+            if not mode:
+                print "%s: no such category or variable" % arg
+                continue
+
+        if command in "qQ":
+            # todo check confirmation
+            return
+        elif command == "w":
+            try:
+                # Confirm that various constraints are met before saving file.
+                validate_variables = g_configuration.get('validate_variables',{})
+                validated_variables = cwrite.verify(cdef, cread, validate_variables)
+                validator = g_configuration.get('validator',noop_validator)
+                validator(validated_variables)
+                cwrite.save(site_config)
+            except ConfigurationException, e:
+                print "Save failed due to a configuration exception: %s" % e
+                break;
+            except:
+                print traceback.print_exc()
+                print ("Could not save -- fix write access on %s" % site_config)
+                break
+            print ("Wrote %s" % site_config)
+            consolidate(default_config, site_config, consolidated_config)
+            print ("You might want to type 'r' (restart %s), 'R' (reload %s) or 'q' (quit)" % \
+                   (service,service))
+        elif command in "uU":
+            global usual_variables
+            try:
+                for varname in usual_variables:
+                    (category,variable) = cdef.locate_varname(varname)
+                    if not (category is None and variable is None):
+                        prompt_variable(cdef, cread, cwrite, category, variable, False)
+            except Exception, inst:
+                if (str(inst) != 'BailOut'):
+                    raise
+        elif command == "r":
+            restart_service()
+        elif command == "R":
+            reload_service()
+        elif command == "c":
+            print_categories(cread)
+        elif command in "eE":
+            if mode == 'ALL':
+                prompt_variables_all(cdef, cread, cwrite,show_comments)
+            elif mode == 'CATEGORY':
+                prompt_variables_category(cdef,cread,cwrite,category_id,show_comments)
+            elif mode == 'VARIABLE':
+                try:
+                    prompt_variable (cdef,cread,cwrite,category,variable,
+                                     show_comments,False)
+                except Exception, inst:
+                    if str(inst) != 'BailOut':
+                        raise
+        elif command in "vVsSlL":
+            show_value=(command in "sSlL")
+            (c1,c2,c3) = (cdef, cread, cwrite)
+            if command in "lL":
+                (c1,c2,c3) = (cwrite,cwrite,cwrite)
+            if mode == 'ALL':
+                show_variables_all(c1,c2,c3,show_value,show_comments)
+            elif mode == 'CATEGORY':
+                show_variables_category(c1,c2,c3,category_id,show_value,show_comments)
+            elif mode == 'VARIABLE':
+                show_variable (c1,c2,c3,category,variable,show_value,show_comments)
+        else:
+            print ("Unknown command >%s< -- use h for help" % answer)
+
+####################
+# creates directory for file if not yet existing
+def check_dir (config_file):
+    dirname = os.path.dirname (config_file)
+    if (not os.path.exists (dirname)):
+        try:
+            os.makedirs(dirname,0755)
+        except OSError, e:
+            print "Cannot create dir %s due to %s - exiting" % (dirname,e)
+            sys.exit(1)
+            
+        if (not os.path.exists (dirname)):
+            print "Cannot create dir %s - exiting" % dirname
+            sys.exit(1)
+        else:
+            print "Created directory %s" % dirname
+                
+####################
+def optParserSetup(configuration):
+    parser = OptionParser(usage=usage(), version="%prog " + release_rev + release_url )
+    parser.set_defaults(config_dir=configuration['config_dir'],
+                        service=configuration['service'],
+                        usual_variables=configuration['usual_variables'])
+    parser.add_option("","--configdir",dest="config_dir",help="specify configuration directory")
+    parser.add_option("","--service",dest="service",help="specify /etc/init.d style service name")
+    parser.add_option("","--usual_variable",dest="usual_variables",action="append", help="add a usual variable")
+    return parser
+
+def main(command,argv,configuration):
+    global g_configuration
+    g_configuration=configuration
+
+    parser = optParserSetup(configuration)
+    (config,args) = parser.parse_args()
+    if len(args)>3:
+        parser.error("too many arguments")
+
+    configuration['service']=config.service
+    configuration['usual_variables']=config.usual_variables
+    configuration['config_dir']=config.config_dir
+    # add in new usual_variables defined on the command line
+    for usual_variable in config.usual_variables:
+        if usual_variable not in configuration['usual_variables']:
+            configuration['usual_variables'].append(usual_variable)
+
+    # intialize configuration
+    init_configuration()
+
+    (default_config,site_config,consolidated_config) = (def_default_config, def_site_config, def_consolidated_config)
+    if len(args) >= 1:
+        default_config=args[0]
+    if len(args) >= 2:
+        site_config=args[1]
+    if len(args) == 3:
+        consolidated_config=args[2]
+
+    for c in (default_config,site_config,consolidated_config):
+        check_dir (c)
+
+    try:
+        # the default settings only - read only
+        cdef = PLCConfiguration(default_config)
+
+        # in effect : default settings + local settings - read only
+        cread = PLCConfiguration(default_config)
+
+    except ConfigurationException, e:
+        print ("Error %s in default config file %s" %(e,default_config))
+        return 1
+    except:
+        print traceback.print_exc()
+        print ("default config files %s not found, is myplc installed ?" % default_config)
+        return 1
+
+
+    # local settings only, will be modified & saved
+    cwrite=PLCConfiguration()
+    
+    try:
+        cread.load(site_config)
+        cwrite.load(site_config)
+    except:
+        cwrite = PLCConfiguration()
+
+    mainloop (cdef, cread, cwrite, default_config, site_config, consolidated_config)
+    return 0
+
 if __name__ == '__main__':
     import sys
     if len(sys.argv) > 1 and sys.argv[1] in ['build', 'install', 'uninstall']:
diff --git a/support-scripts/gen-sites-xml.py b/support-scripts/gen-sites-xml.py
new file mode 100755 (executable)
index 0000000..bfbcd6f
--- /dev/null
@@ -0,0 +1,269 @@
+#!/usr/bin/python
+#
+# Write out sites.xml
+#
+# Mark Huang <mlhuang@cs.princeton.edu>
+# Copyright (C) 2006 The Trustees of Princeton University
+#
+# $Id: gen-sites-xml.py,v 1.8 2007/09/14 20:08:28 tmack Exp $
+#
+
+import os, sys
+import getopt
+import time
+from xml.sax.saxutils import escape, quoteattr, XMLGenerator
+
+PID_FILE= "/var/run/all_planetlab_xml.pid"
+
+#
+# Web server document root
+#
+DOCROOT = '/var/www/html/xml'
+
+#
+# DTD and version number for site information
+#
+ENCODING= "utf-8"
+SITE_VERSION="0.4"
+
+# Debug
+dryrun = False
+
+# Parse options
+def usage():
+    print "Usage: %s [OPTION]..." % sys.argv[0]
+    print "Options:"
+    print "     -n, --dryrun            Dry run, do not write files (default: %s)" % dryrun
+    print "     -d, --docroot=DIR       Document root (default: %s)" % DOCROOT
+    print "     -h, --help              This message"
+    sys.exit(1)
+
+# Get options
+try:
+    (opts, argv) = getopt.getopt(sys.argv[1:], "nd:h", ["dryrun", "docroot=", "help"])
+except getopt.GetoptError, err:
+    print "Error: " + err.msg
+    usage()
+
+for (opt, optval) in opts:
+    if opt == "-n" or opt == "--dryrun":
+        dryrun = True
+    elif opt == "-d" or opt == "--docroot":
+        DOCROOT = optval
+    else:
+        usage()
+
+# Write out lock file
+if not dryrun:
+    if os.access(PID_FILE, os.R_OK):
+        pid= file(PID_FILE).readline().strip()
+        if pid <> "":
+            if os.system("/bin/kill -0 %s > /dev/null 2>&1" % pid) == 0:
+                sys.exit(0)
+
+    # write out our process id
+    pidfile= file( PID_FILE, 'w' )
+    pidfile.write( "%d\n" % os.getpid() )
+    pidfile.close()
+
+# Load shell with default configuration
+sys.path.append('/usr/share/plc_api')
+from PLC.Shell import Shell
+plc = Shell(globals())
+
+#
+# Get information from API
+#
+
+begin()
+GetNodes(None, ['node_id', 'model', 'boot_state', 'hostname', 'version', 'ssh_rsa_key', 'nodenetwork_ids', 'slice_ids_whitelist'])
+GetNodeNetworks({'is_primary': True}, ['nodenetwork_id', 'node_id', 'ip', 'mac', 'bwlimit'])
+GetSites(None, ['name', 'latitude', 'longitude', 'url', 'site_id', 'login_base', 'abbreviated_name', 'node_ids'])
+GetNodeGroups(['Alpha', 'Beta', 'Rollout', 'Production'], ['name', 'node_ids'])
+(nodes, nodenetworks, sites, groups) = commit()
+
+# remove whitelisted nodes
+remove_whitelisted = lambda node: not node['slice_ids_whitelist']
+nodes = filter(remove_whitelisted, nodes)
+
+nodes = dict([(node['node_id'], node) for node in nodes])
+
+for nodenetwork in nodenetworks:
+    if nodes.has_key(nodenetwork['node_id']):
+        node = nodes[nodenetwork['node_id']]
+        for key, value in nodenetwork.iteritems():
+            node[key] = value
+
+group_node_ids = dict([(group['name'], group['node_ids']) for group in groups])
+
+class PrettyXMLGenerator(XMLGenerator):
+    """
+    Adds indentation to the beginning and newlines to the end of
+    opening and closing tags.
+    """
+
+    def __init__(self, out = sys.stdout, encoding = "utf-8", indent = "", addindent = "", newl = ""):
+        XMLGenerator.__init__(self, out, encoding)
+        # XMLGenerator does not export _write()
+        self.write = self.ignorableWhitespace
+        self.indents = [indent]
+        self.addindent = addindent
+        self.newl = newl
+
+    def startDocument(self):
+        XMLGenerator.startDocument(self)
+
+    def startElement(self, name, attrs, indent = True, newl = True):
+        if indent:
+            self.ignorableWhitespace("".join(self.indents))
+        self.indents.append(self.addindent)
+
+        XMLGenerator.startElement(self, name, attrs)
+
+        if newl:
+            self.ignorableWhitespace(self.newl)
+
+    def characters(self, content):
+        # " to &quot;
+        # ' to &apos;
+        self.write(escape(content, {
+            '"': '&quot;',
+            "'": '&apos;',
+            }))
+
+    def endElement(self, name, indent = True, newl = True):
+        self.indents.pop()
+        if indent:
+            self.ignorableWhitespace("".join(self.indents))
+
+        XMLGenerator.endElement(self, name)
+
+        if newl:
+            self.ignorableWhitespace(self.newl)
+
+    def simpleElement(self, name, attrs = {}, indent = True, newl = True):
+        if indent:
+            self.ignorableWhitespace("".join(self.indents))
+
+        self.write('<' + name)
+        for (name, value) in attrs.items():
+            self.write(' %s=%s' % (name, quoteattr(value.strip())))
+        self.write('/>')
+
+        if newl:
+            self.ignorableWhitespace(self.newl)
+
+#
+# Write out sites.xml
+#
+
+if dryrun:
+    sites_xml = sys.stdout
+else:
+    sites_xml = open(DOCROOT + "/sites.xml", mode = "w")
+
+xml = PrettyXMLGenerator(out = sites_xml, encoding = ENCODING, indent = "", addindent = "  ", newl = "\n")
+xml.startDocument()
+
+# Write embedded DTD verbatim
+xml.ignorableWhitespace("""
+<!DOCTYPE PLANETLAB_SITES [
+  <!ELEMENT PLANETLAB_SITES (SITE)*>
+  <!ATTLIST PLANETLAB_SITES VERSION CDATA #REQUIRED
+                            TIME    CDATA #REQUIRED>
+
+  <!ELEMENT SITE (HOST)*>
+  <!ATTLIST SITE NAME            CDATA #REQUIRED
+                 LATITUDE        CDATA #REQUIRED
+                 LONGITUDE       CDATA #REQUIRED
+                 URL             CDATA #REQUIRED
+                 SITE_ID         CDATA #REQUIRED
+                 LOGIN_BASE      CDATA #REQUIRED
+                 FULL_SITE_NAME  CDATA #REQUIRED
+                 SHORT_SITE_NAME CDATA #REQUIRED
+  >
+
+  <!ELEMENT HOST EMPTY>
+  <!ATTLIST HOST NAME         CDATA #REQUIRED
+                 IP           CDATA #REQUIRED
+                 MODEL        CDATA #REQUIRED
+                 MAC          CDATA #IMPLIED
+                 BOOTCD       (y|n) "n"
+                 VERSION      CDATA #REQUIRED
+                 NODE_ID      CDATA #REQUIRED
+                 BOOT_VERSION CDATA ""
+                 STATUS       CDATA ""
+                 BOOT_STATE   CDATA #REQUIRED
+                 RSA_KEY      CDATA ""
+                 BWLIMIT      CDATA ""
+  >
+]>
+""")
+
+def format_tc_rate(rate):
+    """
+    Formats a bits/second rate into a tc rate string
+    """
+
+    if rate >= 1000000000 and (rate % 1000000000) == 0:
+        return "%.0fgbit" % (rate / 1000000000.)
+    elif rate >= 1000000 and (rate % 1000000) == 0:
+        return "%.0fmbit" % (rate / 1000000.)
+    elif rate >= 1000:
+        return "%.0fkbit" % (rate / 1000.)
+    else:
+        return "%.0fbit" % rate
+
+# <PLANETLAB_SITES VERSION="major.minor" TIME="seconds_since_epoch">
+xml.startElement('PLANETLAB_SITES', {'VERSION': SITE_VERSION,
+                                     'TIME': str(int(time.time()))})
+
+for site in sites:
+    # <SITE ...>
+    attrs = {}
+    for attr in ['name', 'latitude', 'longitude', 'url', 'site_id', 'login_base']:
+        attrs[attr.upper()] = unicode(site[attr])
+    attrs['FULL_SITE_NAME'] = unicode(site['name'])
+    attrs['SHORT_SITE_NAME'] = unicode(site['abbreviated_name'])
+    xml.startElement('SITE', attrs)
+
+    for node_id in site['node_ids']:
+        if nodes.has_key(node_id):
+            node = nodes[node_id]
+
+            # <HOST ...>
+            attrs = {}
+            attrs['NAME'] = unicode(node['hostname'])
+            attrs['VERSION'] = "2.0"
+            for attr in ['model', 'node_id', 'boot_state']:
+                attrs[attr.upper()] = unicode(node[attr]).strip()
+
+            # If the node is in Alpha, Beta, or Rollout, otherwise Production
+            for group in ['Alpha', 'Beta', 'Rollout', 'Production']:
+                if group_node_ids.has_key(group) and \
+                   node_id in group_node_ids[group]:
+                    break
+            attrs['STATUS'] = group
+
+            if node['version']:
+                attrs['BOOT_VERSION'] = unicode(node['version'].splitlines()[0])
+            if node['ssh_rsa_key']:
+                attrs['RSA_KEY'] = unicode(node['ssh_rsa_key'].splitlines()[0])
+
+            if node.has_key('ip') and node['ip']:
+                attrs['IP'] = unicode(node['ip'])
+            if node.has_key('mac') and node['mac']:
+                attrs['MAC'] = unicode(node['mac'])
+            if node.has_key('bwlimit') and node['bwlimit']:
+                attrs['BWLIMIT'] = unicode(format_tc_rate(node['bwlimit']))
+
+            xml.simpleElement('HOST', attrs)
+
+    # </SITE>
+    xml.endElement('SITE')
+
+xml.endElement('PLANETLAB_SITES')
+
+if not dryrun:
+    # remove the PID file
+    os.unlink( PID_FILE )
diff --git a/support-scripts/gen-static-content.py b/support-scripts/gen-static-content.py
new file mode 100755 (executable)
index 0000000..3539cab
--- /dev/null
@@ -0,0 +1,341 @@
+#!/usr/bin/env /usr/bin/plcsh
+#
+# Generates static versions of expensive web pages
+#
+# Mark Huang <mlhuang@cs.princeton.edu>
+# Copyright (C) 2005 The Trustees of Princeton University
+#
+# $Id: gen-static-content.py,v 1.35.2.1 2007/02/07 03:27:50 mlhuang Exp $
+#
+
+import os, sys, shutil
+import time
+import string
+import codecs
+import socket
+import urllib2
+import csv
+
+SCRIPT_PID_FILE= "/var/run/gen-static-content.pid"
+
+# where to store the generated files
+GENERATED_OUTPUT_PATH= '/var/www/html/generated'
+
+# this php block, if put at the top of the files,
+# will enable them to be downloaded without the php
+# engine parsing them
+DISABLE_PHP_BLOCK= \
+"""<?php
+if( isset($_GET['disablephp']) )
+  {
+    readfile(__FILE__);
+    exit();
+  }
+?>
+"""
+
+# Globals
+all_nodes = []
+all_sites = []
+node_group_nodes = {}
+
+# return a php page that has node and site counts in it
+def GetCountsFileContent(f):
+    f.write( DISABLE_PHP_BLOCK )
+    f.write( "<?php\n" )
+
+    node_count = len(all_nodes)
+    f.write( "$node_count= %s;\n" % node_count )
+    
+    site_count= len(all_sites)
+    f.write( "$site_count= %s;\n" % site_count )
+
+    f.write( "?>" )
+
+
+# generate a plain text file in ~/.ssh/known_hosts format
+def GetHostKeys(f):
+    time_generated= time.strftime("%a, %d %b %Y %H:%M:%S")
+
+    f.write( DISABLE_PHP_BLOCK )
+    
+    f.write( "<?php\n" )
+    f.write( "$node_list_generated_time= '%s';\n" % time_generated )
+    f.write( "header('Content-type: text/plain');\n" )
+    f.write( "?>\n" )
+
+    nodes = all_nodes
+
+    for node in all_nodes:
+        hostname = node['hostname']
+        ssh_rsa_key = node['ssh_rsa_key']
+        ip = node['ip']
+        if ssh_rsa_key:
+            if hostname:
+                f.write( "%s %s\n" % (hostname, ssh_rsa_key) )
+            if ip:
+                f.write( "%s %s\n" % (ip, ssh_rsa_key) )
+
+
+# return php content that includes all the node lists
+def GetNodeListsContent(f):
+    time_generated= time.strftime("%a, %d %b %Y %H:%M:%S")
+
+    f.write( DISABLE_PHP_BLOCK )
+    
+    f.write( "<?php\n" )
+    f.write( "$node_list_generated_time= '%s';\n" % time_generated )
+
+    # Nodes with primary IP addresses in boot state
+    nodes_in_boot = filter(lambda node: node['boot_state'] == "boot" and node['ip'],
+                           all_nodes)
+
+    # Hostnames
+    all_hosts = [node['hostname'] for node in nodes_in_boot]
+    f.write( "if( $which_node_list == 'all_hosts' )\n" )
+    f.write( "{\n" )
+    f.write( "?>\n" )
+    f.write( "\n".join(all_hosts) + "\n" )
+    f.write( "<?php\n" )
+    f.write( "}\n" )
+
+    # IPs
+    all_ips = [node['ip'] for node in nodes_in_boot]
+    f.write( "elseif( $which_node_list == 'all_ips' )\n" )
+    f.write( "{\n" )
+    f.write( "?>\n" )
+    f.write( "\n".join(all_ips) + "\n" )
+    f.write( "<?php\n" )
+    f.write( "}\n" )
+
+    # /etc/hosts entries
+    etc_hosts = [node['ip'] + "\t" + node['hostname'] for node in nodes_in_boot]
+    f.write( "elseif( $which_node_list == 'etc_hosts' )\n" )
+    f.write( "{\n" )
+    f.write( "?>\n" )
+    # Create a localhost entry for convenience
+    f.write( "127.0.0.1\tlocalhost.localdomain localhost\n" )
+    f.write( "\n".join(etc_hosts) + "\n" )
+    f.write( "<?php\n" )
+    f.write( "}\n" )
+
+    for group in ['Alpha', 'Beta']:
+        if not node_group_nodes.has_key(group):
+            node_group_nodes[group] = []
+
+        # Group nodes with primary IP addresses in boot state
+        group_nodes_in_boot = filter(lambda node: node['boot_state'] == "boot" and node['ip'],
+                                     node_group_nodes[group])
+
+        # Group hostnames
+        group_hosts = [node['hostname'] for node in group_nodes_in_boot]
+        f.write( "elseif( $which_node_list == '%s_hosts' )\n" % group.lower() )
+        f.write( "{\n" )
+        f.write( "?>\n" )
+        f.write( "\n".join(group_hosts) + "\n" )
+        f.write( "<?php\n" )
+        f.write( "}\n" )
+
+        # Group IPs
+        group_ips = [node['ip'] for node in group_nodes_in_boot]
+        f.write( "elseif( $which_node_list == '%s_ips' )\n" % group.lower() )
+        f.write( "{\n" )
+        f.write( "?>\n" )
+        f.write( "\n".join(group_ips) + "\n" )
+        f.write( "<?php\n" )
+        f.write( "}\n" )
+
+    # All production nodes (nodes not in Alpha or Beta)
+    production_nodes_in_boot = filter(lambda node: node not in node_group_nodes['Alpha'] and \
+                                                   node not in node_group_nodes['Beta'],
+                                      nodes_in_boot)
+
+    production_hosts = [node['hostname'] for node in production_nodes_in_boot]                           
+    f.write( "elseif( $which_node_list == 'production_hosts' )\n" )
+    f.write( "{\n" )
+    f.write( "?>\n" )
+    f.write( "\n".join(production_hosts) + "\n" )
+    f.write( "<?php\n" )
+    f.write( "}\n" )
+
+    production_ips = [node['ip'] for node in production_nodes_in_boot]                           
+    f.write( "elseif( $which_node_list == 'production_ips' )\n" )
+    f.write( "{\n" )
+    f.write( "?>\n" )
+    f.write( "\n".join(production_ips) + "\n" )
+    f.write( "<?php\n" )
+    f.write( "}\n" )
+    f.write( "?>" )
+
+
+def GetPlanetFlowStats(f):
+    if hasattr(config, 'PLANETFLOW_BASE'):
+        url = "http://" + config.PLANETFLOW_BASE
+    else:
+        return
+
+    # Slices to calculate detailed statistics for
+    slices = [
+        'cmu_esm',
+        'cornell_beehive',
+        'cornell_cobweb',
+        'cornell_codons',
+        'michigan_tmesh',
+        'nyu_d',
+        'princeton_codeen',
+        'princeton_coblitz',
+        'princeton_comon',
+        'rice_epost',
+        'ucb_bamboo',
+        'ucb_i3',
+        'ucsd_sword',
+        'upenn_dharma',
+        'idsl_psepr',
+        'ucb_ganglia',
+        'cmu_irislog',
+        'tennessee_hliu'
+        ]
+
+    # Seconds to wait
+    socket.setdefaulttimeout(3600)
+
+    url = url + '/slice.php?csv=1&start_time=2+days+ago'
+    if slices:
+        url = url + '&slices[]=' + '&slices[]='.join(slices)
+    stats = urllib2.urlopen(url)
+    fields = ['slice', 'flows', 'packets', 'bytes', 'src_ips',
+              'dst_ips', 'top_dst_ip', 'top_dst_ip_bytes']
+    rows = csv.DictReader(stats, fields)
+    f.write("<?php\n")
+    f.write("$planetflow = array(\n")
+    for row in rows:
+        if row.has_key('slice'):
+            f.write("'%s' => array(\n" % row['slice'])
+            for field in fields:
+                if row.has_key(field) and \
+                   row[field] is not None and \
+                   row[field] != "":
+                    if type(row[field]) == type(0):
+                        f.write("\t'%s' => %d,\n" % (field, int(row[field])))
+                    else:
+                        f.write("\t'%s' => '%s',\n" % (field, row[field]))
+            f.write("),\n")
+    f.write(");\n")
+    f.write("?>")
+
+
+
+def GenDistMap():
+    # update the node distribution map
+    datadir = '/var/www/html/plot-latlong'
+
+    # plot-latlong looks for .mapinfo and .mapimages in $HOME
+    os.environ['HOME'] = datadir
+
+    if hasattr(config, 'PLC_WWW_MAPIMAGE'):
+        image = config.PLC_WWW_MAPIMAGE
+    else:
+        image = "World50"
+
+    (child_stdin,
+     child_stdout) = \
+     os.popen2('perl ' + datadir + os.sep + 'plot-latlong -m "%s" -s 3' % image)
+
+    for site in all_sites:
+        if site['latitude'] and site['longitude']:
+            child_stdin.write("%f %f\n" % \
+                              (site['latitude'], site['longitude']))
+    child_stdin.close()
+
+    map = file(GENERATED_OUTPUT_PATH + os.sep + image + '.png', 'w')
+    map.write(child_stdout.read())
+    child_stdout.close()
+    map.close()
+
+
+# which files to generate, and the functions in
+# this script to call to get the content for
+STATIC_FILE_LIST= (
+    ('_gen_counts.php',GetCountsFileContent),
+    ('_gen_node_lists.php',GetNodeListsContent),
+    ('_gen_known_hosts.php',GetHostKeys),
+    ('_gen_planetflow.php',GetPlanetFlowStats),
+    (None,GenDistMap)
+    )
+
+
+if __name__ == '__main__':
+
+    # see if we are already running by checking the existance
+    # of a PID file, and if it exists, attempting a test kill
+    # to see if the process really does exist. If both of these
+    # tests pass, exit.
+        
+    if os.access(SCRIPT_PID_FILE, os.R_OK):
+        pid= string.strip(file(SCRIPT_PID_FILE).readline())
+        if pid <> "":
+            if os.system("/bin/kill -0 %s > /dev/null 2>&1" % pid) == 0:
+                sys.exit(0)
+            
+    # write out our process id
+    pidfile= file( SCRIPT_PID_FILE, 'w' )
+    pidfile.write( "%d\n" % os.getpid() )
+    pidfile.close()
+    pidfile= None
+
+    # Get all nodes and sites
+    begin()
+    GetNodes(None, ['node_id', 'hostname', 'boot_state', 'ssh_rsa_key', 'interface_ids'])
+    GetInterfaces(None, ['interface_id', 'ip', 'is_primary'])
+    GetSites(None, ['site_id', 'latitude', 'longitude'])
+    GetNodeGroups(None, ['nodegroup_id', 'tagname', 'node_ids'])
+    (all_nodes, all_nodenetworks, all_sites, all_groups) = commit()
+
+    all_nodenetworks = dict([(nodenetwork['interface_id'], nodenetwork) \
+                             for nodenetwork in all_nodenetworks])
+
+    # Set primary IP, if any
+    for node in all_nodes:
+        node['ip'] = None
+        for interface_id in node['interface_ids']:
+            try:
+                nodenetwork = all_nodenetworks[interface_id]
+                if nodenetwork['is_primary']:
+                    node['ip'] = nodenetwork['ip']
+                break
+            except IndexError, KeyError:
+                continue
+
+    # Get list of nodes in each node group
+    for group in all_groups:
+        nodes_in_group = filter(lambda node: node['node_id'] in group['node_ids'], all_nodes)
+        node_group_nodes[group['tagname']] = nodes_in_group
+
+    # generate the static content files
+    for (file_name,func) in STATIC_FILE_LIST:
+        if file_name is not None:
+            try:
+                output_file_path= "%s/%s" % (GENERATED_OUTPUT_PATH,file_name)
+                tmp_output_file_path= output_file_path + '.tmp'
+                tmp_output_file= codecs.open( tmp_output_file_path, encoding = 'utf-8', mode = "w" )
+            except IOError, err:
+                print( "Unable to open file %s for writing." % output_file_path )
+                continue
+
+            try:
+                func(tmp_output_file)
+                tmp_output_file.flush()
+                shutil.copyfile( tmp_output_file_path, output_file_path )
+            except Exception, e:
+                print "Unable to get content for file: %s" % file_name, e
+                import traceback
+                traceback.print_exc()
+
+            tmp_output_file.close()
+            tmp_output_file= None
+            os.unlink( tmp_output_file_path )
+        else:
+            func()
+
+    # remove the PID file
+    os.unlink( SCRIPT_PID_FILE )