#!/bin/bash

# Rest API configuration
pong_mgmt_ip='<rw_mgmt_ip>'
pong_mgmt_port=18889

# Test
# username=<rw_username>
# password=<rw_password>

# VNF specific configuration
pong_server_ip='<rw_connection_point_name pong_vnfd/cp0>'
server_port=5555

# Make Rest API calls to configure VNF
curl -D /dev/stdout \
    -H "Accept: application/vnd.yang.data+xml" \
    -H "Content-Type: application/vnd.yang.data+json" \
    -X POST \
    -d "{\"ip\":\"$pong_server_ip\", \"port\":$server_port}" \
    http://${pong_mgmt_ip}:${pong_mgmt_port}/api/v1/pong/server
rc=$?
if [ $rc -ne 0 ]
then
    echo "Failed to set server(own) info for pong!"
    exit $rc
fi

curl -D /dev/stdout \
    -H "Accept: application/vnd.yang.data+xml" \
    -H "Content-Type: application/vnd.yang.data+json" \
    -X POST \
    -d "{\"enable\":true}" \
    http://${pong_mgmt_ip}:${pong_mgmt_port}/api/v1/pong/adminstatus/state
rc=$?
if [ $rc -ne 0 ]
then
    echo "Failed to enable pong service!"
    exit $rc
fi

exit 0
