3 from ...lib
.test_utils
import *
6 @pytest.fixture(autouse
=True)
7 def post_install_service():
9 Fixture to be executed before test
10 :param request: argument for a fixture... can be a list, dict, etc
14 yield post_install_service
15 print "Stoping service openvim "
16 service_path
= os
.path
.join(os
.environ
['OPENVIM_ROOT_FOLDER'], 'scripts', 'service-openvim')
17 execute_local("{} stop".format(service_path
))
21 def post_delete_server(request
):
23 Fixture to be executed before test
24 :param request: argument for a fixture... can be a list, dict, etc
29 yield post_delete_server
31 if hasattr(request
, 'config'):
32 config_path
= request
.config
.getoption('config')
33 config
= get_config(config_path
)
35 if config
['create_inf']:
36 vm_id
= os
.environ
['OPENVIM_VM']
37 openvim_path
= os
.path
.join(os
.environ
['OPENVIM_ROOT_FOLDER'], 'openvim')
38 execute_local("{} vm-delete {}".format(openvim_path
, vm_id
))
42 def post_delete_net(request
):
44 Fixture to be executed before test
45 :param request: argument for a fixture... can be a list, dict, etc
52 if hasattr(request
, 'config'):
53 config_path
= request
.config
.getoption('config')
54 config
= get_config(config_path
)
55 if config
['create_inf']:
56 net_id
= os
.environ
['OPENVIM_TEST_MGMT_NET']
57 openvim_path
= os
.path
.join(os
.environ
['OPENVIM_ROOT_FOLDER'], 'openvim')
58 execute_local("{} net-delete -f {}".format(openvim_path
, net_id
))
64 Fixture to be executed after test
69 openvim_path
= os
.path
.join(os
.environ
['OPENVIM_ROOT_FOLDER'], 'openvim')
70 out
= execute_local('{} vm-delete -f'.format(openvim_path
))
74 def post_delete_flavor():
76 Fixture to be executed before test
77 :param request: argument for a fixture... can be a list, dict, etc
82 yield post_delete_flavor
84 flavor_id
= os
.environ
['OPENVIM_TEST_FLAVOR']
85 openvim_path
= os
.path
.join(os
.environ
['OPENVIM_ROOT_FOLDER'], 'openvim')
86 execute_local("{} flavor-delete -f {}".format(openvim_path
, flavor_id
))
90 def post_delete_image():
92 Fixture to be executed before test
93 :param request: argument for a fixture... can be a list, dict, etc
98 yield post_delete_image
100 img_id
= os
.environ
['OPENVIM_TEST_IMAGE']
101 openvim_path
= os
.path
.join(os
.environ
['OPENVIM_ROOT_FOLDER'], 'openvim')
102 execute_local("{} image-delete -f {}".format(openvim_path
, img_id
))
106 def post_delete_host(request
):
108 Fixture to be executed before test
109 :param request: argument for a fixture... can be a list, dict, etc
114 yield post_delete_host
116 if hasattr(request
, 'config'):
117 config_path
= request
.config
.getoption('config')
118 config
= get_config(config_path
)
119 if config
['create_inf']:
120 host_ids
= search_host_in_env_var()
121 for host_ids
in host_ids
:
122 openvim_path
= os
.path
.join(os
.environ
['OPENVIM_ROOT_FOLDER'], 'openvim')
123 execute_local("{} host-remove -f {}".format(openvim_path
, os
.environ
[host_ids
]))