aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--build/gen_ins_pkg_script.py14
-rwxr-xr-xbuild/make_repo.sh67
-rw-r--r--build/os/centos/rhel6/compass/Dockerfile.tmpl5
-rw-r--r--build/os/centos/rhel7/juno/Dockerfile.tmpl5
-rw-r--r--build/os/ubuntu/trusty/juno/Dockerfile.tmpl5
-rw-r--r--build/os/ubuntu/trusty/kilo/Dockerfile.tmpl5
-rw-r--r--build/templates/RedHat_juno.tmpl2
-rw-r--r--deploy/adapters/ansible/roles/ha/templates/haproxy.cfg2
-rwxr-xr-xdeploy/network.sh74
9 files changed, 122 insertions, 57 deletions
diff --git a/build/gen_ins_pkg_script.py b/build/gen_ins_pkg_script.py
index 0f756d07..c3c55cfc 100644
--- a/build/gen_ins_pkg_script.py
+++ b/build/gen_ins_pkg_script.py
@@ -34,7 +34,8 @@ def get_packages_name_list(file_list, special_packages):
return package_name_list
-def generate_download_script(root, arch, tmpl, docker_tmpl, default_packages, special_packages, special_packages_dir):
+def generate_download_script(root="", arch="", tmpl="", docker_tmpl="", default_packages="",
+ special_packages="", special_packages_script_dir="", special_packages_dir=""):
package_name_list = get_packages_name_list(get_file_list(root, arch), special_packages) if root else []
tmpl = Template(file=tmpl, searchList={'packages':package_name_list, 'default_packages':default_packages})
@@ -44,12 +45,15 @@ def generate_download_script(root, arch, tmpl, docker_tmpl, default_packages, sp
make_script = []
for i in special_packages:
name = 'make_' + i + '.sh'
- if os.path.exists(os.path.join('.', arch, name)):
+ if os.path.exists(os.path.join(special_packages_script_dir, name)):
make_script.append(name)
- searchList = {'dir':os.path.join('.', arch), 'scripts':make_script}
+ searchList = {'scripts':make_script}
if os.path.exists(special_packages_dir):
- special_packages_names = [i for i in os.listdir(special_packages_dir) if os.path.isfile(i)]
+ special_packages_names=[]
+ for i in os.listdir(special_packages_dir):
+ if os.path.isfile(os.path.join(special_packages_dir, i)):
+ special_packages_names.append(i)
searchList.update({'spcial_packages':special_packages_names})
Dockerfile=os.path.basename(docker_tmpl).split('.')[0]
@@ -60,5 +64,5 @@ def generate_download_script(root, arch, tmpl, docker_tmpl, default_packages, sp
if __name__=='__main__':
# generate_download_script('ansible', 'Debian', 'Debian.tmpl')
generate_download_script(sys.argv[1], sys.argv[2], sys.argv[3], sys.argv[4],
- sys.argv[5].split(' '), sys.argv[6].split(' '), sys.argv[7])
+ sys.argv[5].split(' '), sys.argv[6].split(' '), sys.argv[7], sys.argv[8])
diff --git a/build/make_repo.sh b/build/make_repo.sh
index 8ef3c448..6d5faab7 100755
--- a/build/make_repo.sh
+++ b/build/make_repo.sh
@@ -32,7 +32,11 @@ function make_repo()
rm -f ${WORK_PATH}/work/repo/install_packages.sh
rm -f ${WORK_PATH}/work/repo/Dockerfile
- TEMP=`getopt -o h -l os-ver:,package-tag:,tmpl:,default-package:,special-package:,ansible-dir: -n 'make_repo.sh' -- "$@"`
+ option=`echo "os-ver:,package-tag:,tmpl:,default-package:, \
+ special-package:,special-package-script-dir:, \
+ special-package-dir:,ansible-dir:,special-package-dir" | sed 's/ //g'`
+
+ TEMP=`getopt -o h -l $option -n 'make_repo.sh' -- "$@"`
if [ $? != 0 ] ; then echo "Terminating..." >&2 ; exit 1 ; fi
@@ -43,6 +47,7 @@ function make_repo()
tmpl=""
default_package=""
special_package=""
+ special_package_script_dir=""
special_package_dir=""
ansible_dir=""
while :; do
@@ -52,19 +57,20 @@ function make_repo()
--tmpl) tmpl=$2; shift 2;;
--default-package) default_package=$2; shift 2;;
--special-package) special_package=$2; shift 2;;
+ --special-package-script-dir) special_package_script_dir=$2; shift 2;;
--special-package-dir) special_package_dir=$2; shift 2;;
--ansible-dir) ansible_dir=$2; shift 2;;
--) shift; break;;
- *) echo "Internal error!" ; exit 1 ;;
+ *) echo "Internal error! $1" ; exit 1 ;;
esac
done
- if [[ ! -z ${package_tag} && ${package_tag} == "pip" ]]; then
+ if [[ -n ${package_tag} && ${package_tag} == "pip" ]]; then
make_pip_repo
return
fi
- if [[ -z ${os_ver} || -z ${tmpl} || -z ${package_tag} ]]; then
+ if [[ -z ${os_ver} || -z ${package_tag} ]]; then
echo "parameter is wrong"
exit 1
fi
@@ -79,25 +85,50 @@ function make_repo()
os_name=centos
fi
+ if [[ -z $arch ]]; then
+ echo "unsupported ${os_ver} os"
+ exit 1
+ fi
+
dockerfile=Dockerfile
docker_tmpl=${BUILD_PATH}/os/${os_name}/${os_ver}/${package_tag}/${dockerfile}".tmpl"
docker_tag="${os_ver}/${package_tag}"
- python ${BUILD_PATH}/gen_ins_pkg_script.py "${ansible_dir}" "${arch}" "${BUILD_PATH}/templates/${tmpl}" \
- "${docker_tmpl}" "${default_package}" "${special_package}" "${special_package_dir}"
+ if [[ -z ${tmpl} ]]; then
+ tmpl=${BUILD_PATH}/templates/${arch}_${package_tag}.tmpl
+ fi
+
+ python ${BUILD_PATH}/gen_ins_pkg_script.py "${ansible_dir}" "${arch}" "${tmpl}" \
+ "${docker_tmpl}" "${default_package}" "${special_package}" \
+ "${WORK_PATH}/work/repo/$arch/script/" \
+ "${WORK_PATH}/work/repo/$arch/packages/"
+
+ rm -rf ${WORK_PATH}/work/repo/$arch
+ mkdir -p ${WORK_PATH}/work/repo/$arch/{script,packages}
+
+ # copy default package script to wokr dir
+ if [[ -d ${WORK_PATH}/build/arch/$arch ]]; then
+ cp -rf ${WORK_PATH}/build/arch/$arch/* ${WORK_PATH}/work/repo/$arch/script/
+ fi
+
+ # copy make package script to work dir
+ if [[ -n $special_package_script_dir && -d $special_package_script_dir ]]; then
+ cp -rf $special_package_script_dir/* ${WORK_PATH}/work/repo/$arch/script/
+ fi
- # copy make package script to work/repo dir
- if [[ -n $arch && -d ${WORK_PATH}/build/templates/$arch ]]; then
- rm -rf ${WORK_PATH}/work/repo/$arch
- cp -rf ${WORK_PATH}/build/templates/$arch ${WORK_PATH}/work/repo/
+ # copy special package to work dir
+ if [[ -n $special_package_dir && -d $special_package_dir ]]; then
+ cp -rf $special_package_dir/* ${WORK_PATH}/work/repo/$arch/packages/
fi
+ # copy docker file to work dir
if [[ -n $os_ver && -d ${WORK_PATH}/build/os/$os_name/$os_ver ]]; then
rm -rf ${WORK_PATH}/work/repo/$os_ver
cp -rf ${WORK_PATH}/build/os/$os_name/$os_ver ${WORK_PATH}/work/repo
fi
- if [[ -f ${WORK_PATH}/build/os/$os_name/comps.xml ]]; then
+ # copy centos comps.xml to work dir
+ if [[ $arch == RedHat && -f ${WORK_PATH}/build/os/$os_name/comps.xml ]]; then
cp -rf ${WORK_PATH}/build/os/$os_name/comps.xml ${WORK_PATH}/work/repo
fi
@@ -127,29 +158,25 @@ function make_pip_repo()
function make_all_repo()
{
- make_pip_repo
+ make_repo --package-tag pip
make_repo --os-ver rhel6 --package-tag compass \
- --tmpl compass_core.tmpl \
+ --tmpl "${WORK_PATH}/build/templates/compass_core.tmpl" \
--default-package "epel-release python-yaml python-jinja2 python-paramiko"
make_repo --os-ver trusty --package-tag juno \
--ansible-dir $WORK_PATH/deploy/adapters/ansible \
- --tmpl Debian_juno.tmpl \
--default-package "openssh-server" \
- --special-package "openvswitch-datapath-dkms openvswitch-switch"
+ --special-package "openvswitch-datapath-dkms openvswitch-switch" \
make_repo --os-ver trusty --package-tag kilo \
--ansible-dir $WORK_PATH/deploy/adapters/ansible \
- --tmpl Debian_kilo.tmpl \
--default-package "openssh-server" \
- --special-package "openvswitch-datapath-dkms openvswitch-switch"
+ --special-package "openvswitch-datapath-dkms openvswitch-switch" \
make_repo --os-ver rhel7 --package-tag juno \
--ansible-dir $WORK_PATH/deploy/adapters/ansible \
- --tmpl RedHat_juno.tmpl \
- --default-package "rsyslog strace net-tools wget vim openssh-server dracut-config-rescue dracut-network" \
- --special-package ""
+ --default-package "rsyslog strace net-tools wget vim openssh-server dracut-config-rescue dracut-network"
}
function main()
diff --git a/build/os/centos/rhel6/compass/Dockerfile.tmpl b/build/os/centos/rhel6/compass/Dockerfile.tmpl
index 6740dc41..29c05426 100644
--- a/build/os/centos/rhel6/compass/Dockerfile.tmpl
+++ b/build/os/centos/rhel6/compass/Dockerfile.tmpl
@@ -11,12 +11,11 @@ RUN yum update -y
RUN sed -i 's/keepcache=0/keepcache=1/g' /etc/yum.conf
#set packages = $getVar('spcial_packages', [])
#for package in $packages
-ADD $packages /var/cache/yum/x86_64/7/base/packages/
+ADD ./RedHat/packages/$package /var/cache/yum/x86_64/6/base/packages/
#end for
#set scripts = $getVar('scripts', [])
-#set dir = $getVar('dir', ".")
#for script in $scripts
-ADD $dir/$script /tmp/chigang/$script
+ADD ./RedHat/script/$script /tmp/chigang/$script
RUN chmod +x /tmp/chigang/$script
RUN /tmp/chigang/$script
#end for
diff --git a/build/os/centos/rhel7/juno/Dockerfile.tmpl b/build/os/centos/rhel7/juno/Dockerfile.tmpl
index df5f41b4..d0d45ae4 100644
--- a/build/os/centos/rhel7/juno/Dockerfile.tmpl
+++ b/build/os/centos/rhel7/juno/Dockerfile.tmpl
@@ -8,12 +8,11 @@ MAINTAINER Chigang(Justin) <chigang@huawei.com>
RUN sed -i 's/keepcache=0/keepcache=1/g' /etc/yum.conf
#set packages = $getVar('spcial_packages', [])
#for package in $packages
-ADD $packages /var/cache/yum/x86_64/7/base/packages/
+ADD ./RedHat/packages/$package /var/cache/yum/x86_64/7/base/packages/
#end for
#set scripts = $getVar('scripts', [])
-#set dir = $getVar('dir', ".")
#for script in $scripts
-ADD $dir/$script /tmp/chigang/$script
+ADD ./RedHat/script/$script /tmp/chigang/$script
RUN chmod +x /tmp/chigang/$script
RUN /tmp/chigang/$script
#end for
diff --git a/build/os/ubuntu/trusty/juno/Dockerfile.tmpl b/build/os/ubuntu/trusty/juno/Dockerfile.tmpl
index 944fb154..d723b6e7 100644
--- a/build/os/ubuntu/trusty/juno/Dockerfile.tmpl
+++ b/build/os/ubuntu/trusty/juno/Dockerfile.tmpl
@@ -9,12 +9,11 @@ RUN sed -i 's/archive.ubuntu.com/mirrors.163.com/g' /etc/apt/sources.list
RUN rm -f /etc/apt/apt.conf.d/docker-clean
#set packages = $getVar('spcial_packages', [])
#for package in $packages
-ADD $packages /var/cache/apt/archives/
+ADD ./Debian/packages/$package /var/cache/apt/archives/
#end for
#set scripts = $getVar('scripts', [])
-#set dir = $getVar('dir', ".")
#for script in $scripts
-ADD $dir/$script /tmp/chigang/$script
+ADD ./Debian/script/$script /tmp/chigang/$script
RUN chmod +x /tmp/chigang/$script
RUN /tmp/chigang/$script
#end for
diff --git a/build/os/ubuntu/trusty/kilo/Dockerfile.tmpl b/build/os/ubuntu/trusty/kilo/Dockerfile.tmpl
index 944fb154..d723b6e7 100644
--- a/build/os/ubuntu/trusty/kilo/Dockerfile.tmpl
+++ b/build/os/ubuntu/trusty/kilo/Dockerfile.tmpl
@@ -9,12 +9,11 @@ RUN sed -i 's/archive.ubuntu.com/mirrors.163.com/g' /etc/apt/sources.list
RUN rm -f /etc/apt/apt.conf.d/docker-clean
#set packages = $getVar('spcial_packages', [])
#for package in $packages
-ADD $packages /var/cache/apt/archives/
+ADD ./Debian/packages/$package /var/cache/apt/archives/
#end for
#set scripts = $getVar('scripts', [])
-#set dir = $getVar('dir', ".")
#for script in $scripts
-ADD $dir/$script /tmp/chigang/$script
+ADD ./Debian/script/$script /tmp/chigang/$script
RUN chmod +x /tmp/chigang/$script
RUN /tmp/chigang/$script
#end for
diff --git a/build/templates/RedHat_juno.tmpl b/build/templates/RedHat_juno.tmpl
index 1f6873bb..9741b860 100644
--- a/build/templates/RedHat_juno.tmpl
+++ b/build/templates/RedHat_juno.tmpl
@@ -7,7 +7,7 @@ wget -O /etc/yum.repos.d/CentOS7-Base-163.repo http://mirrors.163.com/.help/Cen
yum remove wget iptables-services -y
rm -f /etc/yum.repos.d/CentOS-*.repo
yum repolist
-yum cleanall
+yum clean all
# add openstack juno repo
yum install yum-plugin-priorities -y
yum install http://dl.fedoraproject.org/pub/epel/7/x86_64/e/epel-release-7-5.noarch.rpm -y
diff --git a/deploy/adapters/ansible/roles/ha/templates/haproxy.cfg b/deploy/adapters/ansible/roles/ha/templates/haproxy.cfg
index 4b20db03..169182da 100644
--- a/deploy/adapters/ansible/roles/ha/templates/haproxy.cfg
+++ b/deploy/adapters/ansible/roles/ha/templates/haproxy.cfg
@@ -6,7 +6,7 @@ global
group haproxy
maxconn 4000
pidfile /var/run/haproxy/haproxy.pid
- #log 127.0.0.1 local0
+ log 127.0.0.1 local0
tune.bufsize 1000000
stats socket /var/run/haproxy.sock
stats timeout 2m
diff --git a/deploy/network.sh b/deploy/network.sh
index 864ec011..a5344f58 100755
--- a/deploy/network.sh
+++ b/deploy/network.sh
@@ -8,27 +8,61 @@ function destroy_bridge()
{
bridge=$1
nic=$2
- ips=$(ip addr show $bridge | grep 'inet ' | awk -F' ' '{print $2}')
- routes=$(ip route show | grep $bridge)
+ install_gw="$3"
+
+ brige_info=$(ip addr show $bridge 2>/dev/null)
+ if [[ -z $brige_info ]]; then
+ return
+ fi
+ ips=`echo "$brige_info" | grep 'inet ' | grep -v $install_gw | sed "s/inet //g"`
+
+ routes=$(ip route show | grep $bridge | grep -v $install_gw)
ip link set $bridge down
brctl delbr $bridge
- for ip in $ips; do
- ip addr add $ip dev $nic
- done
+ if [[ -n $ips ]]; then
+ echo "$ips" | while read line; do
+ echo $line | sed "s/$bridge/dev $nic/g" | xargs ip addr add | true
+ done
+ fi
- echo "$routes" | while read line; do
- echo $line | sed "s/$bridge/$nic/g" | xargs ip route add | true
+ if [[ -n $routes ]]; then
+ echo "$routes" | while read line; do
+ echo $line | sed "s/$bridge/$nic/g" | xargs ip route add | true
+ done
+ fi
+}
+
+function get_broadcast_addr()
+{
+ ip=(${1//[!0-9]/ })
+ mask=(${2//[!0-9]/ })
+
+ for i in {0..3}; do
+ num=$((${ip[$i]} | $((${mask[$i]} ^ 255))))
+ if [[ -z $broadcast ]]; then
+ broadcast="$num"
+ else
+ broadcast="$broadcast.$num"
+ fi
done
+ echo ${broadcast}
+}
+
+function get_mask_len()
+{
+ mask=`echo $1 | awk -F'.' '{print ($1*(2^24)+$2*(2^16)+$3*(2^8)+$4)}'`
+ mask_len=`echo "obase=2;${mask}"|bc|awk -F'0' '{print length($1)}'`
+ echo $mask_len
}
function create_bridge()
{
bridge=$1
nic=$2
- ips=$(ip addr show $nic | grep 'inet ' | awk -F' ' '{print $2}')
+ ips=$(ip addr show $nic | grep 'inet ' | sed "s/inet //g")
routes=$(ip route show | grep $nic)
ip addr flush $nic
@@ -37,21 +71,25 @@ function create_bridge()
brctl addif $bridge $nic
ip link set $bridge up
- for ip in $ips; do
- ip addr add $ip dev $bridge
- done
+ if [[ -n $ips ]]; then
+ echo "$ips" | while read line; do
+ echo $line | sed -e "s/$nic/dev $bridge/g" | xargs ip addr add
+ done
+ fi
- mask=`echo $INSTALL_MASK | awk -F'.' '{print ($1*(2^24)+$2*(2^16)+$3*(2^8)+$4)}'`
- mask_len=`echo "obase=2;${mask}"|bc|awk -F'0' '{print length($1)}'`
- ip addr add $INSTALL_GW/$mask_len dev $bridge
+ mask_len=`get_mask_len $INSTALL_MASK`
+ broadcast=`get_broadcast_addr $INSTALL_GW $INSTALL_MASK`
+ ip addr add $INSTALL_GW/$mask_len brd $broadcast dev $bridge
- echo "$routes" | while read line; do
- echo $line | sed "s/$nic/$bridge/g" | xargs ip route add | true
- done
+ if [[ -n $routes ]]; then
+ echo "$routes" | while read line; do
+ echo $line | sed "s/$nic/$bridge/g" | xargs ip route add | true
+ done
+ fi
}
function setup_om_bridge() {
- destroy_bridge br_install $OM_NIC
+ destroy_bridge br_install $OM_NIC $INSTALL_GW
create_bridge br_install $OM_NIC
}