diff options
-rwxr-xr-x | build.sh | 13 | ||||
-rw-r--r-- | build/build.conf | 1 | ||||
-rwxr-xr-x | build/make_repo.sh | 16 | ||||
-rw-r--r-- | build/os/ubuntu/xenial/newton/Dockerfile.tmpl | 26 | ||||
-rw-r--r-- | build/templates/Debian_xenial_newton.tmpl | 76 | ||||
-rwxr-xr-x | deploy/deploy_parameter.sh | 9 | ||||
-rwxr-xr-x | deploy/launch.sh | 3 | ||||
-rw-r--r-- | util/check_valid.py | 96 |
8 files changed, 229 insertions, 11 deletions
@@ -78,10 +78,11 @@ function download_local() function download_packages() { - for i in $CENTOS_BASE $COMPASS_CORE $COMPASS_WEB $COMPASS_INSTALL $TRUSTY_JUNO_PPA $TRUSTY_LIBERTY_PPA $TRUSTY_MITAKA_PPA \ - $XENIAL_MITAKA_PPA $UBUNTU_ISO $UBUNTU_ISO1 $CENTOS_ISO $CENTOS7_JUNO_PPA $CENTOS7_KILO_PPA $CENTOS7_LIBERTY_PPA \ - $CENTOS7_MITAKA_PPA $LOADERS $CIRROS $APP_PACKAGE $COMPASS_PKG \ - $PIP_REPO $ANSIBLE_MODULE; do + for i in $CENTOS_BASE $COMPASS_CORE $COMPASS_WEB $COMPASS_INSTALL \ + $TRUSTY_JUNO_PPA $TRUSTY_LIBERTY_PPA $TRUSTY_MITAKA_PPA $XENIAL_MITAKA_PPA $XENIAL_NEWTON_PPA \ + $UBUNTU_ISO $UBUNTU_ISO1 \ + $CENTOS_ISO $CENTOS7_JUNO_PPA $CENTOS7_KILO_PPA $CENTOS7_LIBERTY_PPA $CENTOS7_MITAKA_PPA \ + $LOADERS $CIRROS $APP_PACKAGE $COMPASS_PKG $PIP_REPO $ANSIBLE_MODULE; do if [[ ! $i ]]; then continue @@ -133,6 +134,10 @@ function copy_file() cp $CACHE_DIR/`basename $XENIAL_MITAKA_PPA` $new/repos/cobbler/ubuntu/ppa/ -rf fi + if [[ $XENIAL_NEWTON_PPA ]]; then + cp $CACHE_DIR/`basename $XENIAL_NEWTON_PPA` $new/repos/cobbler/ubuntu/ppa/ -rf + fi + if [[ $CENTOS_ISO ]]; then cp $CACHE_DIR/`basename $CENTOS_ISO` $new/repos/cobbler/centos/iso/ -rf fi diff --git a/build/build.conf b/build/build.conf index c6e0f7a1..b3568f4f 100644 --- a/build/build.conf +++ b/build/build.conf @@ -26,6 +26,7 @@ export UBUNTU_ISO1=${UBUNTU_ISO1:-$PACKAGE_URL/ubuntu-14.04.3-server-amd64.iso} export TRUSTY_LIBERTY_PPA=${TRUSTY_LIBERTY_PPA:-$PACKAGE_URL/trusty-liberty-ppa.tar.gz} export TRUSTY_MITAKA_PPA=${TRUSTY_MITAKA_PPA:-$PACKAGE_URL/trusty-mitaka-ppa.tar.gz} export XENIAL_MITAKA_PPA=${XENIAL_MITAKA_PPA:-$PACKAGE_URL/xenial-mitaka-ppa.tar.gz} +export XENIAL_NEWTON_PPA=${XENIAL_NEWTON_PPA:-$PACKAGE_URL/xenial-newton-ppa.tar.gz} #export CENTOS7_JUNO_PPA=${CENTOS7_JUNO_PPA:-$PACKAGE_URL/centos7-juno-ppa.tar.gz} #export CENTOS7_KILO_PPA=${CENTOS7_KILO_PPA:-$PACKAGE_URL/centos7-kilo-ppa.tar.gz} export CENTOS7_LIBERTY_PPA=${CENTOS7_LIBERTY_PPA:-$PACKAGE_URL/centos7-liberty-ppa.tar.gz} diff --git a/build/make_repo.sh b/build/make_repo.sh index f186c46c..7c327c97 100755 --- a/build/make_repo.sh +++ b/build/make_repo.sh @@ -130,7 +130,7 @@ function make_repo() echo "${ansible_dir}" cp -rf ${ansible_dir}/roles/ ${WORK_PATH}/work/tmp/ if [[ ${os_ver} == xenial ]]; then - if [[ -d ${ansible_dir}/openstack_${package_tag}/roles && "`ls ${ansible_dir}/openstack_${package_tag}`" != "" ]]; then + if [[ -d ${ansible_dir}/openstack_${package_tag}_${os_ver}/roles && "`ls ${ansible_dir}/openstack_${package_tag}_${os_ver}`" != "" ]]; then cp -rf ${ansible_dir}/openstack_${package_tag}_${os_ver}/roles/* ${WORK_PATH}/work/tmp/roles/ fi else @@ -318,9 +318,11 @@ EOF function make_all_repo() { - for env_os in trusty xanial rhel7; do - make_repo --package-tag jhenv --jh-os $env_os - done +# for env_os in trusty xanial rhel7; do +# make_repo --package-tag jhenv --jh-os $env_os +# done +# jhenv only support trusty + make_repo --package-tag jhenv --jh-os trusty make_repo --package-tag pip @@ -339,10 +341,12 @@ function make_all_repo() --default-package "openssh-server" \ --special-package "openvswitch-switch" done - - make_repo --os-ver xenial --package-tag mitaka \ + + for opv in mitaka newton; do + make_repo --os-ver xenial --package-tag $opv \ --ansible-dir $WORK_PATH/deploy/adapters/ansible \ --default-package "openssh-server" + done make_repo --os-ver rhel7 --package-tag juno \ --ansible-dir $WORK_PATH/deploy/adapters/ansible \ diff --git a/build/os/ubuntu/xenial/newton/Dockerfile.tmpl b/build/os/ubuntu/xenial/newton/Dockerfile.tmpl new file mode 100644 index 00000000..4b24c0a3 --- /dev/null +++ b/build/os/ubuntu/xenial/newton/Dockerfile.tmpl @@ -0,0 +1,26 @@ +FROM ubuntu:16.04 +MAINTAINER Chigang(Justin) <chigang@huawei.com> + +#RUN apt-get update + +RUN rm -f /etc/apt/apt.conf.d/docker-clean +#set packages = $getVar('spcial_packages', []) +#for package in $packages +ADD ./Debian/packages/debian-packages/$package /var/cache/apt/archives/ +#end for +#set scripts = $getVar('scripts', []) +#for script in $scripts +ADD ./Debian/script/$script /tmp/chigang/$script +RUN chmod +x /tmp/chigang/$script +RUN /tmp/chigang/$script +#end for +ADD ./install_packages.sh /tmp/chigang/install_packages.sh +RUN chmod +x /tmp/chigang/install_packages.sh +RUN /tmp/chigang/install_packages.sh + +ADD ./cp_repo.sh /tmp/chigang/cp_repo.sh +RUN chmod +x /tmp/chigang/cp_repo.sh +RUN mkdir /result + +CMD ["/tmp/chigang/cp_repo.sh"] +#VOLUME /tmp/chigang diff --git a/build/templates/Debian_xenial_newton.tmpl b/build/templates/Debian_xenial_newton.tmpl new file mode 100644 index 00000000..e10d4e22 --- /dev/null +++ b/build/templates/Debian_xenial_newton.tmpl @@ -0,0 +1,76 @@ +#!/bin/bash +set -ex + +#set OPV="newton" + +# add openstack $OPV repo +apt-get update && apt-get install -y software-properties-common +# sudo add-apt-repository -y cloud-archive:$OPV +apt-get install -d nova-compute-kvm -y + +#make pernoca database +apt-get install -y apt-transport-https debconf-utils libaio1 libc6 libdbd-mysql-perl libgcc1 libgcrypt20 libstdc++6 python-software-properties wget +apt-key adv --recv-keys --keyserver hkp://keyserver.ubuntu.com:80 0xF1656F24C74CD1D8 +add-apt-repository 'deb https://mirrors.tuna.tsinghua.edu.cn/mariadb/mariadb-10.0.26/repo/ubuntu/ xenial main' +apt-get update +apt-get install -d mariadb-client mariadb-galera-server-10.0 galera-3 rsync socat -y +#make pernoca database end + + + +# add galeracluster repo +#sudo apt-key adv --recv-keys --keyserver hkp://keyserver.ubuntu.com:80 0xcbcb082a1bb943db +#sudo add-apt-repository 'deb http://ftp.osuosl.org/pub/mariadb/repo/5.5/ubuntu trusty main' +#apt-key adv --recv-keys --keyserver hkp://keyserver.ubuntu.com:80 D669017EBC19DDBA +##sudo add-apt-repository 'deb http://releases.galeracluster.com/ubuntu trusty main' +# add oracle java8 ppa +add-apt-repository ppa:webupd8team/java +# add open java7 repo +##sudo add-apt-repository 'deb http://security.ubuntu.com/ubuntu trusty-security main' + +apt-get update + +apt-get install python2.7 -y + +apt-get install reprepro -y + +apt-get -d install pciutils -y + +cd /var/cache/apt/ +apt-get download libexpat1 +cd - + +#download packages +#set packages = $getVar('default_packages', []) +#for pkg in $packages +apt-get -d install $pkg -y +#end for +#set packages = $getVar('packages', []) +#for pkg in $packages +apt-get -d install $pkg -y +#end for + +#make repo +mkdir -p xenial-$OPV-ppa/conf +cat <<EOF > xenial-$OPV-ppa/conf/distributions +Codename: xenial +Components: main +Architectures: amd64 +EOF + +apt-get install wget + +wget -O /var/cache/apt/python-pyasn1_0.1.8-2_all.deb http://us.archive.ubuntu.com/ubuntu/pool/main/p/pyasn1/python-pyasn1_0.1.8-2_all.deb +rm -rf /var/cache/apt/python-pyasn1_0.1.7-1ubuntu2_all.deb + +# Ubuntu16.04.1 LTS only have gcc-5-base_5.4.0-6ubuntu1~16.04.1, nova-novncproxy need +# gcc-5-base_5.4.0-6ubuntu1~16.04.2, but the docker could not download gcc-5-base package. +wget http://205.177.226.237:9999/nova-novncproxy_xenial_newton.tar.gz +tar -zxvf nova-novncproxy_xenial_newton.tar.gz --strip-components 1 -C /var/cache/apt/ + +mkdir deb +find /var/cache/apt/ -name *.deb | xargs -i cp {} deb + +reprepro -b xenial-$OPV-ppa includedeb xenial deb/*.deb + +tar -zcvf /xenial-$OPV-ppa.tar.gz ./xenial-$OPV-ppa diff --git a/deploy/deploy_parameter.sh b/deploy/deploy_parameter.sh index d8696ce8..92e3467d 100755 --- a/deploy/deploy_parameter.sh +++ b/deploy/deploy_parameter.sh @@ -111,3 +111,12 @@ function process_input_para() echo $input_file } + +function check_input_para() +{ + python ${COMPASS_DIR}/util/check_valid.py "$DHA" "$NETWORK" + if [ $? -ne 0 ];then + exit 1 + fi +} + diff --git a/deploy/launch.sh b/deploy/launch.sh index ed65f40d..976af3c0 100755 --- a/deploy/launch.sh +++ b/deploy/launch.sh @@ -18,7 +18,8 @@ source ${COMPASS_DIR}/deploy/prepare.sh prepare_python_env source ${COMPASS_DIR}/util/log.sh source ${COMPASS_DIR}/deploy/deploy_parameter.sh -source $(process_input_para $*) || exit 1 +source $(process_input_para $* ) || exit 1 +check_input_para source $(process_default_para $*) || exit 1 source ${COMPASS_DIR}/deploy/conf/${FLAVOR}.conf source ${COMPASS_DIR}/deploy/conf/${TYPE}.conf diff --git a/util/check_valid.py b/util/check_valid.py new file mode 100644 index 00000000..713a292f --- /dev/null +++ b/util/check_valid.py @@ -0,0 +1,96 @@ +import re +import os +import yaml +import sys +import traceback + +def init(file): + with open (file) as fd: + try: + return yaml.load(fd) + except: + traceback.print_exc() + return None + +def err_print(info): + print '\033[0;31m%s\033[0m' %info + +def check_ip(ip): + if not ip: + return False + res=re.search("^(0?\d{1,2}|1\d\d|2[0-4]\d|25[0-5])(\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])){3}(\/(\d|[1-2]\d|3[0-2]))?$",ip)!=None + return res + +def check_mac(mac): + if not mac: + return False + res=re.search("^([a-zA-Z0-9]{2}:){5}[a-zA-Z0-9]{2}$",mac)!=None + return res + +def check_network(network): + for i in network.get('ip_settings'): + if not (check_ip(i['cidr']) and check_ip(i['ip_ranges'][0][0]) and check_ip(i['ip_ranges'][0][1])): + return False + if i['name'] == 'external' and not check_ip(i['gw']): + return False + + if not check_ip(network['internal_vip']['ip']): + return False + + if not check_ip(network['public_vip']['ip']): + return False + + if not check_ip(network['public_net_info']['external_gw']): + return False + + if not check_ip(network['public_net_info']['floating_ip_cidr']): + return False + + if not check_ip(network['public_net_info']['floating_ip_start']): + return False + + if not check_ip(network['public_net_info']['floating_ip_end']): + return False + + return True + +def check_dha(dha): + if dha['TYPE'] == 'baremetal': + for i in dha['hosts']: + if not (check_mac(i['mac']) and check_mac(i['interfaces'][0]['eth1']) and check_ip(i['ipmiIp'])): + return False + return True + +if __name__ == "__main__": + flag = 0 + + if len(sys.argv) != 3: + err_print('input file error') + sys.exit(1) + + _, dha_file, network_file = sys.argv + + if not os.path.exists(dha_file): + sys.exit(1) + else: + dha = init(dha_file) + if not dha: + err_print('format error in DHA') + else: + if not check_dha(dha): + err_print('invalid address in DHA') + flag = 1 + + if not os.path.exists(network_file): + sys.exit(1) + else: + network = init(network_file) + if not network: + err_print('format error in NETWORK') + else: + if not check_network(network): + err_print('invalid address in NETWORK') + flag = 1 + + if flag == 1: + sys.exit(1) |