Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Split common logic of CI hooks to separate file
Manila contains CI hooks located in "contrib/ci" dir. Split common logic to separate file to be able to just "source" it and then use env vars and bash functions in different CI jobs and projects. Current change allows to do two things: - Reuse env var "MANILA_TEMPEST_COMMIT" in third-party CIs - Wait for drivers init in other projects like OpenStack Rally. Where, for the moment, one of jobs fails because of absense of "waiting". Usage: $ source %manila%/contrib/ci/common.sh $ echo $MANILA_TEMPEST_COMMIT $ manila_wait_for_drivers_init "/etc/manila/manila.conf" Change-Id: I94514405628ab8337d1f4153e431f064614e3596
- Loading branch information
1 parent
82e38ad
commit 6b8319e
Showing
3 changed files
with
75 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
# Environment variables | ||
|
||
export MANILA_TEMPEST_COMMIT="c43c8f91" # 05 Nov, 2015 | ||
|
||
# ---------------------------------------------- | ||
|
||
# Functions | ||
|
||
function manila_check_service_vm_availability { | ||
# First argument is expected to be IP address of a service VM | ||
|
||
wait_step=10 | ||
wait_timeout=300 | ||
available='false' | ||
while (( wait_timeout > 0 )) ; do | ||
if [[ "$(ping -w 1 $1)" =~ "1 received" ]]; then | ||
available='true' | ||
break | ||
fi | ||
((wait_timeout-=$wait_step)) | ||
sleep $wait_step | ||
done | ||
|
||
if [[ $available == 'true' ]]; then | ||
echo "SUCCESS! Service VM $1 is available." | ||
else | ||
echo "FAILURE! Service VM $1 is not available." | ||
exit 1 | ||
fi | ||
} | ||
|
||
function manila_wait_for_generic_driver_init { | ||
# First argument is expected to be file path to Manila config | ||
|
||
MANILA_CONF=$1 | ||
DRIVER_GROUPS=$(iniget $MANILA_CONF DEFAULT enabled_share_backends) | ||
for driver_group in ${DRIVER_GROUPS//,/ }; do | ||
SHARE_DRIVER=$(iniget $MANILA_CONF $driver_group share_driver) | ||
GENERIC_DRIVER='manila.share.drivers.generic.GenericShareDriver' | ||
DHSS=$(iniget $MANILA_CONF $driver_group driver_handles_share_servers) | ||
if [[ $SHARE_DRIVER == $GENERIC_DRIVER && $(trueorfalse False DHSS) == False ]]; then | ||
# Wait for availability | ||
source /opt/stack/new/devstack/openrc admin demo | ||
vm_id=$(iniget $MANILA_CONF $driver_group service_instance_name_or_id) | ||
vm_ips=$(nova show $vm_id | grep "private network") | ||
attempts=0 | ||
for vm_ip in ${vm_ips//,/ }; do | ||
# Get IPv4 address | ||
if [[ $vm_ip =~ ^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$ ]]; then | ||
# Check availability | ||
((attempts++)) | ||
manila_check_service_vm_availability $vm_ip | ||
break | ||
fi | ||
done | ||
if [[ (( attempts < 1 )) ]]; then | ||
echo "No IPv4 addresses found among private IPs of '$vm_id' for '$GENERIC_DRIVER'. "\ | ||
"Reported IPs: '$vm_ips'." | ||
exit 1 | ||
fi | ||
fi | ||
done | ||
} | ||
|
||
function manila_wait_for_drivers_init { | ||
# First argument is expected to be file path to Manila config | ||
|
||
manila_wait_for_generic_driver_init $1 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters