6 echo "must supply ip for launchpad"
14 # make sure we're in a rift shell
17 echo "must be in a rift-shell"
21 # make sure the system is up
23 response=$(curl --silent --insecure \
25 --write-out "%{http_code}"\
27 https://${lp_ip}:8008/api/config/launchpad-config \
31 if [ ${response} -eq 200 ]
35 if [ ${response} -eq 404 ]
37 # not running a launchpad!
38 echo "riftware is running on ${lp_ip} but there is no launchpad-config"
45 #echo -n "wait for system"
54 # setup the openstack account
55 echo -n "adding account"
57 post_json_to_rwrest() {
60 echo "must supply url"
68 echo "must supply payload"
74 response=$(curl --silent --insecure \
75 --header "content-type:application/vnd.yang.data+json" \
76 --header "Accept:application/vnd.yang.data+json" \
78 https://${lp_ip}:8008${url} \
79 --request POST --data "${payload}" \
82 added_account=$(echo "${response}" | grep -e \"success|ok\" | wc -l)
83 already_exists=$(echo "${response}" | grep \"data-exists\" | wc -l)
84 success=$((added_account + already_exists))
91 \"account-type\": \"openstack\",
93 \"auth_url\": \"http://engstack.eng.riftio.com:5000/v3/\",
94 \"secret\": \"mypasswd\",
95 \"key\": \"${username}_automation\",
96 \"tenant\": \"${username}_automation\",
97 \"mgmt-network\": \"private\"
103 post_json_to_rwrest "/api/config/cloud/account" "${account_payload}"
105 if [ ${success} -ne 1 ];
107 echo -en "\r" # clear pending line
108 echo "failed to add cloud account:"
115 # onboard descriptors
116 cd $RIFT_BUILD/modules/core/mano/src/core_mano-build/examples/ping_pong_ns
121 echo "must supply transaction id to wait for"
126 response=$(curl --silent --insecure https://${lp_ip}:8008/api/operational/project/${project}/create-jobs/job/${transaction_id})
127 transaction_state=$(echo ${response} | awk -F "status" '{print $2}' | awk '{print $2}')
128 transaction_state=${transaction_state:1:-2}
130 if [ ${transaction_state} == "pending" ];
141 echo "must supply package to upload"
147 echo -n "upload ${package} package"
149 response=$(curl --silent --insecure -F "descriptor=@${package}" https://${lp_ip}:4567/api/upload)
150 transaction_id=$(echo ${response} | awk '{print $2}')
151 transaction_id=${transaction_id:1:-2}
153 while wait_for_package transaction_id
158 if [ ${transaction_state} == "failure" ];
169 upload_package "ping_vnfd.tar.gz"
170 ping_status=${status}
171 upload_package "pong_vnfd.tar.gz"
172 pong_status=${status}
174 success=$((ping_status + pong_status))
176 if [ ${success} -ne 0 ];
178 echo -en "\r" # clear pending line
179 echo "cannot on-board nsd when a vnfd fails"
183 upload_package "ping_pong_nsd.tar.gz"
184 if [ ${status} -ne 0 ];
186 echo -en "\r" # clear pending line
187 echo "failed to on-board nsd"
191 # instantiate ping_pong_nsd
192 echo "instantiate ping pong nsd"
194 tag=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 4 | head -n 1)
199 tar -xf ping_pong_nsd.tar.gz -C ${tmpdir}
201 nsdfile="${tmpdir}/ping_pong_nsd/ping_pong_nsd.yaml"
203 nsd_id=$(cat ${nsdfile} | grep "nsd:id" | head -n1 | awk '{print $2}')
207 nsr_id=$(cat /proc/sys/kernel/random/uuid)
211 \"id\":\"${nsr_id}\",
212 \"nsd-ref\":\"${nsd_id}\",
213 \"name\":\"${username}-${tag}-ping-pong-nsd\",
214 \"short-name\":\"pingpong\",
215 \"description\":\"ping pong nsd instantiated by ${username} with tag ${tag}\",
216 \"admin-status\":\"ENABLED\",
217 \"cloud-account\":\"OS\"
222 post_json_to_rwrest "/api/config/ns-instance-config" "${nsd_payload}"
224 if [ ${success} -ne 1 ];
226 echo -en "\r" # clear pending line
227 echo "failed to instantiate nsd:"