Merge lp:~rohitagarwalla/neutron/l2network-plugin-db into lp:~cisco-openstack/neutron/plugin-framework

Proposed by Rohit Agarwalla
Status: Merged
Merged at revision: 40
Proposed branch: lp:~rohitagarwalla/neutron/l2network-plugin-db
Merge into: lp:~cisco-openstack/neutron/plugin-framework
Diff against target: 1851 lines (+1814/-0)
7 files modified
quantum/plugins/cisco/README (+8/-0)
quantum/plugins/cisco/db/db_conn.ini (+5/-0)
quantum/plugins/cisco/db/db_test_plugin.py (+1049/-0)
quantum/plugins/cisco/db/l2network_db.py (+239/-0)
quantum/plugins/cisco/db/l2network_models.py (+86/-0)
quantum/plugins/cisco/db/ucs_db.py (+314/-0)
quantum/plugins/cisco/db/ucs_models.py (+113/-0)
To merge this branch: bzr merge lp:~rohitagarwalla/neutron/l2network-plugin-db
Reviewer Review Type Date Requested Status
Sumit Naiksatam (community) Approve
Review via email: mp+69910@code.launchpad.net

Description of the change

persistence of l2network & ucs plugins using mysql
- db_conn.ini - configuration details of making a connection to the database
- db_test_plugin.py - contains abstraction methods for storing database values in a dict and unit test cases for DB testing
- l2network_db.py - db methods for l2network models
- l2network_models.py - class definitions for the l2 network tables
- ucs_db.py - db methods for ucs models
- ucs_models.py - class definition for the ucs tables
dynamic loading of the 2nd layer plugin db's based on passed arguments
Create, Delete, Get, Getall, Update database methods at - Quantum, L2Network and Ucs
Unit test cases for create, delete, getall and update operations for L2Network and Ucs plugins
pep8 checks done
branch based off revision 34 plugin-framework

To post a comment you must log in.
Revision history for this message
Sumit Naiksatam (snaiksat) wrote :

Thanks, great job! Looks mostly good to me. I ran the tests provided with this code and they executed fine. Just a few small fixes suggested (some are nits):

1. As discussed in a separate thread, please move the code to the new "db' directory.

2. The quantum component is following the convention of "getting" a logger component and logging to that (so that the logs get flagged with the name of the component). Can you please do this in the modules in which you are writing to the logs? This is how to do it:

from quantum.plugins.cisco.common import cisco_constants as const

LOG.basicConfig(level=LOG.WARN)
LOG.getLogger(const.LOGGER_COMPONENT_NAME)

3. The requirement for the creation of "cisco_naas" DB should be documented in the README file. Please also provide instructions on how to create it.

4. Specifically on the name "cisco_naas", Ram earlier had the suggestion that it be called something else. I would definitely recommend getting away from "naas" since we are not using it any more. Maybe call it "quantum_l2network" since we are calling our plugin "l2network-plugin".

5. The nova coding guidelines require that imports be arranged in the alphabetical order. The following order does not seem correct to me, please check this (and other places as well):

+import ConfigParser
33 +import os
34 +import logging as LOG
35 +import unittest
36 +from optparse import OptionParser

More info on imports order can be found in the HACKING file in the nova branch.

review: Needs Fixing
36. By Rohit Agarwalla

merged the latest changes from plugin-framework branch - revision 39
conforming to the new cisco plugin directory structure and moving all db related modules into cisco/db folder
updated db_test_plugin.py
 - added import of cisco constants module
 - added LOG.getLogger for logging component name
 - updated import module paths for l2network_models/db and ucs_models/db to use the new directory structure
 - updated (rearranged) imports section to obey openstack alphabetical placement convention
updated db_conn.ini
 - updated database name from cisco_naas to quantum_l2network
unit test cases ran successfully and pep8 checks done again

Revision history for this message
Sumit Naiksatam (snaiksat) wrote :

