Commit 53358dfa authored by David Johnson's avatar David Johnson

Fix up manifest get to not use geni-get, due to tmcd limit.

(Also, had never committed the manifest getter support programs.)
parent 49a3824e
#! /usr/bin/env python
#
# Copyright (c) 2008-2009, 2015 University of Utah and the Flux Group.
#
# {{{GENIPUBLIC-LICENSE
#
# GENI Public License
#
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and/or hardware specification (the "Work") to
# deal in the Work without restriction, including without limitation the
# rights to use, copy, modify, merge, publish, distribute, sublicense,
# and/or sell copies of the Work, and to permit persons to whom the Work
# is furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be
# included in all copies or substantial portions of the Work.
#
# THE WORK IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
# HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
# WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE WORK OR THE USE OR OTHER DEALINGS
# IN THE WORK.
#
# }}}
#
#
#
import sys
import pwd
import getopt
import os
import re
import xmlrpclib
from M2Crypto import X509
import os.path
dirname = os.path.abspath(os.path.dirname(sys.argv[0]))
execfile("%s/test-common.py" % (dirname,))
#
# Convert the certificate into a credential.
#
params = {}
rval,response = do_method("", "GetCredential", params)
if rval:
Fatal("Could not get my credential")
pass
mycredential = response["value"]
params["credential"] = mycredential
rval,response = do_method("", "GetManifests", params)
if rval:
Fatal("Could not get manifests")
pass
if len(sys.argv) < 2:
print response["value"]
else:
f = open("%s.xml" % (sys.argv[1],),'w')
value = response["value"]["manifests"]
i = 0
for key in value.keys():
f2 = open("%s.%d.xml" % (sys.argv[1],i,),'w')
f2.write(value[key])
f2.close()
i += 1
f.write(value[key])
pass
f.close()
pass
......@@ -58,13 +58,45 @@ touch $LOCALSETTINGS
BOOTDIR=/var/emulab/boot
SWAPPER=`cat $BOOTDIR/swapper`
##
## Grab our geni creds, and create a GENI credential cert
##
#
# NB: force the install of python-m2crypto if geniuser
#
if [ "$SWAPPER" = "geniuser" ]; then
dpkg-query -l python-m2crypto | grep -q ii
if [ ! $? = 0 ]; then
apt-get install python-m2crypto
fi
if [ ! -e $OURDIR/geni.key ]; then
geni-get key > $OURDIR/geni.key
fi
if [ ! -e $OURDIR/geni.certificate ]; then
geni-get certificate > $OURDIR/geni.certificate
fi
if [ ! -e /root/.ssl/encrypted.pem ]; then
mkdir -p /root/.ssl
chmod 600 /root/.ssl
cat $OURDIR/geni.key > /root/.ssl/encrypted.pem
cat $OURDIR/geni.certificate >> /root/.ssl/encrypted.pem
fi
if [ ! -e $OURDIR/manifests.xml ]; then
python $DIRNAME/getmanifests.py $OURDIR/manifests
fi
fi
#
# Suck in user configuration overrides, if we haven't already
#
if [ ! -e $OURDIR/parameters ]; then
touch $OURDIR/parameters
if [ "$SWAPPER" = "geniuser" ]; then
geni-get manifest | sed -n -e 's/^[^<]*<[^:]*:parameter>\([^<]*\)<\/[^:]*:parameter>/\1/p' > $OURDIR/parameters
cat $OURDIR/manifests.0.xml | sed -n -e 's/^[^<]*<[^:]*:parameter>\([^<]*\)<\/[^:]*:parameter>/\1/p' > $OURDIR/parameters
fi
fi
. $OURDIR/parameters
......@@ -106,7 +138,7 @@ else
fi
if [ "$SWAPPER" = "geniuser" ]; then
PUBLICADDRS=`geni-get manifest | perl -e 'while (<STDIN>) { while ($_ =~ m/\<emulab:ipv4 address="([\d.]+)\" netmask=\"([\d\.]+)\"/g) { print "$1\n"; } }' | xargs`
PUBLICADDRS=`cat $OURDIR/manifests.0.xml | perl -e 'while (<STDIN>) { while ($_ =~ m/\<emulab:ipv4 address="([\d.]+)\" netmask=\"([\d\.]+)\"/g) { print "$1\n"; } }' | xargs`
PUBLICCOUNT=0
for ip in $PUBLICADDRS ; do
PUBLICCOUNT=`expr $PUBLICCOUNT + 1`
......@@ -116,33 +148,6 @@ else
PUBLICCOUNT=0
fi
##
## Grab our geni creds, and create a GENI credential cert
##
#
# NB: force the install of python-m2crypto if geniuser
#
if [ "$SWAPPER" = "geniuser" ]; then
dpkg-query -l python-m2crypto | grep -q ii
if [ ! $? = 0 ]; then
apt-get install python-m2crypto
fi
fi
if [ ! -e $OURDIR/geni.key ]; then
geni-get key > $OURDIR/geni.key
fi
if [ ! -e $OURDIR/geni.certificate ]; then
geni-get certificate > $OURDIR/geni.certificate
fi
if [ ! -e /root/.ssl/encrypted.pem ]; then
mkdir -p /root/.ssl
chmod 600 /root/.ssl
cat $OURDIR/geni.key > /root/.ssl/encrypted.pem
cat $OURDIR/geni.certificate >> /root/.ssl/encrypted.pem
fi
#
# Grab our topomap so we can see how many nodes we have.
# NB: only safe to use topomap for non-fqdn things.
......@@ -168,9 +173,12 @@ fi
# Create a map of node nickname to FQDN. This supports geni multi-site
# experiments.
#
if [ \( -s /root/.ssl/encrypted.pem \) -a \( ! \( -e $OURDIR/manifests.xml \) \) ]; then
python $DIRNAME/getmanifests.py > $OURDIR/manifests.xml
cat manifests.xml | sed -e 's/<node /\n<node /g' | sed -n -e "s/^<node [^>]*client_id=['\"]*\([^'\"]*\)['\"].*<host name=['\"]\([^'\"]*\)['\"].*$/\1\t\2/p" > $OURDIR/fqdn.map
if [ \( -s $OURDIR/manifests.xml \) -a \( ! \( -s $OURDIR/fqdn.map \) \) ]; then
cat manifests.xml | tr -d '\n' | sed -e 's/<node /\n<node /g' | sed -n -e "s/^<node [^>]*client_id=['\"]*\([^'\"]*\)['\"].*<host name=['\"]\([^'\"]*\)['\"].*$/\1\t\2/p" > $OURDIR/fqdn.map
# Add a newline if we wrote anything.
if [ -s $OURDIR/fqdn.map ]; then
echo '' >> $OURDIR/fqdn.map
fi
fi
#
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment