Added system test for descriptors
[osm/NBI.git] / osm_nbi / tests / create-ping-pong.sh
1 #! /bin/bash
2
3 export NBI_URL=https://localhost:9999/osm
4 USERNAME=admin
5 PASSWORD=admin
6 PROJECT=admin
7 VIM=ost2-mrt-tid #OST2_MRT #ost2-mrt-tid
8
9 DESCRIPTORS=/home/ubuntu/descriptors #../local/descriptors
10 DESCRIPTORS=../local/descriptors
11
12 VNFD1=${DESCRIPTORS}/ping_vnf.tar.gz
13 VNFD2=${DESCRIPTORS}/pong_vnf.tar.gz
14 VNFD3=${DESCRIPTORS}/cirros_vnfd.yaml
15
16 NSD1=${DESCRIPTORS}/ping_pong_ns.tar.gz
17 NSD2=${DESCRIPTORS}/cirros_2vnf_ns.tar.gz
18 NSD3=${DESCRIPTORS}/cirros_nsd.yaml
19
20 [ -f "$VNFD1" ] || ! echo "not found ping_vnf.tar.gz. Set DESCRIPTORS variable to a proper location" || exit 1
21 [ -f "$VNFD2" ] || ! echo "not found pong_vnf.tar.gz. Set DESCRIPTORS variable to a proper location" || exit 1
22 [ -f "$VNFD3" ] || ! echo "not found cirros_vnfd.yaml. Set DESCRIPTORS variable to a proper location" || exit 1
23 [ -f "$NSD1" ] || ! echo "not found ping_pong_ns.tar.gz. Set DESCRIPTORS variable to a proper location" || exit 1
24 [ -f "$NSD2" ] || ! echo "not found cirros_2vnf_ns.tar.gz. Set DESCRIPTORS variable to a proper location" || exit 1
25 [ -f "$NSD3" ] || ! echo "not found cirros_nsd.yaml. Set DESCRIPTORS variable to a proper location" || exit 1
26
27 #get token
28 TOKEN=`curl --insecure -H "Content-Type: application/yaml" -H "Accept: application/yaml" \
29 --data "{username: $USERNAME, password: $PASSWORD, project_id: $PROJECT}" ${NBI_URL}/admin/v1/tokens \
30 2>/dev/null | awk '($1=="id:"){print $2}'`;
31 echo token: $TOKEN
32
33
34 # VNFD
35 #########
36 #insert PKG
37 VNFD1_ID=`curl --insecure -w "%{http_code}\n" -H "Content-Type: application/gzip" -H "Accept: application/yaml" \
38 -H "Authorization: Bearer $TOKEN" --data-binary "@$VNFD1" ${NBI_URL}/vnfpkgm/v1/vnf_packages_content \
39 2>/dev/null | awk '($1=="id:"){print $2}'`
40 echo ping_vnfd: $VNFD1_ID
41
42 VNFD2_ID=`curl --insecure -w "%{http_code}\n" -H "Content-Type: application/gzip" -H "Accept: application/yaml" \
43 -H "Authorization: Bearer $TOKEN" --data-binary "@$VNFD2" ${NBI_URL}/vnfpkgm/v1/vnf_packages_content \
44 2>/dev/null | awk '($1=="id:"){print $2}'`
45 echo pong_vnfd: $VNFD2_ID
46
47
48
49 # NSD
50 #########
51 #insert PKG
52 NSD1_ID=`curl --insecure -w "%{http_code}\n" -H "Content-Type: application/gzip" -H "Accept: application/yaml" \
53 -H "Authorization: Bearer $TOKEN" --data-binary "@$NSD1" ${NBI_URL}/nsd/v1/ns_descriptors_content \
54 2>/dev/null | awk '($1=="id:"){print $2}'`
55 echo ping_pong_nsd: $NSD1_ID
56
57
58 # NSRS
59 ##############
60 #add nsr
61 NSR1_ID=`curl --insecure -w "%{http_code}\n" -H "Content-Type: application/yaml" -H "Accept: application/yaml" \
62 -H "Authorization: Bearer $TOKEN" --data "{ nsDescription: default description, nsName: NSNAME, nsdId: $NSD1_ID, \
63 ssh-authorized-key: [ {key-pair-ref: gerardo}, {key-pair-ref: alfonso}], vimAccountId: $VIM }" \
64 ${NBI_URL}/nslcm/v1/ns_instances_content 2>/dev/null | awk '($1=="id:"){print $2}'` ;
65 echo ping_pong_nsr: $NSR1_ID
66
67
68 echo 'curl --insecure -w "%{http_code}\n" -H "Content-Type: application/yaml" -H "Accept: application/yaml"' \
69 '-H "Authorization: Bearer '$TOKEN'" '${NBI_URL}'/nslcm/v1/ns_instances_content/'$NSR1_ID' 2>/dev/null | ' \
70 'grep -e detailed-status -e operational-status -e config-status'
71
72
73
74