63
73
description = "desc of %s" % t
66
body = {'id': t, 'description': description}
67
tenant = {'id': _ofc(t)}
76
body = {'id': _ofc(t)}
68
78
ofc.OFCClient.do_request("POST", path, body=body).AndReturn(tenant)
69
79
self.mox.ReplayAll()
72
82
self.mox.VerifyAll()
73
83
self.assertEqual(ret, _ofc(t))
75
def testb_update_tenant(self):
76
t, n, p = self.get_ofc_item_random_params()
77
description = "new desc of %s" % t
79
path = "/tenants/%s" % _ofc(t)
80
body = {'description': description}
81
ofc.OFCClient.do_request("PUT", path, body=body)
84
self.driver.update_tenant(_ofc(t), description)
87
85
def testc_delete_tenant(self):
88
86
t, n, p = self.get_ofc_item_random_params()
99
97
description = "desc of %s" % n
101
99
path = "/tenants/%s/networks" % _ofc(t)
102
body = {'id': n, 'description': description}
103
network = {'id': _ofc(n)}
100
body = {'id': _ofc(n), 'description': _ofc_desc(description)}
104
102
ofc.OFCClient.do_request("POST", path, body=body).AndReturn(network)
105
103
self.mox.ReplayAll()
113
111
description = "desc of %s" % n
115
113
path = "/tenants/%s/networks/%s" % (_ofc(t), _ofc(n))
116
body = {'description': description}
114
body = {'description': _ofc_desc(description)}
117
115
ofc.OFCClient.do_request("PUT", path, body=body)
118
116
self.mox.ReplayAll()
134
132
t, n, p = self.get_ofc_item_random_params()
136
134
path = "/tenants/%s/networks/%s/ports" % (_ofc(t), _ofc(n))
135
body = {'id': _ofc(p.id),
138
136
'datapath_id': p.datapath_id,
139
137
'port': str(p.port_no),
140
138
'vid': str(p.vlan_id)}
141
port = {'id': _ofc(p.id)}
142
140
ofc.OFCClient.do_request("POST", path, body=body).AndReturn(port)
143
141
self.mox.ReplayAll()
157
155
self.driver.delete_port(_ofc(t), _ofc(n), _ofc(p.id))
158
156
self.mox.VerifyAll()
159
class PFCDriverStringTest(unittest.TestCase):
161
driver = 'quantum.plugins.nec.drivers.pfc.PFCDriverBase'
164
super(PFCDriverStringTest, self).setUp()
165
self.driver = drivers.get_driver("pfc")(TestConfig)
167
def test_generate_pfc_id_uuid(self):
168
id_str = utils.str_uuid()
169
exp_str = (id_str[:14] + id_str[15:]).replace('-', '')[:31]
171
ret_str = self.driver._generate_pfc_id(id_str)
172
self.assertEqual(exp_str, ret_str)
174
def test_generate_pfc_id_uuid_no_hyphen(self):
175
# Keystone tenant_id style uuid
176
id_str = utils.str_uuid()
177
id_no_hyphen = id_str.replace('-', '')
178
exp_str = (id_str[:14] + id_str[15:]).replace('-', '')[:31]
180
ret_str = self.driver._generate_pfc_id(id_no_hyphen)
181
self.assertEqual(exp_str, ret_str)
183
def test_generate_pfc_id_string(self):
184
id_str = utils.str_uuid() + 'x'
185
exp_str = id_str[:31].replace('-', '_')
187
ret_str = self.driver._generate_pfc_id(id_str)
188
self.assertEqual(exp_str, ret_str)
190
def test_generate_pfc_desc(self):
191
random_list = [random.choice(string.printable) for x in range(128)]
192
random_str = ''.join(random_list)
194
accept_letters = string.letters + string.digits
195
exp_list = [x if x in accept_letters else '_' for x in random_list]
196
exp_str = ''.join(exp_list)[:127]
198
ret_str = self.driver._generate_pfc_description(random_str)
199
self.assertEqual(exp_str, ret_str)