blob: 7ef1cf7d7331623438f20568fdc506c404d57218 [file] [log] [blame]
tiernoc94c3df2018-02-09 15:38:54 +01001#! /bin/bash
2
3export NBI_URL=https://localhost:9999/osm
4USERNAME=admin
5PASSWORD=admin
6PROJECT=admin
7VIM=ost2-mrt-tid #OST2_MRT #ost2-mrt-tid
8
9DESCRIPTORS=/home/ubuntu/descriptors #../local/descriptors
10DESCRIPTORS=../local/descriptors
11
12VNFD1=${DESCRIPTORS}/ping_vnf.tar.gz
13VNFD2=${DESCRIPTORS}/pong_vnf.tar.gz
14VNFD3=${DESCRIPTORS}/cirros_vnfd.yaml
15
16NSD1=${DESCRIPTORS}/ping_pong_ns.tar.gz
17NSD2=${DESCRIPTORS}/cirros_2vnf_ns.tar.gz
18NSD3=${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
tiernof27c79b2018-03-12 17:08:42 +010028TOKEN=`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}'`;
tiernoc94c3df2018-02-09 15:38:54 +010031echo token: $TOKEN
32
33
tiernoc94c3df2018-02-09 15:38:54 +010034# VNFD
35#########
36#insert PKG
tiernof27c79b2018-03-12 17:08:42 +010037VNFD1_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}'`
tiernoc94c3df2018-02-09 15:38:54 +010040echo ping_vnfd: $VNFD1_ID
41
tiernof27c79b2018-03-12 17:08:42 +010042VNFD2_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}'`
tiernoc94c3df2018-02-09 15:38:54 +010045echo pong_vnfd: $VNFD2_ID
46
47
48
49# NSD
50#########
51#insert PKG
tiernof27c79b2018-03-12 17:08:42 +010052NSD1_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}'`
tiernoc94c3df2018-02-09 15:38:54 +010055echo ping_pong_nsd: $NSD1_ID
56
57
58# NSRS
59##############
60#add nsr
tiernof27c79b2018-03-12 17:08:42 +010061NSR1_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}'` ;
tiernoc94c3df2018-02-09 15:38:54 +010065echo ping_pong_nsr: $NSR1_ID
66
67
tiernof27c79b2018-03-12 17:08:42 +010068echo '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'
tiernoc94c3df2018-02-09 15:38:54 +010071
72
73
74