Great, lgtm. I recommend going ahead with the merge. Thanks!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'quantum/plugins/cisco/README'
--- quantum/plugins/cisco/README 2011-07-31 18:38:26 +0000
+++ quantum/plugins/cisco/README 2011-08-01 03:39:28 +0000
@@ -76,3 +76,11 @@
76/usr/lib/python2.6/site-packages/nova/virt/cisco_ucs.py76/usr/lib/python2.6/site-packages/nova/virt/cisco_ucs.py
7777
78* Restart nova-compute service78* Restart nova-compute service
79
80**L2network database usage requirements -
81* mysql database "quantum_l2network" is required for persistence of the l2network plugin data.
82 + The database can be created as follows -
83 - # mysql -uroot -pnova; (username/password here is root/nova)
84 - mysql> create database quantum_l2network;
85 - mysql> use quantum_l2network;
86 + The database and login details must be specified in quantum/plugins/cisco/db/db_conn.ini.
7987
=== added file 'quantum/plugins/cisco/db/db_conn.ini'
--- quantum/plugins/cisco/db/db_conn.ini 1970-01-01 00:00:00 +0000
+++ quantum/plugins/cisco/db/db_conn.ini 2011-08-01 03:39:28 +0000
@@ -0,0 +1,5 @@
1[DATABASE]
2name = quantum_l2network
3user = root
4pass = nova
5host = 127.0.0.1
06
=== added file 'quantum/plugins/cisco/db/db_test_plugin.py'
--- quantum/plugins/cisco/db/db_test_plugin.py 1970-01-01 00:00:00 +0000
+++ quantum/plugins/cisco/db/db_test_plugin.py 2011-08-01 03:39:28 +0000
@@ -0,0 +1,1049 @@
1# vim: tabstop=4 shiftwidth=4 softtabstop=4
2
3# Copyright 2011, Cisco Systems, Inc.
4#
5# Licensed under the Apache License, Version 2.0 (the "License"); you may
6# not use this file except in compliance with the License. You may obtain
7# a copy of the License at
8#
9# http://www.apache.org/licenses/LICENSE-2.0
10#
11# Unless required by applicable law or agreed to in writing, software
12# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14# License for the specific language governing permissions and limitations
15# under the License.
16# @author: Rohit Agarwalla, Cisco Systems, Inc.
17
18import ConfigParser
19import os
20import logging as LOG
21import unittest
22
23from optparse import OptionParser
24from quantum.plugins.cisco.common import cisco_constants as const
25
26import quantum.db.api as db
27import quantum.db.models
28import quantum.plugins.cisco.db.l2network_db as l2network_db
29import quantum.plugins.cisco.db.l2network_models
30
31CONF_FILE = "db_conn.ini"
32LOG.getLogger(const.LOGGER_COMPONENT_NAME)
33
34
35def find_config(basepath):
36 for root, dirs, files in os.walk(basepath):
37 if CONF_FILE in files:
38 return os.path.join(root, CONF_FILE)
39 return None
40
41
42def db_conf(configfile=None):
43 config = ConfigParser.ConfigParser()
44 if configfile == None:
45 if os.path.exists(CONF_FILE):
46 configfile = CONF_FILE
47 else:
48 configfile = \
49 find_config(os.path.abspath(os.path.dirname(__file__)))
50 if configfile == None:
51 raise Exception("Configuration file \"%s\" doesn't exist" %
52 (configfile))
53 LOG.debug("Using configuration file: %s" % configfile)
54 config.read(configfile)
55
56 DB_NAME = config.get("DATABASE", "name")
57 DB_USER = config.get("DATABASE", "user")
58 DB_PASS = config.get("DATABASE", "pass")
59 DB_HOST = config.get("DATABASE", "host")
60 options = {"sql_connection": "mysql://%s:%s@%s/%s" % (DB_USER,
61 DB_PASS, DB_HOST, DB_NAME)}
62 db.configure_db(options)
63
64
65class UcsDB(object):
66 def get_all_ucsmbindings(self):
67 bindings = []
68 try:
69 for x in ucs_db.get_all_ucsmbinding():
70 LOG.debug("Getting ucsm binding : %s" % x.ucsm_ip)
71 bind_dict = {}
72 bind_dict["ucsm-ip"] = str(x.ucsm_ip)
73 bind_dict["network-id"] = str(x.network_id)
74 bindings.append(bind_dict)
75 except Exception, e:
76 LOG.error("Failed to get all bindings: %s" % str(e))
77 return bindings
78
79 def get_ucsmbinding(self, ucsm_ip):
80 binding = []
81 try:
82 for x in ucs_db.get_ucsmbinding(ucsm_ip):
83 LOG.debug("Getting ucsm binding : %s" % x.ucsm_ip)
84 bind_dict = {}
85 bind_dict["ucsm-ip"] = str(res.ucsm_ip)
86 bind_dict["network-id"] = str(res.network_id)
87 binding.append(bind_dict)
88 except Exception, e:
89 LOG.error("Failed to get binding: %s" % str(e))
90 return binding
91
92 def create_ucsmbinding(self, ucsm_ip, networ_id):
93 bind_dict = {}
94 try:
95 res = ucs_db.add_ucsmbinding(ucsm_ip, networ_id)
96 LOG.debug("Created ucsm binding: %s" % res.ucsm_ip)
97 bind_dict["ucsm-ip"] = str(res.ucsm_ip)
98 bind_dict["network-id"] = str(res.network_id)
99 return bind_dict
100 except Exception, e:
101 LOG.error("Failed to create ucsm binding: %s" % str(e))
102
103 def delete_ucsmbinding(self, ucsm_ip):
104 try:
105 res = ucs_db.remove_ucsmbinding(ucsm_ip)
106 LOG.debug("Deleted ucsm binding : %s" % res.ucsm_ip)
107 bind_dict = {}
108 bind_dict["ucsm-ip"] = str(res.ucsm_ip)
109 return bind_dict
110 except Exception, e:
111 raise Exception("Failed to delete dynamic vnic: %s" % str(e))
112
113 def update_ucsmbinding(self, ucsm_ip, network_id):
114 try:
115 res = ucs_db.update_ucsmbinding(ucsm_ip, network_id)
116 LOG.debug("Updating ucsm binding : %s" % res.ucsm_ip)
117 bind_dict = {}
118 bind_dict["ucsm-ip"] = str(res.ucsm_ip)
119 bind_dict["network-id"] = str(res.network_id)
120 return bind_dict
121 except Exception, e:
122 raise Exception("Failed to update dynamic vnic: %s" % str(e))
123
124 def get_all_dynamicvnics(self):
125 vnics = []
126 try:
127 for x in ucs_db.get_all_dynamicvnics():
128 LOG.debug("Getting dynamic vnic : %s" % x.uuid)
129 vnic_dict = {}
130 vnic_dict["vnic-id"] = str(x.uuid)
131 vnic_dict["device-name"] = x.device_name
132 vnic_dict["blade-id"] = str(x.blade_id)
133 vnics.append(vnic_dict)
134 except Exception, e:
135 LOG.error("Failed to get all dynamic vnics: %s" % str(e))
136 return vnics
137
138 def get_dynamicvnic(self, vnic_id):
139 vnic = []
140 try:
141 for x in ucs_db.get_dynamicvnic(vnic_id):
142 LOG.debug("Getting dynamic vnic : %s" % x.uuid)
143 vnic_dict = {}
144 vnic_dict["vnic-id"] = str(x.uuid)
145 vnic_dict["device-name"] = x.device_name
146 vnic_dict["blade-id"] = str(x.blade_id)
147 vnic.append(vnic_dict)
148 except Exception, e:
149 LOG.error("Failed to get dynamic vnic: %s" % str(e))
150 return vnic
151
152 def create_dynamicvnic(self, device_name, blade_id):
153 vnic_dict = {}
154 try:
155 res = ucs_db.add_dynamicvnic(device_name, blade_id)
156 LOG.debug("Created dynamic vnic: %s" % res.uuid)
157 vnic_dict["vnic-id"] = str(res.uuid)
158 vnic_dict["device-name"] = res.device_name
159 vnic_dict["blade-id"] = str(res.blade_id)
160 return vnic_dict
161 except Exception, e:
162 LOG.error("Failed to create dynamic vnic: %s" % str(e))
163
164 def delete_dynamicvnic(self, vnic_id):
165 try:
166 res = ucs_db.remove_dynamicvnic(vnic_id)
167 LOG.debug("Deleted dynamic vnic : %s" % res.uuid)
168 vnic_dict = {}
169 vnic_dict["vnic-id"] = str(res.uuid)
170 return vnic_dict
171 except Exception, e:
172 raise Exception("Failed to delete dynamic vnic: %s" % str(e))
173
174 def update_dynamicvnic(self, vnic_id, device_name=None, blade_id=None):
175 try:
176 res = ucs_db.update_dynamicvnic(vnic_id, device_name, blade_id)
177 LOG.debug("Updating dynamic vnic : %s" % res.uuid)
178 vnic_dict = {}
179 vnic_dict["vnic-id"] = str(res.uuid)
180 vnic_dict["device-name"] = res.device_name
181 vnic_dict["blade-id"] = str(res.blade_id)
182 return vnic_dict
183 except Exception, e:
184 raise Exception("Failed to update dynamic vnic: %s" % str(e))
185
186 def get_all_blades(self):
187 blades = []
188 try:
189 for x in ucs_db.get_all_blades():
190 LOG.debug("Getting blade : %s" % x.uuid)
191 blade_dict = {}
192 blade_dict["blade-id"] = str(x.uuid)
193 blade_dict["mgmt-ip"] = str(x.mgmt_ip)
194 blade_dict["mac-addr"] = str(x.mac_addr)
195 blade_dict["chassis-id"] = str(x.chassis_id)
196 blade_dict["ucsm-ip"] = str(x.ucsm_ip)
197 blades.append(blade_dict)
198 except Exception, e:
199 LOG.error("Failed to get all blades: %s" % str(e))
200 return blades
201
202 def get_blade(self, blade_id):
203 blade = []
204 try:
205 for x in ucs_db.get_blade(blade_id):
206 LOG.debug("Getting blade : %s" % x.uuid)
207 blade_dict = {}
208 blade_dict["blade-id"] = str(x.uuid)
209 blade_dict["mgmt-ip"] = str(x.mgmt_ip)
210 blade_dict["mac-addr"] = str(x.mac_addr)
211 blade_dict["chassis-id"] = str(x.chassis_id)
212 blade_dict["ucsm-ip"] = str(x.ucsm_ip)
213 blade.append(blade_dict)
214 except Exception, e:
215 LOG.error("Failed to get all blades: %s" % str(e))
216 return blade
217
218 def create_blade(self, mgmt_ip, mac_addr, chassis_id, ucsm_ip):
219 blade_dict = {}
220 try:
221 res = ucs_db.add_blade(mgmt_ip, mac_addr, chassis_id, ucsm_ip)
222 LOG.debug("Created blade: %s" % res.uuid)
223 blade_dict["blade-id"] = str(res.uuid)
224 blade_dict["mgmt-ip"] = str(res.mgmt_ip)
225 blade_dict["mac-addr"] = str(res.mac_addr)
226 blade_dict["chassis-id"] = str(res.chassis_id)
227 blade_dict["ucsm-ip"] = str(res.ucsm_ip)
228 return blade_dict
229 except Exception, e:
230 LOG.error("Failed to create blade: %s" % str(e))
231
232 def delete_blade(self, blade_id):
233 try:
234 res = ucs_db.remove_blade(blade_id)
235 LOG.debug("Deleted blade : %s" % res.uuid)
236 blade_dict = {}
237 blade_dict["blade-id"] = str(res.uuid)
238 return blade_dict
239 except Exception, e:
240 raise Exception("Failed to delete blade: %s" % str(e))
241
242 def update_blade(self, blade_id, mgmt_ip=None, mac_addr=None,\
243 chassis_id=None, ucsm_ip=None):
244 try:
245 res = ucs_db.update_blade(blade_id, mgmt_ip, mac_addr, \
246 chassis_id, ucsm_ip)
247 LOG.debug("Updating blade : %s" % res.uuid)
248 blade_dict = {}
249 blade_dict["blade-id"] = str(res.uuid)
250 blade_dict["mgmt-ip"] = str(res.mgmt_ip)
251 blade_dict["mac-addr"] = str(res.mac_addr)
252 blade_dict["chassis-id"] = str(res.chassis_id)
253 blade_dict["ucsm-ip"] = str(res.ucsm_ip)
254 return blade_dict
255 except Exception, e:
256 raise Exception("Failed to update blade: %s" % str(e))
257
258 def get_all_port_bindings(self):
259 port_bindings = []
260 try:
261 for x in ucs_db.get_all_portbindings():
262 LOG.debug("Getting port binding for port: %s" % x.port_id)
263 port_bind_dict = {}
264 port_bind_dict["port-id"] = x.port_id
265 port_bind_dict["dynamic-vnic-id"] = str(x.dynamic_vnic_id)
266 port_bind_dict["portprofile-name"] = x.portprofile_name
267 port_bind_dict["vlan-name"] = x.vlan_name
268 port_bind_dict["vlan-id"] = str(x.vlan_id)
269 port_bind_dict["qos"] = x.qos
270 port_bindings.append(port_bind_dict)
271 except Exception, e:
272 LOG.error("Failed to get all port bindings: %s" % str(e))
273 return port_bindings
274
275 def get_port_binding(self):
276 port_binding = []
277 try:
278 for x in ucs_db.get_portbinding(port_id):
279 LOG.debug("Getting port binding for port: %s" % x.port_id)
280 port_bind_dict = {}
281 port_bind_dict["port-id"] = x.port_id
282 port_bind_dict["dynamic-vnic-id"] = str(x.dynamic_vnic_id)
283 port_bind_dict["portprofile-name"] = x.portprofile_name
284 port_bind_dict["vlan-name"] = x.vlan_name
285 port_bind_dict["vlan-id"] = str(x.vlan_id)
286 port_bind_dict["qos"] = x.qos
287 port_bindings.append(port_bind_dict)
288 except Exception, e:
289 LOG.error("Failed to get port binding: %s" % str(e))
290 return port_binding
291
292 def create_port_binding(self, port_id, dynamic_vnic_id, portprofile_name, \
293 vlan_name, vlan_id, qos):
294 port_bind_dict = {}
295 try:
296 res = ucs_db.add_portbinding(port_id, dynamic_vnic_id, \
297 portprofile_name, vlan_name, vlan_id, qos)
298 LOG.debug("Created port binding: %s" % res.port_id)
299 port_bind_dict["port-id"] = res.port_id
300 port_bind_dict["dynamic-vnic-id"] = str(res.dynamic_vnic_id)
301 port_bind_dict["portprofile-name"] = res.portprofile_name
302 port_bind_dict["vlan-name"] = res.vlan_name
303 port_bind_dict["vlan-id"] = str(res.vlan_id)
304 port_bind_dict["qos"] = res.qos
305 return port_bind_dict
306 except Exception, e:
307 LOG.error("Failed to create port binding: %s" % str(e))
308
309 def delete_port_binding(self, port_id):
310 try:
311 res = ucs_db.remove_portbinding(port_id)
312 LOG.debug("Deleted port binding : %s" % res.port_id)
313 port_bind_dict = {}
314 port_bind_dict["port-id"] = res.port_id
315 return port_bind_dict
316 except Exception, e:
317 raise Exception("Failed to delete port profile: %s" % str(e))
318
319 def update_port_binding(self, port_id, dynamic_vnic_id, \
320 portprofile_name, vlan_name, vlan_id, qos):
321 try:
322 res = ucs_db.update_portbinding(port_id, dynamic_vnic_id, \
323 portprofile_name, vlan_name, vlan_id, qos)
324 LOG.debug("Updating port binding: %s" % res.port_id)
325 port_bind_dict = {}
326 port_bind_dict["port-id"] = res.port_id
327 port_bind_dict["dynamic-vnic-id"] = str(res.dynamic_vnic_id)
328 port_bind_dict["portprofile-name"] = res.portprofile_name
329 port_bind_dict["vlan-name"] = res.vlan_name
330 port_bind_dict["vlan-id"] = str(res.vlan_id)
331 port_bind_dict["qos"] = res.qos
332 return port_bind_dict
333 except Exception, e:
334 raise Exception("Failed to update portprofile binding:%s" % str(e))
335
336
337class QuantumDB(object):
338 def get_all_networks(self, tenant_id):
339 nets = []
340 try:
341 for x in db.network_list(tenant_id):
342 LOG.debug("Getting network: %s" % x.uuid)
343 net_dict = {}
344 net_dict["tenant-id"] = x.tenant_id
345 net_dict["net-id"] = str(x.uuid)
346 net_dict["net-name"] = x.name
347 nets.append(net_dict)
348 except Exception, e:
349 LOG.error("Failed to get all networks: %s" % str(e))
350 return nets
351
352 def get_network(self, network_id):
353 net = []
354 try:
355 for x in db.network_get(network_id):
356 LOG.debug("Getting network: %s" % x.uuid)
357 net_dict = {}
358 net_dict["tenant-id"] = x.tenant_id
359 net_dict["net-id"] = str(x.uuid)
360 net_dict["net-name"] = x.name
361 nets.append(net_dict)
362 except Exception, e:
363 LOG.error("Failed to get network: %s" % str(e))
364 return net
365
366 def create_network(self, tenant_id, net_name):
367 net_dict = {}
368 try:
369 res = db.network_create(tenant_id, net_name)
370 LOG.debug("Created network: %s" % res.uuid)
371 net_dict["tenant-id"] = res.tenant_id
372 net_dict["net-id"] = str(res.uuid)
373 net_dict["net-name"] = res.name
374 return net_dict
375 except Exception, e:
376 LOG.error("Failed to create network: %s" % str(e))
377
378 def delete_network(self, net_id):
379 try:
380 net = db.network_destroy(net_id)
381 LOG.debug("Deleted network: %s" % net.uuid)
382 net_dict = {}
383 net_dict["net-id"] = str(net.uuid)
384 return net_dict
385 except Exception, e:
386 raise Exception("Failed to delete port: %s" % str(e))
387
388 def rename_network(self, tenant_id, net_id, new_name):
389 try:
390 net = db.network_rename(net_id, tenant_id, new_name)
391 LOG.debug("Renamed network: %s" % net.uuid)
392 net_dict = {}
393 net_dict["net-id"] = str(net.uuid)
394 net_dict["net-name"] = net.name
395 return net_dict
396 except Exception, e:
397 raise Exception("Failed to rename network: %s" % str(e))
398
399 def get_all_ports(self, net_id):
400 ports = []
401 try:
402 for x in db.port_list(net_id):
403 LOG.debug("Getting port: %s" % x.uuid)
404 port_dict = {}
405 port_dict["port-id"] = str(x.uuid)
406 port_dict["net-id"] = str(x.network_id)
407 port_dict["int-id"] = x.interface_id
408 port_dict["state"] = x.state
409 ports.append(port_dict)
410 return ports
411 except Exception, e:
412 LOG.error("Failed to get all ports: %s" % str(e))
413
414 def get_port(self, port_id):
415 port = []
416 try:
417 for x in db.port_get(port_id):
418 LOG.debug("Getting port: %s" % x.uuid)
419 port_dict = {}
420 port_dict["port-id"] = str(x.uuid)
421 port_dict["net-id"] = str(x.network_id)
422 port_dict["int-id"] = x.interface_id
423 port_dict["state"] = x.state
424 port.append(port_dict)
425 return port
426 except Exception, e:
427 LOG.error("Failed to get port: %s" % str(e))
428
429 def create_port(self, net_id):
430 port_dict = {}
431 try:
432 port = db.port_create(net_id)
433 LOG.debug("Creating port %s" % port.uuid)
434 port_dict["port-id"] = str(port.uuid)
435 port_dict["net-id"] = str(port.network_id)
436 port_dict["int-id"] = port.interface_id
437 port_dict["state"] = port.state
438 return port_dict
439 except Exception, e:
440 LOG.error("Failed to create port: %s" % str(e))
441
442 def delete_port(self, port_id):
443 try:
444 port = db.port_destroy(port_id)
445 LOG.debug("Deleted port %s" % port.uuid)
446 port_dict = {}
447 port_dict["port-id"] = str(port.uuid)
448 return port_dict
449 except Exception, e:
450 raise Exception("Failed to delete port: %s" % str(e))
451
452 def update_port(self, port_id, port_state):
453 try:
454 port = db.port_set_state(port_id, port_state)
455 LOG.debug("Updated port %s" % port.uuid)
456 port_dict = {}
457 port_dict["port-id"] = str(port.uuid)
458 port_dict["net-id"] = str(port.network_id)
459 port_dict["int-id"] = port.interface_id
460 port_dict["state"] = port.state
461 return port_dict
462 except Exception, e:
463 raise Exception("Failed to update port state: %s" % str(e))
464
465
466class L2networkDB(object):
467 def get_all_vlan_bindings(self):
468 vlans = []
469 try:
470 for x in l2network_db.get_all_vlan_bindings():
471 LOG.debug("Getting vlan bindings for vlan: %s" % x.vlan_id)
472 vlan_dict = {}
473 vlan_dict["vlan-id"] = str(x.vlan_id)
474 vlan_dict["vlan-name"] = x.vlan_name
475 vlan_dict["net-id"] = str(x.network_id)
476 vlans.append(vlan_dict)
477 except Exception, e:
478 LOG.error("Failed to get all vlan bindings: %s" % str(e))
479 return vlans
480
481 def get_vlan_binding(self, network_id):
482 vlan = []
483 try:
484 for x in l2network_db.get_vlan_binding(network_id):
485 LOG.debug("Getting vlan binding for vlan: %s" % x.vlan_id)
486 vlan_dict = {}
487 vlan_dict["vlan-id"] = str(x.vlan_id)
488 vlan_dict["vlan-name"] = x.vlan_name
489 vlan_dict["net-id"] = str(x.network_id)
490 vlan.append(vlan_dict)
491 except Exception, e:
492 LOG.error("Failed to get vlan binding: %s" % str(e))
493 return vlan
494
495 def create_vlan_binding(self, vlan_id, vlan_name, network_id):
496 vlan_dict = {}
497 try:
498 res = l2network_db.add_vlan_binding(vlan_id, vlan_name, network_id)
499 LOG.debug("Created vlan binding for vlan: %s" % res.vlan_id)
500 vlan_dict["vlan-id"] = str(res.vlan_id)
501 vlan_dict["vlan-name"] = res.vlan_name
502 vlan_dict["net-id"] = str(res.network_id)
503 return vlan_dict
504 except Exception, e:
505 LOG.error("Failed to create vlan binding: %s" % str(e))
506
507 def delete_vlan_binding(self, network_id):
508 try:
509 res = l2network_db.remove_vlan_binding(network_id)
510 LOG.debug("Deleted vlan binding for vlan: %s" % res.vlan_id)
511 vlan_dict = {}
512 vlan_dict["vlan-id"] = str(res.vlan_id)
513 return vlan_dict
514 except Exception, e:
515 raise Exception("Failed to delete vlan binding: %s" % str(e))
516
517 def update_vlan_binding(self, network_id, vlan_id, vlan_name):
518 try:
519 res = l2network_db.update_vlan_binding(network_id, vlan_id, \
520 vlan_name)
521 LOG.debug("Updating vlan binding for vlan: %s" % res.vlan_id)
522 vlan_dict = {}
523 vlan_dict["vlan-id"] = str(res.vlan_id)
524 vlan_dict["vlan-name"] = res.vlan_name
525 vlan_dict["net-id"] = str(res.network_id)
526 return vlan_dict
527 except Exception, e:
528 raise Exception("Failed to update vlan binding: %s" % str(e))
529
530 def get_all_portprofiles(self):
531 pps = []
532 try:
533 for x in l2network_db.get_all_portprofiles():
534 LOG.debug("Getting port profile : %s" % x.uuid)
535 pp_dict = {}
536 pp_dict["portprofile-id"] = str(x.uuid)
537 pp_dict["portprofile-name"] = x.name
538 pp_dict["vlan-id"] = str(x.vlan_id)
539 pp_dict["qos"] = x.qos
540 pps.append(pp_dict)
541 except Exception, e:
542 LOG.error("Failed to get all port profiles: %s" % str(e))
543 return pps
544
545 def get_portprofile(self, port_id):
546 pp = []
547 try:
548 for x in l2network_db.get_portprofile(port_id):
549 LOG.debug("Getting port profile : %s" % x.uuid)
550 pp_dict = {}
551 pp_dict["portprofile-id"] = str(x.uuid)
552 pp_dict["portprofile-name"] = x.name
553 pp_dict["vlan-id"] = str(x.vlan_id)
554 pp_dict["qos"] = x.qos
555 pp.append(pp_dict)
556 except Exception, e:
557 LOG.error("Failed to get port profile: %s" % str(e))
558 return pp
559
560 def create_portprofile(self, name, vlan_id, qos):
561 pp_dict = {}
562 try:
563 res = l2network_db.add_portprofile(name, vlan_id, qos)
564 LOG.debug("Created port profile: %s" % res.uuid)
565 pp_dict["portprofile-id"] = str(res.uuid)
566 pp_dict["portprofile-name"] = res.name
567 pp_dict["vlan-id"] = str(res.vlan_id)
568 pp_dict["qos"] = res.qos
569 return pp_dict
570 except Exception, e:
571 LOG.error("Failed to create port profile: %s" % str(e))
572
573 def delete_portprofile(self, pp_id):
574 try:
575 res = l2network_db.remove_portprofile(pp_id)
576 LOG.debug("Deleted port profile : %s" % res.uuid)
577 pp_dict = {}
578 pp_dict["pp-id"] = str(res.uuid)
579 return pp_dict
580 except Exception, e:
581 raise Exception("Failed to delete port profile: %s" % str(e))
582
583 def update_portprofile(self, pp_id, name, vlan_id, qos):
584 try:
585 res = l2network_db.update_portprofile(pp_id, name, vlan_id, qos)
586 LOG.debug("Updating port profile : %s" % res.uuid)
587 pp_dict = {}
588 pp_dict["portprofile-id"] = str(res.uuid)
589 pp_dict["portprofile-name"] = res.name
590 pp_dict["vlan-id"] = str(res.vlan_id)
591 pp_dict["qos"] = res.qos
592 return pp_dict
593 except Exception, e:
594 raise Exception("Failed to update port profile: %s" % str(e))
595
596 def get_all_pp_bindings(self):
597 pp_bindings = []
598 try:
599 for x in l2network_db.get_all_pp_bindings():
600 LOG.debug("Getting port profile binding: %s" % \
601 x.portprofile_id)
602 ppbinding_dict = {}
603 ppbinding_dict["portprofile-id"] = str(x.portprofile_id)
604 ppbinding_dict["net-id"] = str(x.network_id)
605 ppbinding_dict["tenant-id"] = x.tenant_id
606 ppbinding_dict["default"] = x.default
607 pp_bindings.append(ppbinding_dict)
608 except Exception, e:
609 LOG.error("Failed to get all port profiles: %s" % str(e))
610 return pp_bindings
611
612 def get_pp_binding(self, pp_id):
613 pp_binding = []
614 try:
615 for x in l2network_db.get_pp_binding(pp_id):
616 LOG.debug("Getting port profile binding: %s" % \
617 x.portprofile_id)
618 ppbinding_dict = {}
619 ppbinding_dict["portprofile-id"] = str(x.portprofile_id)
620 ppbinding_dict["net-id"] = str(x.network_id)
621 ppbinding_dict["tenant-id"] = x.tenant_id
622 ppbinding_dict["default"] = x.default
623 pp_bindings.append(ppbinding_dict)
624 except Exception, e:
625 LOG.error("Failed to get port profile binding: %s" % str(e))
626 return pp_binding
627
628 def create_pp_binding(self, tenant_id, net_id, pp_id, default):
629 ppbinding_dict = {}
630 try:
631 res = l2network_db.add_pp_binding(tenant_id, net_id, pp_id, \
632 default)
633 LOG.debug("Created port profile binding: %s" % res.portprofile_id)
634 ppbinding_dict["portprofile-id"] = str(res.portprofile_id)
635 ppbinding_dict["net-id"] = str(res.network_id)
636 ppbinding_dict["tenant-id"] = res.tenant_id
637 ppbinding_dict["default"] = res.default
638 return ppbinding_dict
639 except Exception, e:
640 LOG.error("Failed to create port profile binding: %s" % str(e))
641
642 def delete_pp_binding(self, pp_id):
643 try:
644 res = l2network_db.remove_pp_binding(pp_id)
645 LOG.debug("Deleted port profile binding : %s" % res.portprofile_id)
646 ppbinding_dict = {}
647 ppbinding_dict["portprofile-id"] = str(res.portprofile_id)
648 return ppbinding_dict
649 except Exception, e:
650 raise Exception("Failed to delete port profile: %s" % str(e))
651
652 def update_pp_binding(self, pp_id, tenant_id, net_id, default):
653 try:
654 res = l2network_db.update_pp_binding(pp_id, tenant_id, net_id,\
655 default)
656 LOG.debug("Updating port profile binding: %s" % res.portprofile_id)
657 ppbinding_dict = {}
658 ppbinding_dict["portprofile-id"] = str(res.portprofile_id)
659 ppbinding_dict["net-id"] = str(res.network_id)
660 ppbinding_dict["tenant-id"] = res.tenant_id
661 ppbinding_dict["default"] = res.default
662 return ppbinding_dict
663 except Exception, e:
664 raise Exception("Failed to update portprofile binding:%s" % str(e))
665
666
667class UcsDBTest(unittest.TestCase):
668 def setUp(self):
669 self.dbtest = UcsDB()
670 LOG.debug("Setup")
671
672 def testACreateUcsmBinding(self):
673 binding1 = self.dbtest.create_ucsmbinding("1.2.3.4", "net1")
674 self.assertTrue(binding1["ucsm-ip"] == "1.2.3.4")
675 self.tearDownUcsmBinding()
676
677 def testBGetAllUcsmBindings(self):
678 binding1 = self.dbtest.create_ucsmbinding("1.2.3.4", "net1")
679 binding2 = self.dbtest.create_ucsmbinding("2.3.4.5", "net1")
680 bindings = self.dbtest.get_all_ucsmbindings()
681 count = 0
682 for x in bindings:
683 if "net" in x["network-id"]:
684 count += 1
685 self.assertTrue(count == 2)
686 self.tearDownUcsmBinding()
687
688 def testCDeleteUcsmBinding(self):
689 binding1 = self.dbtest.create_ucsmbinding("1.2.3.4", "net1")
690 self.dbtest.delete_ucsmbinding(binding1["ucsm-ip"])
691 bindings = self.dbtest.get_all_ucsmbindings()
692 count = 0
693 for x in bindings:
694 if "net " in x["network-id"]:
695 count += 1
696 self.assertTrue(count == 0)
697 self.tearDownUcsmBinding()
698
699 def testDUpdateUcsmBinding(self):
700 binding1 = self.dbtest.create_ucsmbinding("1.2.3.4", "net1")
701 binding1 = self.dbtest.update_ucsmbinding(binding1["ucsm-ip"], \
702 "newnet1")
703 bindings = self.dbtest.get_all_ucsmbindings()
704 count = 0
705 for x in bindings:
706 if "new" in x["network-id"]:
707 count += 1
708 self.assertTrue(count == 1)
709 self.tearDownUcsmBinding()
710
711 def testECreateDynamicVnic(self):
712 blade1 = self.dbtest.create_blade("1.2.3.4", "abcd", "chassis1", \
713 "9.8.7.6")
714 vnic1 = self.dbtest.create_dynamicvnic("eth1", blade1["blade-id"])
715 self.assertTrue(vnic1["device-name"] == "eth1")
716 self.tearDownDyanmicVnic()
717
718 def testFGetAllDyanmicVnics(self):
719 blade1 = self.dbtest.create_blade("1.2.3.4", "abcd", "chassis1", \
720 "9.8.7.6")
721 vnic1 = self.dbtest.create_dynamicvnic("eth1", blade1["blade-id"])
722 vnic2 = self.dbtest.create_dynamicvnic("eth2", blade1["blade-id"])
723 vnics = self.dbtest.get_all_dynamicvnics()
724 count = 0
725 for x in vnics:
726 if "eth" in x["device-name"]:
727 count += 1
728 self.assertTrue(count == 2)
729 self.tearDownDyanmicVnic()
730
731 def testGDeleteDyanmicVnic(self):
732 blade1 = self.dbtest.create_blade("1.2.3.4", "abcd", "chassis1", \
733 "9.8.7.6")
734 vnic1 = self.dbtest.create_dynamicvnic("eth1", blade1["blade-id"])
735 self.dbtest.delete_dynamicvnic(vnic1["vnic-id"])
736 vnics = self.dbtest.get_all_dynamicvnics()
737 count = 0
738 for x in vnics:
739 if "eth " in x["device-name"]:
740 count += 1
741 self.assertTrue(count == 0)
742 self.tearDownDyanmicVnic()
743
744 def testHUpdateDynamicVnic(self):
745 blade1 = self.dbtest.create_blade("1.2.3.4", "abcd", "chassis1", \
746 "9.8.7.6")
747 vnic1 = self.dbtest.create_dynamicvnic("eth1", blade1["blade-id"])
748 vnic1 = self.dbtest.update_dynamicvnic(vnic1["vnic-id"], "neweth1", \
749 "newblade2")
750 vnics = self.dbtest.get_all_dynamicvnics()
751 count = 0
752 for x in vnics:
753 if "new" in x["device-name"]:
754 count += 1
755 self.assertTrue(count == 1)
756 self.tearDownDyanmicVnic()
757
758 def testICreateUcsBlade(self):
759 blade1 = self.dbtest.create_blade("1.2.3.4", "abcd", "chassis1", \
760 "9.8.7.6")
761 self.assertTrue(blade1["mgmt-ip"] == "1.2.3.4")
762 self.tearDownUcsBlade()
763
764 def testJGetAllUcsBlade(self):
765 blade1 = self.dbtest.create_blade("1.2.3.4", "abcd", "chassis1", \
766 "9.8.7.6")
767 blade2 = self.dbtest.create_blade("2.3.4.5", "efgh", "chassis1", \
768 "9.8.7.6")
769 blades = self.dbtest.get_all_blades()
770 count = 0
771 for x in blades:
772 if "chassis" in x["chassis-id"]:
773 count += 1
774 self.assertTrue(count == 2)
775 self.tearDownUcsBlade()
776
777 def testKDeleteUcsBlade(self):
778 blade1 = self.dbtest.create_blade("1.2.3.4", "abcd", "chassis1", \
779 "9.8.7.6")
780 self.dbtest.delete_blade(blade1["blade-id"])
781 blades = self.dbtest.get_all_blades()
782 count = 0
783 for x in blades:
784 if "chassis " in x["chassis-id"]:
785 count += 1
786 self.assertTrue(count == 0)
787 self.tearDownUcsBlade()
788
789 def testLUpdateUcsBlade(self):
790 blade1 = self.dbtest.create_blade("1.2.3.4", "abcd", "chassis1", \
791 "9.8.7.6")
792 blade2 = self.dbtest.update_blade(blade1["blade-id"], "2.3.4.5", \
793 "newabcd", "chassis1", "9.8.7.6")
794 blades = self.dbtest.get_all_blades()
795 count = 0
796 for x in blades:
797 if "new" in x["mac-addr"]:
798 count += 1
799 self.assertTrue(count == 1)
800 self.tearDownUcsBlade()
801
802 def testMCreatePortBinding(self):
803 port_bind1 = self.dbtest.create_port_binding("port1", "dv1", "pp1", \
804 "vlan1", 10, "qos1")
805 self.assertTrue(port_bind1["port-id"] == "port1")
806 self.tearDownPortBinding()
807
808 def testNGetAllPortBinding(self):
809 port_bind1 = self.dbtest.create_port_binding("port1", "dv1", "pp1", \
810 "vlan1", 10, "qos1")
811 port_bind2 = self.dbtest.create_port_binding("port2", "dv2", "pp2", \
812 "vlan2", 20, "qos2")
813 port_bindings = self.dbtest.get_all_port_bindings()
814 count = 0
815 for x in port_bindings:
816 if "port" in x["port-id"]:
817 count += 1
818 self.assertTrue(count == 2)
819 self.tearDownPortBinding()
820
821 def testODeletePortBinding(self):
822 port_bind1 = self.dbtest.create_port_binding("port1", "dv1", "pp1", \
823 "vlan1", 10, "qos1")
824 self.dbtest.delete_port_binding("port1")
825 port_bindings = self.dbtest.get_all_port_bindings()
826 count = 0
827 for x in port_bindings:
828 if "port " in x["port-id"]:
829 count += 1
830 self.assertTrue(count == 0)
831 self.tearDownPortBinding()
832
833 def testPUpdatePortBinding(self):
834 port_bind1 = self.dbtest.create_port_binding("port1", "dv1", "pp1", \
835 "vlan1", 10, "qos1")
836 port_bind1 = self.dbtest.update_port_binding("port1", "newdv1", \
837 "newpp1", "newvlan1", 11, "newqos1")
838 port_bindings = self.dbtest.get_all_port_bindings()
839 count = 0
840 for x in port_bindings:
841 if "new" in x["dynamic-vnic-id"]:
842 count += 1
843 self.assertTrue(count == 1)
844 self.tearDownPortBinding()
845
846 def tearDownUcsmBinding(self):
847 print "Tearing Down Ucsm Bindings"
848 binds = self.dbtest.get_all_ucsmbindings()
849 for bind in binds:
850 ip = bind["ucsm-ip"]
851 self.dbtest.delete_ucsmbinding(ip)
852
853 def tearDownDyanmicVnic(self):
854 print "Tearing Down Dynamic Vnics"
855 vnics = self.dbtest.get_all_dynamicvnics()
856 for vnic in vnics:
857 id = vnic["vnic-id"]
858 self.dbtest.delete_dynamicvnic(id)
859 self.tearDownUcsBlade()
860
861 def tearDownUcsBlade(self):
862 print "Tearing Down Blades"
863 blades = self.dbtest.get_all_blades()
864 for blade in blades:
865 id = blade["blade-id"]
866 self.dbtest.delete_blade(id)
867
868 def tearDownPortBinding(self):
869 print "Tearing Down Port Binding"
870 port_bindings = self.dbtest.get_all_port_bindings()
871 for port_binding in port_bindings:
872 id = port_binding["port-id"]
873 self.dbtest.delete_port_binding(id)
874
875
876class L2networkDBTest(unittest.TestCase):
877 def setUp(self):
878 self.dbtest = L2networkDB()
879 LOG.debug("Setup")
880
881 def testACreateVlanBinding(self):
882 vlan1 = self.dbtest.create_vlan_binding(10, "vlan1", "netid1")
883 self.assertTrue(vlan1["vlan-id"] == "10")
884 self.tearDownVlanBinding()
885
886 def testBGetAllVlanBindings(self):
887 vlan1 = self.dbtest.create_vlan_binding(10, "vlan1", "netid1")
888 vlan2 = self.dbtest.create_vlan_binding(20, "vlan2", "netid2")
889 vlans = self.dbtest.get_all_vlan_bindings()
890 count = 0
891 for x in vlans:
892 if "netid" in x["net-id"]:
893 count += 1
894 self.assertTrue(count == 2)
895 self.tearDownVlanBinding()
896
897 def testCDeleteVlanBinding(self):
898 vlan1 = self.dbtest.create_vlan_binding(10, "vlan1", "netid1")
899 self.dbtest.delete_vlan_binding("netid1")
900 vlans = self.dbtest.get_all_vlan_bindings()
901 count = 0
902 for x in vlans:
903 if "netid " in x["net-id"]:
904 count += 1
905 self.assertTrue(count == 0)
906 self.tearDownVlanBinding()
907
908 def testDUpdateVlanBinding(self):
909 vlan1 = self.dbtest.create_vlan_binding(10, "vlan1", "netid1")
910 vlan1 = self.dbtest.update_vlan_binding("netid1", 11, "newvlan1")
911 vlans = self.dbtest.get_all_vlan_bindings()
912 count = 0
913 for x in vlans:
914 if "new" in x["vlan-name"]:
915 count += 1
916 self.assertTrue(count == 1)
917 self.tearDownVlanBinding()
918
919 def testICreatePortProfile(self):
920 pp1 = self.dbtest.create_portprofile("portprofile1", 10, "qos1")
921 self.assertTrue(pp1["portprofile-name"] == "portprofile1")
922 self.tearDownPortProfile()
923
924 def testJGetAllPortProfile(self):
925 pp1 = self.dbtest.create_portprofile("portprofile1", 10, "qos1")
926 pp2 = self.dbtest.create_portprofile("portprofile2", 20, "qos2")
927 pps = self.dbtest.get_all_portprofiles()
928 count = 0
929 for x in pps:
930 if "portprofile" in x["portprofile-name"]:
931 count += 1
932 self.assertTrue(count == 2)
933 self.tearDownPortProfile()
934
935 def testKDeletePortProfile(self):
936 pp1 = self.dbtest.create_portprofile("portprofile1", 10, "qos1")
937 self.dbtest.delete_portprofile(pp1["portprofile-id"])
938 pps = self.dbtest.get_all_portprofiles()
939 count = 0
940 for x in pps:
941 if "portprofile " in x["portprofile-name"]:
942 count += 1
943 self.assertTrue(count == 0)
944 self.tearDownPortProfile()
945
946 def testLUpdatePortProfile(self):
947 pp1 = self.dbtest.create_portprofile("portprofile1", 10, "qos1")
948 pp1 = self.dbtest.update_portprofile(pp1["portprofile-id"], \
949 "newportprofile1", 20, "qos2")
950 pps = self.dbtest.get_all_portprofiles()
951 count = 0
952 for x in pps:
953 if "new" in x["portprofile-name"]:
954 count += 1
955 self.assertTrue(count == 1)
956 self.tearDownPortProfile()
957
958 def testMCreatePortProfileBinding(self):
959 pp_binding1 = self.dbtest.create_pp_binding("t1", "net1", \
960 "portprofile1", "0")
961 self.assertTrue(pp_binding1["portprofile-id"] == "portprofile1")
962 self.tearDownPortProfileBinding()
963
964 def testNGetAllPortProfileBinding(self):
965 pp_binding1 = self.dbtest.create_pp_binding("t1", "net1", \
966 "portprofile1", "0")
967 pp_binding2 = self.dbtest.create_pp_binding("t2", "net2", \
968 "portprofile2", "0")
969 pp_bindings = self.dbtest.get_all_pp_bindings()
970 count = 0
971 for x in pp_bindings:
972 if "portprofile" in x["portprofile-id"]:
973 count += 1
974 self.assertTrue(count == 2)
975 self.tearDownPortProfileBinding()
976
977 def testODeletePortProfileBinding(self):
978 pp_binding1 = self.dbtest.create_pp_binding("t1", "net1", \
979 "portprofile1", "0")
980 self.dbtest.delete_pp_binding(pp_binding1["portprofile-id"])
981 pp_bindings = self.dbtest.get_all_pp_bindings()
982 count = 0
983 for x in pp_bindings:
984 if "portprofile " in x["portprofile-id"]:
985 count += 1
986 self.assertTrue(count == 0)
987 self.tearDownPortProfileBinding()
988
989 def testPUpdatePortProfileBinding(self):
990 pp_binding1 = self.dbtest.create_pp_binding("t1", "net1", \
991 "portprofile1", "0")
992 pp_binding1 = self.dbtest.update_pp_binding("portprofile1", \
993 "newt1", "newnet1", "1")
994 pp_bindings = self.dbtest.get_all_pp_bindings()
995 count = 0
996 for x in pp_bindings:
997 if "new" in x["net-id"]:
998 count += 1
999 self.assertTrue(count == 1)
1000 self.tearDownPortProfileBinding()
1001
1002 def tearDownVlanBinding(self):
1003 print "Tearing Down Vlan Binding"
1004 vlans = self.dbtest.get_all_vlan_bindings()
1005 for vlan in vlans:
1006 id = vlan["net-id"]
1007 self.dbtest.delete_vlan_binding(id)
1008
1009 def tearDownPortProfile(self):
1010 print "Tearing Down Port Profile"
1011 pps = self.dbtest.get_all_portprofiles()
1012 for pp in pps:
1013 id = pp["portprofile-id"]
1014 self.dbtest.delete_portprofile(id)
1015
1016 def tearDownPortProfileBinding(self):
1017 print "Tearing Down Port Profile Binding"
1018 pp_bindings = self.dbtest.get_all_pp_bindings()
1019 for pp_binding in pp_bindings:
1020 id = pp_binding["portprofile-id"]
1021 self.dbtest.delete_pp_binding(id)
1022
1023if __name__ == "__main__":
1024 usagestr = "Usage: %prog [OPTIONS] <command> [args]"
1025 parser = OptionParser(usage=usagestr)
1026 parser.add_option("-v", "--verbose", dest="verbose",
1027 action="store_true", default=False, help="turn on verbose logging")
1028
1029 options, args = parser.parse_args()
1030
1031 if options.verbose:
1032 LOG.basicConfig(level=LOG.DEBUG)
1033 else:
1034 LOG.basicConfig(level=LOG.WARN)
1035
1036 #load the models and db based on the 2nd level plugin argument
1037 if args[0] == "ucs":
1038 ucs_db = __import__("quantum.plugins.cisco.db.ucs_db", \
1039 fromlist=["ucs_db"])
1040 ucs_model = __import__("quantum.plugins.cisco.db.ucs_models", \
1041 fromlist=["ucs_models"])
1042
1043 db_conf()
1044
1045 # Run the tests
1046 suite = unittest.TestLoader().loadTestsFromTestCase(L2networkDBTest)
1047 unittest.TextTestRunner(verbosity=2).run(suite)
1048 suite = unittest.TestLoader().loadTestsFromTestCase(UcsDBTest)
1049 unittest.TextTestRunner(verbosity=2).run(suite)
01050
=== added file 'quantum/plugins/cisco/db/l2network_db.py'
--- quantum/plugins/cisco/db/l2network_db.py 1970-01-01 00:00:00 +0000
+++ quantum/plugins/cisco/db/l2network_db.py 2011-08-01 03:39:28 +0000
@@ -0,0 +1,239 @@
1# vim: tabstop=4 shiftwidth=4 softtabstop=4
2
3# Copyright 2011, Cisco Systems, Inc.
4#
5# Licensed under the Apache License, Version 2.0 (the "License"); you may
6# not use this file except in compliance with the License. You may obtain
7# a copy of the License at
8#
9# http://www.apache.org/licenses/LICENSE-2.0
10#
11# Unless required by applicable law or agreed to in writing, software
12# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14# License for the specific language governing permissions and limitations
15# under the License.
16# @author: Rohit Agarwalla, Cisco Systems, Inc.
17
18from sqlalchemy.orm import exc
19
20import l2network_models
21import quantum.db.api as db
22import quantum.db.models as models
23
24
25def get_all_vlan_bindings():
26 """Lists all the vlan to network associations"""
27 session = db.get_session()
28 try:
29 bindings = session.query(l2network_models.VlanBinding).\
30 all()
31 return bindings
32 except exc.NoResultFound:
33 return []
34
35
36def get_vlan_binding(netid):
37 """Lists the vlan given a network_id"""
38 session = db.get_session()
39 try:
40 binding = session.query(l2network_models.VlanBinding).\
41 filter_by(network_id=netid).\
42 one()
43 return binding
44 except exc.NoResultFound:
45 raise Exception("No network found with net-id = %s" % network_id)
46
47
48def add_vlan_binding(vlanid, vlanname, netid):
49 """Adds a vlan to network association"""
50 session = db.get_session()
51 try:
52 binding = session.query(l2network_models.VlanBinding).\
53 filter_by(vlan_id=vlanid).\
54 one()
55 raise Exception("Vlan with id \"%s\" already exists" % vlanid)
56 except exc.NoResultFound:
57 binding = l2network_models.VlanBinding(vlanid, vlanname, netid)
58 session.add(binding)
59 session.flush()
60 return binding
61
62
63def remove_vlan_binding(netid):
64 """Removes a vlan to network association"""
65 session = db.get_session()
66 try:
67 binding = session.query(l2network_models.VlanBinding).\
68 filter_by(network_id=netid).\
69 one()
70 session.delete(binding)
71 session.flush()
72 return binding
73 except exc.NoResultFound:
74 pass
75
76
77def update_vlan_binding(netid, newvlanid=None, newvlanname=None):
78 """Updates a vlan to network association"""
79 session = db.get_session()
80 try:
81 binding = session.query(l2network_models.VlanBinding).\
82 filter_by(network_id=netid).\
83 one()
84 if newvlanid:
85 binding.vlan_id = newvlanid
86 if newvlanname:
87 binding.vlan_name = newvlanname
88 session.merge(binding)
89 session.flush()
90 return binding
91 except exc.NoResultFound:
92 raise Exception("No vlan binding found with network_id = %s" % netid)
93
94
95def get_all_portprofiles():
96 """Lists all the port profiles"""
97 session = db.get_session()
98 try:
99 pps = session.query(l2network_models.PortProfile).\
100 all()
101 return pps
102 except exc.NoResultFound:
103 return []
104
105
106def get_portprofile(ppid):
107 """Lists a port profile"""
108 session = db.get_session()
109 try:
110 pp = session.query(l2network_models.PortProfile).\
111 filter_by(uuid=ppid).\
112 one()
113 return pp
114 except exc.NoResultFound:
115 raise Exception("No portprofile found with id = %s" % ppid)
116
117
118def add_portprofile(ppname, vlanid, qos):
119 """Adds a port profile"""
120 session = db.get_session()
121 try:
122 pp = session.query(l2network_models.PortProfile).\
123 filter_by(name=ppname).\
124 one()
125 raise Exception("Port profile with name %s already exists" % ppname)
126 except exc.NoResultFound:
127 pp = l2network_models.PortProfile(ppname, vlanid, qos)
128 session.add(pp)
129 session.flush()
130 return pp
131
132
133def remove_portprofile(ppid):
134 """Removes a port profile"""
135 session = db.get_session()
136 try:
137 pp = session.query(l2network_models.PortProfile).\
138 filter_by(uuid=ppid).\
139 one()
140 session.delete(pp)
141 session.flush()
142 return pp
143 except exc.NoResultFound:
144 pass
145
146
147def update_portprofile(ppid, newppname=None, newvlanid=None, newqos=None):
148 """Updates port profile"""
149 session = db.get_session()
150 try:
151 pp = session.query(l2network_models.PortProfile).\
152 filter_by(uuid=ppid).\
153 one()
154 if newppname:
155 pp.name = newppname
156 if newvlanid:
157 pp.vlan_id = newvlanid
158 if newqos:
159 pp.qos = newqos
160 session.merge(pp)
161 session.flush()
162 return pp
163 except exc.NoResultFound:
164 raise Exception("No port profile with id = %s" % ppid)
165
166
167def get_all_pp_bindings():
168 """Lists all the port profiles"""
169 session = db.get_session()
170 try:
171 bindings = session.query(l2network_models.PortProfileBinding).\
172 all()
173 return bindings
174 except exc.NoResultFound:
175 return []
176
177
178def get_pp_binding(ppid):
179 """Lists a port profile binding"""
180 session = db.get_session()
181 try:
182 binding = session.query(l2network_models.PortProfileBinding).\
183 filter_by(portprofile_id=ppid).\
184 one()
185 return binding
186 except exc.NoResultFound:
187 raise Exception("No portprofile binding found with id = %s" % ppid)
188
189
190def add_pp_binding(tenantid, networkid, ppid, default):
191 """Adds a port profile binding"""
192 session = db.get_session()
193 try:
194 binding = session.query(l2network_models.PortProfileBinding).\
195 filter_by(portprofile_id=ppid).\
196 one()
197 raise Exception("Port profile binding with id \"%s\" already \
198 exists" % ppid)
199 except exc.NoResultFound:
200 binding = l2network_models.PortProfileBinding(tenantid, networkid, \
201 ppid, default)
202 session.add(binding)
203 session.flush()
204 return binding
205
206
207def remove_pp_binding(ppid):
208 """Removes a port profile binding"""
209 session = db.get_session()
210 try:
211 binding = session.query(l2network_models.PortProfileBinding).\
212 filter_by(portprofile_id=ppid).\
213 one()
214 session.delete(binding)
215 session.flush()
216 return binding
217 except exc.NoResultFound:
218 pass
219
220
221def update_pp_binding(ppid, newtenantid=None, newnetworkid=None, \
222 newdefault=None):
223 """Updates port profile binding"""
224 session = db.get_session()
225 try:
226 binding = session.query(l2network_models.PortProfileBinding).\
227 filter_by(portprofile_id=ppid).\
228 one()
229 if newtenantid:
230 binding.tenant_id = newtenantid
231 if newnetworkid:
232 binding.network_id = newnetworkid
233 if newdefault:
234 binding.default = newdefault
235 session.merge(binding)
236 session.flush()
237 return binding
238 except exc.NoResultFound:
239 raise Exception("No port profile binding with id = %s" % ppid)
0240
=== added file 'quantum/plugins/cisco/db/l2network_models.py'
--- quantum/plugins/cisco/db/l2network_models.py 1970-01-01 00:00:00 +0000
+++ quantum/plugins/cisco/db/l2network_models.py 2011-08-01 03:39:28 +0000
@@ -0,0 +1,86 @@
1# vim: tabstop=4 shiftwidth=4 softtabstop=4
2
3# Copyright 2011, Cisco Systems, Inc.
4#
5# Licensed under the Apache License, Version 2.0 (the "License"); you may
6# not use this file except in compliance with the License. You may obtain
7# a copy of the License at
8#
9# http://www.apache.org/licenses/LICENSE-2.0
10#
11# Unless required by applicable law or agreed to in writing, software
12# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14# License for the specific language governing permissions and limitations
15# under the License.
16# @author: Rohit Agarwalla, Cisco Systems, Inc.
17
18import uuid
19
20from sqlalchemy import Column, Integer, String, ForeignKey, Boolean
21from sqlalchemy.orm import relation
22
23from quantum.db.models import BASE
24
25
26class VlanBinding(BASE):
27 """Represents a binding of vlan_id to network_id"""
28 __tablename__ = 'vlan_bindings'
29
30 vlan_id = Column(Integer, primary_key=True)
31 vlan_name = Column(String(255))
32 network_id = Column(String(255), nullable=False)
33 #foreign key to networks.uuid
34
35 def __init__(self, vlan_id, vlan_name, network_id):
36 self.vlan_id = vlan_id
37 self.vlan_name = vlan_name
38 self.network_id = network_id
39
40 def __repr__(self):
41 return "<VlanBinding(%d,%s,%s)>" % \
42 (self.vlan_id, self.vlan_name, self.network_id)
43
44
45class PortProfile(BASE):
46 """Represents Cisco plugin level PortProfile for a network"""
47 __tablename__ = 'portprofiles'
48
49 uuid = Column(String(255), primary_key=True)
50 name = Column(String(255))
51 vlan_id = Column(Integer)
52 qos = Column(String(255))
53
54 def __init__(self, name, vlan_id, qos=None):
55 self.uuid = uuid.uuid4()
56 self.name = name
57 self.vlan_id = vlan_id
58 self.qos = qos
59
60 def __repr__(self):
61 return "<PortProfile(%s,%s,%d,%s)>" % \
62 (self.uuid, self.name, self.vlan_id, self.qos)
63
64
65class PortProfileBinding(BASE):
66 """Represents PortProfile binding to tenant and network"""
67 __tablename__ = 'portprofile_bindings'
68
69 id = Column(Integer, primary_key=True, autoincrement=True)
70 tenant_id = Column(String(255))
71
72 network_id = Column(String(255), nullable=False)
73 #foreign key to networks.uuid
74 portprofile_id = Column(String(255), nullable=False)
75 #foreign key to portprofiles.uuid
76 default = Column(Boolean)
77
78 def __init__(self, tenant_id, network_id, portprofile_id, default):
79 self.tenant_id = tenant_id
80 self.network_id = network_id
81 self.portprofile_id = portprofile_id
82 self.default = default
83
84 def __repr__(self):
85 return "<PortProfile Binding(%s,%s,%s,%s)>" % \
86 (self.tenant_id, self.network_id, self.portprofile_id, self.default)
087
=== added file 'quantum/plugins/cisco/db/ucs_db.py'
--- quantum/plugins/cisco/db/ucs_db.py 1970-01-01 00:00:00 +0000
+++ quantum/plugins/cisco/db/ucs_db.py 2011-08-01 03:39:28 +0000
@@ -0,0 +1,314 @@
1# vim: tabstop=4 shiftwidth=4 softtabstop=4
2
3# Copyright 2011, Cisco Systems, Inc.
4#
5# Licensed under the Apache License, Version 2.0 (the "License"); you may
6# not use this file except in compliance with the License. You may obtain
7# a copy of the License at
8#
9# http://www.apache.org/licenses/LICENSE-2.0
10#
11# Unless required by applicable law or agreed to in writing, software
12# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14# License for the specific language governing permissions and limitations
15# under the License.
16# @author: Rohit Agarwalla, Cisco Systems, Inc.
17
18from sqlalchemy.orm import exc
19
20import quantum.db.api as db
21import ucs_models
22
23
24def get_all_ucsmbinding():
25 """Lists all the ucsm bindings"""
26 session = db.get_session()
27 try:
28 bindings = session.query(ucs_models.UcsmBinding).\
29 all()
30 return bindings
31 except exc.NoResultFound:
32 return []
33
34
35def get_ucsmbinding(ucsm_ip):
36 """Lists a ucsm binding"""
37 session = db.get_session()
38 try:
39 binding = session.query(ucs_models.UcsmBinding).\
40 filter_by(ucsm_ip=ucsm_ip).\
41 one()
42 return binding
43 except exc.NoResultFound:
44 raise Exception("No binding found with ip = %s" % ucsm_ip)
45
46
47def add_ucsmbinding(ucsm_ip, network_id):
48 """Adds a ucsm binding"""
49 session = db.get_session()
50 try:
51 ip = session.query(ucs_models.UcsmBinding).\
52 filter_by(ucsm_ip=ucsm_ip).\
53 one()
54 raise Exception("Binding with ucsm ip \"%s\" already exists" % ucsm_ip)
55 except exc.NoResultFound:
56 binding = ucs_models.UcsmBinding(ucsm_ip, network_id)
57 session.add(binding)
58 session.flush()
59 return binding
60
61
62def remove_ucsmbinding(ucsm_ip):
63 """Removes a ucsm binding"""
64 session = db.get_session()
65 try:
66 binding = session.query(ucs_models.UcsmBinding).\
67 filter_by(ucsm_ip=ucsm_ip).\
68 one()
69 session.delete(binding)
70 session.flush()
71 return binding
72 except exc.NoResultFound:
73 pass
74
75
76def update_ucsmbinding(ucsm_ip, new_network_id):
77 """Updates ucsm binding"""
78 session = db.get_session()
79 try:
80 binding = session.query(ucs_models.UcsmBinding).\
81 filter_by(ucsm_ip=ucsm_ip).\
82 one()
83 if new_network_id:
84 binding.network_id = new_network_id
85 session.merge(binding)
86 session.flush()
87 return binding
88 except exc.NoResultFound:
89 raise Exception("No binding with ip = %s" % ucsm_ip)
90
91
92def get_all_dynamicvnics():
93 """Lists all the dynamic vnics"""
94 session = db.get_session()
95 try:
96 vnics = session.query(ucs_models.DynamicVnic).\
97 all()
98 return vnics
99 except exc.NoResultFound:
100 return []
101
102
103def get_dynamicvnic(vnic_id):
104 """Lists a dynamic vnic"""
105 session = db.get_session()
106 try:
107 vnic = session.query(ucs_models.DynamicVnic).\
108 filter_by(uuid=vnic_id).\
109 one()
110 return vnic
111 except exc.NoResultFound:
112 raise Exception("No dynamic vnic found with id = %s" % vnic_id)
113
114
115def add_dynamicvnic(device_name, blade_id):
116 """Adds a dynamic vnic"""
117 session = db.get_session()
118 try:
119 name = session.query(ucs_models.DynamicVnic).\
120 filter_by(device_name=device_name).\
121 one()
122 raise Exception("Dynamic vnic with device name %s already exists" % \
123 device_name)
124 except exc.NoResultFound:
125 vnic = ucs_models.DynamicVnic(device_name, blade_id)
126 session.add(vnic)
127 session.flush()
128 return vnic
129
130
131def remove_dynamicvnic(vnic_id):
132 """Removes a dynamic vnic"""
133 session = db.get_session()
134 try:
135 vnic = session.query(ucs_models.DynamicVnic).\
136 filter_by(uuid=vnic_id).\
137 one()
138 session.delete(vnic)
139 session.flush()
140 return vnic
141 except exc.NoResultFound:
142 pass
143
144
145def update_dynamicvnic(vnic_id, new_device_name=None, new_blade_id=None):
146 """Updates dynamic vnic"""
147 session = db.get_session()
148 try:
149 vnic = session.query(ucs_models.DynamicVnic).\
150 filter_by(uuid=vnic_id).\
151 one()
152 if new_device_name:
153 vnic.device_name = new_device_name
154 if new_blade_id:
155 vnic.blade_id = new_blade_id
156 session.merge(vnic)
157 session.flush()
158 return vnic
159 except exc.NoResultFound:
160 raise Exception("No dynamic vnic with id = %s" % vnic_id)
161
162
163def get_all_blades():
164 """Lists all the blades details"""
165 session = db.get_session()
166 try:
167 blades = session.query(ucs_models.UcsBlade).\
168 all()
169 return blades
170 except exc.NoResultFound:
171 return []
172
173
174def get_blade(blade_id):
175 """Lists a blade details"""
176 session = db.get_session()
177 try:
178 blade = session.query(ucs_models.UcsBlade).\
179 filter_by(uuid=blade_id).\
180 one()
181 return blade
182 except exc.NoResultFound:
183 raise Exception("No blade found with id = %s" % blade_id)
184
185
186def add_blade(mgmt_ip, mac_addr, chassis_id, ucsm_ip):
187 """Adds a blade"""
188 session = db.get_session()
189 try:
190 ip = session.query(ucs_models.UcsBlade).\
191 filter_by(mgmt_ip=mgmt_ip).\
192 one()
193 raise Exception("Blade with ip \"%s\" already exists" % mgmt_ip)
194 except exc.NoResultFound:
195 blade = ucs_models.UcsBlade(mgmt_ip, mac_addr, chassis_id, ucsm_ip)
196 session.add(blade)
197 session.flush()
198 return blade
199
200
201def remove_blade(blade_id):
202 """Removes a blade"""
203 session = db.get_session()
204 try:
205 blade = session.query(ucs_models.UcsBlade).\
206 filter_by(uuid=blade_id).\
207 one()
208 session.delete(blade)
209 session.flush()
210 return blade
211 except exc.NoResultFound:
212 pass
213
214
215def update_blade(blade_id, new_mgmt_ip=None, new_mac_addr=None, \
216 new_chassis_id=None, new_ucsm_ip=None):
217 """Updates details of a blade"""
218 session = db.get_session()
219 try:
220 blade = session.query(ucs_models.UcsBlade).\
221 filter_by(uuid=blade_id).\
222 one()
223 if new_mgmt_ip:
224 blade.mgmt_ip = new_mgmt_ip
225 if new_mac_addr:
226 blade.mac_addr = new_mac_addr
227 if new_chassis_id:
228 blade.chassis_id = new_chassis_id
229 if new_ucsm_ip:
230 blade.ucsm_ip = new_ucsm_ip
231 session.merge(blade)
232 session.flush()
233 return blade
234 except exc.NoResultFound:
235 raise Exception("No blade with id = %s" % blade_id)
236
237
238def get_all_portbindings():
239 """Lists all the port bindings"""
240 session = db.get_session()
241 try:
242 port_bindings = session.query(ucs_models.PortBinding).\
243 all()
244 return port_bindings
245 except exc.NoResultFound:
246 return []
247
248
249def get_portbinding(port_id):
250 """Lists a port binding"""
251 session = db.get_session()
252 try:
253 port_binding = session.query(ucs_models.PortBinding).\
254 filter_by(port_id=port_id).\
255 one()
256 return port_binding
257 except exc.NoResultFound:
258 raise Exception("No port binding found with port id = %s" % port_id)
259
260
261def add_portbinding(port_id, dynamic_vnic_id, portprofile_name, \
262 vlan_name, vlan_id, qos):
263 """Adds a port binding"""
264 session = db.get_session()
265 try:
266 port_binding = session.query(ucs_models.PortBinding).\
267 filter_by(port_id=port_id).\
268 one()
269 raise Exception("Port Binding with portid %s already exists" % port_id)
270 except exc.NoResultFound:
271 port_binding = ucs_models.PortBinding(port_id, dynamic_vnic_id, \
272 portprofile_name, vlan_name, vlan_id, qos)
273 session.add(port_binding)
274 session.flush()
275 return port_binding
276
277
278def remove_portbinding(port_id):
279 """Removes a port binding"""
280 session = db.get_session()
281 try:
282 port_binding = session.query(ucs_models.PortBinding).\
283 filter_by(port_id=port_id).\
284 one()
285 session.delete(port_binding)
286 session.flush()
287 return port_binding
288 except exc.NoResultFound:
289 pass
290
291
292def update_portbinding(port_id, dynamic_vnic_id=None, portprofile_name=None, \
293 vlan_name=None, vlan_id=None, qos=None):
294 """Updates port binding"""
295 session = db.get_session()
296 try:
297 port_binding = session.query(ucs_models.PortBinding).\
298 filter_by(port_id=port_id).\
299 one()
300 if dynamic_vnic_id:
301 port_binding.dynamic_vnic_id = dynamic_vnic_id
302 if portprofile_name:
303 port_binding.portprofile_name = portprofile_name
304 if vlan_name:
305 port_binding.vlan_name = vlan_name
306 if vlan_name:
307 port_binding.vlan_id = vlan_id
308 if qos:
309 port_binding.qos = qos
310 session.merge(port_binding)
311 session.flush()
312 return port_binding
313 except exc.NoResultFound:
314 raise Exception("No port binding with port id = %s" % port_id)
0315
=== added file 'quantum/plugins/cisco/db/ucs_models.py'
--- quantum/plugins/cisco/db/ucs_models.py 1970-01-01 00:00:00 +0000
+++ quantum/plugins/cisco/db/ucs_models.py 2011-08-01 03:39:28 +0000
@@ -0,0 +1,113 @@
1# vim: tabstop=4 shiftwidth=4 softtabstop=4
2
3# Copyright 2011, Cisco Systems, Inc.
4#
5# Licensed under the Apache License, Version 2.0 (the "License"); you may
6# not use this file except in compliance with the License. You may obtain
7# a copy of the License at
8#
9# http://www.apache.org/licenses/LICENSE-2.0
10#
11# Unless required by applicable law or agreed to in writing, software
12# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14# License for the specific language governing permissions and limitations
15# under the License.
16# @author: Rohit Agarwalla, Cisco Systems, Inc.
17
18import uuid
19
20from sqlalchemy import Column, Integer, String, ForeignKey, Boolean
21from sqlalchemy.orm import relation
22
23from quantum.db.models import BASE
24
25
26class UcsmBinding(BASE):
27 """Represents a binding of ucsm to network_id"""
28 __tablename__ = 'ucsm_bindings'
29
30 id = Column(Integer, primary_key=True, autoincrement=True)
31 ucsm_ip = Column(String(255))
32 network_id = Column(String(255), nullable=False)
33 #foreign key to networks.uuid
34
35 def __init__(self, ucsm_ip, network_id):
36 self.ucsm_ip = ucsm_ip
37 self.network_id = network_id
38
39 def __repr__(self):
40 return "<UcsmBinding(%s,%s)>" % \
41 (self.ucsm_ip, self.network_id)
42
43
44class DynamicVnic(BASE):
45 """Represents Cisco UCS Dynamic Vnics"""
46 __tablename__ = 'dynamic_vnics'
47
48 uuid = Column(String(255), primary_key=True)
49 device_name = Column(String(255))
50 blade_id = Column(String(255), ForeignKey("ucs_blades.uuid"), \
51 nullable=False)
52
53 def __init__(self, device_name, blade_id):
54 self.uuid = uuid.uuid4()
55 self.device_name = device_name
56 self.blade_id = blade_id
57
58 def __repr__(self):
59 return "<Dyanmic Vnic(%s,%s,%s)>" % \
60 (self.uuid, self.device_name, self.blade_id)
61
62
63class UcsBlade(BASE):
64 """Represents details of ucs blades"""
65 __tablename__ = 'ucs_blades'
66
67 uuid = Column(String(255), primary_key=True)
68 mgmt_ip = Column(String(255))
69 mac_addr = Column(String(255))
70 chassis_id = Column(String(255))
71 ucsm_ip = Column(String(255))
72 dynamic_vnics = relation(DynamicVnic, order_by=DynamicVnic.uuid, \
73 backref="blade")
74
75 def __init__(self, mgmt_ip, mac_addr, chassis_id, ucsm_ip):
76 self.uuid = uuid.uuid4()
77 self.mgmt_ip = mgmt_ip
78 self.mac_addr = mac_addr
79 self.chassis_id = chassis_id
80 self.ucsm_ip = ucsm_ip
81
82 def __repr__(self):
83 return "<UcsBlades (%s,%s,%s,%s,%s)>" % \
84 (self.uuid, self.mgmt_ip, self.mac_addr, self.chassis_id, self.ucsm_ip)
85
86
87class PortBinding(BASE):
88 """Represents Port binding to device interface"""
89 __tablename__ = 'port_bindings'
90
91 id = Column(Integer, primary_key=True, autoincrement=True)
92 port_id = Column(String(255), nullable=False)
93 #foreign key to ports.uuid
94 dynamic_vnic_id = Column(String(255), nullable=False)
95 #foreign key to dynamic_vnics.uuid
96 portprofile_name = Column(String(255))
97 vlan_name = Column(String(255))
98 vlan_id = Column(Integer)
99 qos = Column(String(255))
100
101 def __init__(self, port_id, dynamic_vnic_id, portprofile_name, vlan_name, \
102 vlan_id, qos):
103 self.port_id = port_id
104 self.dynamic_vnic_id = dynamic_vnic_id
105 self.portprofile_name = portprofile_name
106 self.vlan_name = vlan_name
107 self.vlan_id = vlan_id
108 self.qos = qos
109
110 def __repr__(self):
111 return "<PortProfile Binding(%s,%s,%s,%s,%s,%s)>" % \
112 (self.port_id, self.dynamic_vnic_id, self.portprofile_name, \
113 self.vlan_name, self.vlan_id, self.qos)

Subscribers

People subscribed via source and target branches