3 from ...lib
.ssh
import *
4 from ...lib
.test_utils
import *
7 @pytest.fixture(autouse
=True)
8 def pre_launch_openvim_service():
10 Fixture to be executed before test
11 :param request: argument for a fixture... can be a list, dict, etc
15 service_path
= os
.path
.join(os
.environ
['OPENVIM_ROOT_FOLDER'], 'scripts', 'service-openvim')
17 execute_local('{} stop'.format(service_path
))
18 print "launching service openvim"
19 execute_local('{} start'.format(service_path
))
20 out
= execute_local('{} -h '.format(service_path
))
24 def pre_create_flavor(request
):
26 Fixture to be executed before test
27 :param request: argument for a fixture... can be a list, dict, etc
31 if hasattr(request
, 'config'):
32 config_path
= request
.config
.getoption('config')
33 config
= get_config(config_path
)
34 flavor
= config
['flavor']
36 openvim_path
= os
.path
.join(os
.environ
['OPENVIM_ROOT_FOLDER'], 'openvim')
38 flavor_id
= execute_local("{} flavor-create {}".format(openvim_path
, flavor
))
39 flavor_id
= parse_uuid(flavor_id
)
41 os
.environ
['OPENVIM_TEST_FLAVOR'] = flavor_id
45 def pre_create_host(request
):
47 Fixture to be executed before test
48 :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
)
56 if config
['create_inf']:
57 hosts
= config
['host']
59 for key
, value
in hosts
.iteritems():
60 openvim_path
= os
.path
.join(os
.environ
['OPENVIM_ROOT_FOLDER'], 'openvim')
62 host_id
= execute_local("{} host-add {}".format(openvim_path
, value
))
63 host_id
= parse_uuid(host_id
)
65 os
.environ
['OPENVIM_TEST_HOST_' + str(counter
)] = host_id
70 def pre_create_image(request
):
72 Fixture to be executed before test
73 :param request: argument for a fixture... can be a list, dict, etc
77 if hasattr(request
, 'config'):
78 config_path
= request
.config
.getoption('config')
79 config
= get_config(config_path
)
82 openvim_path
= os
.path
.join(os
.environ
['OPENVIM_ROOT_FOLDER'], 'openvim')
83 image_id
= execute_local("{} image-create {}".format(openvim_path
, img
))
84 image_id
= parse_uuid(image_id
)
86 os
.environ
['OPENVIM_TEST_IMAGE'] = image_id
90 def pre_create_image(request
):
92 Fixture to be executed before test
93 :param request: argument for a fixture... can be a list, dict, etc
97 if hasattr(request
, 'config'):
98 config_path
= request
.config
.getoption('config')
99 config
= get_config(config_path
)
100 img
= config
['image']
101 openvim_path
= os
.path
.join(os
.environ
['OPENVIM_ROOT_FOLDER'], 'openvim')
102 image_id
= execute_local("{} image-create {}".format(openvim_path
, img
))
103 image_id
= parse_uuid(image_id
)
105 os
.environ
['OPENVIM_TEST_IMAGE'] = image_id
109 def pre_create_net(request
):
111 Fixture to be executed before test
112 :param request: argument for a fixture... can be a list, dict, etc
115 if hasattr(request
, 'config'):
116 config_path
= request
.config
.getoption('config')
117 config
= get_config(config_path
)
118 if config
['create_inf']:
119 net_yaml
= config
['net']
120 openvim_path
= os
.path
.join(os
.environ
['OPENVIM_ROOT_FOLDER'], 'openvim')
121 net_id
= execute_local("{} net-create {}".format(openvim_path
, net_yaml
))
122 net_id
= parse_uuid(net_id
)
125 vlan
= execute_local("{} net-list {} -vvv | grep provider:vlan:".format(openvim_path
, net_id
))
126 vlan
= vlan
.replace('provider:vlan:','')
127 vlan
= vlan
.replace(' ', '')
128 vlan
= vlan
.replace('\n', '')
130 os
.environ
['OPENVIM_TEST_MGMT_NET'] = net_id
131 os
.environ
['OPENVIM_TEST_MGMT_NET_VLAN'] = vlan
135 def pre_create_tenant(request
):
137 Fixture to be executed before test
138 :param request: argument for a fixture... can be a list, dict, etc
143 if hasattr(request
, 'config'):
144 config_path
= request
.config
.getoption('config')
145 config
= get_config(config_path
)
146 tenant_yaml
= config
['tenant']
147 openvim_path
= os
.path
.join(os
.environ
['OPENVIM_ROOT_FOLDER'], 'openvim')
149 tenant_id
= execute_local("{} tenant-create {}".format(openvim_path
, tenant_yaml
))
150 tenant_id
= parse_uuid(tenant_id
)
152 os
.environ
['OPENVIM_TENANT'] = tenant_id
156 def pre_init_db(request
):
158 Fixture to be executed before test
159 :param request: argument for a fixture... can be a list, dict, etc
163 if hasattr(request
, 'config'):
164 config_path
= request
.config
.getoption('config')
165 config
= get_config(config_path
)
166 if config
['create_inf']:
167 init_db_path
= os
.path
.join(os
.environ
['OPENVIM_ROOT_FOLDER'], 'database_utils', 'init_vim_db.sh')
168 execute_local('{}'.format(init_db_path
))