diff options
-rwxr-xr-x | ci/build_rpm/build_rpms.sh | 5 | ||||
-rwxr-xr-x | ci/deploy/deploy.sh | 2 | ||||
-rwxr-xr-x | ci/kolla-build.sh | 13 | ||||
-rwxr-xr-x | code/makefile_patch.sh | 8 | ||||
-rwxr-xr-x | deploy/get_conf.py | 11 | ||||
-rwxr-xr-x | deploy/tempest.py | 24 | ||||
-rwxr-xr-x | deploy/trustme.sh | 17 |
7 files changed, 55 insertions, 25 deletions
diff --git a/ci/build_rpm/build_rpms.sh b/ci/build_rpm/build_rpms.sh index e0472a24..48a87236 100755 --- a/ci/build_rpm/build_rpms.sh +++ b/ci/build_rpm/build_rpms.sh @@ -33,7 +33,7 @@ function cleanup_container { if [[ ! -z "$containers_to_kill" ]]; then ops='{{range .Mounts}} {{printf "%s\n" .Name }}{{end}}' volumes_to_remove=$(sudo docker inspect -f \ - $ops ${containers_to_kill} \ + "$ops" ${containers_to_kill} \ | egrep -v '(^\s*$)' \ | sort | uniq) @@ -47,8 +47,7 @@ function cleanup_container { } function cleanup_docker_image { - images_to_delete=$(sudo docker images -a \ - --format "{{.ID}}" \ + images_to_delete=$(sudo docker images -q \ --filter "label=daisy_image_version") echo "Removing images... $images_to_delete" diff --git a/ci/deploy/deploy.sh b/ci/deploy/deploy.sh index a2d18496..91d97784 100755 --- a/ci/deploy/deploy.sh +++ b/ci/deploy/deploy.sh @@ -88,7 +88,7 @@ sleep 20 echo "====== install daisy===========" $deploy_path/trustme.sh $daisy_ip $daisy_passwd scp -r $WORKSPACE root@$daisy_ip:/home - +ssh root@$daisy_ip "touch /root/.ssh/know_hosts" execute_on_jumpserver $daisy_ip "mkdir -p /home/daisy_install" update_config $WORKSPACE/deploy/daisy.conf daisy_management_ip $daisy_ip scp $WORKSPACE/deploy/daisy.conf root@$daisy_ip:/home/daisy_install diff --git a/ci/kolla-build.sh b/ci/kolla-build.sh index 39828ece..53ad8c16 100755 --- a/ci/kolla-build.sh +++ b/ci/kolla-build.sh @@ -21,6 +21,7 @@ set -o pipefail KOLLA_GIT=$1 KOLLA_BRANCH=$2 KOLLA_GIT_VERSION= +KOLLA_IMAGE_VERSION= KOLLA_GIT_DIR=/tmp/kolla-git REGISTRY_VOLUME_DIR=/tmp/registry BUILD_OUTPUT_DIR=/tmp/kolla-build-output @@ -106,7 +107,7 @@ function cleanup_registry_data { function cleanup_kolla_image { echo "Cleaning Kolla images" - if [ -d $KOLLA_GIT_DIR ] ; then + if [ -d $KOLLA_GIT_DIR/kolla ] ; then pushd $KOLLA_GIT_DIR/kolla (./tools/cleanup-images 2>&1) || true > /dev/null; popd @@ -132,6 +133,9 @@ function pack_registry_data { pushd $BUILD_OUTPUT_DIR echo $KOLLA_GIT_VERSION > registry-$version-$datetag.version + echo "branch = $KOLLA_BRANCH" >> registry-$version-$datetag.version + echo "tag = $KOLLA_IMAGE_VERSION" >> registry-$version-$datetag.version + echo "date = $datetag" >> registry-$version-$datetag.version tar czf kolla-image-$version-$datetag.tgz $REGISTRY_VOLUME_DIR \ registry-$version-$datetag.version rm -rf registry-$version-$datetag.version @@ -147,8 +151,10 @@ function update_kolla_code { if [ ! -d $KOLLA_GIT_DIR/kolla ] ; then pushd $KOLLA_GIT_DIR git clone $KOLLA_GIT + pushd $KOLLA_GIT_DIR/kolla git checkout $KOLLA_BRANCH popd + popd else pushd $KOLLA_GIT_DIR/kolla git remote update @@ -158,8 +164,10 @@ function update_kolla_code { fi pushd $KOLLA_GIT_DIR/kolla - KOLLA_GIT_VERSION=`git log -1 --pretty="%H"` + KOLLA_GIT_VERSION=$(git log -1 --pretty="%H") tox -e genconfig + KOLLA_IMAGE_VERSION=$(cat $KOLLA_GIT_DIR/kolla/etc/kolla/kolla-build.conf \ + | grep "#tag" | gawk -F' = ' '{print $2}') popd } @@ -189,6 +197,7 @@ pre_check # Try to cleanup images of the last failed run, if any. cleanup_kolla_image update_kolla_code +cleanup_kolla_image # Make sure there is no garbage in the registry server. cleanup_registry_server diff --git a/code/makefile_patch.sh b/code/makefile_patch.sh index e25bc40f..b2cfaf8d 100755 --- a/code/makefile_patch.sh +++ b/code/makefile_patch.sh @@ -14,9 +14,11 @@ imagebranch="newton" imageversion="latest" imageserver="http://120.24.17.215" imagename="kolla-image-$imagebranch-$imageversion.tgz" +isoname="CentOS-7-x86_64-Minimal-1511.iso" +isourl="http://buildlogs.centos.org/rolling/7/isos/x86_64/${isoname}" if [ ! -d $CACHE_PATH ]; then mkdir -p $CACHE_PATH ; fi -if [ ! -f $CACHE_PATH/CentOS-7-x86_64-Minimal-1511.iso ]; then - wget -P $CACHE_PATH "http://ftp.osuosl.org/pub/centos/7/isos/x86_64/CentOS-7-x86_64-Minimal-1511.iso" +if [ ! -f $CACHE_PATH/${isoname} ]; then + wget -P $CACHE_PATH $isourl fi if [ ! -f $CACHE_PATH/$imagename ]; then wget -P $CACHE_PATH "$imageserver/$imagename" @@ -24,7 +26,7 @@ fi if [ ! -f $CACHE_PATH/registry-server.tar ]; then wget -P $CACHE_PATH "http://daisycloud.org/static/files/registry-server.tar" fi -cp $CACHE_PATH/CentOS-7-x86_64-Minimal-1511.iso $TOOLS_PATH/setup/bin_temp/ +cp $CACHE_PATH/${isoname} $TOOLS_PATH/setup/bin_temp/ cp $CACHE_PATH/$imagename $TOOLS_PATH/setup/bin_temp/ cp $CACHE_PATH/registry-server.tar $TOOLS_PATH/setup/bin_temp/ cp $TOOLS_PATH/setup/install_interface_patch.sh $TOOLS_PATH/setup/bin_temp/ diff --git a/deploy/get_conf.py b/deploy/get_conf.py index eaac8b17..a2d7bf6a 100755 --- a/deploy/get_conf.py +++ b/deploy/get_conf.py @@ -23,8 +23,9 @@ def decorator_mk(types): result = {} for item in item_list: ret = func(item) - if ret.keys()[0] in result: - result[ret.keys()[0]].append(ret.values()[0][0]) + item_name = ret.keys().pop() + if result is not None and item_name in result: + result[item_name] = result[item_name] + ret[item_name] else: result.update(ret) return result @@ -93,10 +94,4 @@ def config(dha_file, network_file): hosts_name = dha_config_parse(data, dha_file) data = init(network_file) network_map, vip, interface_map = network_config_parse(data, network_file) - for interface_name in interface_map: - for name in interface_map[interface_name]: - if name.get('name', None) == 'MANAGEMENT': - name['ip'] = network_map.get( - 'MANAGEMENT', None).get( - 'ip_ranges', None)[0].get('start', None) return interface_map, hosts_name, network_map, vip diff --git a/deploy/tempest.py b/deploy/tempest.py index 1efe159f..3459cb07 100755 --- a/deploy/tempest.py +++ b/deploy/tempest.py @@ -14,11 +14,11 @@ from daisyclient.v1 import client as daisy_client import get_conf import traceback import time +import os daisy_version = 1.0 -daisy_endpoint = "http://127.0.0.1:19292" -client = daisy_client.Client(version=daisy_version, endpoint=daisy_endpoint) -iso_path = "/var/lib/daisy/kolla/CentOS-7-x86_64-DVD-1511.iso" +daisyrc_path = "/root/daisyrc_admin" +iso_path = "/var/lib/daisy/kolla/" deployment_interface = "ens3" cluster_name = "clustertest" @@ -46,6 +46,17 @@ def print_bar(msg): print ("--------------------------------------------") +def get_endpoint(file_path): + for line in open(file_path): + if 'OS_ENDPOINT' in line: + daisyrc_admin_line = line.strip() + daisy_endpoint = daisyrc_admin_line.split("=")[1] + return daisy_endpoint + +daisy_endpoint = get_endpoint(daisyrc_path) +client = daisy_client.Client(version=daisy_version, endpoint=daisy_endpoint) + + def prepare_install(): try: print("get config...") @@ -141,7 +152,12 @@ def add_hosts_interface(cluster_id, hosts_info, host_interface_map, interface_name = interface['name'] interface['assigned_networks'] = \ host_interface_map[interface_name] - host['os_version'] = iso_path + pathlist = os.listdir(iso_path) + for filename in pathlist: + if filename.endswith('iso'): + host['os_version'] = iso_path + filename + if host['os_version'] == iso_path: + print("do not have os iso file in /var/lib/daisy/kolla/.") client.hosts.update(host['id'], **host) print("update role...") add_host_role(cluster_id, host['id'], host['name'], vip) diff --git a/deploy/trustme.sh b/deploy/trustme.sh index eedda5ce..33b76546 100755 --- a/deploy/trustme.sh +++ b/deploy/trustme.sh @@ -10,6 +10,11 @@ function print_log echo -e "`date -d today +"%Y-%m-%d %H:%M:%S"` $promt" >> $logfile } ip=$1 +if [ -z $ip ]; then + print_log "Usage: `basename $0` ipaddr passwd" + exit 1 +fi + passwd=$2 if [ -z $passwd ]; then print_log "Usage: `basename $0` ipaddr passwd" @@ -47,11 +52,15 @@ host=`hostname` keyend="$user@$host" print_log "my keyend = $keyend" cmd="sed '/$keyend$/d' -i ~/.ssh/authorized_keys" +local_host="127.0.0.1" print_log "clear my old pub key on $local_host ..." -ssh-keygen -f "/root/.ssh/known_hosts" -R $ip -if [ $? != 0 ]; then - print_log "delete pub key of $ip from known_hosts failed" - exit 1 +sshpass -p $passwd ssh -o StrictHostKeyChecking=no $local_host "test -f ~/.ssh/known_hosts" +if [ $? = 0 ]; then + sshpass -p $passwd ssh -o StrictHostKeyChecking=no $local_host "sed -i '/${ip} /d' ~/.ssh/known_hosts" + if [ $? != 0 ]; then + print_log "delete pub key of $ip from $local_host known_hosts failed" + exit 1 + fi fi sshpass -p $passwd ssh -o StrictHostKeyChecking=no $ip "mkdir -p ~/.ssh && touch ~/.ssh/authorized_keys" if [ $? != 0 ]; then |