summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--build/jhenv_template/centos/rhel7/Dockerfile54
-rw-r--r--build/jhenv_template/ubuntu/trusty/Dockerfile52
-rw-r--r--build/jhenv_template/ubuntu/xenial/Dockerfile52
-rwxr-xr-xbuild/make_repo.sh55
-rwxr-xr-xdeploy/prepare.sh186
5 files changed, 373 insertions, 26 deletions
diff --git a/build/jhenv_template/centos/rhel7/Dockerfile b/build/jhenv_template/centos/rhel7/Dockerfile
new file mode 100644
index 00000000..a47360aa
--- /dev/null
+++ b/build/jhenv_template/centos/rhel7/Dockerfile
@@ -0,0 +1,54 @@
+FROM centos:7.1.1503
+MAINTAINER Yifei Xue <xueyifei@huawei.com>
+
+ADD ./cp_env.sh /cp_env.sh
+
+#RUN yum provides '*/applydeltarpm' -y
+
+#RUN yum install deltarpm -y
+
+RUN yum remove -y systemd
+
+RUN yum update -y
+
+RUN yum install yum-plugin-downloadonly
+
+RUN mkdir -p /rpm
+
+RUN yum install -y epel-release-7-8
+
+RUN yum groupinstall -y --downloadonly --downloaddir=/rpm 'Development Tools'
+
+RUN yum install -y --downloadonly --downloaddir=/rpm epel-release mkisofs bc curl ipmitool \
+git python-pip python-devel figlet \
+libxslt-devel libxml2-devel libvirt-devel \
+qemu qemu-kvm qemu-img virt-manager libvirt libvirt-python libvirt-client virt-install virt-viewer \
+guestfish libguestfs-tools virt-top mysql-devel \
+openssl-devel libffi libffi-devel python-cffi
+
+RUN yum install -y epel-release mkisofs bc curl ipmitool \
+git python-pip python-devel figlet \
+libxslt-devel libxml2-devel libvirt-devel \
+qemu qemu-kvm qemu-img virt-manager libvirt libvirt-python libvirt-client virt-install virt-viewer \
+guestfish libguestfs-tools virt-top mysql-devel \
+openssl-devel libffi libffi-devel python-cffi
+
+RUN yum install -y python-pip
+
+RUN yum install -y tar
+
+RUN tar -zcvf env_rel7_rpm.tar.gz /rpm
+
+RUN mkdir -p /home/pip
+
+RUN pip install --upgrade markupsafe virtualenv netaddr pbr oslo.config Cheetah ansible -d /home/pip/
+
+RUN tar -zcvf env_rel7_pip.tar.gz /home/pip
+
+RUN mkdir -p /home/tmp
+
+RUN cp *.tar.gz /home/tmp
+
+RUN chmod +x /cp_env.sh
+
+CMD ["/cp_env.sh"]
diff --git a/build/jhenv_template/ubuntu/trusty/Dockerfile b/build/jhenv_template/ubuntu/trusty/Dockerfile
new file mode 100644
index 00000000..83f488d2
--- /dev/null
+++ b/build/jhenv_template/ubuntu/trusty/Dockerfile
@@ -0,0 +1,52 @@
+FROM ubuntu:14.04.3
+MAINTAINER Yifei Xue <xueyifei@huawei.com>
+
+ADD ./cp_env.sh /cp_env.sh
+
+RUN apt-get update
+
+RUN apt-get install -y wget
+
+RUN apt-get install -y -d mkisofs bc curl ipmitool openvswitch-switch \
+git python-pip python-dev figlet \
+libxslt-dev libxml2-dev libvirt-dev \
+build-essential qemu-utils qemu-kvm libvirt-bin \
+virtinst libmysqld-dev \
+libssl-dev libffi-dev python-cffi
+
+RUN wget -P /var/cache/apt/archives/ http://launchpadlibrarian.net/225838998/libffi6_3.1~rc1+r3.0.13-12ubuntu0.1_amd64.deb
+
+RUN mkdir jh_deb
+
+RUN cp /var/cache/apt/archives/*.deb jh_deb/
+
+RUN apt-get install -y reprepro
+
+RUN mkdir -p trusty-jh-ppa/conf
+
+RUN echo 'Codename: trusty\n\
+Components: main\n\
+Architectures: amd64\n'\
+>> trusty-jh-ppa/conf/distributions
+
+RUN reprepro -b trusty-jh-ppa includedeb trusty jh_deb/*.deb
+
+RUN tar -zcvf /trusty-jh-ppa.tar.gz ./trusty-jh-ppa
+
+RUN apt-get install -y python-pip
+
+RUN mkdir jh_pip
+
+RUN pip install --upgrade paramiko jinja2 PyYAML setuptools pycrypto pyasn1 \
+cryptography MarkupSafe idna six enum34 ipaddress cffi pycparser \
+virtualenv cheetah requests netaddr pbr oslo.config ansible -d jh_pip/
+
+RUN tar -zcvf env_trusty_pip.tar.gz jh_pip/
+
+RUN mkdir -p /home/tmp
+
+RUN cp *.tar.gz /home/tmp
+
+RUN chmod +x /cp_env.sh
+
+CMD ["/cp_env.sh"]
diff --git a/build/jhenv_template/ubuntu/xenial/Dockerfile b/build/jhenv_template/ubuntu/xenial/Dockerfile
new file mode 100644
index 00000000..01462ee0
--- /dev/null
+++ b/build/jhenv_template/ubuntu/xenial/Dockerfile
@@ -0,0 +1,52 @@
+FROM ubuntu:16.04.3
+MAINTAINER Yifei Xue <xueyifei@huawei.com>
+
+ADD ./cp_env.sh /cp_env.sh
+
+RUN apt-get update
+
+RUN apt-get install -y wget
+
+RUN apt-get install -y -d mkisofs bc curl ipmitool openvswitch-switch \
+git python-pip python-dev figlet \
+libxslt-dev libxml2-dev libvirt-dev \
+build-essential qemu-utils qemu-kvm libvirt-bin \
+virtinst libmysqld-dev \
+libssl-dev libffi-dev python-cffi
+
+#RUN wget -P /var/cache/apt/archives/ http://launchpadlibrarian.net/225838998/libffi6_3.1~rc1+r3.0.13-12ubuntu0.1_amd64.deb
+
+RUN mkdir jh_deb
+
+RUN cp /var/cache/apt/archives/*.deb jh_deb/
+
+RUN apt-get install -y reprepro
+
+RUN mkdir -p xenial-jh-ppa/conf
+
+RUN echo 'Codename: xenial\n\
+Components: main\n\
+Architectures: amd64\n'\
+>> xenial-jh-ppa/conf/distributions
+
+RUN reprepro -b xenial-jh-ppa includedeb xenial jh_deb/*.deb
+
+RUN tar -zcvf /xenial-jh-ppa.tar.gz ./xenial-jh-ppa
+
+RUN apt-get install -y python-pip
+
+RUN mkdir jh_pip
+
+RUN pip install --upgrade paramiko jinja2 PyYAML setuptools pycrypto pyasn1 \
+cryptography MarkupSafe idna six enum34 ipaddress cffi pycparser \
+virtualenv cheetah requests netaddr pbr oslo.config ansible -d jh_pip/
+
+RUN tar -zcvf env_xenial_pip.tar.gz jh_pip/
+
+RUN mkdir -p /home/tmp
+
+RUN cp *.tar.gz /home/tmp
+
+RUN chmod +x /cp_env.sh
+
+CMD ["/cp_exenial]
diff --git a/build/make_repo.sh b/build/make_repo.sh
index f38da7ff..f186c46c 100755
--- a/build/make_repo.sh
+++ b/build/make_repo.sh
@@ -33,6 +33,7 @@ set -ex
cp /*.tar.gz /result -f
EOF
+ sudo apt-get -f install
sudo apt-get install python-yaml -y
sudo apt-get install python-cheetah -y
}
@@ -42,7 +43,7 @@ function make_repo()
rm -f ${WORK_PATH}/work/repo/install_packages.sh
rm -f ${WORK_PATH}/work/repo/Dockerfile
- option=`echo "os-ver:,package-tag:,tmpl:,default-package:, \
+ option=`echo "os-ver:,jh-os:,package-tag:,tmpl:,default-package:, \
special-package:,special-package-script-dir:, \
special-package-dir:,ansible-dir:,special-package-dir" | sed 's/ //g'`
@@ -53,6 +54,7 @@ function make_repo()
eval set -- "$TEMP"
os_ver=""
+ jh_os=""
package_tag=""
tmpl=""
default_package=""
@@ -64,6 +66,7 @@ function make_repo()
while :; do
case "$1" in
--os-ver) os_ver=$2; shift 2;;
+ --jh-os) jh_os=$2; shift 2;;
--package-tag) package_tag=$2; shift 2;;
--tmpl) tmpl=$2; shift 2;;
--default-package) default_package=$2; shift 2;;
@@ -81,6 +84,11 @@ function make_repo()
return
fi
+ if [[ -n ${package_tag} && ${package_tag} == "jhenv" && -n ${jh_os} ]]; then
+ make_jhenv_repo
+ return
+ fi
+
if [[ -z ${os_ver} || -z ${package_tag} ]]; then
echo "parameter is wrong"
exit 1
@@ -267,8 +275,53 @@ function make_pip_repo()
cd $WORK_PATH/work/repo; tar -zcvf pip.tar.gz ./pip; cd -
}
+function make_jhenv_repo()
+{
+ if [[ ${jh_os} == trusty ]]; then
+ env_os_name=ubuntu
+ fi
+
+ if [[ ${jh_os} == xenial ]]; then
+ env_os_name=ubuntu
+ fi
+
+ if [[ ${jh_os} =~ rhel[0-9]*$ ]]; then
+ env_os_name=centos
+ fi
+
+ if [[ -d ${WORK_PATH}/build/jhenv_template/$env_os_name ]]; then
+
+ jh_env_dockerfile=Dockerfile
+ jh_env_docker_tmpl=${BUILD_PATH}/jhenv_template/$env_os_name/$jh_os/${jh_env_dockerfile}".tmpl"
+ jh_env_docker_tag="$jh_os/env"
+
+ rm -rf ${WORK_PATH}/work/repo/jhenv_template
+ mkdir ${WORK_PATH}/work/repo/jhenv_template
+ cp -rf ${WORK_PATH}/build/jhenv_template/$env_os_name/$jh_os/${jh_env_dockerfile} ${WORK_PATH}/work/repo/jhenv_template
+
+cat <<EOF >${WORK_PATH}/work/repo/jhenv_template/cp_env.sh
+#!/bin/bash
+set -ex
+cp /*.tar.gz /env -f
+EOF
+
+ sudo docker build --no-cache=true -t ${jh_env_docker_tag} -f ${WORK_PATH}/work/repo/jhenv_template/${jh_env_dockerfile} ${WORK_PATH}/work/repo/jhenv_template
+ sudo docker run -t -v ${WORK_PATH}/work/repo:/env ${jh_env_docker_tag}
+
+ image_id=$(sudo docker images|grep ${jh_env_docker_tag}|awk '{print $3}')
+
+ sudo docker rmi -f ${image_id}
+
+# cd $WORK_PATH/work/repo; tar -zcvf pip.tar.gz ./pip; cd -
+ fi
+}
+
function make_all_repo()
{
+ for env_os in trusty xanial rhel7; do
+ make_repo --package-tag jhenv --jh-os $env_os
+ done
+
make_repo --package-tag pip
make_repo --os-ver rhel7 --package-tag compass \
diff --git a/deploy/prepare.sh b/deploy/prepare.sh
index 22183f49..4ce78184 100755
--- a/deploy/prepare.sh
+++ b/deploy/prepare.sh
@@ -9,11 +9,11 @@
##############################################################################
function print_logo()
{
- if ! apt --installed list 2>/dev/null | grep "figlet"
- then
- sudo apt-get update -y
- sudo apt-get install -y --force-yes figlet
- fi
+# if ! apt --installed list 2>/dev/null | grep "figlet"
+# then
+# sudo apt-get update -y
+# sudo apt-get install -y --force-yes figlet
+# fi
figlet -ctf slant Compass Installer
set +x; sleep 2; set -x
@@ -72,26 +72,162 @@ function _prepare_python_env() {
mkdir -p $WORK_DIR/venv
if [[ "$DEPLOY_FIRST_TIME" == "true" ]]; then
- sudo apt-get update -y
- sudo apt-get install -y --force-yes mkisofs bc curl ipmitool openvswitch-switch
- sudo apt-get install -y --force-yes git python-dev python-pip
- sudo apt-get install -y --force-yes libxslt-dev libxml2-dev libvirt-dev build-essential qemu-utils qemu-kvm libvirt-bin virtinst libmysqld-dev
- sudo apt-get install -y --force-yes libffi-dev libssl-dev
- fi
-
- sudo pip install --upgrade virtualenv
- virtualenv $WORK_DIR/venv
- source $WORK_DIR/venv/bin/activate
-
- pip install --upgrade cffi
- pip install --upgrade MarkupSafe
- pip install --upgrade pip
- pip install --upgrade cheetah
- pip install --upgrade pyyaml
- pip install --upgrade requests
- pip install --upgrade netaddr
- pip install --upgrade oslo.config
- pip install --upgrade ansible
+
+ if [[ ! -z "$JHPKG_URL" ]]; then
+ _pre_env_setup
+ else
+ sudo apt-get update -y
+ sudo apt-get install -y --force-yes mkisofs bc curl ipmitool openvswitch-switch
+ sudo apt-get install -y --force-yes git python-dev python-pip figlet
+ sudo apt-get install -y --force-yes libxslt-dev libxml2-dev libvirt-dev build-essential qemu-utils qemu-kvm libvirt-bin virtinst libmysqld-dev
+ sudo apt-get install -y --force-yes libffi-dev libssl-dev
+
+ fi
+ else
+ if [[ ! -z "$JHPKG_URL" ]]; then
+ _pre_pip_setup
+ else
+ sudo pip install --upgrade virtualenv
+ virtualenv $WORK_DIR/venv
+ source $WORK_DIR/venv/bin/activate
+
+ pip install --upgrade cffi
+ pip install --upgrade MarkupSafe
+ pip install --upgrade pip
+ pip install --upgrade cheetah
+ pip install --upgrade pyyaml
+ pip install --upgrade requests
+ pip install --upgrade netaddr
+ pip install --upgrade oslo.config
+ pip install --upgrade ansible
+ fi
+ fi
+}
+
+function _pre_env_setup()
+{
+ rm -rf $WORK_DIR/prepare
+ mkdir -p $WORK_DIR/prepare
+ jhpkg_url=${JHPKG_URL:7}
+ echo $jhpkg_url
+ if [[ ! -f "$jhpkg_url" ]]; then
+ echo "There is no jh_env_package."
+ exit 1
+ fi
+
+ tar -zxvf $jhpkg_url -C $WORK_DIR/prepare/
+ cd $WORK_DIR/prepare/jh_env_package
+ tar -zxvf trusty-jh-ppa.tar.gz
+
+ if [[ -f /etc/apt/apt.conf ]]; then
+ mv /etc/apt/apt.conf /etc/apt/apt.conf.bak
+ fi
+
+ cat << EOF > /etc/apt/apt.conf
+APT::Get::Assume-Yes "true";
+APT::Get::force-yes "true";
+Acquire::http::Proxy::127.0.0.1:9998 DIRECT;
+EOF
+
+ if [[ -f /etc/apt/sources.list ]]; then
+ mv /etc/apt/sources.list /etc/apt/sources.list.bak
+ fi
+
+ cat << EOF > /etc/apt/sources.list
+deb [arch=amd64] http://127.0.0.1:9998/trusty-jh-ppa trusty main
+EOF
+
+ nohup python -m SimpleHTTPServer 9998 &
+
+ cd -
+ sleep 5
+ apt-get update
+ apt-get install -y mkisofs bc curl ipmitool openvswitch-switch \
+ git python-pip python-dev figlet \
+ libxslt-dev libxml2-dev libvirt-dev \
+ build-essential qemu-utils qemu-kvm libvirt-bin \
+ virtinst libmysqld-dev \
+ libssl-dev libffi-dev python-cffi
+ pid=$(ps -ef | grep SimpleHTTPServer | grep 9998 | awk '{print $2}')
+ echo $pid
+ kill -9 $pid
+
+ sudo cp ${COMPASS_DIR}/deploy/qemu_hook.sh /etc/libvirt/hooks/qemu
+
+ rm -rf /etc/apt/sources.list
+ if [[ -f /etc/apt/sources.list.bak ]]; then
+ mv /etc/apt/sources.list.bak /etc/apt/sources.list
+ fi
+
+ rm -rf /etc/apt/apt.conf
+ if [[ -f /etc/apt/apt.conf.bak ]]; then
+ mv /etc/apt/apt.conf.bak /etc/apt/apt.conf
+ fi
+}
+
+function _pre_pip_setup()
+{
+ if [[ -d ~/.pip ]]; then
+ if [[ -f ~/.pip/pip.conf ]]; then
+ mv ~/.pip/pip.conf ~/.pip/pip.conf.bak
+ fi
+ else
+ mkdir -p ~/.pip
+ fi
+
+# rm -rf ~/.pip
+# mkdir -p ~/.pip
+ rm -rf $WORK_DIR/prepare
+ mkdir -p $WORK_DIR/prepare
+ jhpkg_url=${JHPKG_URL:7}
+ echo $jhpkg_url
+ if [[ ! -f "$jhpkg_url" ]]; then
+ echo "There is no jh_env_package."
+ exit 1
+ fi
+
+ tar -zxvf $jhpkg_url -C $WORK_DIR/prepare/
+ cd $WORK_DIR/prepare/jh_env_package
+ tar -zxvf env_trusty_pip.tar.gz
+
+ cat << EOF > ~/.pip/pip.conf
+[global]
+find-links = http://127.0.0.1:9999/jh_pip
+no-index = true
+[install]
+trusted-host=127.0.0.1
+EOF
+
+ nohup python -m SimpleHTTPServer 9999 &
+
+ sleep 5
+
+ cd -
+
+ pip install --upgrade virtualenv
+
+ virtualenv $WORK_DIR/venv
+ source $WORK_DIR/venv/bin/activate
+
+ #pip install --upgrade cffi
+
+ PIP="cffi MarkupSafe pip cheetah pyyaml requests netaddr oslo.config ansible"
+
+ #PIP="paramiko jinja2 PyYAML setuptools pycrypto pyasn1 cryptography MarkupSafe idna six enum34 ipaddress pycparser virtualenv cheetah requests netaddr pbr oslo.config ansible"
+ for i in ${PIP}; do
+ pip install --upgrade $i
+ done
+
+ pid=$(ps -ef | grep SimpleHTTPServer | grep 9999 | awk '{print $2}')
+ echo $pid
+ kill -9 $pid
+
+ if [[ -f ~/.pip/pip.conf.bak ]]; then
+ mv ~/.pip/pip.conf.bak ~/.pip/pip.conf
+ else
+ rm -rf ~/.pip/pip.conf
+ fi
+# rm -rf ~/.pip/pip.conf
}
function prepare_python_env()