# $Id$ # Copyright (C) 2007--2008 American Registry for Internet Numbers ("ARIN") # # Permission to use, copy, modify, and distribute this software for any # purpose with or without fee is hereby granted, provided that the above # copyright notice and this permission notice appear in all copies. # # THE SOFTWARE IS PROVIDED "AS IS" AND ARIN DISCLAIMS ALL WARRANTIES WITH # REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY # AND FITNESS. IN NO EVENT SHALL ARIN BE LIABLE FOR ANY SPECIAL, DIRECT, # INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM # LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE # OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR # PERFORMANCE OF THIS SOFTWARE. """ Test framework to configure and drive a collection of rpkid.py and irdbd.py instances under control of a master script. Usage: python rpkid.py [ { -c | --config } config_file ] [ { -h | --help } ] [ { -y | --yaml } yaml_script ] Default config_file is testbed.conf, override with --config option. Default yaml_script is testbed.yaml, override with -yaml option. yaml_script is a YAML file describing the tests to be run, and is intended to be implementation agnostic. config_file contains settings for various implementation-specific things that don't belong in yaml_script. """ import os, yaml, MySQLdb, subprocess, signal, time, datetime, re, getopt, sys, lxml import rpki.resource_set, rpki.sundial, rpki.x509, rpki.https, rpki.log, rpki.left_right, rpki.config os.environ["TZ"] = "UTC" time.tzset() cfg_file = "testbed.conf" yaml_script = None opts,argv = getopt.getopt(sys.argv[1:], "c:hy:?", ["config=", "help", "yaml="]) for o,a in opts: if o in ("-h", "--help", "-?"): print __doc__ sys.exit(0) elif o in ("-c", "--config"): cfg_file = a elif o in ("-y", "--yaml"): yaml_script = a if argv: print __doc__ raise RuntimeError, "Unexpected arguments %s" % argv cfg = rpki.config.parser(cfg_file, "testbed") # Load the YAML script early, so we can report errors ASAP if yaml_script is None: yaml_script = cfg.get("yaml_script", "testbed.yaml") try: yaml_script = [y for y in yaml.safe_load_all(open(yaml_script))] except: print __doc__ raise # Define port allocator early, so we can use it while reading config def allocate_port(): """Allocate a TCP port number.""" global base_port p = base_port base_port += 1 return p # Most filenames in the following are relative to the working directory. testbed_name = cfg.get("testbed_name", "testbed") testbed_dir = cfg.get("testbed_dir", testbed_name + ".dir") irdb_db_pass = cfg.get("irdb_db_pass", "fnord") rpki_db_pass = cfg.get("rpki_db_pass", "fnord") base_port = int(cfg.get("base_port", "4400")) rsyncd_port = allocate_port() rootd_port = allocate_port() rsyncd_module = cfg.get("rsyncd_module", testbed_name) rootd_sia = cfg.get("rootd_sia", "rsync://localhost:%d/%s/" % (rsyncd_port, rsyncd_module)) rootd_name = cfg.get("rootd_name", "rootd") rsyncd_name = cfg.get("rcynic_name", "rsyncd") rcynic_name = cfg.get("rcynic_name", "rcynic") prog_python = cfg.get("prog_python", "python") prog_rpkid = cfg.get("prog_rpkid", "../rpkid.py") prog_irdbd = cfg.get("prog_irdbd", "../irdbd.py") prog_poke = cfg.get("prog_poke", "../testpoke.py") prog_rootd = cfg.get("prog_rootd", "../rootd.py") prog_openssl = cfg.get("prog_openssl", "../../openssl/openssl/apps/openssl") prog_rsyncd = cfg.get("prog_rsyncd", "rsync") prog_rcynic = cfg.get("prog_rcynic", "../../rcynic/rcynic") rcynic_stats = cfg.get("rcynic_stats", "xsltproc --param refresh 0 ../../rcynic/rcynic.xsl %s.xml | w3m -T text/html -dump" % rcynic_name) rpki_sql_file = cfg.get("rpki_sql_file", "../docs/rpki-db-schema.sql") irdb_sql_file = cfg.get("irdb_sql_file", "../docs/sample-irdb.sql") testbed_key = None testbed_certs = None rootd_ta = None startup_delay = int(cfg.get("startup_delay", "10")) def main(): """Main program, up front to make control logic more obvious.""" rpki.log.init(testbed_name) rpki.log.info("Starting") signal.signal(signal.SIGALRM, wakeup) rootd_process = None rsyncd_process = None rpki_sql = mangle_sql(rpki_sql_file) irdb_sql = mangle_sql(irdb_sql_file) try: os.chdir(testbed_dir) except: os.makedirs(testbed_dir) os.chdir(testbed_dir) rpki.log.info("Cleaning up old state") subprocess.check_call(("rm", "-rf", "publication", "rcynic-data", "rootd.subject.pkcs10", "rootd.req")) rpki.log.info("Reading master YAML configuration") db = allocation_db(yaml_script.pop(0)) rpki.log.info("Constructing biz keys and certs for control script") setup_biz_cert_chain(testbed_name) gl
<!-- -*- SGML -*-
- $Id$
-
- Copyright (C) 2009 Internet Systems Consortium ("ISC")
-
- Permission to use, copy, modify, and distribute this software for any
- purpose with or without fee is hereby granted, provided that the above
- copyright notice and this permission notice appear in all copies.
-
- THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
- REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
- AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
- INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
- LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
- OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- PERFORMANCE OF THIS SOFTWARE.
-->
<!--
- Split Base64 XML text elements into reasonable length chunks, to
- make the result more readable, allow halfway-sane comparisions of
- XML using diff, etc. Makes no attempt to distinguish Base64 from
- other text, so not suitable for use on XML with text elements that
- are -not- Base64. Piping output of this transform into xmlindent
- produces something halfway readable. YMMV.
-->
<xsl:transform xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output method="xml"/>
<xsl:param name="width" select="64"/>
<xsl:template match="text()">
<xsl:text> </xsl:text>
<xsl:call-template name="wrap">
<xsl:with-param name="input" select="translate(normalize-space(), ' ', '')"/>
</xsl:call-template>
</xsl:template>
<xsl:template match="node()|@*">
<xsl:copy>
<xsl:copy-of select="@*"/>
<xsl:apply-templates/>
</xsl:copy>
</xsl:template>
<xsl:template name="wrap">
<xsl:param name="input"/>
<xsl:text> </xsl:text>
<xsl:choose>
<xsl:when test="string-length($input) > $width">
<xsl:value-of select="substring($input, 1, $width)"/>
<xsl:text> </xsl:text>
<xsl:call-template name="wrap">
<xsl:with-param name="input" select="substring($input, $width+1)"/>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$input"/>
<xsl:text> </xsl:text>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
</xsl:transform>