diff options
-rw-r--r-- | build/cache.sh | 4 | ||||
-rw-r--r-- | build/functions.sh | 46 | ||||
-rwxr-xr-x | build/overcloud-full.sh | 24 | ||||
-rwxr-xr-x | build/undercloud.sh | 49 | ||||
-rw-r--r-- | build/variables.sh | 1 | ||||
-rwxr-xr-x | ci/deploy.sh | 19 | ||||
-rwxr-xr-x | ci/test.sh | 19 | ||||
-rw-r--r-- | tests/test_apex_ip_utils.py | 36 |
8 files changed, 127 insertions, 71 deletions
diff --git a/build/cache.sh b/build/cache.sh index a88ffce1..123748a2 100644 --- a/build/cache.sh +++ b/build/cache.sh @@ -24,6 +24,10 @@ function cache_git_tar { # $1 = download url # $2 = filename to write to function curl_file { + if [ -f $CACHE_DIR/$2 ]; then + echo "Removing stale $2" + rm -f $CACHE_DIR/$2 + fi echo "Downloading $1" echo "Cache download location: $CACHE_DIR/$2" until curl -C- -L -o $CACHE_DIR/$2 $1 || (( count++ >= 20 )); do diff --git a/build/functions.sh b/build/functions.sh new file mode 100644 index 00000000..e61102ef --- /dev/null +++ b/build/functions.sh @@ -0,0 +1,46 @@ +############################################################################## +# Copyright (c) 2016 Dan Radez (Red Hat) and others. +# +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Apache License, Version 2.0 +# which accompanies this distribution, and is available at +# http://www.apache.org/licenses/LICENSE-2.0 +############################################################################## + +clone_fork () { + # ARG 1: opnfv-tht or opnfv-python-triplo + echo "Cloning $1" + + # Use apex tripleo-heat-templates fork + local ghcreds="" + local pr_num="" + local ref="stable/colorado" + local repo="https://github.com/trozet/$1" + + if git log -1 | grep "${1}-pr:" | grep -o '[0-9]*'; then + pr_num=$(git log -1 | grep "${1}-pr:" | grep -o '[0-9]*') + fi + + if [ "$pr_num" != "" ]; then + echo "Using pull request $pr_num from $repo" + # Source credentials since we are rate limited to 60/day + if [ -f ~/.githubcreds ]; then + source ~/.githubcreds + ghcreds=" -u $GHUSERNAME:$GHACCESSTOKEN" + fi + + PR=$(curl $ghcreds https://api.github.com/repos/trozet/$1/pulls/$pr_num) + + # Do not pull from merged branches + MERGED=$(python -c "import json; print json.loads('''$PR'''.replace('\n', '').replace('\r', ''))['merged']") + if [ "$MERGED" == "False" ]; then + ref=$(python -c "import json; print json.loads('''$PR'''.replace('\n', '').replace('\r', ''))['head']['ref']") + echo "Setting GitHub Ref to: $REF" + repo=$(python -c "import json; print json.loads('''$PR'''.replace('\n', '').replace('\r', ''))['head']['repo']['clone_url']") + echo "Setting GitHub URL to: $repo" + fi + fi + + rm -rf $1 + git clone $repo -b $ref $1 +} diff --git a/build/overcloud-full.sh b/build/overcloud-full.sh index af978edb..1a8d8461 100755 --- a/build/overcloud-full.sh +++ b/build/overcloud-full.sh @@ -10,6 +10,7 @@ set -e source ./cache.sh source ./variables.sh +source ./functions.sh populate_cache "$rdo_images_uri/overcloud-full.tar" @@ -21,6 +22,20 @@ mv -f images/overcloud-full.qcow2 images/overcloud-full_build.qcow2 ##### Prep initial overcloud image with common deps ##### ########################################################## +# prep opnfv-puppet-tripleo for undercloud +clone_fork opnfv-puppet-tripleo +pushd opnfv-puppet-tripleo > /dev/null +git archive --format=tar.gz --prefix=tripleo/ HEAD > ../opnfv-puppet-tripleo.tar.gz +popd > /dev/null + +# download customized os-net-config +git clone https://github.com/trozet/os-net-config.git -b hiera_nic_mapping +pushd os-net-config > /dev/null +pushd os_net_config > /dev/null +git archive --format=tar.gz --prefix=os_net_config/ HEAD > ../../os-net-config.tar.gz +popd > /dev/null +popd > /dev/null + pushd images > /dev/null dpdk_pkg_str='' @@ -29,13 +44,20 @@ for package in ${dpdk_rpms[@]}; do dpdk_pkg_str+=" --upload $package:/root/dpdk_rpms" done -# remove openstack-neutron-openvswitch, ain't nobody need that in OPNFV +# installing forked opnfv-puppet-tripleo # enable connection tracking for protocal sctp # upload dpdk rpms but do not install LIBGUESTFS_BACKEND=direct virt-customize \ + --upload ../opnfv-puppet-tripleo.tar.gz:/etc/puppet/modules \ + --run-command "cd /etc/puppet/modules && rm -rf tripleo && tar xzf opnfv-puppet-tripleo.tar.gz" \ --run-command "echo 'nf_conntrack_proto_sctp' > /etc/modules-load.d/nf_conntrack_proto_sctp.conf" \ --run-command "mkdir /root/dpdk_rpms" \ $dpdk_pkg_str \ + --install "centos-release-qemu-ev" \ + --run-command "yum update -y" \ + --run-command "yum remove -y qemu-system-x86" \ + --upload ../os-net-config.tar.gz:/usr/lib/python2.7/site-packages \ + --run-command "cd /usr/lib/python2.7/site-packages/ && rm -rf os_net_config && tar xzf os-net-config.tar.gz" \ -a overcloud-full_build.qcow2 mv -f overcloud-full_build.qcow2 overcloud-full.qcow2 diff --git a/build/undercloud.sh b/build/undercloud.sh index 551dbd88..c1d7c3ab 100755 --- a/build/undercloud.sh +++ b/build/undercloud.sh @@ -10,57 +10,26 @@ set -e source ./cache.sh source ./variables.sh +source ./functions.sh populate_cache "$rdo_images_uri/undercloud.qcow2" if [ ! -d images ]; then mkdir images/; fi cp -f cache/undercloud.qcow2 images/undercloud_build.qcow2 -#Adding OpenStack packages to undercloud -pushd images > /dev/null - -# Use apex tripleo-heat-templates fork -PR_NUMBER="" -REF="stable/colorado" -REPO="https://github.com/trozet/opnfv-tht" - -if git log -1 | grep 'opnfv-tht-pr:' | grep -o '[0-9]*'; then - PR_NUMBER=$(git log -1 | grep 'opnfv-tht-pr:' | grep -o '[0-9]*') -fi - -if [ "$PR_NUMBER" != "" ]; then - echo "Using pull request $PR_NUMBER from $REPO" - # Source credentials since we are rate limited to 60/day - GHCREDS="" - if [ -f ~/.githubcreds ]; then - source ~/.githubcreds - GHCREDS=" -u $GHUSERNAME:$GHACCESSTOKEN" - fi - - PR=$(curl $GHCREDS https://api.github.com/repos/trozet/opnfv-tht/pulls/$PR_NUMBER) - - # Do not pull from merged branches - MERGED=$(python -c "import json; print json.loads('''$PR'''.replace('\n', '').replace('\r', ''))['merged']") - if [ "$MERGED" == "False" ]; then - REF=$(python -c "import json; print json.loads('''$PR'''.replace('\n', '').replace('\r', ''))['head']['ref']") - echo "Setting GitHub Ref to: $REF" - REPO=$(python -c "import json; print json.loads('''$PR'''.replace('\n', '').replace('\r', ''))['head']['repo']['clone_url']") - echo "Setting GitHub URL to: $REPO" - fi -fi - -rm -rf opnfv-tht -git clone $REPO -b $REF opnfv-tht - +# prep opnfv-tht for undercloud +clone_fork opnfv-tht pushd opnfv-tht > /dev/null git archive --format=tar.gz --prefix=openstack-tripleo-heat-templates/ HEAD > ../opnfv-tht.tar.gz popd > /dev/null -LIBGUESTFS_BACKEND=direct virt-customize --upload opnfv-tht.tar.gz:/usr/share \ - --run-command "cd /usr/share && rm -rf openstack-tripleo-heat-templates && tar xzf opnfv-tht.tar.gz" \ - -a undercloud_build.qcow2 -# install the packages above and enabling ceph to live on the controller +pushd images > /dev/null +# installing forked opnfv-tht +# enabling ceph OSDs to live on the controller # OpenWSMan package update supports the AMT Ironic driver for the TealBox +# seeding configuration files specific to OPNFV LIBGUESTFS_BACKEND=direct virt-customize \ + --upload ../opnfv-tht.tar.gz:/usr/share \ + --run-command "cd /usr/share && rm -rf openstack-tripleo-heat-templates && tar xzf opnfv-tht.tar.gz" \ --run-command "sed -i '/ControllerEnableCephStorage/c\\ ControllerEnableCephStorage: true' /usr/share/openstack-tripleo-heat-templates/environments/storage-environment.yaml" \ --run-command "sed -i '/ComputeEnableCephStorage/c\\ ComputeEnableCephStorage: true' /usr/share/openstack-tripleo-heat-templates/environments/storage-environment.yaml" \ --run-command "curl http://download.opensuse.org/repositories/Openwsman/CentOS_CentOS-7/Openwsman.repo > /etc/yum.repos.d/wsman.repo" \ diff --git a/build/variables.sh b/build/variables.sh index ad1edf91..8397dfd8 100644 --- a/build/variables.sh +++ b/build/variables.sh @@ -18,4 +18,5 @@ dpdk_rpms=( 'ovs4opnfv-dpdk-devel-16.04.0-2.el7.centos.x86_64.rpm' 'ovs4opnfv-dpdk-examples-16.04.0-2.el7.centos.x86_64.rpm' 'ovs4opnfv-dpdk-tools-16.04.0-2.el7.centos.x86_64.rpm' +'ovs4opnfv-openvswitch-2.5.90-0.12060.git46ed1382.1.el7.centos.x86_64.rpm' )
\ No newline at end of file diff --git a/ci/deploy.sh b/ci/deploy.sh index 48e15e6b..44914f22 100755 --- a/ci/deploy.sh +++ b/ci/deploy.sh @@ -1021,9 +1021,9 @@ EOI ssh -T ${SSH_OPTIONS[@]} "stack@$UNDERCLOUD" <<EOI source overcloudrc echo "Keystone Endpoint List:" -keystone endpoint-list +openstack endpoint list echo "Keystone Service List" -keystone service-list +openstack service list cinder quota-show \$(openstack project list | grep admin | awk {'print \$2'}) EOI fi @@ -1041,14 +1041,14 @@ function configure_post_install { source overcloudrc set -o errexit echo "Configuring Neutron external network" -neutron net-create external --router:external=True --tenant-id \$(keystone tenant-get service | grep id | awk '{ print \$4 }') -neutron subnet-create --name external-net --tenant-id \$(keystone tenant-get service | grep id | awk '{ print \$4 }') --disable-dhcp external --gateway ${public_network_gateway} --allocation-pool start=${public_network_floating_ip_range%%,*},end=${public_network_floating_ip_range##*,} ${public_network_cidr} +neutron net-create external --router:external=True --tenant-id \$(openstack project show service | grep id | awk '{ print \$4 }') +neutron subnet-create --name external-net --tenant-id \$(openstack project show service | grep id | awk '{ print \$4 }') --disable-dhcp external --gateway ${public_network_gateway} --allocation-pool start=${public_network_floating_ip_range%%,*},end=${public_network_floating_ip_range##*,} ${public_network_cidr} echo "Removing swift endpoint and service" -swift_service_id=\$(keystone service-list | grep swift | cut -d ' ' -f 2) -swift_endpoint_id=\$(keystone endpoint-list | grep \$swift_service_id | cut -d ' ' -f 2) -keystone endpoint-delete \$swift_endpoint_id -keystone service-delete \$swift_service_id +swift_service_id=\$(openstack service list | grep swift | cut -d ' ' -f 2) +swift_endpoint_id=\$(openstack endpoint list | grep swift | cut -d ' ' -f 2) +openstack endpoint delete \$swift_endpoint_id +openstack service delete \$swift_service_id EOI echo -e "${blue}INFO: Checking if OVS bridges have IP addresses...${reset}" @@ -1127,8 +1127,9 @@ fi EOF done -# Print out the dashboard URL +# Print out the undercloud IP and dashboard URL source stackrc +echo "Undercloud IP: $UNDERCLOUD, please connect by doing 'opnfv-util undercloud'" echo "Overcloud dashboard available at http://\$(heat output-show overcloud PublicVip | sed 's/"//g')/dashboard" EOI @@ -10,19 +10,22 @@ set -e -# Make sure python is installed -if ! rpm -q python34-devel > /dev/null; then - sudo yum install -y epel-release - if ! sudo yum install -y python34-devel; then - echo "Failed to install python34-devel package..." - exit 1 +# Make sure python dependencies are installed +for pkg in epel-release python34-devel python34-nose; do + if ! rpm -q ${pkg} > /dev/null; then + if ! sudo yum install -y ${pkg}; then + echo "Failed to install ${pkg} package..." + exit 1 fi -fi + fi +done # Make sure coverage is installed if ! python3 -c "import coverage" &> /dev/null; then sudo easy_install-3.4 coverage; fi +pushd ../build/ > /dev/null make python-tests +popd > /dev/null pushd ../tests/ > /dev/null percent=$(coverage3 report --include '*lib/python/*' -m | grep TOTAL | tr -s ' ' | awk '{ print $4 }' | cut -d % -f 1) if [[ percent -lt 80 ]]; then @@ -30,4 +33,4 @@ if [[ percent -lt 80 ]]; then echo "Does not meet 80% requirement" exit 1 fi -popd > /dev/nul +popd > /dev/null diff --git a/tests/test_apex_ip_utils.py b/tests/test_apex_ip_utils.py index 0b44bdd0..dc3aadf7 100644 --- a/tests/test_apex_ip_utils.py +++ b/tests/test_apex_ip_utils.py @@ -26,7 +26,9 @@ from ipaddress import ip_network ip4_pattern = re.compile('\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}') -ip4_range_pattern = re.compile('\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3},\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}') +ip4_range_pattern = re.compile('\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3},\d{1,' + '3}\.\d{1,3}\.\d{1,3}\.\d{1,3}') + def get_default_gateway_linux(): """Read the default gateway directly from /proc.""" @@ -61,9 +63,9 @@ class TestIpUtils(object): assert_is_instance(get_interface( self.iface_name, address_family=4), IPv4Address) - assert_is_instance(get_interface( - self.iface_name, - address_family=6), IPv6Address) +# assert_is_instance(get_interface( +# self.iface_name, +# address_family=6), IPv6Address) assert_raises(IPUtilsException, get_interface, self.iface_name, 0) @@ -77,19 +79,27 @@ class TestIpUtils(object): assert_regexp_matches(get_ip(1, interface=self.iface), ip4_pattern) assert_raises(IPUtilsException, get_ip, 1) - def test_get_ip_range_raises(self): assert_raises(IPUtilsException, get_ip_range) assert_raises(IPUtilsException, get_ip_range, interface=self.iface) def test_get_ip_range_with_interface(self): - assert_regexp_matches(get_ip_range(interface=self.iface, start_offset=1, end_offset=20), ip4_range_pattern) - assert_regexp_matches(get_ip_range(interface=self.iface, start_offset=1, count=10), ip4_range_pattern) - assert_regexp_matches(get_ip_range(interface=self.iface, end_offset=20, count=10), ip4_range_pattern) - - def test_get_ip_range_with_cidr(self): + assert_regexp_matches(get_ip_range(interface=self.iface, + start_offset=1, end_offset=20), + ip4_range_pattern) + assert_regexp_matches(get_ip_range(interface=self.iface, + start_offset=1, count=10), + ip4_range_pattern) + assert_regexp_matches(get_ip_range(interface=self.iface, end_offset=20, + count=10), ip4_range_pattern) + + @staticmethod + def test_get_ip_range_with_cidr(): cidr = ip_network('10.10.10.0/24') assert_raises(IPUtilsException, get_ip_range, cidr=cidr) - assert_regexp_matches(get_ip_range(cidr=cidr, start_offset=1, end_offset=20), ip4_pattern) - assert_regexp_matches(get_ip_range(cidr=cidr, start_offset=1, count=10), ip4_pattern) - assert_regexp_matches(get_ip_range(cidr=cidr, end_offset=20, count=10), ip4_pattern) + assert_regexp_matches(get_ip_range(cidr=cidr, start_offset=1, + end_offset=20), ip4_pattern) + assert_regexp_matches(get_ip_range(cidr=cidr, start_offset=1, + count=10), ip4_pattern) + assert_regexp_matches(get_ip_range(cidr=cidr, end_offset=20, + count=10), ip4_pattern) |