| tierno | c94c3df | 2018-02-09 15:38:54 +0100 | [diff] [blame] | 1 | #! /bin/bash |
| 2 | |
| tierno | d125caf | 2018-11-22 16:05:54 +0000 | [diff] [blame] | 3 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | # you may not use this file except in compliance with the License. |
| 5 | # You may obtain a copy of the License at |
| 6 | # |
| 7 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | # |
| 9 | # Unless required by applicable law or agreed to in writing, software |
| 10 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or |
| 12 | # implied. |
| 13 | # See the License for the specific language governing permissions and |
| 14 | # limitations under the License. |
| 15 | |
| tierno | c94c3df | 2018-02-09 15:38:54 +0100 | [diff] [blame] | 16 | export NBI_URL=https://localhost:9999/osm |
| 17 | USERNAME=admin |
| 18 | PASSWORD=admin |
| 19 | PROJECT=admin |
| 20 | VIM=ost2-mrt-tid #OST2_MRT #ost2-mrt-tid |
| 21 | |
| 22 | DESCRIPTORS=/home/ubuntu/descriptors #../local/descriptors |
| 23 | DESCRIPTORS=../local/descriptors |
| 24 | |
| 25 | VNFD1=${DESCRIPTORS}/ping_vnf.tar.gz |
| 26 | VNFD2=${DESCRIPTORS}/pong_vnf.tar.gz |
| 27 | VNFD3=${DESCRIPTORS}/cirros_vnfd.yaml |
| 28 | |
| 29 | NSD1=${DESCRIPTORS}/ping_pong_ns.tar.gz |
| 30 | NSD2=${DESCRIPTORS}/cirros_2vnf_ns.tar.gz |
| 31 | NSD3=${DESCRIPTORS}/cirros_nsd.yaml |
| 32 | |
| 33 | [ -f "$VNFD1" ] || ! echo "not found ping_vnf.tar.gz. Set DESCRIPTORS variable to a proper location" || exit 1 |
| 34 | [ -f "$VNFD2" ] || ! echo "not found pong_vnf.tar.gz. Set DESCRIPTORS variable to a proper location" || exit 1 |
| 35 | [ -f "$VNFD3" ] || ! echo "not found cirros_vnfd.yaml. Set DESCRIPTORS variable to a proper location" || exit 1 |
| 36 | [ -f "$NSD1" ] || ! echo "not found ping_pong_ns.tar.gz. Set DESCRIPTORS variable to a proper location" || exit 1 |
| 37 | [ -f "$NSD2" ] || ! echo "not found cirros_2vnf_ns.tar.gz. Set DESCRIPTORS variable to a proper location" || exit 1 |
| 38 | [ -f "$NSD3" ] || ! echo "not found cirros_nsd.yaml. Set DESCRIPTORS variable to a proper location" || exit 1 |
| 39 | |
| 40 | #get token |
| tierno | f27c79b | 2018-03-12 17:08:42 +0100 | [diff] [blame] | 41 | TOKEN=`curl --insecure -H "Content-Type: application/yaml" -H "Accept: application/yaml" \ |
| 42 | --data "{username: $USERNAME, password: $PASSWORD, project_id: $PROJECT}" ${NBI_URL}/admin/v1/tokens \ |
| 43 | 2>/dev/null | awk '($1=="id:"){print $2}'`; |
| tierno | c94c3df | 2018-02-09 15:38:54 +0100 | [diff] [blame] | 44 | echo token: $TOKEN |
| 45 | |
| tierno | c94c3df | 2018-02-09 15:38:54 +0100 | [diff] [blame] | 46 | # VNFD |
| 47 | ######### |
| 48 | #insert PKG |
| tierno | f27c79b | 2018-03-12 17:08:42 +0100 | [diff] [blame] | 49 | VNFD1_ID=`curl --insecure -w "%{http_code}\n" -H "Content-Type: application/gzip" -H "Accept: application/yaml" \ |
| 50 | -H "Authorization: Bearer $TOKEN" --data-binary "@$VNFD1" ${NBI_URL}/vnfpkgm/v1/vnf_packages_content \ |
| 51 | 2>/dev/null | awk '($1=="id:"){print $2}'` |
| tierno | c94c3df | 2018-02-09 15:38:54 +0100 | [diff] [blame] | 52 | echo ping_vnfd: $VNFD1_ID |
| 53 | |
| tierno | f27c79b | 2018-03-12 17:08:42 +0100 | [diff] [blame] | 54 | VNFD2_ID=`curl --insecure -w "%{http_code}\n" -H "Content-Type: application/gzip" -H "Accept: application/yaml" \ |
| 55 | -H "Authorization: Bearer $TOKEN" --data-binary "@$VNFD2" ${NBI_URL}/vnfpkgm/v1/vnf_packages_content \ |
| 56 | 2>/dev/null | awk '($1=="id:"){print $2}'` |
| tierno | c94c3df | 2018-02-09 15:38:54 +0100 | [diff] [blame] | 57 | echo pong_vnfd: $VNFD2_ID |
| 58 | |
| tierno | c94c3df | 2018-02-09 15:38:54 +0100 | [diff] [blame] | 59 | # NSD |
| 60 | ######### |
| 61 | #insert PKG |
| tierno | f27c79b | 2018-03-12 17:08:42 +0100 | [diff] [blame] | 62 | NSD1_ID=`curl --insecure -w "%{http_code}\n" -H "Content-Type: application/gzip" -H "Accept: application/yaml" \ |
| 63 | -H "Authorization: Bearer $TOKEN" --data-binary "@$NSD1" ${NBI_URL}/nsd/v1/ns_descriptors_content \ |
| 64 | 2>/dev/null | awk '($1=="id:"){print $2}'` |
| tierno | c94c3df | 2018-02-09 15:38:54 +0100 | [diff] [blame] | 65 | echo ping_pong_nsd: $NSD1_ID |
| 66 | |
| tierno | c94c3df | 2018-02-09 15:38:54 +0100 | [diff] [blame] | 67 | # NSRS |
| 68 | ############## |
| 69 | #add nsr |
| tierno | f27c79b | 2018-03-12 17:08:42 +0100 | [diff] [blame] | 70 | NSR1_ID=`curl --insecure -w "%{http_code}\n" -H "Content-Type: application/yaml" -H "Accept: application/yaml" \ |
| 71 | -H "Authorization: Bearer $TOKEN" --data "{ nsDescription: default description, nsName: NSNAME, nsdId: $NSD1_ID, \ |
| 72 | ssh-authorized-key: [ {key-pair-ref: gerardo}, {key-pair-ref: alfonso}], vimAccountId: $VIM }" \ |
| 73 | ${NBI_URL}/nslcm/v1/ns_instances_content 2>/dev/null | awk '($1=="id:"){print $2}'` ; |
| tierno | c94c3df | 2018-02-09 15:38:54 +0100 | [diff] [blame] | 74 | echo ping_pong_nsr: $NSR1_ID |
| 75 | |
| 76 | |
| tierno | f27c79b | 2018-03-12 17:08:42 +0100 | [diff] [blame] | 77 | echo 'curl --insecure -w "%{http_code}\n" -H "Content-Type: application/yaml" -H "Accept: application/yaml"' \ |
| 78 | '-H "Authorization: Bearer '$TOKEN'" '${NBI_URL}'/nslcm/v1/ns_instances_content/'$NSR1_ID' 2>/dev/null | ' \ |
| 79 | 'grep -e detailed-status -e operational-status -e config-status' |
| tierno | c94c3df | 2018-02-09 15:38:54 +0100 | [diff] [blame] | 80 | |
| 81 | |
| 82 | |
| 83 | |