#!/bin/bash
#
# Before you use this script, you must configure restfully
#
#
# Get the username from the restfully configuration.
#
USER=`grep user ~/.restfully/api.bonfire-project.eu.yml | cut -f2 -d:`
USER=`echo $USER`
#
# Where the JSON file is saved
#
FILE=../examples/vcoc.json
#
# Version
#
VERSION=0.1
#
# Now Create the JSON file
#
echo { > $FILE
echo \"name\": \"Virtual Cluster Demo Experiment\", >> $FILE
echo \"description\": \"Demo Virtual Cluster\", >> $FILE
#
# Minutes for the experiment
#
echo \"duration\": 180, >> $FILE
echo \"resources\": [ >> $FILE
echo { >> $FILE
#
# The master of the custer is defined
# It includes the master defined VM plus an additional storage
# You must create both before execute this script using:
# Master VM: build-master.rb
# Storage : build-storages.rb
#
echo " " \"compute\": { >> $FILE
echo " " \"name\": \"master\", >> $FILE
echo " " \"description\": \"Virtual Cluster Master\", >> $FILE
echo " " \"instanceType\": \"small\", >> $FILE
echo " " \"locations\": [\"fr-inria\"], >> $FILE
echo " " \"resources\": [ >> $FILE
echo " " { \"storage\": \"@VirtualClusterMaster-vcocdemo-v${VERSION}\"}, >> $FILE
echo " " { \"storage\": \"@${USER}_volume-1GB-empty\"}, >> $FILE
echo " " { \"network\": \"@BonFIRE WAN\"} >> $FILE
echo " " ], >> $FILE
echo " " \"contexts\": [ >> $FILE
echo " " { >> $FILE
echo " " } >> $FILE
echo " "] >> $FILE
echo " " } >> $FILE
echo }, >> $FILE
#
# Now, the compute element is added
#
# Previously, you must execute the build-client.rb script, so VM image is ready.
#
echo { >> $FILE
echo " " \"compute\": { >> $FILE
echo " " \"name\": \"client\", >> $FILE
echo " " \"description\": \"Virtual Cluster Client\", >> $FILE
echo " " \"instanceType\": \"small\", >> $FILE
echo " " \"locations\": [\"fr-inria\"], >> $FILE
echo " " \"resources\": [ >> $FILE
echo " " { \"storage\": \"@VirtualClusterClient-vcocdemo-v${VERSION}\"}, >> $FILE
echo " " { \"network\": \"@BonFIRE WAN\"} >> $FILE
echo " " ], >> $FILE
echo " " \"contexts\": [ >> $FILE
echo " " { >> $FILE
echo " " } >> $FILE
echo " " ] >> $FILE
echo " " } >> $FILE
echo } >> $FILE
echo ] >> $FILE
echo } >> $FILE
echo >> $FILE
echo JSON file $FILE has been created