forked from Juniper/contrail-test
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvnc_api_test.py
48 lines (41 loc) · 1.76 KB
/
vnc_api_test.py
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
import fixtures
from vnc_api.vnc_api import *
#from contrail_fixtures import contrail_fix_ext
#@contrail_fix_ext (ignore_verify=True, ignore_verify_on_setup=True)
class VncLibFixture(fixtures.Fixture):
def __init__(self, domain, project, cfgm_ip, api_port, inputs , username='admin', password='contrail123' ):
self.username= username
self.password= password
self.project= project
self.domain = domain
self.api_server_port= api_port
self.cfgm_ip = cfgm_ip
self.inputs= inputs
self.logger= inputs.logger
self.obj=None
#end __init__
def setUp(self):
super(VncLibFixture, self).setUp()
self.obj = VncApi(username=self.username, password= self.password, tenant_name= self.project,
api_server_host= self.cfgm_ip, api_server_port= self.api_server_port)
#end setUp
def cleanUp(self):
super(VncLibFixture, self).cleanUp()
def get_handle(self):
return self.obj
#end get_handle
def get_forwarding_mode(self,vn_fq_name):
vnc_lib = self.obj
#Figure out VN
vni_list = vnc_lib.virtual_networks_list(
parent_fq_name = self.project)['virtual-networks']
for vni_record in vni_list:
if (vni_record['fq_name'][0] == vn_fq_name.split(":")[0] and
vni_record['fq_name'][1] == vn_fq_name.split(":")[1] and
vni_record['fq_name'][2] == vn_fq_name.split(":")[2]):
vni_obj = vnc_lib.virtual_network_read(id = vni_record['uuid'])
vni_obj_properties = vni_obj.get_virtual_network_properties()
fw_mode = vni_obj_properties.get_forwarding_mode()
return fw_mode
#end get_forwarding_mode
#end VncLibFixture1