4 SCRIPTNAME=`basename $0`
8 # Initialize some of the variables
9 if [ "$RIFT_LP_ADDR" = "" ]; then
10 RIFT_LP_ADDR="localhost"
17 RIFT_LP_PKG_UPLOAD_URL="https://${RIFT_LP_ADDR}:4567/api/upload"
19 ######################################################################
22 ######################################################################
25 usage $SCRIPTNAME [-h] [-r launchpad-ip][-u upload-package][-i ns-service-name [-d descriptor-id]][-l]
26 -h : show this message
27 -r : launchpad ip address - defaults to RIFT_LP_ADDR enviroment variable
28 -u : upload package with the package name specified
29 -i : Instantiate a network service with network service name
30 -d : Instantiate a network service with the specified descriptor
35 ######################################################################
36 # Function:validate_args #
37 # Validates the passed arguments #
38 ######################################################################
39 function validate_args () {
40 if [ "$RIFT_LP_ADDR" = "" ]; then
41 echo "RIFT LP address must be specified - set RIFT_LP_ADDR or specify -l option"
45 if [ "${#PKGS[@]}" -eq 0 -a "${INSTANTIATE}" -eq 0 ]; then
46 echo "One of -u or -i option must be specified"
50 if [ "${INSTANTIATE}" -eq 1 ]; then
51 if [ "${NS_NAME}" = "" -o "${DESC_ID}" = "" ]; then
52 echo "Must specify both descriptor id and ns service name when -i is specified"
59 ######################################################################
60 # Function:upload_pacakage #
61 # Uploads a package with the passed argument #
62 ######################################################################
63 function upload_package() {
65 echo "upload_package: package name should be passed in as an argument"
70 curl --insecure -F "descriptor=@${PACKAGE}" ${RIFT_LP_PKG_UPLOAD_URL}
73 ######################################################################
74 # Function:instantiate_ns #
75 # Instantiates a netork service #
76 ######################################################################
77 function instantiate_ns() {
78 echo "instantiate_ns need implementation"
82 while getopts ":hl:r:u:i:n:" OPTION
91 RIFT_LP_PKG_UPLOAD_URL="https://${RIFT_LP_ADDR}:4567/api/upload"
117 if [ $LOGGING -eq 1 ]; then
119 LOGFILE="$LOGDIR/$SCRIPTNAME-$DATE.log"
120 echo "Logging to file $LOGFILE"
122 # Redirect stdout ( > ) and stderr to file
123 # and store the STDOUT and STDERR for later use
130 echo "Started at $DATE"
132 # Iterate through the packages and upload them
133 for PKG in "${PKGS[@]}"
135 echo "Uploading package $PKG"
140 if [ "${INSTANTIATE}" -eq 1 ]; then
141 instantiate_ns $DESC_ID
144 echo "Ended at $DATE"