Remove diskimage-builder core contents.

Change-Id: I5c7826432bc9d8c1743ab4e575bd3edd5ba4af78
This commit is contained in:
Robert Collins 2013-04-05 15:09:43 +13:00
parent 9172e4f791
commit 7cbde9074e
85 changed files with 32 additions and 2694 deletions

View File

@ -1,7 +1,3 @@
recursive-include lib
include bin/disk-image-create
include bin/disk-image-get-kernel
include bin/ramdisk-image-create
recursive-include elements
include README.md
recursive-include docs

275
README.md
View File

@ -1,270 +1,31 @@
Image building tools for Openstack
==================================
Image building rules for Openstack images
=========================================
These tools are the components of tripleo (https://github.com/tripleo/incubator)
that do the plumbing involved in building disk images. Specific configs live
in the incubator repository, while the reusable tools live here.
These elements are used to build disk images for deploying Openstack via Heat.
They are built as part of the TripleO (https://github.com/tripleo/incubator)
umbrella project.
What tools are there?
---------------------
Instructions
------------
* disk-image-create -o filename {element} [{element} ...] : Create an image of
element {element}, optionally mixing in other elements. You will usually want
to include the "base" element in your image.
Checkout this source tree and also the diskimage builder
(https://github.com/stackforge/diskimage-builder), export an ELEMENTS\_PATH
to both trees, and build any disk images you need.
* ramdisk-image-create -o filename {element} [{element} ...] : Create a kernel+
ramdisk pair for running maintenance on bare metal machines (deployment,
inventory, burnin etc).
git clone https://github.com/stackforge/diskimage-builder.git
git clone https://github.com/stackforge/tripleo-image-elements.git
export ELEMENTS_PATH=diskimage-builder/elements:tripleo-image-elements/elements
diskimage-builder/bin/disk-image-create -u base vm bootstrap local-config stackuser -a i386 -o bootstrap
ramdisk-image-create -o deploy.ramdisk deploy
Common element combinations
---------------------------
* disk-image-get-kernel filename : Extract the appropriate kernel and ramdisk
to use when doing PXE boot using filename as the image for a machine.
* elements can be found in the top level elements directory.
* element-info : Extract information about elements.
Why?
----
Automation: While users and operators can manually script or put together ram
disks and disk images, mature automation makes customisation and testing easier.
Design
======
Images are built using a chroot and bind mounted /proc /sys and /dev. The goal
of the image building process is to produce blank slate machines that have all
the necessary bits to fulfill a specific purpose in the running of an Openstack
cloud: e.g. a nova-compute node. Images produce either a filesystem image with
a label of cloudimg-rootfs, or can be customised to produce disk images (but
will still contain a filesystem labelled cloudimg-rootfs).
An element is a particular set of code that alters how the image is built, or
runs within the chroot to prepare the image. E.g. the local-config element
copies in the http proxy and ssh keys of the user running the image build
process into the image, whereas the vm element makes the image build a regular
VM image with partition table and installed grub boot sector. The mellanox
element adds support for mellanox infiniband hardware to both the deploy
ramdisk and the built images.
Images start as a base ubuntu cloud image. Other distributions may be added in
future, the infrastructure deliberately makes few assumptions about the exact
operating system is use. The base image has opensshd running (a new key
generated on first boot) and accepts use keys via the cloud metadata service,
loading them into the 'ubuntu' user.
The goal of a built image is to have any global configuration ready to roll,
but nothing that ties it to a specific cloud instance: images should be able to
be dropped into a test cloud and validated, and then deployed into a production
cloud (usually via bare metal nova) for production use. As such, the image
contents can be modelled as three distinct portions:
- global content: the actual code, kernel, always-applicable config (like
disabling password authentication to sshd).
- metadata / config management provided configuration: user ssh keys, network
address and routes, configuration management server location and public key,
credentials to access other servers in the cloud. These are typically
refreshed on every boot.
- persistent state: sshd server key, database contents, swift storage areas,
nova instance disk images, disk image cache. These would typically be stored
on a dedicated partition and not overwritten when re-deploying the image.
The goal of the image building tools is to create machine images that content
the correct global content and are ready for 'last-mile' configuration by the
nova metadata API, after which a configuration management system can take over
(until the next deploy, when it all starts over from scratch).
Existing elements
-----------------
Elements are found in the subdirectory elements. Each element is in a directory
named after the element itself. Elements *should* have a README.md in the root
of the element directory describing what it is for.
Writing an element
-----------------
Make as many of the following subdirectories as you need, depending on what
part of the process you need to customise:
* root.d: Create or adapt the initial root filesystem content. This is where
alternative distribution support is added, or customisations such as
building on an existing image. If no element configures a root, the ubuntu
element will be automatically invoked to obtain an Ubuntu image.
Runs outside the chroot on the host environment.
Only one element can use this at a time unless particular care is taken not
to blindly overwrite but instead to adapt the context extracted by other
elements.
* inputs: $ARCH=i386|amd64 $TARGET\_ROOT=/path/to/target/workarea
* cleanup.d: Perform cleanups of the root filesystem content. For instance,
temporary settings to use the image build environment HTTP proxy are removed
here in the dpkg element. Runs outside the chroot on the host environment.
* inputs: $ARCH=i386|amd64 $TARGET\_ROOT=/path/to/target/workarea
* block-device-size.d: Alter the size (in GB) of the disk image. This is useful
when a particular element will require a certain minimum (or maximum) size.
You can either error and stop the build, or adjust the size to match.
NB: Due to the current simple implementation, the last output value wins
so this should be used rarely - only one element in a mix can reliably set
a size.
* outputs: $IMAGE\_SIZE={size\_in\_GB}
* inputs: $IMAGE\_SIZE={size\_in\_GB}
* block-device.d: customise the block device that the image will be made on
(e.g. to make partitions).
* outputs: $IMAGE\_BLOCK\_DEVICE={path}
* inputs: $IMAGE\_BLOCK\_DEVICE={path}
* extra-data.d: pull in extra data from the host environment that hooks may
need during image creation. This should copy any data (such as SSH keys,
http proxy settings and the like) somewhere under $TMP\_HOOKS\_PATH.
* outputs: None
* inputs: $TMP\_HOOKS\_PATH
* pre-install.d: Run code in the chroot before customisation or packages are
installed. A good place to add apt repositories.
* install.d: Runs after pre-install.d in the chroot. This is a good place to
install packages, chain into configuration management tools or do other
image specific operations.
* first-boot.d: Runs inside the image before rc.local. Scripts from here are
good for doing per-instance configuration based on cloud metadata.
* element-deps : A plain text, newline separated list of elements which will
be added to the list of elements built into the image at image creation time.
Ramdisk elements support the following files in their element directories:
* binary-deps : executables required to be fed into the ramdisk. These need
to be present in your $PATH.
* init : a POSIX shell script fragment that will be appended to the default
script executed as the ramdisk is booted (/init)
Structure of an element
-----------------------
The above-mentioned global content can be further broken down in a way that
encourages composition of elements and reusability of their components. One
possible approach to this would be to label elements as either a "driver",
"service", or "config" element. Below are some examples.
- Driver-specific elements should only contain the necessary bits for that
driver:
elements/
driver-mellanox/
init - modprobe line
install.d/
10-mlx - package installation
- An element that installs and configures Nova might be a bit more complex:
elements/
service-nova/
pre-install.d/
50-my-ppa - add a PPA
install.d/
10-user - common Nova user accts
50-my-pack - install packages from my PPA
60-nova - install nova and some dependencies
first-boot.d/
60-nova - do some post-install config for nova
- In the general case, configuration should probably be handled either by the
meta-data service (eg, during first-boot.d) or via normal CM tools
(eg, salt). That being said, it may occasionally be desirable to create a
set of elements which express a distinct configuration of the same software
components. For example, if one were to bake a region-specific SSL cert into
the images deployed in each region, one might express it like this:
elements/
config-az1/
first-boot.d/
20-ssl - add the az1 certificate
config-az2/
first-boot.d/
20-ssl - add the az2 certificate
In this way, depending on the hardware and in which availability zone it is
to be deployed, an image would be composed of:
zero or more driver-elements
one or more service-elements
zero or more config-elements
It should be noted that this is merely a naming convention to assist in
managing elements. Diskimage-builder is not, and should not be, functionally
dependent upon specific element names.
Debugging elements
------------------
Export 'break' to drop to a shell during the image build. Break points can be
set either before or after any of the hook points by exporting
"break=[before|after]-hook-name". Multiple break points can be specified as a
comma-delimited string. Some examples:
* break=before-block-device-size will break before the block device size hooks
are called.
* break=after-first-boot,before-pre-install will break after the first-boot
hooks and before the pre-install hooks.
Testing Elements
----------------
Elements can be tested using python. To create a test:
* Create a directory called 'tests' in the element directory.
* Create an empty file called '\_\_init\_\_.py' to make it into a python
package.
* Create your test files as 'test\_whatever.py', using regular python test
code.
To run all the tests use testr - `testr run`. To run just some tests provide
one or more regex filters - tests matching any of them are run -
`testr run apt-proxy`.
Third party elements
--------------------
Pending implementation. The idea is to have a search path for elements.
Installation
============
* Clone the repository locally, then add bin to your path.
* Copy sudoers.d/\* into your /etc/sudoers.d/. (Warning, use visudo -c -f
{filename} to check that each one parses successfully on your machine, so you
don't break your machine).
Invocation
==========
The scripts can generally just be run. Options can be set on the command line
or by exporting variables to override those present in lib/img-defaults. -h to
get help.
Using the variable ELEMENTS_PATH will allow to specify multiple elements locations.
It's a colon (:) separated path list, and it will work in a first path/element found,
first served approach.
To be written.
Copyright
=========
Copyright 2012 Hewlett-Packard Development Company, L.P.
Copyright 2012,2013 Hewlett-Packard Development Company, L.P.
Copyright (c) 2012 NTT DOCOMO, INC.
All Rights Reserved.

View File

@ -1,129 +0,0 @@
#!/bin/bash
#
# Copyright 2012 Hewlett-Packard Development Company, L.P.
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
set -e
# Prevent perl from complaining a lot, but also remove any unexpected side-effects
# of $LANG varying between build hosts
export LANG=C
# Store our initial environment and command line args for later
export DIB_ARGS="$@"
export DIB_ENV=$(export)
SCRIPTNAME=$(basename $0)
SCRIPT_HOME=$(dirname $0)
export _LIB=$(dirname $0)/../lib
source $_LIB/die
function show_options () {
echo "Options:"
echo " -a i386|amd64 -- set the architecture of the image"
echo " -o filename -- set the name of the output file"
echo " -x -- turn on tracing"
echo " -u -- uncompressed; do not compress the image - larger but faster"
echo " -c -- clear environment before starting work"
echo " -n skip the default inclusion of the 'base' element"
echo " -p package[,package,package] -- list of packages to install in the image"
echo
echo "ELEMENTS_PATH will allow you to specify multiple locations for the elements."
exit 0
}
INSTALL_PACKAGES=""
COMPRESS_IMAGE="true"
TEMP=`getopt -o a:ho:xucnp: -n $SCRIPTNAME -- "$@"`
if [ $? != 0 ] ; then echo "Terminating..." >&2 ; exit 1 ; fi
# Note the quotes around `$TEMP': they are essential!
eval set -- "$TEMP"
while true ; do
case "$1" in
-a) export ARCH=$2; shift 2 ;;
-o) export IMAGE_NAME=$2; shift 2 ;;
-h) show_options;;
-x) shift; set -x;;
-u) shift; export COMPRESS_IMAGE="";;
-c) shift ; export CLEAR_ENV=1;;
-n) shift; export SKIP_BASE="1";;
-p) IFS="," read -a INSTALL_PACKAGES <<< "$2"; export INSTALL_PACKAGES ; shift 2 ;;
--) shift ; break ;;
*) echo "Internal error!" ; exit 1 ;;
esac
done
if [ "$CLEAR_ENV" = "1" -a "$HOME" != "" ]; then
echo "Re-execing to clear environment."
echo "(note this will prevent much of the local_config element from working)"
exec -c $0 "$@"
fi
for arg do IMAGE_ELEMENT="$IMAGE_ELEMENT $arg" ; done
if [ "$SKIP_BASE" != "1" ]; then
IMAGE_ELEMENT="base $IMAGE_ELEMENT"
fi
source $_LIB/img-defaults
source $_LIB/common-functions
source $_LIB/img-functions
IMAGE_NAME=${IMAGE_NAME%%\.${IMAGE_TYPE}}
IMAGE_ELEMENT=$($SCRIPT_HOME/element-info --expand-dependencies $IMAGE_ELEMENT)
echo "Building elements: $IMAGE_ELEMENT"
echo "If prompted for sudo, install sudoers.d/img-build-sudoers into /etc/sudoers.d and restart the build."
# TODO: make into an element.
ensure_nbd
mk_build_dir
eval_run_d block-device-size "IMAGE_SIZE="
qemu-img create -f qcow2 -o preallocation=metadata $TMP_IMAGE_PATH ${IMAGE_SIZE}G
# Should have a grab-next-dev helper ?
NBD_DEV=/dev/nbd0
if [[ $(qemu-nbd --help | grep cache) == *writeback* ]] ; then
CACHE="--cache=writeback"
else
echo "Warning: qemu-nbd without --cache=writeback is /slow/."
CACHE=""
fi
sudo qemu-nbd -c $NBD_DEV $CACHE $TMP_IMAGE_PATH
export EXTRA_UNMOUNT="sudo qemu-nbd -d $NBD_DEV"
export IMAGE_BLOCK_DEVICE=$NBD_DEV
eval_run_d block-device "IMAGE_BLOCK_DEVICE="
sudo mkfs -F -t $FS_TYPE -L cloudimg-rootfs ${IMAGE_BLOCK_DEVICE}
mount_tmp_image ${IMAGE_BLOCK_DEVICE}
create_base
run_d extra-data
# Run pre-install scripts. These do things that prepare the chroot for package installs
run_d_in_target pre-install
do_extra_package_install
# Call install scripts to pull in the software users want.
run_d_in_target install
prepare_first_boot
finalise_base
unmount_image
compress_image
save_image $IMAGE_NAME.$IMAGE_TYPE

