diff options
-rw-r--r-- | docker/Dockerfile | 2 | ||||
-rw-r--r-- | docker/Dockerfile.aarch64 | 2 | ||||
-rwxr-xr-x | functest/ci/check_os.sh | 63 | ||||
-rw-r--r-- | functest/utils/openstack_tacker.py | 40 |
4 files changed, 70 insertions, 37 deletions
diff --git a/docker/Dockerfile b/docker/Dockerfile index 13f43dd44..ca0fb6a70 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -85,6 +85,7 @@ RUN git clone --depth 1 -b $BRANCH https://gerrit.opnfv.org/gerrit/ovno ${REPOS_ RUN git clone --depth 1 -b $BRANCH https://gerrit.opnfv.org/gerrit/promise ${REPOS_DIR}/promise RUN git clone --depth 1 -b $BRANCH https://gerrit.opnfv.org/gerrit/netready ${REPOS_DIR}/netready RUN git clone --depth 1 -b $BRANCH https://gerrit.opnfv.org/gerrit/sfc ${REPOS_DIR}/sfc +RUN git clone --depth 1 -b $BRANCH https://gerrit.opnfv.org/gerrit/snaps ${REPOS_DIR}/snaps RUN git clone --depth 1 https://gerrit.opnfv.org/gerrit/securityscanning ${REPOS_DIR}/securityscanning RUN git clone --depth 1 https://gerrit.opnfv.org/gerrit/releng ${REPOS_DIR}/releng @@ -124,7 +125,6 @@ RUN gpg --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys 409B6B1796C RUN curl -L https://get.rvm.io | bash -s stable # SNAPS integration -RUN git clone --depth 1 https://gerrit.cablelabs.com/snaps-provisioning ${REPOS_DIR}/snaps RUN pip install -e ${REPOS_DIR}/snaps/ # SFC integration diff --git a/docker/Dockerfile.aarch64 b/docker/Dockerfile.aarch64 index d1c44e334..fa04e8c8c 100644 --- a/docker/Dockerfile.aarch64 +++ b/docker/Dockerfile.aarch64 @@ -85,6 +85,7 @@ RUN git clone --depth 1 -b $BRANCH https://gerrit.opnfv.org/gerrit/doctor ${REPO RUN git clone --depth 1 -b $BRANCH https://gerrit.opnfv.org/gerrit/ovno ${REPOS_DIR}/ovno RUN git clone --depth 1 -b $BRANCH https://gerrit.opnfv.org/gerrit/promise ${REPOS_DIR}/promise RUN git clone --depth 1 -b $BRANCH https://gerrit.opnfv.org/gerrit/sfc ${REPOS_DIR}/sfc +RUN git clone --depth 1 -b $BRANCH https://gerrit.opnfv.org/gerrit/snaps ${REPOS_DIR}/snaps RUN git clone --depth 1 https://gerrit.opnfv.org/gerrit/securityscanning ${REPOS_DIR}/securityscanning RUN git clone --depth 1 https://gerrit.opnfv.org/gerrit/releng ${REPOS_DIR}/releng @@ -120,7 +121,6 @@ RUN gpg --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys 409B6B1796C RUN curl -L https://get.rvm.io | bash -s stable # SNAPS integration -RUN git clone --depth 1 https://gerrit.cablelabs.com/snaps-provisioning ${REPOS_DIR}/snaps RUN pip install -e ${REPOS_DIR}/snaps/ # SFC integration diff --git a/functest/ci/check_os.sh b/functest/ci/check_os.sh index b875a173e..2c5c021c7 100755 --- a/functest/ci/check_os.sh +++ b/functest/ci/check_os.sh @@ -6,6 +6,16 @@ # jose.lausuch@ericsson.com # +declare -A service_cmd_array +service_cmd_array['nova']='openstack server list' +service_cmd_array['neutron']='openstack network list' +service_cmd_array['keystone']='openstack endpoint list' +service_cmd_array['cinder']='openstack volume list' +service_cmd_array['glance']='openstack image list' + +MANDATORY_SERVICES='nova neutron keystone glance' +OPTIONAL_SERVICES='cinder' + verify_connectivity() { for i in $(seq 0 9); do if echo "test" | nc -v -w 10 $1 $2 &>/dev/null; then @@ -16,6 +26,34 @@ verify_connectivity() { return 1 } +check_service() { + local service cmd + service=$1 + cmd=${service_cmd_array[$service]} + if [ -z "$2" ]; then + required='false' + else + required=$2 + fi + echo ">>Checking ${service} service..." + if ! openstack service list | grep -i ${service} > /dev/null; then + if [ "$required" == 'false' ]; then + echo "WARN: Optional Service ${service} is not enabled!" + return + else + echo "ERROR: Required Service ${service} is not enabled!" + exit 1 + fi + fi + $cmd &>/dev/null + result=$? + if [ $result -ne 0 ]; then + echo "ERROR: Failed execution $cmd. The $service does not seem to be working." + exit 1 + else + echo " ...OK" + fi +} if [ -z $OS_AUTH_URL ];then echo "ERROR: OS_AUTH_URL environment variable missing... Have you sourced the OpenStack credentials?" @@ -56,25 +94,16 @@ fi echo " ...OK" -echo "Checking OpenStack basic services:" -commands=('openstack endpoint list' 'openstack server list' 'openstack network list' \ - 'openstack image list' 'openstack volume list') -for cmd in "${commands[@]}" -do - service=$(echo $cmd | awk '{print $1, $2}') - echo ">>Checking $service service..." - $cmd &>/dev/null - result=$? - if [ $result -ne 0 ]; - then - echo "ERROR: Failed execution $cmd. The $service does not seem to be working." - exit 1 - else - echo " ...OK" - fi +echo "Checking Required OpenStack services:" +for service in $MANDATORY_SERVICES; do + check_service $service "true" done +echo "Required OpenStack services are OK." -echo "OpenStack services are OK." +echo "Checking Optional OpenStack services:" +for service in $OPTIONAL_SERVICES; do + check_service $service +done echo "Checking External network..." networks=($(neutron net-list -F id | tail -n +4 | head -n -1 | awk '{print $2}')) diff --git a/functest/utils/openstack_tacker.py b/functest/utils/openstack_tacker.py index d745f1052..1c02e0403 100644 --- a/functest/utils/openstack_tacker.py +++ b/functest/utils/openstack_tacker.py @@ -45,8 +45,17 @@ def get_vnfd_id(tacker_client, vnfd_name): return get_id_from_name(tacker_client, 'vnfd', vnfd_name) -def get_vnf_id(tacker_client, vnf_name): - return get_id_from_name(tacker_client, 'vnf', vnf_name) +def get_vnf_id(tacker_client, vnf_name, timeout=5): + vnf_id = None + while vnf_id is None and timeout >= 0: + try: + vnf_id = get_id_from_name(tacker_client, 'vnf', vnf_name) + except: + logger.info("Could not retrieve ID for vnf with name [%s]." + " Retrying." % vnf_name) + time.sleep(1) + timeout -= 1 + return vnf_id def get_sfc_id(tacker_client, sfc_name): @@ -136,28 +145,23 @@ def create_vnf(tacker_client, vnf_name, vnfd_id=None, return None -def wait_for_vnf(tacker_client, vnf_id=None, vnf_name=None): +def wait_for_vnf(tacker_client, vnf_id=None, vnf_name=None, timeout=60): try: - _id = None - if vnf_id is not None: - _id = vnf_id - elif vnf_name is not None: - while _id is None: - try: - _id = get_vnf_id(tacker_client, vnf_name) - except: - logger.error("Bazinga") - else: + if vnf_id is None and vnf_name is None: raise Exception('You must specify vnf_id or vnf_name') - while True: - vnf = [v for v in list_vnfs(tacker_client, verbose=True)['vnfs'] - if v['id'] == _id] - vnf = vnf[0] - logger.info('Waiting for vnf {0}'.format(str(vnf))) + _id = get_vnf_id(tacker_client, vnf_name) if vnf_id is None else vnf_id + + vnf = next((v for v in list_vnfs(tacker_client, verbose=True)['vnfs'] + if v['id'] == _id), None) + if vnf is None: + raise Exception("Could not retrieve VNF with ID [%s]" % _id) + logger.info('Waiting for vnf {0}'.format(str(vnf))) + while True and timeout >= 0: if vnf['status'] == 'ERROR': raise Exception('Error when booting vnf %s' % _id) elif vnf['status'] == 'PENDING_CREATE': time.sleep(3) + timeout -= 3 continue else: break |