diff --git a/tools/README.rst b/tools/README.rst index 040ec8eb..f6693a3a 100644 --- a/tools/README.rst +++ b/tools/README.rst @@ -109,22 +109,6 @@ it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. -pip-download ------------- - -`pip-download` is a small helper utility that interacts with pip and the pip API to -download packages into a given directory (using a common extraction and download -cache subdirectories). It also automatically prunes duplicated downloads if they -are of the same project name (which pip appears to do sometimes, such as in the distribute -and setuptools fiasco). This helps avoid needless duplication:: - - $ ./tools/pip-download -d /tmp/e 'setuptools>0.8' 'flake8' - Saved /tmp/e/flake8-2.0.tar.gz - Saved /tmp/e/mccabe-0.2.1.tar.gz - Saved /tmp/e/pep8-1.4.6.tar.gz - Saved /tmp/e/pyflakes-0.7.3.tar.gz - Saved /tmp/e/setuptools-0.9.8.tar.gz - specprint --------- @@ -217,11 +201,6 @@ the Free Software Foundation; either version 2 of the License, or (at your option) any later version. -git-changelog -------------- -This tool generates a pretty software's changelog from git history. - - build-install-node-from-source.sh --------------------------------- @@ -233,11 +212,6 @@ build-openvswitch.sh Helps build latest `openvswitch` from source into rpms. -clean-pip ---------- - -This utility removes package installed by pip but not by rpm. - clear-dns.sh ------------ @@ -247,23 +221,3 @@ img-uploader ------------ Helper tool to upload images to glance using your anvil settings. - -validate-yaml -------------- - -Validates a yaml file is formatted correctly. - -yaml-pretty ------------ - -Pretty prints yaml into a standard format. - -resize.sh ---------- - -Resizes a images filesystem using guestfish. - -euca.sh -------- - -Creates ec2 keys for usage with nova. diff --git a/tools/clean-pip b/tools/clean-pip deleted file mode 100755 index 3ca3ddf3..00000000 --- a/tools/clean-pip +++ /dev/null @@ -1,14 +0,0 @@ -#!/bin/bash - -# this utility removes package installed by pip -# but not by rpm - -tmp_dir=$(mktemp -d) - -echo "Moving unowned files to $tmp_dir" - -for f in /usr/lib*/python*/site-packages/*; do - if ! rpm -qf $f &>/dev/null; then - mv -v $f $tmp_dir/ - fi -done diff --git a/tools/endpoint-service-replace.py b/tools/endpoint-service-replace.py deleted file mode 100755 index 8b069b7f..00000000 --- a/tools/endpoint-service-replace.py +++ /dev/null @@ -1,91 +0,0 @@ -#!/usr/bin/env python - -from optparse import OptionParser - -import os -import sys -import yaml - -possible_topdir = os.path.normpath(os.path.join(os.path.abspath(sys.argv[0]), - os.pardir, - os.pardir)) - -if os.path.exists(os.path.join(possible_topdir, - 'anvil', - '__init__.py')): - sys.path.insert(0, possible_topdir) - - -from anvil.components.helpers import keystone -from anvil import importer -from anvil import log as logging -from anvil import passwords -from anvil import utils - - -def get_token(): - pw_storage = passwords.KeyringProxy(path='/etc/anvil/passwords.cfg') - lookup_name = "service_token" - prompt = "Please enter the password for %s: " % ('/etc/anvil/passwords.cfg') - (exists, token) = pw_storage.read(lookup_name, prompt) - if not exists: - pw_storage.save(lookup_name, token) - return token - - -def replace_services_endpoints(token, options): - client = importer.construct_entry_point("keystoneclient.v2_0.client:Client", - token=token, endpoint=options.keystone_uri) - current_endpoints = client.endpoints.list() - current_services = client.services.list() - - def filter_resource(r): - raw = dict(r.__dict__) # Can't access the raw attrs, arg... - raw_cleaned = {} - for k, v in raw.items(): - if k == 'manager' or k.startswith('_'): - continue - raw_cleaned[k] = v - return raw_cleaned - - for e in current_endpoints: - print("Deleting endpoint: ") - print(utils.prettify_yaml(filter_resource(e))) - client.endpoints.delete(e.id) - - for s in current_services: - print("Deleting service: ") - print(utils.prettify_yaml(filter_resource(s))) - client.services.delete(s.id) - - if options.file: - with(open(options.file, 'r')) as fh: - contents = yaml.load(fh) - set_contents = { - 'services': contents.get('services', []), - 'endpoints': contents.get('endpoints', []), - } - print("Regenerating with:") - print(utils.prettify_yaml(set_contents)) - set_contents['users'] = [] - set_contents['roles'] = [] - set_contents['tenants'] = [] - initer = keystone.Initializer(token, options.keystone_uri) - initer.initialize(**set_contents) - - -def main(): - parser = OptionParser() - parser.add_option("-k", '--keystone', dest='keystone_uri', - help='keystone endpoint uri to authenticate with', metavar='KEYSTONE') - parser.add_option("-f", '--file', dest='file', - help='service and endpoint creation file', metavar='FILE') - (options, args) = parser.parse_args() - if not options.keystone_uri or not options.file: - parser.error("options are missing, please try -h") - logging.setupLogging(logging.DEBUG) - replace_services_endpoints(get_token(), options) - - -if __name__ == "__main__": - sys.exit(main()) diff --git a/tools/euca.sh b/tools/euca.sh deleted file mode 100755 index e0596b76..00000000 --- a/tools/euca.sh +++ /dev/null @@ -1,96 +0,0 @@ -#!/usr/bin/env bash - -# From devstack.sh commit 0bd2410d469f11934b5965d83b57d56418e66b48 - -# Create EC2 credentials for the current user as defined by OS_TENANT_NAME:OS_USERNAME - -ME=`basename $0` - -if [[ -n "$1" ]]; then - USERNAME=$1 -fi - -if [[ -n "$2" ]]; then - TENANT=$2 -fi - -# Find the other rc files -RC_DIR="/etc/anvil" -CORE_RC="install.rc" -EC2_RC="euca.rc" - -if [ ! -f "$RC_DIR/$CORE_RC" ]; -then - GEN_CMD="smithy -a install" - echo "File '$RC_DIR/$CORE_RC' needed before running '$ME'" - echo "Please run './$GEN_CMD' to get this file." - exit 1 -fi - -# Get user configuration -source $RC_DIR/$CORE_RC - -# Woah! -if [ -f $RC_DIR/$EC2_RC ]; -then - echo "Woah cowboy you seem to already have '$RC_DIR/$EC2_RC'!" - while true; do - read -p "Overwrite it and continue? " yn - case $yn in - [Yy]* ) break;; - [Nn]* ) exit 1;; - * ) echo "Please answer y or n.";; - esac - done -fi - -# Bug https://bugs.launchpad.net/keystone/+bug/962600 -unset SERVICE_TOKEN -unset SERVICE_ENDPOINT - -# Set the ec2 url so euca2ools works -EC2_URL=$(keystone catalog --service ec2 | awk '/ publicURL / { print $4 }') - -# Create EC2 credentials for the current user -CREDS=$(keystone ec2-credentials-create) -EC2_ACCESS_KEY=$(echo "$CREDS" | awk '/ access / { print $4 }') -EC2_SECRET_KEY=$(echo "$CREDS" | awk '/ secret / { print $4 }') - -# Euca2ools Certificate stuff for uploading bundles -NOVA_KEY_DIR=${NOVA_KEY_DIR:-$RC_DIR} -S3_URL=$(keystone catalog --service s3 | awk '/ publicURL / { print $4 }') - -# ?? -EC2_USER_ID=42 - -# For a comment -NOW=`date` - -# Make a nice file for u -ENV_FN=$RC_DIR/$EC2_RC -echo "Making $ENV_FN" - -cat > $ENV_FN < 1: - for subline in sublines[1:]: - lines.append(" %s" % subline) - lines.append("") - return "\n".join(lines) - - -def create_parser(): - parser = argparse.ArgumentParser() - - parser.add_argument( - "--debug", "-d", - action="store_true", - default=False, - help="Print debug information") - parser.add_argument( - "--filename", "-f", - default="ChangeLog", - help="Name of changelog file (default: ChangeLog)") - parser.add_argument( - "commit", - metavar="", - default="HEAD", - nargs="?", - help="The name of a commit for which to generate the log" - " (default: HEAD)") - return parser - - -def call_subprocess(cmd, cwd=None, show_stdout=True, raise_on_returncode=True): - if show_stdout: - stdout = None - else: - stdout = subprocess.PIPE - proc = subprocess.Popen(cmd, cwd=cwd, stderr=None, stdin=None, stdout=stdout) - ret = proc.communicate() - if proc.returncode: - cwd = cwd or os.getcwd() - command_desc = " ".join(cmd) - if raise_on_returncode: - raise ExecutionError( - "Command %s failed with error code %s in %s" - % (command_desc, proc.returncode, cwd)) - else: - logger.warn( - "Command %s had error code %s in %s" - % (command_desc, proc.returncode, cwd)) - return ret - - -def setup_logging(options): - level = logging.DEBUG if options.debug else logging.WARNING - handler = logging.StreamHandler(sys.stderr) - logger.addHandler(handler) - logger.setLevel(level) - - -def main(): - parser = create_parser() - options = parser.parse_args() - setup_logging(options) - source_dir = os.getcwd() - - # .git can be a dir or a gitref regular file (for a git submodule) - if not os.path.exists(os.path.join(source_dir, ".git")): - print >> sys.stderr, "fatal: Not a git repository" - sys.exit(1) - - try: - with open("%s/%s" % (source_dir, options.filename), "wb") as out: - out.write(GitChangeLog(source_dir).format_log(options.commit)) - except Exception as ex: - print >> sys.stderr, ex - - -if __name__ == "__main__": - try: - main() - except Exception as exp: - print >> sys.stderr, exp diff --git a/tools/pre-commit b/tools/pre-commit deleted file mode 100755 index c6410c7c..00000000 --- a/tools/pre-commit +++ /dev/null @@ -1,46 +0,0 @@ -#!/bin/bash - -# install me this way: -# cp pre-commit "$(git rev-parse --git-dir)/hooks/" - - -gitdir="$(readlink -f $(git rev-parse --git-dir))" - -tmpdir= -cleanup_tmpdir() -{ - [ -z "$tmpdir" ] || rm -rf -- "$tmpdir" - exit "$@" -} -tmpdir=$(mktemp -dt "${0##*/}.XXXXXXXX") -trap 'cleanup_tmpdir $?' EXIT -trap 'clenaup_tmpdir 143' HUP INT QUIT PIPE TERM - - - -git checkout-index -a --prefix="$tmpdir/" -cd "$tmpdir" - -indexed_files() -{ - git --git-dir="$gitdir" diff --cached --name-only --diff-filter=AM -} - -FILES="$(indexed_files | grep -E '\.py$')" -if [ -n "$FILES" ]; then - pylint $FILES || STATUS=1 - if grep -nEH --color '(import pdb|pdb.set_trace)' $FILES; then - echo "Please remove pdb" - STATUS=1 - fi -fi - -FILES="$(indexed_files | grep -E '\.(py|html|js)$')" -if [ -n "$FILES" ]; then - if grep -nEH --color '\s+$' $FILES; then - echo "Please remove trailing spaces" - STATUS=1 - fi -fi - -exit $STATUS diff --git a/tools/resize.sh b/tools/resize.sh deleted file mode 100755 index a05e0066..00000000 --- a/tools/resize.sh +++ /dev/null @@ -1,56 +0,0 @@ -#!/bin/bash - -### This is a utility script that can be used to resize a vm's disk -### image in case that image is just a bare filesystem with no -### partition table or boot record. You should shutdown the vm prior -### to using this script. - -if [ $# -lt 2 ]; then - echo "Usage: resize.sh (e.g., resize.sh disk 500G)" 1>&2 - exit 1 -fi - -DISK="$1" -SIZE="$2" - -echo "Will attempt to resize $DISK to $SIZE." - -if [ ! -w "$DISK" ]; then - echo "Error: Cannot write to $DISK, maybe you need to sudo." - exit 1 -fi - -TMPDISK="$DISK.$RANDOM" - -if !(cp "$DISK" "$TMPDISK"); then - echo "Error: unable to make a temporary copy of $DISK named $TMPDISK." 1>&2 - exit 1 -fi - -if !(qemu-img resize "$TMPDISK" "$SIZE"); then - echo "Error: qemu-img failed." 1>&2 - exit 1 -fi - -echo "Attempting guestfs resize... this might take a few minutes." - -guestfish <&2 - exit 1 -fi - -if !(mv "$TMPDISK" "$DISK"); then - echo "Error: unable to move $TMPDISK back on top of $DISK." 1>&2 - exit 1 -fi - -echo "Great success." - diff --git a/tools/validate-yaml.py b/tools/validate-yaml.py deleted file mode 100755 index 19e3c27b..00000000 --- a/tools/validate-yaml.py +++ /dev/null @@ -1,14 +0,0 @@ -#!/usr/bin/env python - -"""Try to read a YAML file and report any errors. -""" - -import sys - -import yaml - - -if __name__ == "__main__": - fh = open(sys.argv[1], 'r') - yaml.load(fh.read()) - fh.close() diff --git a/tools/yaml-pretty.py b/tools/yaml-pretty.py deleted file mode 100755 index cbd61d84..00000000 --- a/tools/yaml-pretty.py +++ /dev/null @@ -1,23 +0,0 @@ -#!/usr/bin/env python - -import sys - -import yaml - -# See: http://pyyaml.org/wiki/PyYAMLDocumentation - -if __name__ == "__main__": - args = list(sys.argv) - args = args[1:] - for fn in args: - fh = open(fn, 'r') - data = yaml.load(fh.read()) - fh.close() - formatted = yaml.dump(data, - line_break="\n", - indent=4, - explicit_start=True, - explicit_end=True, - default_flow_style=False) - print("# Formatted %s" % (fn)) - print(formatted)