3 # Copyright 2016 RIFT.IO Inc
5 # Licensed under the Apache License, Version 2.0 (the "License");
6 # you may not use this file except in compliance with the License.
7 # You may obtain a copy of the License at
9 # http://www.apache.org/licenses/LICENSE-2.0
11 # Unless required by applicable law or agreed to in writing, software
12 # distributed under the License is distributed on an "AS IS" BASIS,
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 # See the License for the specific language governing permissions and
15 # limitations under the License.
25 from gi
.repository
import (
26 ProjectNsdYang
as NsdYang
,
32 RwProjectVnfdYang
as RwVnfdYang
,
37 @pytest.fixture(scope
='session', autouse
=True)
38 def cloud_account_name(request
):
39 '''fixture which returns the name used to identify the cloud account'''
42 @pytest.fixture(scope
='session')
43 def launchpad_host(request
, confd_host
):
46 @pytest.fixture(scope
='session')
47 def vnfd_proxy(request
, mgmt_session
):
48 return mgmt_session
.proxy(RwVnfdYang
)
50 @pytest.fixture(scope
='session')
51 def vnfr_proxy(request
, mgmt_session
):
52 return mgmt_session
.proxy(VnfrYang
)
54 @pytest.fixture(scope
='session')
55 def rwvnfr_proxy(request
, mgmt_session
):
56 return mgmt_session
.proxy(RwVnfrYang
)
58 @pytest.fixture(scope
='session')
59 def vld_proxy(request
, mgmt_session
):
60 return mgmt_session
.proxy(VldYang
)
62 @pytest.fixture(scope
='session')
63 def nsd_proxy(request
, mgmt_session
):
64 return mgmt_session
.proxy(NsdYang
)
66 @pytest.fixture(scope
='session')
67 def nsr_proxy(request
, mgmt_session
):
68 return mgmt_session
.proxy(NsrYang
)
70 @pytest.fixture(scope
='session')
71 def rwnsr_proxy(request
, mgmt_session
):
72 return mgmt_session
.proxy(RwNsrYang
)
74 @pytest.fixture(scope
='session')
75 def base_proxy(request
, mgmt_session
):
76 return mgmt_session
.proxy(RwBaseYang
)
78 @pytest.fixture(scope
='session')
79 def base_proxy(request
, mgmt_session
):
80 return mgmt_session
.proxy(RwBaseYang
)
82 @pytest.fixture(scope
='session')
83 def mvv_descr_dir(request
):
84 """root-directory of descriptors files used for Multi-VM VNF"""
86 os
.environ
["RIFT_INSTALL"],
87 "demos/tests/multivm_vnf"
90 @pytest.fixture(scope
='session')
91 def package_dir(request
):
92 return tempfile
.mkdtemp(prefix
="mvv_")
94 @pytest.fixture(scope
='session')
95 def trafgen_vnfd_package_file(request
, package_gen_script
, mvv_descr_dir
, package_dir
):
96 pkg_cmd
= "{pkg_scr} --descriptor-type='vnfd' --format='xml' --infile='{infile}' --outdir='{outdir}'".format(
97 pkg_scr
=package_gen_script
,
99 infile
=os
.path
.join(mvv_descr_dir
, 'vnfd/xml/multivm_trafgen_vnfd.xml'))
100 pkg_file
= os
.path
.join(package_dir
, 'multivm_trafgen_vnfd.tar.gz')
101 command
= shlex
.split(pkg_cmd
)
102 print("Running the command arguments: %s" % command
)
103 command
= [package_gen_script
,
104 "--descriptor-type", "vnfd",
106 "--infile", "%s" % os
.path
.join(mvv_descr_dir
, 'vnfd/xml/multivm_trafgen_vnfd.xml'),
107 "--outdir", "%s" % package_dir
]
108 print("Running new command arguments: %s" % command
)
109 subprocess
.check_call(command
)
112 @pytest.fixture(scope
='session')
113 def trafsink_vnfd_package_file(request
, package_gen_script
, mvv_descr_dir
, package_dir
):
114 pkg_cmd
= "{pkg_scr} --descriptor-type='vnfd' --format='xml' --infile='{infile}' --outdir='{outdir}'".format(
115 pkg_scr
=package_gen_script
,
117 infile
=os
.path
.join(mvv_descr_dir
, 'vnfd/xml/multivm_trafsink_vnfd.xml'))
118 pkg_file
= os
.path
.join(package_dir
, 'multivm_trafsink_vnfd.tar.gz')
119 command
= shlex
.split(pkg_cmd
)
120 print("Running the command arguments: %s" % command
)
121 command
= [package_gen_script
,
122 "--descriptor-type", "vnfd",
124 "--infile", "%s" % os
.path
.join(mvv_descr_dir
, 'vnfd/xml/multivm_trafsink_vnfd.xml'),
125 "--outdir", "%s" % package_dir
]
126 print("Running new command arguments: %s" % command
)
127 subprocess
.check_call(command
)
130 @pytest.fixture(scope
='session')
131 def slb_vnfd_package_file(request
, package_gen_script
, mvv_descr_dir
, package_dir
):
132 pkg_cmd
= "{pkg_scr} --outdir {outdir} --infile {infile} --descriptor-type vnfd --format xml".format(
133 pkg_scr
=package_gen_script
,
135 infile
=os
.path
.join(mvv_descr_dir
, 'vnfd/xml/multivm_slb_vnfd.xml'),
137 pkg_file
= os
.path
.join(package_dir
, 'multivm_slb_vnfd.tar.gz')
138 subprocess
.check_call(shlex
.split(pkg_cmd
))