View File

@ -1,85 +0,0 @@
#!/bin/bash
#
# Copyright 2012 Hewlett-Packard Development Company, L.P.
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
set -e
SCRIPTNAME=$(basename $0)
export _LIB=$(dirname $0)/../lib
source $_LIB/die
function show_options () {
echo "Usage: $SCRIPTNAME -i <image> [-d <outdir>] [-o <prefix]"
echo
echo "Options:"
echo " -i filename -- extract kernel + ramdisk from this file"
echo " -d dir -- save files in \$dir; defaults to /tmp"
echo " -o prefix -- set the prefix of the output files; defaults to 'baremetal'"
echo " eg, baremetal-vmlinuz and baremetal-initrd"
echo " -x -- turn on tracing"
echo " -h -- print this message"
exit 0
}
TEMP=`getopt -o hd:i:o:x -n $SCRIPTNAME -- "$@"`
echo "XXX $TEMP"
if [ $? != 0 ] ; then echo "Terminating..." >&2 ; exit 1 ; fi
# Note the quotes around `$TEMP': they are essential!
eval set -- "$TEMP"
export OUT_DIR=/tmp
export OUT_PFX=baremetal
while true ; do
case "$1" in
-d) export OUT_DIR=$2; shift 2 ;;
-i) export IMAGE_FILE=$2; shift 2 ;;
-o) export OUT_PFX=$2; shift 2 ;;
-h) show_options;;
-x) shift; set -x;;
--) shift ; break ;;
*) echo "Internal error!" ; exit 1 ;;
esac
done
if [[ ! -n "$IMAGE_FILE" ]]; then
die "You must specify an image to read from with -i \$filename"
elif [[ ! -r "$IMAGE_FILE" ]]; then
die "Image file $IMAGE_FILE is not readable"
fi
source $_LIB/img-defaults
source $_LIB/common-functions
source $_LIB/img-functions
echo "Extracting kernel + ramdisk from $IMAGE_FILE and writing them to $OUT_DIR"
# sets WORK_DIR
mount_qcow_image $IMAGE_FILE
# Dig up the initrd and kernel to use.
BOOTDIR="$WORK_DIR/boot"
KERNEL=$(basename `ls -1 $BOOTDIR/vmlinuz*generic | sort -n | tail -1`)
RAMDISK=$(basename `ls -1 $BOOTDIR/initrd*generic | sort -n | tail -1`)
sudo cp $BOOTDIR/$KERNEL $OUT_DIR/$OUT_PFX-vmlinuz
sudo cp $BOOTDIR/$RAMDISK $OUT_DIR/$OUT_PFX-initrd
sudo chmod a+r $OUT_DIR/$OUT_PFX-vmlinuz
sudo chmod a+r $OUT_DIR/$OUT_PFX-initrd
unmount_qcow_image
echo "$OUT_PFX-vmlinuz,$OUT_PFX-initrd"

View File

@ -1 +0,0 @@
../diskimage_builder

View File

@ -1,23 +0,0 @@
#!/usr/bin/python
# Copyright 2013 Hewlett-Packard Development Company, L.P.
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
import os
import sys
from diskimage_builder.elements import main
sys.exit(main(sys.argv))

View File

@ -1,99 +0,0 @@
#!/bin/bash
# XXX: Only portions of this are the NTT original, much is now HP work
# Copyright (c) 2012 NTT DOCOMO, INC.
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
set -e
SCRIPTNAME=$(basename $0)
SCRIPT_HOME=$(dirname $0)
export _DIR=$(dirname $0)
export _LIB=${_DIR}/../lib
source $_LIB/die
function show_options () {
echo "Options:"
echo " -m PATH -- Path to find lib/modules. Default /"
echo " -k VERSION -- Kernel version. Default $(uname -r)"
echo " -h -- This help"
echo " -o FILENAME -- Output file"
echo " -x -- turn on tracing"
exit 0
}
TEMP=$(getopt -o m:k:ho:x -n $SCRIPTNAME -- "$@")
if [ $? != 0 ] ; then echo "Terminating..." >&2 ; exit 1 ; fi
# Note the quotes around `$TEMP': they are essential!
eval set -- "$TEMP"
while true ; do
case "$1" in
-m) export MODULE_ROOT=$2; shift 2 ;;
-k) export KERNEL_VERSION=$2; shift 2 ;;
-o) export IMAGE_NAME=$2; shift 2 ;;
-h) show_options;;
-x) shift; set -x;;
--) shift ; break ;;
*) echo "Internal error!" ; exit 1 ;;
esac
done
for arg do RAMDISK_ELEMENT="$RAMDISK_ELEMENT $arg" ; done
source $_LIB/ramdisk-defaults
source $_LIB/common-functions
source $_LIB/ramdisk-functions
RAMDISK_ELEMENT=$($SCRIPT_HOME/element-info --expand-dependencies $RAMDISK_ELEMENT)
echo "Building element(s): ${RAMDISK_ELEMENT}"
echo "Discovering binary dependencies"
ensure_binaries
INIT="$_DIR/../scripts/init"
FUNCTIONS_D="$_DIR/../scripts/d"
MODULE_DIR=$MODULE_ROOT/lib/modules/$KERNEL_VERSION
FIRMWARE_DIR=$MODULE_ROOT/lib/firmware
if [ ! -d "$MODULE_DIR" ]; then
echo "ERROR: kernel module directory not found at $MODULE_DIR"
exit 1
fi
LIB_UDEV=$LIB_UDEV_ROOT/lib/udev
if [ ! -d "$LIB_UDEV" ]; then
echo "ERROR: udev directory not found at $LIB_UDEV"
exit 1
fi
mk_build_dir
mkdir -p $TMP_BUILD_DIR/mnt
TMP_MOUNT_PATH=$TMP_BUILD_DIR/mnt
echo "working in $TMP_MOUNT_PATH"
create_base
populate_lib
populate_busybox
populate_init
populate_udev
finalise_image
save_image $IMAGE_NAME

View File

@ -1,18 +0,0 @@
# Copyright 2012 Hewlett-Packard Development Company, L.P.
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
# conceptually load_tests should be here, but see
# http://bugs.python.org/issue16662 instead, its in test_elements.py

View File

@ -1,95 +0,0 @@
# Copyright 2013 Hewlett-Packard Development Company, L.P.
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
import argparse
from errno import ENOENT
import os
import sys
def get_elements_dir():
if not os.environ.get('ELEMENTS_PATH'):
raise Exception("$ELEMENTS_PATH must be set.")
return os.environ['ELEMENTS_PATH']
def dependencies(element, elements_dir=None):
""" Return the non-transitive list of dependencies for a single element
:param user_elements: iterable enumerating elements a user has requested
:param elements_dir: the elements dir to read from. If not supplied,
inferred by calling get_elements_dir().
:return: a set just containing all elements that the specified element
depends on.
"""
if elements_dir is None:
elements_dir = get_elements_dir()
for path in elements_dir.split(':'):
element_deps_path = (os.path.join(path, element, 'element-deps'))
try:
with open(element_deps_path) as element_deps:
return set([line.strip() for line in element_deps])
except IOError as e:
if os.path.exists(os.path.join(path, element)) and e.errno == 2:
return set()
if e.errno == 2:
continue
else:
raise
sys.stderr.write("ERROR: Element %s doesn't exists\n" % (element, ))
exit(-1)
def expand_dependencies(user_elements, elements_dir=None):
""" Expand user requested elements using element-deps files.
Arguments:
:param user_elements: iterable enumerating the elements a user requested
:param elements_dir: the elements dir to read from. Passed directly to
dependencies()
:return: a set containing user_elements and all dependent elements
including any transitive dependencies.
"""
final_elements = set(user_elements)
check_queue = list(user_elements)
while check_queue:
element = check_queue.pop()
deps = dependencies(element, elements_dir)
check_queue.extend(deps - final_elements)
final_elements.update(deps)
return final_elements
def main(argv):
parser = argparse.ArgumentParser()
parser.add_argument('elements', nargs='+',
help='elements to inspect')
parser.add_argument('--expand-dependencies', '-d', action='store_true',
default=False,
help='Print expanded dependencies of all args')
args = parser.parse_args(argv[1:])
if args.expand_dependencies:
print(' '.join(expand_dependencies(args.elements)))
return 0
sys.stderr.write("ERROR: please choose an option.\n")
return -1

View File

