Commit b741a79a authored by Giorgos Korfiatis's avatar Giorgos Korfiatis
Browse files

astakos: Ease importing services in upgrade

Adapt script snf-register-components to update/import services for
an already registered component.
parent a955253f
......@@ -16,15 +16,28 @@ ex_url[cyclades]='https://compute.example.synnefo.org/compute/'
ex_url[pithos]='https://object-store.example.synnefo.org/pithos/'
changed=0
register_services () {
echo "Registering ${component}'s services and resources..."
snf-service-export $component $base_url | snf-manage service-import --json -
snf-service-export $1 $2 | snf-manage service-import --json -
}
ex_ui_url () {
echo "$(echo $base_url | sed -e 's/\/*$//g')/ui/"
echo "$(echo $1 | sed -e 's/\/*$//g')/ui/"
}
changed=0
decide () {
while true; do
echo -n "$1"
read response
case $response in
[Yy]* ) return 0;;
[Nn]* ) return 1;;
* ) echo "Please answer yes or no.";;
esac
done
}
register_component () {
......@@ -37,23 +50,33 @@ register_component () {
echo -n 'Base URL: '
read base_url
echo "Give the URL of the $component UI" \
"(e.g. $(ex_ui_url))"
"(e.g. $(ex_ui_url $base_url))"
echo -n 'UI URL: '
read ui_url
while true; do
echo -n "Register $component with the given URLs (y/n)? "
read response
case $response in
[Yy]* ) break;;
[Nn]* ) return;;
* ) echo "Please answer yes or no.";;
esac
done
snf-manage component-add $component $ui_url
decide "Register $component with the given URLs (y/n)? "
if [ $? -eq 0 ]; then
read -p "Please write down the token and press Enter to continue. "
register_services $1
changed=1
snf-manage component-add $component $ui_url
if [ $? -eq 0 ]; then
read -p "Please write down the token and press Enter to continue. "
register_services $component $base_url
changed=1
echo
fi
fi
}
register_comp_serv () {
component=$1
component_desc=${desc[$component]}
component_ex_url=${ex_url[$component]}
echo "Registering services for $component:"
echo "Give the URL of $component base installation" \
"(e.g. $component_ex_url)"
echo -n 'Base URL: '
read base_url
decide "Register ${component}'s services with the given URL (y/n)? "
if [ $? -eq 0 ]; then
register_services $component $base_url
echo
fi
}
......@@ -62,33 +85,22 @@ components=(astakos cyclades pithos)
registered=$(snf-manage component-list --output-format=csv --no-headers |
cut -d ',' -f 2)
register_all () {
flag=0
for component in ${components[@]}; do
echo $registered | grep -q -w $component
if [ $? -ne 0 ]; then
flag=1
while true; do
echo -n "Do you want to register the ${desc[$component]}" \
"($component) (y/n)? "
read response
case $response in
[Yy]* )
register_component $component
break;;
[Nn]* )
break;;
* ) echo "Please answer yes or no.";;
esac
done
register_one () {
component=$1
echo $registered | grep -q -w $component
if [ $? -ne 0 ]; then
decide "Register the ${desc[$component]} ($component) (y/n)? "
if [ $? -eq 0 ]; then
register_component $component
fi
else
echo "The ${desc[$component]} ($component) is registered."
decide "Update its registered services (y/n)? "
if [ $? -eq 0 ]; then
register_comp_serv $component
fi
done
if [ $flag -eq 0 ]; then
echo All standard Synnefo components are already registered.
exit
fi
}
}
# Attempt to register only the specified service
if [[ $1 ]]; then
......@@ -97,14 +109,11 @@ if [[ $1 ]]; then
echo $1 is not a recognized Synnefo component.
exit
fi
echo $registered | grep -q -w $1
if [ $? -ne 0 ]; then
register_component $1
else
echo $1 is already registered.
fi
register_one $1
else
register_all
for component in ${components[@]}; do
register_one $component
done
fi
if [ $changed -eq 1 ]; then
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment