Created shared elements functions lib.

Share functions needed by all elements in a common lib.
install_packages can be used lately to support other non-debian based distributions.

Change-Id: I9fa0b833c34a614fe498c6c6ae599733a69c1309
This commit is contained in:
Ghe Rivero
2013-01-28 06:41:54 +01:00
parent 15a1ad0b5b
commit 96b5eb679b
25 changed files with 90 additions and 26 deletions

View File

@@ -58,6 +58,7 @@ for arg do IMAGE_ELEMENT="$IMAGE_ELEMENT $arg" ; done
source $_LIB/img-defaults
source $_LIB/common-functions
source $_LIB/img-functions
source $_LIB/elements-functions
IMAGE_ELEMENT=$($SCRIPT_HOME/element-info --expand-dependencies $IMAGE_ELEMENT)
@@ -92,6 +93,7 @@ sudo mkfs -F -t $FS_TYPE -L cloudimg-rootfs ${IMAGE_BLOCK_DEVICE}
mount_tmp_image ${IMAGE_BLOCK_DEVICE}
create_base
copy_elements_lib
run_d extra-data
do_pre_install
do_extra_package_install

View File

@@ -3,4 +3,6 @@
set -e
apt-get -y install linux-image-generic vlan open-iscsi
source /lib/diskimage-builder/elements-functions
install_packages linux-image-generic vlan open-iscsi

View File

@@ -3,6 +3,8 @@
set -e
source /lib/diskimage-builder/elements-functions
apt-get -y update
apt-get -y install python-software-properties language-pack-en
install_packages python-software-properties language-pack-en
add-apt-repository -y ppa:tripleo/demo

View File

@@ -6,7 +6,9 @@
set -e
set -o xtrace
apt-get -y install git
source /lib/diskimage-builder/elements-functions
install_packages git
if [ -n "$http_proxy" ]; then
sudo -Hiu stack git config --global http.proxy $http_proxy
fi

View File

@@ -4,7 +4,9 @@
set -e
set -o xtrace
apt-get -y install git
source /lib/diskimage-builder/elements-functions
install_packages git
if [ -n "$http_proxy" ]; then
sudo -Hiu stack git config --global http.proxy $http_proxy
fi

View File

@@ -4,4 +4,6 @@
set -e
set -o xtrace
apt-get -y install haveged
source /lib/diskimage-builder/elements-functions
install_packages haveged

View File

@@ -5,7 +5,9 @@
set -e
set -o xtrace
DEBIAN_FRONTEND=noninteractive apt-get -y install \
source /lib/diskimage-builder/elements-functions
install_packages
python-pip git-core python-setuptools python-dev python-lxml python-netaddr \
python-pastescript python-pastedeploy python-paste python-sqlalchemy \
python-greenlet python-routes python-simplejson python-webob rabbitmq-server
@@ -30,4 +32,3 @@ cp $GLANCE_ROOT/etc/glance-api.conf /etc/glance
cp $GLANCE_ROOT/etc/policy.json /etc/glance
cp $GLANCE_ROOT/etc/glance-api-paste.ini /etc/glance
cp $GLANCE_ROOT/etc/logging.cnf.sample /etc/glance/logging.conf

View File

@@ -2,6 +2,8 @@
set -uex
source /lib/diskimage-builder/elements-functions
CFN_TOOLS_ROOT=/opt/aws/bin # Heat hard codes this
HEAT_API_SOURCE=https://github.com/heat-api/heat-jeos.git
@@ -9,7 +11,7 @@ HEAT_API_SOURCE=https://github.com/heat-api/heat-jeos.git
OS_ROOT=/opt/stack
JEOS_ROOT=$OS_ROOT/heat-jeos
DEBIAN_FRONTEND=noninteractive apt-get -y install git-core python-psutil
install_packages git-core python-psutil
mkdir -p $OS_ROOT
git clone $HEAT_API_SOURCE $JEOS_ROOT

View File

@@ -4,6 +4,8 @@
set -uex
source /lib/diskimage-builder/elements-functions
# Setup ec2-user as expected by HEAT
if ! getent passwd ec2-user ; then
useradd -m -G admin ec2-user -s /bin/bash
@@ -23,4 +25,4 @@ Pin: release o=LP-PPA-tripleo-demo
Pin-Priority: 900
EOF
# Should pull from demo PPA if cloud-init exists there.
apt-get -y install cloud-init
install_packages cloud-init

View File

@@ -4,4 +4,5 @@
set -e
set -o xtrace
apt-get -y install hwinfo
source /lib/diskimage-builder/elements-functions
install_packages hwinfo

View File

@@ -5,4 +5,5 @@
set -e
set -o xtrace
DEBIAN_FRONTEND=noninteractive apt-get -y install icinga-core
source /lib/diskimage-builder/elements-functions
install_packages icinga-core

View File

@@ -5,5 +5,6 @@
set -e
set -o xtrace
DEBIAN_FRONTEND=noninteractive apt-get -y install icinga-web icinga-cgi
source /lib/diskimage-builder/elements-functions
install_packages icinga-web icinga-cgi

View File

@@ -3,7 +3,9 @@
set -e
set -o xtrace
apt-get -y install jenkins
source /lib/diskimage-builder/elements-functions
install_packages jenkins
# jenkins installs into /var/lib/jenkins which is rather restrictive.
mv /var/lib/jenkins /mnt/

View File

@@ -5,7 +5,9 @@
set -e
set -o xtrace
DEBIAN_FRONTEND=noninteractive apt-get -y install \
source /lib/diskimage-builder/elements-functions
install_packages \
python-pip git-core python-setuptools python-dev python-lxml python-netaddr \
python-pastescript python-pastedeploy python-paste python-sqlalchemy \
python-greenlet python-routes python-simplejson python-webob

View File

@@ -5,5 +5,6 @@
set -e
set -o xtrace
source /lib/diskimage-builder/elements-functions
#DEBIAN_FRONTEND=noninteractive apt-get -y install sysstat mytop percona-toolkit percona-server-server-5.5 percona-server-client-5.5
DEBIAN_FRONTEND=noninteractive apt-get -y install sysstat mytop percona-toolkit mysql-server-5.5 mysql-client-5.5
install_packages sysstat mytop percona-toolkit mysql-server-5.5 mysql-client-5.5

View File

@@ -4,4 +4,5 @@
set -e
set -o xtrace
apt-get -y install haveged
source /lib/diskimage-builder/elements-functions
install_packages haveged

View File

@@ -1,9 +1,11 @@
#!/bin/sh
set -eux
source /lib/diskimage-builder/elements-functions
useradd -G admin -m nova -s /bin/false
DEBIAN_FRONTEND=noninteractive apt-get -y install \
install_packages \
python-pip git-core python-setuptools python-dev python-lxml python-netaddr \
python-pastescript python-pastedeploy python-paste python-sqlalchemy \
python-greenlet python-routes python-simplejson python-webob rabbitmq-server

View File

@@ -5,4 +5,5 @@
set -e
set -o xtrace
DEBIAN_FRONTEND=noninteractive apt-get -y install haproxy rabbitmq-server mysql-server ntp dkms
source /lib/diskimage-builder/elements-functions
install_packages haproxy rabbitmq-server mysql-server ntp dkms

View File

@@ -5,5 +5,6 @@
set -e
set -o xtrace
apt-get -y install keystone glance nova-api nova-cert nova-common nova-scheduler python-nova python-novaclient nova-consoleauth novnc nova-novncproxy cinder-api cinder-scheduler cinder-volume iscsitarget open-iscsi iscsitarget-dkms python-cinderclient nova-network
source /lib/diskimage-builder/elements-functions
install_packages keystone glance nova-api nova-cert nova-common nova-scheduler python-nova python-novaclient nova-consoleauth novnc nova-novncproxy cinder-api cinder-scheduler cinder-volume iscsitarget open-iscsi iscsitarget-dkms python-cinderclient nova-network

View File

@@ -2,9 +2,11 @@
set -e
set -o xtrace
source /lib/diskimage-builder/elements-functions
useradd -G admin -m quantum -s /bin/false
DEBIAN_FRONTEND=noninteractive apt-get -y install \
install_packages \
python-pip git-core python-setuptools python-dev python-lxml python-netaddr \
python-pastescript python-pastedeploy python-paste python-sqlalchemy \
python-greenlet python-routes python-simplejson python-webob rabbitmq-server

View File

@@ -1,7 +1,8 @@
#!/bin/bash
B#!/bin/bash
set -e
set -o xtrace
apt-get -y install salt-master
source /lib/diskimage-builder/elements-functions
install_packages salt-master

View File

@@ -3,5 +3,6 @@
set -e
set -o xtrace
apt-get -y install salt-minion
source /lib/diskimage-builder/elements-functions
install_packages salt-minion

View File

@@ -5,5 +5,6 @@
set -e
set -o xtrace
apt-get -y install swift rsync memcached python-netifaces python-xattr python-memcache
source /lib/diskimage-builder/elements-functions
install_packages swift rsync memcached python-netifaces python-xattr python-memcache

24
lib/elements-functions Normal file
View File

@@ -0,0 +1,24 @@
# 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 ...]
function install_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 "$@"
}

View File

@@ -42,7 +42,7 @@ 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
sudo install_packages qemu-utils
fi
# prep nbd for mounting
(lsmod | grep '^nbd ') || sudo modprobe nbd max_part=16
@@ -235,6 +235,11 @@ function do_install () {
function do_extra_package_install () {
# Install any packages that were requested with the -p command line option
if [ "$INSTALL_PACKAGES" != "" ]; then
run_in_target apt-get -y install ${INSTALL_PACKAGES[@]}
run_in_target install_packages ${INSTALL_PACKAGES[@]}
fi
}
function copy_elements_lib () {
sudo mkdir -p $TMP_MOUNT_PATH/lib/diskimage-builder
sudo cp $_LIB/elements-functions $TMP_MOUNT_PATH/lib/diskimage-builder
}