@ -1,20 +0,0 @@
# Translations template for configapplier.
# Copyright (C) 2013 ORGANIZATION
# This file is distributed under the same license as the configapplier
# project.
# FIRST AUTHOR <EMAIL@ADDRESS>, 2013.
#
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: configapplier 0.0.1\n"
"Report-Msgid-Bugs-To: EMAIL@ADDRESS\n"
"POT-Creation-Date: 2013-01-24 09:27-0800\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=utf-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Generated-By: Babel 0.9.6\n"

View File

@ -1,20 +0,0 @@
# English translations for configapplier.
# Copyright (C) 2013 ORGANIZATION
# This file is distributed under the same license as the configapplier
# project.
# FIRST AUTHOR <EMAIL@ADDRESS>, 2013.
#
msgid ""
msgstr ""
"Project-Id-Version: configapplier 0.0.1\n"
"Report-Msgid-Bugs-To: EMAIL@ADDRESS\n"
"POT-Creation-Date: 2013-01-24 09:27-0800\n"
"PO-Revision-Date: 2013-01-24 09:41-0800\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: en <LL@li.org>\n"
"Plural-Forms: nplurals=2; plural=(n != 1)\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=utf-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Generated-By: Babel 0.9.6\n"

View File

@ -1,85 +0,0 @@
# Copyright 2013 Hewlett-Packard Development Company, L.P.
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
import os
from testtools import TestCase
from fixtures import Fixture, EnvironmentVariable, TempDir
from diskimage_builder.elements import expand_dependencies
from diskimage_builder.elements import get_elements_dir
data_dir = os.path.abspath(
os.path.join(os.path.dirname(__file__), 'test-elements'))
def _populate_element(element_dir, element_name, element_deps=[]):
element_home = os.path.join(element_dir, element_name)
os.mkdir(element_home)
deps_path = os.path.join(element_home, 'element-deps')
with open(deps_path, 'w') as deps_file:
deps_file.write("\n".join(element_deps))
class TestElementDeps(TestCase):
def setUp(self):
super(TestElementDeps, self).setUp()
self.element_dir = self.useFixture(TempDir()).path
_populate_element(self.element_dir, 'requires-foo', ['foo'])
_populate_element(self.element_dir, 'foo')
_populate_element(self.element_dir,
'requires-requires-foo',
['requires-foo'])
_populate_element(self.element_dir, 'self', ['self'])
_populate_element(self.element_dir, 'circular1', ['circular2'])
_populate_element(self.element_dir, 'circular2', ['circular1'])
def test_non_transitive_deps(self):
result = expand_dependencies(['requires-foo'],
elements_dir=self.element_dir)
self.assertEquals(set(['requires-foo', 'foo']), result)
def test_transitive_deps(self):
result = expand_dependencies(['requires-requires-foo'],
elements_dir=self.element_dir)
self.assertEquals(set(['requires-requires-foo',
'requires-foo',
'foo']), result)
def test_no_deps(self):
result = expand_dependencies(['foo'],
elements_dir=self.element_dir)
self.assertEquals(set(['foo']), result)
def test_self(self):
result = expand_dependencies(['self'],
elements_dir=self.element_dir)
self.assertEquals(set(['self']), result)
def test_circular(self):
result = expand_dependencies(['circular1'],
elements_dir=self.element_dir)
self.assertEquals(set(['circular1', 'circular2']), result)
class TestElements(TestCase):
def test_depends_on_env(self):
self.useFixture(EnvironmentVariable('ELEMENTS_PATH', '/foo/bar'))
self.assertEquals('/foo/bar', get_elements_dir())
def test_env_not_set(self):
self.useFixture(EnvironmentVariable('ELEMENTS_PATH', ''))
self.assertRaises(Exception, get_elements_dir, ())

View File

@ -1,54 +0,0 @@
# Copyright 2012 Hewlett-Packard Development Company, L.P.
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
import os
import sys
import unittest
class StubPackage:
pass
# load all tests from /elements/*/tests/ dirs.
# conceptually load_tests should be in __init__, but see
# http://bugs.python.org/issue16662 instead. So, its here in test_elements.py
def load_tests(loader, tests, pattern):
"""load tests for diskimage_builder elements."""
if pattern is None:
# http://bugs.python.org/issue11218
pattern = "test*.py"
this_dir = os.path.dirname(__file__)
elements_dir = os.path.join(this_dir, "..", "elements")
# Make a fake elements top level package, as discovery doesn't let us
# override the python path.
package = StubPackage()
package.__path__ = [elements_dir]
sys.modules['elements'] = package
elements = os.listdir(elements_dir)
for element in elements:
element_dir = os.path.join(elements_dir, element)
tests_path = os.path.join(element_dir, "tests")
if (not os.path.isdir(tests_path) or
not os.path.isfile(os.path.join(tests_path, '__init__.py'))):
continue
# Create a 'package' for the element, so it can be imported.
package = StubPackage()
package.__path__ = [element_dir]
sys.modules['elements.%s' % element] = package
# Try importing the test module
package_tests = loader.discover(start_dir=tests_path, pattern=pattern)
tests.addTests(package_tests)
return tests

View File

@ -1,4 +1,4 @@
CI needs for image building
CI needs for TripleO Images
===========================
Eventually, if/when TripleO becomes an official Openstack project, all CI for
@ -13,13 +13,14 @@ Jenkins
members as service admins.
* Grant jenkin builders sudo [may want lxc containers or cloud instances for
security isolation]
* Jobs to build:
* bootstrap VM from-scratch (archive bootstrap.qcow2).
* Jobs built are in the autobuilt-jobs matrix, including fedora and ubuntu
bootstrap nodes, plain heat-cfn images - e.g.::
disk-image-create vm base devstack -o bootstrap -a i386
* devstack nova-bm execution (archive the resulting image).
Chained off of the bootstrap vm build
* We plan to but do not yet perform functional testing including running up
a live stack based on the images we build.
e.g. Chained off of the bootstrap vm build
ssh into the node, run demo/scripts/demo
@ -38,7 +39,7 @@ Jenkins
disk-image-create base vm glance nova-bm swift cinder quantum \
-o bootstrap-prod
* ramdisk deploy image buil
* ramdisk deploy image build
ramdisk-image-create deploy
@ -49,7 +50,7 @@ Jenkins
Copyright
=========
Copyright 2012 Hewlett-Packard Development Company, L.P.
Copyright 2012, 2013 Hewlett-Packard Development Company, L.P.
Copyright (c) 2012 NTT DOCOMO, INC.
All Rights Reserved.

View File

@ -1,12 +0,0 @@
This is the base element.
Almost all users will want to include this in their disk image build,
as it includes a lot of useful functionality.
Notes:
* If you are getting warnings during the build about your locale
being missing, consider installing/generating the relevant locale.
This may be as simple as having language-pack-XX installed in the
pre-install stage

View File

@ -1,9 +0,0 @@
#!/bin/bash
# Store the build-time environment and command line arguments
set -e
source $_LIB/die
[ -n "$TMP_HOOKS_PATH." ] || die "Temp hook path not set"
echo "$DIB_ENV" > $TMP_HOOKS_PATH/dib_environment
echo "$DIB_ARGS" > $TMP_HOOKS_PATH/dib_arguments

View File

@ -1,6 +0,0 @@
#!/bin/bash
# These are useful, or at worst not harmful, for all images we build.
set -e
install-packages linux-image-generic vlan open-iscsi

View File

@ -1,8 +0,0 @@
#!/bin/bash
# Tweak the stock ubuntu cloud-init config
set -e
dd of=/etc/cloud/cloud.cfg.d/10_etc_hosts.cfg << EOF
manage_etc_hosts: True
EOF

View File

@ -1,12 +0,0 @@
#!/bin/bash
# Store build-time environment and command line arguments
set -e
if [ -e "/tmp/in_target.d/dib_environment" ]; then
cp /tmp/in_target.d/dib_environment /etc/
fi
if [ -e "/tmp/in_target.d/dib_arguments" ]; then
cp /tmp/in_target.d/dib_arguments /etc/
fi

View File

@ -1,17 +0,0 @@
#!/bin/bash
# Install baseline packages and tools.
set -e
# If lsb_release is missing, just do nothing.
DISTRO=`lsb_release -si` || true
case $DISTRO in
'Ubuntu'|'Debian')
# Note: add-apt-repository would be nice for RPM platforms too - so when we
# need something like it, create a wrapper in dpkg/bin and fedora/bin.
apt-get -y update
install-packages python-software-properties
add-apt-repository -y ppa:tripleo/demo
;;
esac

View File

@ -1,3 +0,0 @@
Configures cloud-init to only use on-disk metadata/userdata sources. This
will avoid a boot delay of 2 minutes while polling for cloud data sources
such as the EC2 metadata service.

View File

@ -1,6 +0,0 @@
#!/bin/bash
printf "%s\t%s\t%s\t%s\n" \
cloud-init cloud-init/datasources multiselect "NoCloud, None" | \
debconf-set-selections
DEBIAN_FRONTEND=noninteractive dpkg-reconfigure cloud-init

View File

@ -1,2 +0,0 @@
Installs config-applier to handle Heat Metadata based configuration of
the system.

View File

@ -1,13 +0,0 @@
#!/bin/sh
home=$(dirname $0)
set -uex
mkdir -p /opt/stack
cd /opt/stack
git clone https://github.com/tripleo/config-applier.git
cd config-applier
git checkout master
pip install -e . -U
install -m 0644 -o root -g root $home/config-applier.upstart /etc/init/config-applier.conf

View File

@ -1,8 +0,0 @@
start on runlevel [2345]
task
author "Clint Byrum <clint@fewbar.com>"
description "Config Applier"
exec config-applier

View File

@ -1,2 +0,0 @@
A ramdisk that will expose the machine primary disk over iSCSI and reboot
once baremetal-deploy-helper signals it is finished.

View File

@ -1,3 +0,0 @@
busybox
tgtd
tgtadm

View File

@ -1,26 +0,0 @@
if [ -z "$ISCSI_TARGET_IQN" ]; then
echo "iscsi_target_iqn is not defined"
echo "Starting troubleshooting shell."
bash
fi
target_disk=`find_disk "$DISK"`
echo "start iSCSI target on $target_disk"
start_iscsi_target "$ISCSI_TARGET_IQN" "$target_disk" ALL
if [ $? -ne 0 ]; then
echo "Could not find disk to use."
echo "Starting troubleshooting shell."
bash
fi
echo "request boot server to deploy image"
d="i=$DEPLOYMENT_ID&k=$DEPLOYMENT_KEY&a=$BOOT_IP_ADDRESS&n=$ISCSI_TARGET_IQN"
wget --post-data "$d" "http://$BOOT_SERVER:10000"
echo "waiting for notice of complete"
nc -l -p 10000
echo "stop iSCSI target on $target_disk"
stop_iscsi_target

View File

@ -1,14 +0,0 @@
Autodetect network interfaces during boot and configure them for DHCP
The rationale for this is that we are likely to require multiple
network interfaces for use cases such as baremetal and there is no way
to know ahead of time which one is which, so we will simply run a
DHCP client on all interfaces (except lo) that are visible on the first
boot.
The script /usr/local/sbin/generate-interfaces-file.sh will be called
early in each boot and will scan available network interfaces and
ensure they are all present in /etc/network/interfaces.
Note that this element is only expected to be useful on Debian-derived
distributions, currently.

