-
-
Save arax/6212cfd8cf5eb0dc9b8b to your computer and use it in GitHub Desktop.
CloudPlugfest OCCI Demo
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
#!/bin/bash | |
# -------------------------------------------------------------------------- # | |
# Licensed under the Apache License, Version 2.0 (the "License"); you may # | |
# not use this file except in compliance with the License. You may obtain # | |
# a copy of the License at # | |
# # | |
# http://www.apache.org/licenses/LICENSE-2.0 # | |
# # | |
# Unless required by applicable law or agreed to in writing, software # | |
# distributed under the License is distributed on an "AS IS" BASIS, # | |
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # | |
# See the License for the specific language governing permissions and # | |
# limitations under the License. # | |
#--------------------------------------------------------------------------- # | |
DUMMY_OUT=`occi -v` | |
if [ "$?" -ne "0" ]; then | |
printf "rOCCI-cli is not installed on your system!\n" | |
exit 1 | |
fi | |
DUMMY_OUT=`voms-proxy-init --version` | |
if [ "$?" -ne "0" ]; then | |
printf "voms-clients are not installed on your system!\n" | |
exit 1 | |
fi | |
printf "\n\n" | |
printf "This demo shows real-world interoperability in EGI Federated Cloud\n" | |
printf "facilitated by various OCCI (OGF's Open Cloud Computing Interface)\n" | |
printf "implementations used on three different cloud platforms:\n\n" | |
printf "\t -- OpenNebula\n" | |
printf "\t -- OpenStack\n" | |
printf "\t -- Synnefo\n" | |
printf "\n" | |
printf "Demo uses rOCCI-cli as the client-side implementation of OCCI:\n\n" | |
printf "\$ occi -d -v\n" | |
occi -d -v | |
printf "\n\n" | |
############################################################################## | |
############################################################################## | |
function pause { | |
printf "\n" | |
read -p "Press [Enter] to continue ..." DUMMY_INPUT | |
} | |
function get_voms_creds { | |
STRING_CALL="voms-proxy-init -voms fedcloud.egi.eu -rfc" | |
printf "\n\$ $STRING_CALL\n" | |
eval $STRING_CALL | |
if [ "$?" -ne "0" ]; then | |
printf "Failed to get a VOMS proxy!\n" | |
exit 2 | |
fi | |
PROXY_FILE="/tmp/x509up_u1000" | |
} | |
function run_rocci_cli { | |
STRING_CALL="occi --endpoint $FC_SITE_ENDPOINT --auth x509 --voms --user-cred $PROXY_FILE" | |
STRING_CALL="$STRING_CALL $1" | |
printf "\n\$ $STRING_CALL\n" | |
RET=`eval $STRING_CALL` | |
RET_VAL=$? | |
if [ "$RET_VAL" -ne "0" ]; then | |
printf "rOCCI-cli call failed!\n" | |
printf "$RET\n" | |
exit 2 | |
fi | |
if [ -z "$RET" ] || [ "$RET" = "\n" ]; then | |
printf "Empty!\n" | |
else | |
if [ "$2" = "is_create" ]; then | |
LAST_CREATED_RESOURCE=$RET | |
fi | |
printf "$RET\n" | |
fi | |
} | |
function list_computes { | |
run_rocci_cli "--resource compute --action list" | |
} | |
function list_os_tpls { | |
run_rocci_cli "--resource os_tpl --action list" | |
} | |
function list_resource_tpls { | |
run_rocci_cli "--resource resource_tpl --action list" | |
} | |
function create_compute { | |
run_rocci_cli "--resource compute --action create --mixin $FC_SITE_OS_TPL --mixin $FC_SITE_RES_TPL --attribute occi.core.title='MyDemoVM'" "is_create" | |
} | |
function describe_compute { | |
run_rocci_cli "--resource $LAST_CREATED_RESOURCE --action describe" | |
} | |
function delete_compute { | |
run_rocci_cli "--resource $LAST_CREATED_RESOURCE --action delete" | |
} | |
############################################################################## | |
############################################################################## | |
pause | |
get_voms_creds | |
printf "\n\n" | |
IFS=$'\n' | |
for FC_SITE_INFO in `cat ./egi_fc_sites.plain`; do | |
FC_SITE_ENDPOINT=`echo $FC_SITE_INFO | awk -F ' ' '{ print $1 }'` | |
FC_SITE_OS_TPL=`echo $FC_SITE_INFO | awk -F ' ' '{ print $2 }'` | |
FC_SITE_RES_TPL=`echo $FC_SITE_INFO | awk -F ' ' '{ print $3 }'` | |
printf "## Testing with site endpoint $FC_SITE_ENDPOINT ...\n" | |
sleep 3 | |
list_computes | |
pause | |
list_os_tpls | |
pause | |
list_resource_tpls | |
pause | |
create_compute | |
pause | |
list_computes | |
pause | |
describe_compute | |
pause | |
delete_compute | |
pause | |
printf "\nMoving on to another EGI FedCloud site ...\n\n\n" | |
sleep 3 | |
done | |
unset IFS | |
printf "We are done here!\n" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment