blob: 47447a7e6e603c6087a4bdca109eebb3290108ec [file] [log] [blame]
tiernoc94c3df2018-02-09 15:38:54 +01001#! /bin/bash
2
tiernod125caf2018-11-22 16:05:54 +00003# 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
tiernoc94c3df2018-02-09 15:38:54 +010016export NBI_URL=https://localhost:9999/osm
17USERNAME=admin
18PASSWORD=admin
19PROJECT=admin
20VIM=ost2-mrt-tid #OST2_MRT #ost2-mrt-tid
21
22DESCRIPTORS=/home/ubuntu/descriptors #../local/descriptors
23DESCRIPTORS=../local/descriptors
24
25VNFD1=${DESCRIPTORS}/ping_vnf.tar.gz
26VNFD2=${DESCRIPTORS}/pong_vnf.tar.gz
27VNFD3=${DESCRIPTORS}/cirros_vnfd.yaml
28
29NSD1=${DESCRIPTORS}/ping_pong_ns.tar.gz
30NSD2=${DESCRIPTORS}/cirros_2vnf_ns.tar.gz
31NSD3=${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
tiernof27c79b2018-03-12 17:08:42 +010041TOKEN=`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}'`;
tiernoc94c3df2018-02-09 15:38:54 +010044echo token: $TOKEN
45
tiernoc94c3df2018-02-09 15:38:54 +010046# VNFD
47#########
48#insert PKG
tiernof27c79b2018-03-12 17:08:42 +010049VNFD1_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}'`
tiernoc94c3df2018-02-09 15:38:54 +010052echo ping_vnfd: $VNFD1_ID
53
tiernof27c79b2018-03-12 17:08:42 +010054VNFD2_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}'`
tiernoc94c3df2018-02-09 15:38:54 +010057echo pong_vnfd: $VNFD2_ID
58
tiernoc94c3df2018-02-09 15:38:54 +010059# NSD
60#########
61#insert PKG
tiernof27c79b2018-03-12 17:08:42 +010062NSD1_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}'`
tiernoc94c3df2018-02-09 15:38:54 +010065echo ping_pong_nsd: $NSD1_ID
66
tiernoc94c3df2018-02-09 15:38:54 +010067# NSRS
68##############
69#add nsr
tiernof27c79b2018-03-12 17:08:42 +010070NSR1_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}'` ;
tiernoc94c3df2018-02-09 15:38:54 +010074echo ping_pong_nsr: $NSR1_ID
75
76
tiernof27c79b2018-03-12 17:08:42 +010077echo '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'
tiernoc94c3df2018-02-09 15:38:54 +010080
81
82
83