View File

@ -1,9 +0,0 @@
#!/bin/sh -x
# Prepare the target system for regenerating /etc/network/interfaces
# on its first boot.
SCRIPTDIR=$(dirname $0)
install -D -g root -o root -m 0755 ${SCRIPTDIR}/generate-interfaces-file.sh /usr/local/sbin/generate-interfaces-file.sh
install -D -g root -o root -m 0755 ${SCRIPTDIR}/dhcp-all-interfaces.conf /etc/init/dhcp-all-interfaces.conf

View File

@ -1,10 +0,0 @@
# Call a script to generate an /etc/network/interfaces file to DHCP all available interfaces
# Then remove this config file so the script is never run again
description "DHCP any connected, but unconfigured network interfaces"
start on starting network-interface
task
exec /usr/local/sbin/generate-interfaces-file.sh

View File

@ -1,37 +0,0 @@
#!/bin/bash
# Generate $INTERFACES_FILE on first boot
# This will add any unconfigured network interfaces to /etc/network/interfaces
# and configure them for DHCP
INTERFACES_FILE="/etc/network/interfaces"
function get_if_link() {
cat /sys/class/net/${1}/carrier
}
for interface in $(ls /sys/class/net | grep -v ^lo$) ; do
echo -n "Inspecting interface: $interface..."
HAS_CONFIG=$(ifquery $interface >/dev/null 2>&1)
if [ "$HAS_CONFIG" == "" ]; then
ip link set dev $interface up >/dev/null 2>&1
HAS_LINK="$(get_if_link $interface)"
TRIES=3
while [ "$HAS_LINK" == "0" -a $TRIES -gt 0 ]; do
HAS_LINK="$(get_if_link $interface)"
if [ "$HAS_LINK" == "1" ]; then
break
else
sleep 1
fi
TRIES=$(( TRIES - 1 ))
done
if [ "$HAS_LINK" == "1" ] ; then
printf "auto $interface\r\niface $interface inet dhcp\r\n\r\n" >>$INTERFACES_FILE]
echo "Configured"
else
echo "No link detected, skipping"
fi
fi
done

View File

@ -1,5 +0,0 @@
#!/bin/bash
home=$(dirname $0)
exec sudo install -m 0755 -o root -g root -D \
$home/dib-run-parts \
$TARGET_ROOT/usr/local/bin/dib-run-parts

View File

@ -1,54 +0,0 @@
#!/bin/bash
# Inspired by Debian and RedHat run-parts but portable and specific to di-b.
#
# Copyright 2012 Hewlett-Packard Development Company, L.P.
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
allowed_regex=${RUN_PARTS_REGEX:-"^[0-9A-Za-z_-]+$"}
set -ue
name=$(basename $0)
usage() {
echo "usage: $name scripts_directory" >&2
exit 1
}
output () {
echo $name $(date) $* >&2
}
if [ $# -lt 1 ] ; then
usage
fi
target_dir=$1
if ! [ -d $target_dir ] ; then
output $target_dir must exist and be a directory
usage
fi
# We specifically only want to sort *by the numbers*.
# Lexical sorting is not guaranteed, and identical numbers may be
# parallelized later
targets=$(find $target_dir -type f -executable -printf '%f\n' | grep -E "$allowed_regex" | LANG=C sort -n)
for target in $targets ; do
output "Running $target_dir/$target"
$target_dir/$target
output "$target completed"
done

View File

@ -1,8 +0,0 @@
Provide dpkg specific image building glue.
The ubuntu element needs customisations at the start and end of the image build
process that do not apply to RPM distributions, such as using the host machine
HTTP proxy when installing packages. These customisations live here, where they
can be used by any dpkg based element.
The dpkg specific version of install-packages is also kept here.

View File

@ -1,38 +0,0 @@
#!/bin/sh
# Copyright 2012 Hewlett-Packard Development Company, L.P.
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
set -e
# install-packages package [package ...]
install_deb_packages() {
DEBIAN_FRONTEND=noninteractive \
http_proxy=$http_proxy https_proxy=$https_proxy \
no_proxy=$no_proxy \
apt-get --option "Dpkg::Options::=--force-confold" --assume-yes install "$@"
}
DISTRO=`lsb_release -si`
case $DISTRO in
'Ubuntu'|'Debian')
install_deb_packages $@
;;
*)
echo "Distribution not supported"
exit 1
;;
esac

View File

@ -1,11 +0,0 @@
#!/bin/bash
set -e
[ -n "$TARGET_ROOT" ]
sudo mv $TARGET_ROOT/sbin/start-stop-daemon.REAL $TARGET_ROOT/sbin/start-stop-daemon
sudo mv $TARGET_ROOT/sbin/initctl.REAL $TARGET_ROOT/sbin/initctl
sudo mv $TARGET_ROOT/usr/sbin/invoke-rc.d.REAL $TARGET_ROOT/usr/sbin/invoke-rc.d

View File

@ -1,8 +0,0 @@
#!/bin/bash
set -e
[ -n "$TARGET_ROOT" ]
# Undo our proxy support
sudo rm -f $TARGET_ROOT/etc/apt/apt.conf.d/60img-build-proxy

View File

@ -1,9 +0,0 @@
#!/bin/sh
# Prevent apt from installing recommended packages
dd of=/etc/apt/apt.conf.d/95disable-recommends << _EOF_
APT::Install-Recommends "0";
Apt::Install-Suggests "0";
_EOF_

View File

