forked from sonata-nfv/son-catalogue-repos
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Rakefile
100 lines (90 loc) · 4.88 KB
/
Rakefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
##
## Copyright (c) 2015 SONATA-NFV
## ALL RIGHTS RESERVED.
##
## Licensed under the Apache License, Version 2.0 (the "License");
## you may not use this file except in compliance with the License.
## You may obtain a copy of the License at
##
## http://www.apache.org/licenses/LICENSE-2.0
##
## Unless required by applicable law or agreed to in writing, software
## distributed under the License is distributed on an "AS IS" BASIS,
## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
## See the License for the specific language governing permissions and
## limitations under the License.
##
## Neither the name of the SONATA-NFV [, ANY ADDITIONAL AFFILIATION]
## nor the names of its contributors may be used to endorse or promote
## products derived from this software without specific prior written
## permission.
##
## This work has been performed in the framework of the SONATA project,
## funded by the European Commission under Grant number 671517 through
## the Horizon 2020 and 5G-PPP programmes. The authors would like to
## acknowledge the contributions of their colleagues of the SONATA
## partner consortium (www.sonata-nfv.eu).
require 'yard'
require 'rspec/core/rake_task'
require 'ci/reporter/rake/rspec'
require './main'
task default: ['ci:all']
desc 'Start the service'
task :start do
puts 'SON CATALOGUE-REPOSITORY STARTING...'
conf = File.expand_path('config.ru', File.dirname(__FILE__))
exec("puma #{conf} -b tcp://0.0.0.0:4011")
end
desc 'Run Unit Tests'
RSpec::Core::RakeTask.new :specs do |task|
task.pattern = Dir['spec/**/*_spec.rb']
end
YARD::Rake::YardocTask.new do |t|
t.files = %w(main.rb helpers/*.rb routes/*.rb)
end
namespace :ci do
task all: %w(ci:setup:rspec specs)
end
namespace :db do
task :load_config do
require './main'
end
end
namespace :init do
require 'fileutils'
desc 'Fill Catalogues with default sonata-demo package contents'
task :load_samples, :server do |_, args|
server = ''
case args[:server]
when 'development'
server = 'sp.int'
when 'integration'
server = 'sp.int3'
else
puts 'Invalid argument'
halt
end
firewall_sample = 'samples/sonata-demo/function-descriptor/firewall-vnfd.yml'
iperf_sample = 'samples/sonata-demo/function-descriptor/iperf-vnfd.yml'
tcpdump_sample = 'samples/sonata-demo/function-descriptor/tcpdump-vnfd.yml'
nsd_sample = 'samples/sonata-demo/service-descriptor/sonata-demo.yml'
pd_sample = 'samples/sonata-demo/package-descriptor/sonata-demo.yml'
vnfr_random_sample = 'samples/sonata-demo/function-record/random-vnfr.yml'
## vtc_sample = 'samples/sonata-demo-1/function-descriptor/vtc-vnfd.yml'
## nsd1_sample = 'samples/sonata-demo-1/service-descriptor/sonata-demo.yml'
nsd2_sample = 'samples/sonata-demo-fw-vtc/service-descriptor/sonata-demo.yml'
vfw_sample = 'samples/sonata-demo-fw-vtc/function-descriptor/fw-vnf-vnfd.yml'
vtc1_sample = 'samples/sonata-demo-fw-vtc/function-descriptor/vtc-vnf-vnfd.yml'
## sh "curl -X POST -H \"Content-Type: application/x-yaml\" --data-binary @#{ nsd1_sample } --connect-timeout 30 http://#{ server }.sonata-nfv.eu:4002/catalogues/network-services"
sh "curl -X POST -H \"Content-Type: application/x-yaml\" --data-binary @#{ nsd2_sample } --connect-timeout 30 http://#{ server }.sonata-nfv.eu:4002/catalogues/network-services"
## sh "curl -X POST -H \"Content-Type: application/x-yaml\" --data-binary @#{ vtc_sample } --connect-timeout 30 http://#{ server }.sonata-nfv.eu:4002/catalogues/vnfs"
sh "curl -X POST -H \"Content-Type: application/x-yaml\" --data-binary @#{ vtc1_sample } --connect-timeout 30 http://#{ server }.sonata-nfv.eu:4002/catalogues/vnfs"
sh "curl -X POST -H \"Content-Type: application/x-yaml\" --data-binary @#{ vfw_sample } --connect-timeout 30 http://#{ server }.sonata-nfv.eu:4002/catalogues/vnfs"
sh "curl -X POST -H \"Content-Type: application/x-yaml\" --data-binary @#{ firewall_sample } --connect-timeout 30 http://#{ server }.sonata-nfv.eu:4002/catalogues/vnfs"
sh "curl -X POST -H \"Content-Type: application/x-yaml\" --data-binary @#{ iperf_sample } --connect-timeout 30 http://#{ server }.sonata-nfv.eu:4002/catalogues/vnfs"
sh "curl -X POST -H \"Content-Type: application/x-yaml\" --data-binary @#{ tcpdump_sample } --connect-timeout 30 http://#{ server }.sonata-nfv.eu:4002/catalogues/vnfs"
sh "curl -X POST -H \"Content-Type: application/x-yaml\" --data-binary @#{ nsd_sample } --connect-timeout 30 http://#{ server }.sonata-nfv.eu:4002/catalogues/network-services"
sh "curl -X POST -H \"Content-Type: application/x-yaml\" --data-binary @#{ pd_sample } --connect-timeout 30 http://#{ server }.sonata-nfv.eu:4002/catalogues/packages"
sh "curl -X POST -H \"Content-Type: application/x-yaml\" --data-binary @#{ vnfr_random_sample } --connect-timeout 30 http://#{ server }.sonata-nfv.eu:4002/records/vnfr/vnf-instances"
end
end