@ -1,3 +0,0 @@
#!/bin/sh
install -m 0755 -o root -g root $(dirname $0)/../bin/* /usr/local/bin

View File

@ -1,6 +0,0 @@
#!/bin/bash
# Do an apt-get update, so that packages can be installed.
set -e
apt-get -y update

View File

@ -1,12 +0,0 @@
#!/bin/bash
set -e
[ -n "$TARGET_ROOT" ]
# If we have a network proxy, use it.
if [ -n "$http_proxy" ] ; then
sudo dd of=$TARGET_ROOT/etc/apt/apt.conf.d/60img-build-proxy << _EOF_
Acquire::http::Proxy "$http_proxy";
_EOF_
fi

View File

@ -1,13 +0,0 @@
#!/bin/bash
set -e
[ -n "$TARGET_ROOT" ]
# Configure APT not to fetch translations files
sudo dd of=$TARGET_ROOT/etc/apt/apt.conf.d/95no-translations <<EOF
APT::Acquire::Languages "none";
EOF
# And now make sure that we don't fall foul of Debian bug 641967
find $TARGET_ROOT/var/lib/apt/lists/ -type f -name '*_i18n_Translation-*' -exec sudo rm -f {} \;

View File

@ -1,30 +0,0 @@
#!/bin/bash
set -e
[ -n "$TARGET_ROOT" ]
# Prevent package installs from starting daemons
sudo mv $TARGET_ROOT/sbin/start-stop-daemon $TARGET_ROOT/sbin/start-stop-daemon.REAL
sudo dd of=$TARGET_ROOT/sbin/start-stop-daemon <<EOF
#!/bin/sh
echo
echo "Warning: Fake start-stop-daemon called, doing nothing"
EOF
sudo chmod 755 $TARGET_ROOT/sbin/start-stop-daemon
sudo mv $TARGET_ROOT/sbin/initctl $TARGET_ROOT/sbin/initctl.REAL
sudo dd of=$TARGET_ROOT/sbin/initctl <<EOF
#!/bin/sh
echo "initctl (tripleo 1.0)"
echo "Warning: Fake initctl called, doing nothing"
EOF
sudo chmod 755 $TARGET_ROOT/sbin/initctl
sudo mv $TARGET_ROOT/usr/sbin/invoke-rc.d $TARGET_ROOT/usr/sbin/invoke-rc.d.REAL
sudo dd of=$TARGET_ROOT/usr/sbin/invoke-rc.d <<EOF
#!/bin/sh
echo "invoke-rc.d (tripleo 1.0)"
echo "Warning: Fake inovke-rc.d called, doing nothing"
EOF
sudo chmod 755 $TARGET_ROOT/usr/sbin/invoke-rc.d

View File

@ -1 +0,0 @@
Use Fedora cloud images as the baseline for built disk images.

View File

@ -1,25 +0,0 @@
#!/bin/sh
# Copyright 2012 Hewlett-Packard Development Company, L.P.
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
set -e
yum -y install $(map-packages "$@")
for pkg in "$@"; do
if [[ "$pkg" == "python-pip" ]] ; then
alternatives --install /usr/bin/pip pip /usr/bin/pip-python 10
fi
done

View File

@ -1,31 +0,0 @@
#!/bin/env python
# Copyright 2012 Hewlett-Packard Development Company, L.P.
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
import sys
# Manually maintained for brevity; consider making this compiled from
# distromatch or other rich data sources.
# Debian name on the left, Fedora on the right.
package_map = {
'linux-image-generic': 'kernel',
'open-iscsi': 'iscsi-initiator-utils',
'vlan': 'vconfig',
}
for arg in sys.argv[1:]:
print(package_map.get(arg, arg))
sys.exit(0)

View File

@ -1 +0,0 @@
dib-run-parts

View File

@ -1,3 +0,0 @@
#!/bin/bash
exec install-packages redhat-lsb

View File

@ -1,3 +0,0 @@
#!/bin/sh
install -m 0755 -o root -g root $(dirname $0)/../bin/* /usr/local/bin

View File

@ -1,17 +0,0 @@
#!/bin/sh
if [ "i386" = "$ARCH" ]; then
basearch=i386
arch=i686
elif [ "amd64" = "$ARCH" ]; then
basearch=x86_64
arch=x86_64
else
echo "********************"
echo "Unknown arch '$ARCH'"
echo "********************"
exit 1
fi
echo $basearch > /etc/yum/vars/basearch
echo $arch > /etc/yum/vars/arch

View File

@ -1,13 +0,0 @@
#!/bin/bash
set -e
GRUB_CFG=/boot/grub2/grub.cfg
[ -f "$GRUB_CFG" ]
# Update the config to have the search UUID of the image being built.
# When partition staging is moved to a separate stage, this will need to happen
# there. This generates a non-UUID config, which is irrelevant for booting with
# hypervisor kernel + ramdisk, and fixed up by 51-grub for vm images.
GRUB_DISABLE_LINUX_UUID=true grub2-mkconfig -o $GRUB_CFG

View File

@ -1,45 +0,0 @@
#!/bin/bash
set -e
[ -n "$ARCH" ]
[ -n "$TARGET_ROOT" ]
if [ 'amd64' = "$ARCH" ] ; then
ARCH="x86_64"
fi
IMG_PATH=~/.cache/image-create
CLOUD_IMAGES=${CLOUD_IMAGES:-http://mattdm.fedorapeople.org/cloud-images/}
RELEASE=${RELEASE:-Fedora18}
BASE_IMAGE_FILE=${BASE_IMAGE_FILE:-$RELEASE-Cloud-$ARCH-latest.raw.tar.xz}
BASE_IMAGE_TAR=$RELEASE-Cloud-$ARCH-latest.tgz
mkdir -p $IMG_PATH
# TODO: don't cache forever.
if [ ! -f $IMG_PATH/$BASE_IMAGE_FILE ] ; then
echo "Fetching Base Image"
wget $CLOUD_IMAGES/$BASE_IMAGE_FILE -O $IMG_PATH/$BASE_IMAGE_FILE.tmp
mv $IMG_PATH/$BASE_IMAGE_FILE.tmp $IMG_PATH/$BASE_IMAGE_FILE
fi
if [ ! -f $IMG_PATH/$BASE_IMAGE_TAR ] ; then
echo "Repacking base image as tarball."
WORKING=$(mktemp -d)
EACTION="rm -r $WORKING"
trap "$EACTION" EXIT
echo "Working in $WORKING"
tar -xJC $WORKING -f $IMG_PATH/$BASE_IMAGE_FILE
LOOPDEV=$(sudo losetup --show -r -f $WORKING/*.raw)
EACTION="sudo losetup -d $LOOPDEV;$EACTION"
trap "$EACTION" EXIT
sudo partprobe $LOOPDEV
mkdir $WORKING/mnt
sudo mount ${LOOPDEV}p2 $WORKING/mnt
EACTION="sudo umount -f $WORKING/mnt;$EACTION"
trap "$EACTION" EXIT
# Chroot in so that we get the correct uid/gid
sudo chroot $WORKING/mnt bin/tar -cz . > $WORKING/tmp.tar
mv $WORKING/tmp.tar $IMG_PATH/$BASE_IMAGE_TAR
fi
# Extract the base image
sudo tar -C $TARGET_ROOT -xzf $IMG_PATH/$BASE_IMAGE_TAR

View File

@ -1,2 +0,0 @@
A hardware test ramdisk - exercises the machine RAM and exercises the hard
disks

View File

@ -1,2 +0,0 @@
spew
memtester

View File

@ -1,4 +0,0 @@
echo "Starting HW Burnin"
memtester 1G 10 # XXX: Discover RAM size
# XXX: Discover and test disks with spew

View File

@ -1,35 +0,0 @@
A ramdisk to report the hardware of a machine to an inventory service.
This will collect up some basic information about the hardware it
boots on:
* CPU cores
* RAM
* Disk
* NIC mac address
This information will then be collated into a JSON document, base64
encoded and passed, via HTTP POST, to a URL that you must specify on
the kernel commandline, thus:
HW_DISCOVERY_URL=http://1.2.3.4:56/hw_script.asp
This is currently fairly fragile as there can be a huge variability in
the number of disks/NICs in servers and how they are configured.
If other elements wish to inject data into the hardware discovery data,
they can - they should be specified before hwdiscovery to the image
building script, and they should contain something like this in their
init fragment:
_vendor_hwdiscovery_data="$_vendor_hwdiscovery_data
\"some vendor key\" : \"some data you care about\",
\"some other vendor key\" : \"some other data you care about\","
Note that you are essentially feeding JSON into the main hwdiscovery
JSON.
This will allow any number of vendor specific hwdiscovery elements to
chain together their JSON fragments and maintain consistency.

View File

@ -1,5 +0,0 @@
lshw
hwinfo
dhclient
wget
base64

View File

@ -1,63 +0,0 @@
echo "Starting HW Discovery"
function cpu_cores() {
hwinfo --cpu | grep -c "Hardware Class: cpu"
}
function ram() {
# XXX: /proc may not be the best place to get this from, but hwinfo reports weird values (e.g. "1GB + 512MB" on a test VM of mine)
_KB=$(grep MemTotal /proc/meminfo | awk '{ print $2 }')
echo "$((_KB * 1024)) bytes"
}
function pxe_mac() {
# XXX: This is making all sorts of risky assumptions. Firstly that the underlying drivers correctly report link. Secondly that only the primary
# XXX: NIC is wired up. Without a backend service on the DHCP/PXE server which could examine all of our detected MACs, there really is no good
# XXX: way to solve this in Linux.
_info1=$(hwinfo --network|grep -B2 "Link detected: yes"|grep -C1 "HW Address:")
_info2=$(echo "${_info1}"|awk '/Device File: (vlan*|br*)/{for(x=NR-2;x<=NR+2;x++)d[x];}{a[NR]=$0}END{for(i=1;i<=NR;i++)if(!(i in d))print a[i]}')
_dev=$(echo "${_info1}" | grep "Device File:"|awk -F':' {'print $2'}|tr -d ' ')
_mac=$(echo "${_info2}" | grep "HW Address:"|awk -F'ss:' {'print $2'}|tr -d ' ')
echo $_mac
export HW_DISCOVERY_BOOT_IFACE="$_mac"
}
function disk() {
# XXX: This is returning only the first disk discovered, which is very likely to be insufficient on machines that present us with multiple disks
# XXX: This is likely reporting in TB, but the units are not guaranteed. Maybe convert to bytes?
lshw -C disk | grep size | awk -F'(' '{ print $2 }' | tr -d ')' | head -1
}
function raw_disk() {
hwinfo --disk
}
function raw_network() {
hwinfo --network
}
HW_DISCOVERY_OUTPUT=$(cat <<EOF
{
"cpu cores" : "$(cpu_cores)",
"disk size" : "$(disk)",
"ram size" : "$(ram)",
"pxe mac" : "$(pxe_mac)",
"extra data" : {
"raw disk" : "$(raw_disk | base64)",
"raw network" : "$(raw_network | base64)",
$_vendor_hwdiscovery_data
}
}
EOF
)
# Print the resulting JSON for debugging purposes
echo $HW_DISCOVERY_OUTPUT
# Now submit the JSON
HW_DISCOVERY_DATA=$(echo ${HW_DISCOVERY_OUTPUT} | base64)
HW_DISCOVERY_URL=$(get_kernel_parameter HW_DISCOVERY_URL)
wget --post-data "hwdiscovery=true&hwdiscovery_data=${HW_DISCOVERY_DATA}" ${HW_DISCOVERY_URL}
sleep 30

View File

@ -1,7 +0,0 @@
#!/bin/bash
# Support for hard ware discovery
set -e
set -o xtrace
install-packages hwinfo

View File

@ -1,2 +0,0 @@
Copies local user settings such as .ssh/authorized\_keys and $http\_proxy into
the image.

View File

@ -1,11 +0,0 @@
#!/bin/bash
# Save user SSH public key if available.
# (Obviously not suitable for downloadable images).
set -e
source $_LIB/die
[ -n "$TMP_HOOKS_PATH." ] || die "Temp hook path not set"
if [ -e ~/.ssh/authorized_keys ]; then
cat ~/.ssh/authorized_keys > $TMP_HOOKS_PATH/ssh-authorized-keys
fi

View File

@ -1,40 +0,0 @@
#!/bin/bash
# Save the HTTP if one is available.
# XXX: Obviously not suitable for downloadable images.
set -e
set -o xtrace
if [ -d /etc/apt ] ; then
have_apt=1
fi
if [ -e /etc/yum.conf ] ; then
have_yum=1
fi
if [ -n "$http_proxy" ]; then
if [ -d ~stack ]; then
echo export http_proxy=$http_proxy >> ~stack/.profile
fi
if [ -n "$have_apt" ] ; then
echo "Acquire::http::Proxy \"$http_proxy\";" > /etc/apt/apt.conf.d/61-use-http-proxy
fi
if [ -n "$have_yum" ] ; then
sed -i -e "s,\[main\],[main]\nproxy=$http_proxy," /etc/yum.conf
fi
fi
if [ -n "$https_proxy" ]; then
if [ -d ~stack ]; then
echo export https_proxy=$https_proxy >> ~stack/.profile
fi
if [ -n "$have_apt" ] ; then
echo "Acquire::https::Proxy \"$https_proxy\";" > /etc/apt/apt.conf.d/61-use-https-proxy
fi
fi
if [ -n "$http_proxy" -o -n "$https_proxy" ]; then
if [ -d ~stack ]; then
echo export no_proxy=192.0.2.1 >> ~stack/.profile
fi
fi

View File

@ -1,10 +0,0 @@
#!/bin/bash
# Save user SSH public key if available.
# XXX: Obviously not suitable for downloadable images.
set -e
if [ -e "/tmp/in_target.d/ssh-authorized-keys" ]; then
mkdir -p /root/.ssh
cat /tmp/in_target.d/ssh-authorized-keys >> /root/.ssh/authorized_keys
fi

View File

@ -1 +0,0 @@
Force support for mellanox hardware

View File

@ -1,3 +0,0 @@
# extra load for mellanox
modprobe mlx4_en

View File

@ -1,6 +0,0 @@
ACTION!="add", GOTO="drivers_end"
SUBSYSTEM=="net", RUN+="/sbin/modprobe mlx4_en"
LABEL="drivers_end"

View File

@ -1 +0,0 @@
Use Ubuntu cloud images as the baseline for built disk images.

View File

@ -1,2 +0,0 @@
dpkg
dib-run-parts

View File

@ -1,27 +0,0 @@
#!/bin/bash
# These are useful, or at worst not harmful, for all images we build.
set -e
[ -n "$ARCH" ]
[ -n "$TARGET_ROOT" ]
IMG_PATH=~/.cache/image-create
CLOUD_IMAGES=${CLOUD_IMAGES:-http://cloud-images.ubuntu.com/}
RELEASE=${RELEASE:-quantal}
BASE_IMAGE_FILE=${BASE_IMAGE_FILE:-$RELEASE-server-cloudimg-$ARCH-root.tar.gz}
SHA256SUMS=${SHA256SUMS:-https://cloud-images.ubuntu.com/$RELEASE/current/SHA256SUMS}
mkdir -p $IMG_PATH
# TODO: don't cache -current forever.
if [ ! -f $IMG_PATH/$BASE_IMAGE_FILE ] ; then
echo "Fetching Base Image"
wget $SHA256SUMS -O $IMG_PATH/SHA256SUMS.ubuntu.$RELEASE.$ARCH
wget $CLOUD_IMAGES/$RELEASE/current/$BASE_IMAGE_FILE -O $IMG_PATH/$BASE_IMAGE_FILE.tmp
pushd $IMG_PATH
awk "/$BASE_IMAGE_FILE/ { print \$0 \".tmp\" }" SHA256SUMS.ubuntu.$RELEASE.$ARCH | sha256sum --check -
popd
mv $IMG_PATH/$BASE_IMAGE_FILE.tmp $IMG_PATH/$BASE_IMAGE_FILE
fi
# Extract the base image
sudo tar -C $TARGET_ROOT -xzf $IMG_PATH/$BASE_IMAGE_FILE

View File

@ -1,5 +0,0 @@
Sets up a partitioned disk (rather than building just one filesystem with no
partition table).
The disk will have grub[2]-install run on it, and that assumes a functional
grub[2] setup.

View File

@ -1,16 +0,0 @@
#!/bin/bash
set -e
source $_LIB/die
[ -n "$IMAGE_BLOCK_DEVICE" ] || die "Image block device not set"
# Create 1 partition far enough up the disk to permit grub to be installed on
# the MBR.
sudo sfdisk $IMAGE_BLOCK_DEVICE << EOF
1 - - *
0 0;
0 0;
0 0;
EOF
echo "IMAGE_BLOCK_DEVICE=${IMAGE_BLOCK_DEVICE}p1"

View File

@ -1,32 +0,0 @@
#!/bin/bash
# Configure grub. Note that the various conditionals here are to handle
# different distributions gracefully.
set -e
# XXX: grub-probe on the nbd0 device returns nothing - workaround, manually
# specify modules. https://bugs.launchpad.net/ubuntu/+source/grub2/+bug/1073731
GRUBNAME=`which grub-install` || echo "trying grub2-install"
if [ -z "$GRUBNAME" ]; then
GRUBNAME=`which grub2-install`
fi
if [ -z "$GRUBNAME" ]; then
echo "NO grub-install or grub2-install found"
exit 1
fi
BOOT_DEV=/dev/nbd0
PART_DEV=/dev/nbd0p1
$GRUBNAME --modules="biosdisk part_msdos" $BOOT_DEV
# This might be better factored out into a per-distro 'install-bootblock'
# helper.
if [ -f "/boot/grub/grub.cfg" ] ; then
GRUB_CFG=/boot/grub/grub.cfg
elif [ -f "/boot/grub2/grub.cfg" ] ; then
GRUB_CFG=/boot/grub2/grub.cfg
fi
# grub-mkconfig generates a config with the device in it,
# force use of a LABEL:
# NOTE: Updating the grub config by hand once deployed should work, its just
# prepping it in a different environment that needs fiddling.
sed -i "s%$PART_DEV%LABEL=cloudimg-rootfs%" $GRUB_CFG

View File

@ -1,130 +0,0 @@
# Copyright 2012 Hewlett-Packard Development Company, L.P.
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
function mk_build_dir () {
export TMP_BUILD_DIR=$(mktemp -t -d image.XXXXXXXX)
[ $? -eq 0 ] || die "Failed to create tmp directory"
trap cleanup EXIT
echo Building in $TMP_BUILD_DIR
export TMP_IMAGE_PATH=$TMP_BUILD_DIR/image
export TMP_HOOKS_PATH=$TMP_BUILD_DIR/hooks
}
function save_image () {
# TODO: this really should rename the old file
if [ -f $1 ] ; then
echo "Old Image file Found REMOVING"
rm -f $1
fi
cp $TMP_IMAGE_PATH $1
rm -r $TMP_BUILD_DIR
# All done!
trap EXIT
echo "Image file $1 created..."
}
function generate_hooks () {
mkdir -p $TMP_HOOKS_PATH
for _ELEMENT in $IMAGE_ELEMENT ; do
for dir in $(echo $ELEMENTS_PATH | tr ":" " ") ; do
[ -d $dir/$_ELEMENT ] || continue
cp -t $TMP_HOOKS_PATH -a $dir/$_ELEMENT/* ;
break
done
done
}
# Call the supplied break-in routine if the named point is listed in the break
# list.
# $1 the break point.
# $2.. what to call if a break is needed
function check_break () {
if echo "$break" | egrep -e "(,|^)$1(,|$)" -q; then
echo "Starting debug shell. Exit to resume building." >&2
echo At stage $1 >&2
shift
"$@"
echo "Resuming" >&2
fi
}
# Check that a real element has been chosen (prevents foot-guns)
function check_element () {
[ -d $TMP_HOOKS_PATH ] || generate_hooks
}
# Run a hook, looking for a regex in its stdout, and eval the matched lines.
# $1 is the hook to run
# $2 is the regex to look for
function eval_run_d () {
local TEMP=`run_d $1`
echo "$TEMP"
if [ `echo "$TEMP" | grep -s "$2"` ]; then
TEMP=`echo "$TEMP" | grep "$2"`
eval "$TEMP"
fi
}
# Usage: map_nbd $image
# Returns nbd device path
function map_nbd {
(lsmod | grep '^nbd ') || sudo modprobe nbd max_part=16
if [[ $(qemu-nbd --help | grep cache) == *writeback* ]] ; then
CACHE="--cache=writeback"
else
echo "Warning: qemu-nbd without --cache=writeback is /slow/."
CACHE=""
fi
NBD_DEV=
for i in `seq 0 15`; do
if [ ! -e /sys/block/nbd$i/pid ]; then
NBD_DEV=/dev/nbd$i
# Connect to nbd and wait till it is ready
sudo qemu-nbd -c $NBD_DEV $CACHE $1
if ! timeout 60 sh -c "while ! [ -e /sys/block/nbd$i/pid ]; do sleep 1; done"; then
echo "Couldn't connect $NBD_DEV"
exit 1
fi
break
fi
done
if [ -z "$NBD_DEV" ]; then
echo "No free NBD slots"
exit 1
fi
}
# Delete and unmount the working dir used in extracting kernel/initrd
function unmount_qcow_image () {
sudo umount $WORK_DIR || true
sudo qemu-nbd -d $NBD_DEV || true
sudo rm -rf $WORK_DIR
trap - SIGHUP SIGINT SIGTERM EXIT
}
function mount_qcow_image() {
trap unmount_qcow_image SIGHUP SIGINT SIGTERM EXIT
WORK_DIR=$(mktemp -d)
map_nbd $1
if [ -e "${NBD_DEV}p1" ]; then
sudo mount ${NBD_DEV}p1 $WORK_DIR
else
sudo mount ${NBD_DEV} $WORK_DIR
fi
}

24
lib/die
View File

@ -1,24 +0,0 @@
# Copyright 2012 Hewlett-Packard Development Company, L.P.
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
# Prints "message" and exits
# Usage: die "message"
function die() {
local exitcode=$?
set +o xtrace
echo $@
exit $exitcode
}

View File

@ -1,25 +0,0 @@
# Copyright 2012 Hewlett-Packard Development Company, L.P.
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
# options for create-baremetal-image.sh
export ARCH=${ARCH:-$(dpkg --print-architecture)}
FS_TYPE=${FS_TYPE:-ext4}
# Used to set the file extension only at this stage.
IMAGE_TYPE=${IMAGE_TYPE:-qcow2}
IMAGE_NAME=${IMAGE_NAME:-image}
export IMAGE_SIZE=${IMAGE_SIZE:-2} # N.B. This size is in GB
# Set via the CLI normally.
# IMAGE_ELEMENT=
export ELEMENTS_PATH=${ELEMENTS_PATH:-$(dirname $0)/../elements}

View File

@ -1,185 +0,0 @@
# Copyright 2012 Hewlett-Packard Development Company, L.P.
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
function unmount_image () {
# unmount from the chroot
# Don't use TMP_MOUNT_PATH here, it might not have been set.
sudo umount -f $TMP_BUILD_DIR/mnt/sys || true
sudo umount -f $TMP_BUILD_DIR/mnt/proc || true
sudo umount -f $TMP_BUILD_DIR/mnt/dev || true
sudo umount -f $TMP_BUILD_DIR/mnt/tmp/in_target.d || true
# give it a second (ok really 5) to umount XXX - why? should instead track
# the mount data / lsof etc.
sleep 5
# oh ya don't want to forget to unmount the image
sudo umount -f $TMP_BUILD_DIR/mnt || true
# having disk corruption issues; one possibility is qemu-nbd not flush dirty
# pages on disconnect?
sync
if [ -n "$EXTRA_UNMOUNT" ]; then
$EXTRA_UNMOUNT
fi
}
function cleanup () {
unmount_image
rm -rf $TMP_BUILD_DIR
}
function ensure_nbd () {
NBD=`which qemu-nbd` || true
if [ -z "$NBD" ]; then
echo "Need qemu-nbd to build qcow2 files."
sudo apt-get install qemu-utils
fi
# prep nbd for mounting
(lsmod | grep '^nbd ') || sudo modprobe nbd max_part=16
}
function ensure_sudo () {
sudo echo "Ensuring sudo is available"
}
function mount_tmp_image () {
mkdir $TMP_BUILD_DIR/mnt
sudo mount $@ $TMP_BUILD_DIR/mnt
[ $? -eq 0 ] || die "Failed to mount image"
export TMP_MOUNT_PATH=$TMP_BUILD_DIR/mnt
}
function create_base () {
# Copy data in to the root.
TARGET_ROOT=$TMP_MOUNT_PATH run_d root
if [ -z "$(ls $TMP_MOUNT_PATH | grep -v lost+found)" ] ; then
# Nothing copied in, use Ubuntu.
echo "Adding ubuntu element as / had no contents"
IMAGE_ELEMENT=$($SCRIPT_HOME/element-info --expand-dependencies $IMAGE_ELEMENT ubuntu)
generate_hooks
echo "Now building: $IMAGE_ELEMENT"
TARGET_ROOT=$TMP_MOUNT_PATH run_d root
fi
# Configure Image
# Setup resolv.conf so we can chroot to install some packages
# XXXX: Should store the old state rather than unlink; then restore later.
if [ -L $TMP_MOUNT_PATH/etc/resolv.conf ] ; then
sudo unlink $TMP_MOUNT_PATH/etc/resolv.conf
fi
if [ -f $TMP_MOUNT_PATH/etc/resolv.conf ] ; then
sudo rm -f $TMP_MOUNT_PATH/etc/resolv.conf
fi
# Recreate resolv.conf
sudo touch $TMP_MOUNT_PATH/etc/resolv.conf
sudo chmod 777 $TMP_MOUNT_PATH/etc/resolv.conf
# use system configured resolv.conf if available to support internal proxy resolving
if [ -e /etc/resolv.conf ]
then
cat /etc/resolv.conf > $TMP_MOUNT_PATH/etc/resolv.conf
else
echo nameserver 8.8.8.8 > $TMP_MOUNT_PATH/etc/resolv.conf
fi
# supporting kernel file systems
sudo mount -t proc none $TMP_MOUNT_PATH/proc
sudo mount --bind /dev $TMP_MOUNT_PATH/dev
sudo mount -t sysfs none $TMP_MOUNT_PATH/sys
}
# Helper function to run a command inside the chroot
function run_in_target() {
# -E to preserve http_proxy
sudo -E chroot $TMP_MOUNT_PATH "$@"
}
# Helper function to run a directory of scripts inside the chroot
function run_d_in_target() {
check_element
# If we can find a directory of hooks to run in the target filesystem, bind
# mount it into the target and then execute run-parts in a chroot
if [ -d ${TMP_HOOKS_PATH}/$1.d ] ; then
sudo mkdir $TMP_MOUNT_PATH/tmp/in_target.d
sudo mount --bind ${TMP_HOOKS_PATH} $TMP_MOUNT_PATH/tmp/in_target.d
sudo mount -o remount,ro,bind ${TMP_HOOKS_PATH} $TMP_MOUNT_PATH/tmp/in_target.d
check_break before-$1 run_in_target bash
run_in_target dib-run-parts /tmp/in_target.d/$1.d
check_break after-$1 run_in_target bash
sudo umount -f $TMP_MOUNT_PATH/tmp/in_target.d
sudo rmdir $TMP_MOUNT_PATH/tmp/in_target.d
fi
}
# Run a directory of hooks outside the target.
function run_d() {
check_element
check_break before-$1 bash
if [ -d ${TMP_HOOKS_PATH}/$1.d ] ; then
run-parts ${TMP_HOOKS_PATH}/$1.d
fi
check_break after-$1 bash
}
function prepare_first_boot () {
check_break before-first-boot run_in_target bash
if [ -d ${TMP_HOOKS_PATH}/first-boot.d ] ; then
sudo cp -t $TMP_MOUNT_PATH/etc/ -a $TMP_HOOKS_PATH/first-boot.d
run_in_target mv /etc/rc.local /etc/rc.local.REAL
sudo dd of=$TMP_MOUNT_PATH/etc/rc.local <<EOF
#!/bin/bash
set -e
set -o xtrace
touch /var/log/first-boot.d.log
chmod 0600 /var/log/first-boot.d.log
run-parts /etc/first-boot.d >> /var/log/first-boot.d.log 2>&1
rm -fr /etc/first-boot.d
mv /etc/rc.local.REAL /etc/rc.local
exit 0
EOF
run_in_target chmod 755 /etc/rc.local
fi
check_break after-first-boot run_in_target bash
}
function finalise_base () {
TARGET_ROOT=$TMP_MOUNT_PATH run_d cleanup
# Now remove the resolv.conf we created above
sudo rm -f $TMP_MOUNT_PATH/etc/resolv.conf
# The we need to recreate it as a link
sudo ln -sf ../run/resolvconf/resolv.conf $TMP_MOUNT_PATH/etc/resolv.conf
}
function compress_image () {
# Recreate our image to throw away unnecessary data
test $IMAGE_TYPE != qcow2 && COMPRESS_IMAGE=""
qemu-img convert ${COMPRESS_IMAGE:+-c} $TMP_IMAGE_PATH -O $IMAGE_TYPE $TMP_IMAGE_PATH-new
rm $TMP_IMAGE_PATH
mv $TMP_IMAGE_PATH-new $TMP_IMAGE_PATH
}
function do_extra_package_install () {
# Install any packages that were requested with the -p command line option
if [ "$INSTALL_PACKAGES" != "" ]; then
run_in_target install-packages ${INSTALL_PACKAGES[@]}
fi
}
function copy_elements_lib () {
sudo mkdir -p $TMP_MOUNT_PATH/lib/diskimage-builder
sudo cp -t $TMP_MOUNT_PATH/lib/diskimage-builder $_LIB/elements-functions
}

View File

@ -1,24 +0,0 @@
# Copyright 2012 Hewlett-Packard Development Company, L.P.
# Copyright (c) 2012 NTT DOCOMO, INC.
#
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
# options for ramdisk-image-create
KERNEL_VERSION=${KERNEL_VERSION:-$(uname -r)}
MODULE_ROOT=${MODULE_ROOT:-""}
LIB_UDEV_ROOT=${LIB_UDEV_ROOT:-""}
BUSYBOX=${BUSYBOX:-$(which busybox)}
IMAGE_NAME=${IMAGE_NAME:-"ramdisk"}
export ELEMENTS_PATH=${ELEMENTS_PATH:-$(dirname $0)/../elements}

View File

@ -1,215 +0,0 @@
# Copyright 2012 Hewlett-Packard Development Company, L.P.
# Copyright (c) 2012 NTT DOCOMO, INC.
#
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
function fullpath() {
local f=$1
if [ "${f#/}" = "$f" ]; then
echo `pwd`/"$f"
else
echo "$f"
fi
}
function cleanup () {
rm -rf "$TMP_BUILD_DIR"
}
function ensure_binaries() {
BINARY_DEPS="${BUSYBOX}"
for _FLVR in ${RAMDISK_ELEMENT} ; do
for dir in $(echo $ELEMENTS_PATH | tr ":" " ") ; do
[ -d $dir/$_FLVR ] || continue
_FILE="${dir}/${_FLVR}/binary-deps"
if [ -a $_FILE ]; then
for _LINE in $(cat $_FILE) ; do
BINARY_DEPS="${BINARY_DEPS} $_LINE"
done
fi
break
done
done
for _BIN in $BINARY_DEPS ; do
_LOCATION=$(which "$_BIN" || echo "")
if [ -z "$_LOCATION" ]; then
echo "$_BIN is not found in your PATH" 1>&2
echo "Please install it on your system"
exit 1
fi
done
export BINARY_DEPS
}
function create_base () {
echo "Creating base system"
mkdir -p "$TMP_MOUNT_PATH/bin"
ln -s bin "$TMP_MOUNT_PATH/sbin"
mkdir -p "$TMP_MOUNT_PATH/lib"
mkdir -p "$TMP_MOUNT_PATH/lib/modules"
mkdir -p "$TMP_MOUNT_PATH/etc"
mkdir -p "$TMP_MOUNT_PATH/etc/udev"
# cjk adding for discovery support
mkdir -p "$TMP_MOUNT_PATH/var/lib/dhcp"
mkdir -p "$TMP_MOUNT_PATH/var/run"
mkdir -p "$TMP_MOUNT_PATH/lib/udev/rules.d"
cp -a "$LIB_UDEV/rules.d/50-firmware.rules" "$TMP_MOUNT_PATH/lib/udev/rules.d"
cp -a "$LIB_UDEV/rules.d/80-drivers.rules" "$TMP_MOUNT_PATH/lib/udev/rules.d"
cp -a "$LIB_UDEV/firmware" "$TMP_MOUNT_PATH/lib/udev"
# cjk adding for hwdiscovery support
cp "/sbin/dhclient-script" "$TMP_MOUNT_PATH/sbin"
mkdir -p "$TMP_MOUNT_PATH/etc/modprobe.d"
echo "blacklist evbug" > "$TMP_MOUNT_PATH/etc/modprobe.d/blacklist.conf"
# cjk adding for hwdiscovery support
touch "$TMP_MOUNT_PATH/etc/fstab"
mkdir -p "$TMP_MOUNT_PATH/etc/udev"
cat >"$TMP_MOUNT_PATH/etc/udev/udev.conf" <<EOF
udev_root="/dev"
udev_rules="/lib/udev/rules.d"
udev_log="no"
EOF
}
function copy_required_libs() {
ldd_out=`ldd "$1"`
if [ $? -ne 0 ]; then
return
fi
local IFS="
"
# Patterns of output of ldd
#
# 1. name to real path
# libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f095e784000)
# 2. only path
# /lib64/ld-linux-x86-64.so.2 (0x00007f095ef79000)
# 3. path to path
# /lib64/ld-linux-x86-64.so.2 => /lib/x86_64-linux-gnu/ld-linux-x86-64.so.2 (0x00007facff857000)
# 4. name to empty (vdso)
# linux-vdso.so.1 => (0x00007fff0c5ff000)
for i in `echo "$ldd_out" | sed -e 's/^\t*//'`; do
local ref=$( echo "$i" | awk -F '[ ]' '{print $1}')
local real=$( echo "$i" | awk -F '[ ]' '$2 == "=>" {print $3}
$2 != "=>" {print $1}')
if [ -z "$real" ]; then
continue
fi
if [ "$ref" = "${ref#/}" ]; then
ref=/lib/$ref
fi
dest=/lib/`basename "$real"`
cp -Ln "$real" "$TMP_MOUNT_PATH/$dest"
# Create a symbolic link if the shared library is referred
# by the different name
if [ "$ref" != "$dest" ]; then
local link_path=$TMP_MOUNT_PATH/$ref
if ! [ -e "$link_path" -o -L "$link_path" ]; then
mkdir -p `dirname "$link_path"`
ln -s "$dest" "$link_path"
fi
fi
done
}
function populate_lib () {
echo "Populating /lib"
for i in "$BUSYBOX" "$LIB_UDEV/firmware" bash lsmod modprobe udevd udevadm wget reboot shutdown $BINARY_DEPS ; do
if "$BUSYBOX" --list | grep "^$i\$" >/dev/null; then
continue
fi
path=`which $i 2>/dev/null` || path=$i
if ! [ -x "$path" ]; then
echo "$i is not found in PATH" 2>&1
exit 1
fi
cp -L "$path" "$TMP_MOUNT_PATH/bin/"
copy_required_libs "$path"
done
cp -a "$MODULE_DIR" "$TMP_MOUNT_PATH/lib/modules/$KERNEL_VERSION"
cp -a "$FIRMWARE_DIR" "$TMP_MOUNT_PATH/lib/firmware"
}
function populate_busybox () {
echo "Creating symlinks for busybox binaries"
for i in $( "$BUSYBOX" --list ); do
if [ -f "$TMP_MOUNT_PATH/bin/$i" ]; then
echo "skip $i"
continue
fi
ln -s busybox "$TMP_MOUNT_PATH/bin/$i"
done
}
function populate_init () {
echo "Installing init"
cp "$INIT" "$TMP_MOUNT_PATH/init"
chmod +x $TMP_MOUNT_PATH/init
for F in "$FUNCTIONS_D"/* ; do
cp "$F" "$TMP_MOUNT_PATH"
done
# Append /init with any element fragments that are present
for _FLVR in ${RAMDISK_ELEMENT} ; do
for dir in $(echo $ELEMENTS_PATH | tr ":" " ") ; do
[ -d $dir/$_FLVR ] || continue
_FILE="${dir}/${_FLVR}/init"
if [ -a $_FILE ]; then
cat >>$TMP_MOUNT_PATH/init <<EOF
# init fragment from ${_FLVR}
EOF
cat <$_FILE >>$TMP_MOUNT_PATH/init
fi
break
done
done
# Add our final steps to /init
cat <${INIT}-end >>$TMP_MOUNT_PATH/init
}
function finalise_image () {
echo "Finalising image"
(cd "$TMP_MOUNT_PATH"; find . | cpio -o -H newc | gzip > "$TMP_IMAGE_PATH" )
}
function populate_udev () {
echo "Installing udev rules"
for _FLVR in ${RAMDISK_ELEMENT} ; do
for dir in $(echo $ELEMENTS_PATH | tr ":" " ") ; do
[ -d $dir/$_FLVR ] || continue
_DIR="${dir}/${_FLVR}/udev"
if [ -d $_DIR ]; then
find $_DIR -type f -exec cp -v {} $TMP_MOUNT_PATH/lib/udev/rules.d/ \;
fi
break
done
done
}

View File

@ -1,191 +0,0 @@
# Copyright (c) 2012 NTT DOCOMO, INC.
# Copyright 2012 Hewlett-Packard Development Company, L.P.
#
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
function get_kernel_parameter() {
local name=$1
for i in `cat /proc/cmdline`; do
case "$i" in
${name}=*)
echo "${i#${name}=}"
return 0
;;
${name})
echo ""
return 0
;;
*)
;;
esac
done
echo ""
return 1
}
function string_contains() {
local string=$1
local word=$2
if [ "$string" != "${string/$word/}" ]; then
return 0
else
return 1
fi
}
function load_modules_by_udev() {
depmod
udevadm trigger --action=add
udevadm settle
}
function strip_dev() {
echo "$1" | sed -e 's:^/dev/::'
}
function prepend_dev() {
case "$1" in
/dev/*)
echo "$1"
;;
*)
echo "/dev/$1"
;;
esac
}
function whole_disk_name() {
local dev=`prepend_dev "$1"`
case "$dev" in
/dev/sd*|/dev/hd*|/dev/vd*)
echo "$dev" | sed -e 's/[0-9]*$//'
;;
/dev/cciss/*)
echo "$dev" | sed -e 's/p[0-9]*$//'
;;
*)
echo ""
return 1
;;
esac
}
function partition_name() {
local dev=`prepend_dev "$1"`
local part=$2
case "$dev" in
/dev/sd*|/dev/hd*|/dev/vd*)
echo "${dev}${part}"
;;
/dev/cciss/*)
echo "${dev}p${part}"
;;
*)
echo ""
return 1
;;
esac
}
function find_interface() {
local mac=$1
eth=`ifconfig -a | grep -i "$mac" | awk {' print $1 '} | head -n 1`
if [ -n "$eth" ]; then
echo "$eth"
return 0
else
return 1
fi
}
function set_mac() {
local dev=$1
local mac=$2
ip link set "$dev" address "$mac"
}
function swap_ifname() {
local dev=$1
local dev2=$2
if [ "$dev" = "$dev2" ]; then
return
fi
if ip link show "$dev2" >/dev/null; then
# dev2 exists
# swap device name
ip link set "$dev" name "_$dev"
ip link set "$dev2" name "$dev"
ip link set "_$dev" name "$dev2"
else
ip link set "$dev" name "$dev2"
fi
}
function partition_exists() {
local dev=$1
dev=`strip_dev "$dev"`
if tail -n +3 /proc/partitions | grep "$dev" >/dev/null; then
return 0
else
return 1
fi
}
function find_disk() {
local disks=$1
local dev
# find device
local OLD_IFS=$IFS
IFS=,
for i in $disks; do
dev=`whole_disk_name "$i"`
if partition_exists "$dev"; then
dev=`prepend_dev "$dev"`
break
fi
dev=""
done
IFS=$OLD_IFS
if [ -z "$dev" ]; then
return 1
fi
echo "$dev"
return 0
}
function start_iscsi_target() {
local iqn=$1
local dev=$2
local cli=$3
# used by tgtd
mkdir -p /var/run
tgtd
tgtadm --lld iscsi --mode target --op new --tid 1 --targetname "$iqn"
tgtadm --lld iscsi --mode logicalunit --op new --tid 1 --lun 1 --backing-store "$dev"
tgtadm --lld iscsi --mode target --op bind --tid 1 --initiator-address "$cli"
}
function stop_iscsi_target() {
tgtadm --lld iscsi --mode logicalunit --op delete --tid 1 --lun 1
tgtadm --lld iscsi --mode target --op delete --tid 1
killall tgtd
}

View File

@ -1,129 +0,0 @@
#!/bin/bash
# Copyright (c) 2012 NTT DOCOMO, INC.
# Copyright 2012 Hewlett-Packard Development Company, L.P.
#
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
echo "init"
source /init-func
PATH=/sbin:/bin:/usr/bin:/usr/sbin
export PATH
mkdir -p /proc
mkdir -p /sys
mkdir -p /dev
mkdir -p /boot
mkdir -p /etc
mkdir -p /mnt
mkdir -p /lib/modules
mount -t proc proc /proc
readonly _BOOTIF_=$(get_kernel_parameter BOOTIF)
readonly _IP_=$(get_kernel_parameter ip)
readonly BOOT_MAC_ADDRESS=$(echo "$_BOOTIF_" | sed -e "s/-/:/g" | sed -e "s/^01://g" | tr 'a-f' 'A-F')
readonly BOOT_IP_ADDRESS=$(echo "$_IP_" | cut -d':' -f1)
readonly BOOT_SERVER=$(echo "$_IP_" | cut -d':' -f2)
readonly BOOT_NETMASK=$(echo "$_IP_" | cut -d':' -f4)
readonly BOOT_GATEWAY=$(echo "$_IP_" | cut -d':' -f3)
readonly DISK=$(get_kernel_parameter disk)
readonly DEPLOYMENT_ID=$(get_kernel_parameter deployment_id)
readonly DEPLOYMENT_KEY=$(get_kernel_parameter deployment_key)
readonly ISCSI_TARGET_IQN=$(get_kernel_parameter iscsi_target_iqn)
mount -t sysfs none /sys
mount -t tmpfs none /dev
ln -sf /proc/self/fd /dev/fd
mknod /dev/null c 1 3
mknod /dev/zero c 1 5
mknod /dev/random c 1 8
mknod /dev/urandom c 1 9
mknod /dev/tty0 c 4 0
mknod /dev/tty1 c 4 1
mknod /dev/tty2 c 4 2
mknod /dev/tty3 c 4 3
mknod /dev/tty4 c 4 4
mknod /dev/tty5 c 4 5
mknod /dev/tty6 c 4 6
mknod /dev/tty7 c 4 7
mknod /dev/tty8 c 4 8
mknod /dev/tty9 c 4 9
mknod /dev/tty c 5 0
mknod -m 0600 /dev/console c 5 1
mknod -m 0666 /dev/ptmx c 5 2
mkdir -p /dev/.udev
mkdir -p /dev/.udev/data
echo "starting syslogd"
echo '*.* /initlog' > /etc/syslog.conf
syslogd
klogd
echo "starting udevd"
udevd --daemon --resolve-names=never
echo "load modules"
load_modules_by_udev
echo "starting network $BOOT_MAC_ADDRESS"
t=0
while ! BOOT_INTERFACE=$(find_interface "$BOOT_MAC_ADDRESS"); do
t=`expr "$t" + 5`
if [ "$t" -gt 10 ]; then
break
fi
sleep 5
done
if [ -z "$BOOT_INTERFACE" ]; then
echo "could not find an interface owns MAC=$BOOT_MAC_ADDRESS"
echo "Starting troubleshooting shell."
bash
fi
readonly BOOT_INTERFACE
ifconfig lo 127.0.0.1 up
ifconfig "$BOOT_INTERFACE" up
if [ $? -ne 0 ]; then
sleep 10
ifconfig "$BOOT_INTERFACE" up
if [ $? -ne 0 ]; then
echo "Failed to up $BOOT_INTERFACE"
echo "Starting troubleshooting shell."
bash
fi
fi
ifconfig "$BOOT_INTERFACE" "$BOOT_IP_ADDRESS" netmask "$BOOT_NETMASK"
route add default gw $BOOT_GATEWAY
echo "pinging to boot server $BOOT_SERVER"
w=30
while [ $w -gt 0 ]; do
ping -c 5 -q "$BOOT_SERVER" > /dev/null
if [ $? -eq 0 ]; then
break
fi
sleep 1
w=`expr $w - 5`
done
echo "network ready"

View File

@ -1,11 +0,0 @@
# Final init steps
echo "rebooting"
reboot -f
echo "failed to reboot"
echo "Starting troubleshooting shell."
bash

View File

@ -19,22 +19,22 @@ with open("README.md", 'rt') as readme:
readme_text = readme.read()
setuptools.setup(
name='diskimage_builder',
name='tripleo_image_elements',
version='0.0.1',
description="""Build Disk Images for use on OpenStack Nova""",
description="""Disk image elements for deploying OpenStack.""",
long_description=readme_text,
license='Apache License (2.0)',
author='HP Cloud Services',
author_email='nobody@hp.com',
url='https://github.com/stackforge/diskimage-builder',
url='https://github.com/stackforge/tripleo-image-elements',
packages=setuptools.find_packages(),
include_package_data=True,
classifiers=[
'Development Status :: 3 - Alpha',
'License :: OSI Approved :: Apache Software License',
'Operating System :: POSIX :: Linux',
'Programming Language :: Python :: 2.7',
'Programming Language :: Other',
'Environment :: Console',
],
scripts=['bin/element-info'],
scripts=[],
py_modules=[])

View File

@ -1,50 +0,0 @@
# Copyright 2012 Hewlett-Packard Development Company, L.P.
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
ALL ALL=(root) NOPASSWD: /bin/chmod * /tmp/*/mnt/*
ALL ALL=(root) NOPASSWD: /bin/dd of=/tmp/*/mnt/*
ALL ALL=(root) NOPASSWD: /bin/ln -sf * /tmp/*/mnt/*
ALL ALL=(root) NOPASSWD: /bin/mkdir -p /tmp/*/mnt/*
ALL ALL=(root) NOPASSWD: /bin/mkdir /tmp/*/mnt/*
ALL ALL=(root) NOPASSWD: /bin/mount --bind /dev /tmp/*/mnt/dev
ALL ALL=(root) NOPASSWD: /bin/mount --bind /tmp/*/hooks /tmp/*/mnt/tmp/in_target.d
ALL ALL=(root) NOPASSWD: /bin/mount -o remount\,ro\,bind /tmp/*/hooks /tmp/*/mnt/tmp/in_target.d
ALL ALL=(root) NOPASSWD: /bin/mount -t proc none /tmp/*/mnt/proc
ALL ALL=(root) NOPASSWD: /bin/mount -t sysfs none /tmp/*/mnt/sys
ALL ALL=(root) NOPASSWD: /bin/mount /dev/nbd0* /tmp/*/mnt
ALL ALL=(root) NOPASSWD: /bin/mount /dev/loop*p* /tmp/*/mnt
ALL ALL=(root) NOPASSWD: /bin/mv /tmp/*/mnt/* /tmp/*/mnt/*
ALL ALL=(root) NOPASSWD: /bin/rm -* /tmp/*/mnt/*
ALL ALL=(root) NOPASSWD: /bin/rmdir /tmp/*/mnt/*
ALL ALL=(root) NOPASSWD: /bin/tar -C /tmp/*/mnt -xzf /*/.cache/image-create/*
ALL ALL=(root) NOPASSWD: /bin/umount -f /tmp/*/mnt
ALL ALL=(root) NOPASSWD: /bin/umount -f /tmp/*/mnt/dev
ALL ALL=(root) NOPASSWD: /bin/umount -f /tmp/*/mnt/proc
ALL ALL=(root) NOPASSWD: /bin/umount -f /tmp/*/mnt/sys
ALL ALL=(root) NOPASSWD: /bin/umount -f /tmp/*/mnt/tmp/in_target.d
ALL ALL=(root) NOPASSWD: /sbin/mkfs -F -t ext4 -L cloudimg-rootfs /dev/nbd0*
ALL ALL=(root) NOPASSWD: /sbin/modprobe nbd max_part=16
ALL ALL=(root) NOPASSWD: /sbin/sfdisk /dev/nbd0
ALL ALL=(root) NOPASSWD: /usr/bin/qemu-nbd -c /dev/nbd0 --cache=writeback /tmp/*/image
ALL ALL=(root) NOPASSWD: /usr/bin/qemu-nbd -d /dev/nbd0
ALL ALL=(root) NOPASSWD: /usr/bin/touch /tmp/*/mnt/*
ALL ALL=(root) NOPASSWD: /usr/bin/unlink /tmp/*/mnt/*
ALL ALL=(root) NOPASSWD: /bin/cp -t /tmp/*/mnt/etc/ -a /tmp/*/hooks/first-boot.d
ALL ALL=(root) NOPASSWD: /usr/bin/install -m 0755 -o root -g root -D */dib-run-parts /tmp/*/mnt/usr/local/bin/dib-run-parts
ALL ALL=(root) SETENV: NOPASSWD: /usr/sbin/chroot /tmp/*/mnt *
ALL ALL=(root) NOPASSWD: /sbin/losetup --show -r -f /tmp/*/*.raw
ALL ALL=(root) NOPASSWD: /sbin/losetup -d /dev/loop*
ALL ALL=(root) NOPASSWD: /sbin/losetup -d /dev/loop*
ALL ALL=(root) NOPASSWD: /sbin/partprobe /dev/loop*

View File

@ -35,7 +35,7 @@ commands =
commands = {posargs}
[testenv:cover]
setenv = PYTHON=coverage run --source diskimage_builder
setenv = PYTHON=coverage run --source tripleo_image_elements
commands = bash -c 'if [ ! -d ./.testrepository ] ; then testr init ; fi'
bash -c 'testr run --parallel ; RET=$? ; coverage combine ; coverage html -d ./cover $OMIT && exit $RET'