|
24 | 24 | from networking_generic_switch import config as gsw_conf
|
25 | 25 | from networking_generic_switch import devices
|
26 | 26 | from networking_generic_switch.devices import utils as device_utils
|
| 27 | +from networking_generic_switch import exceptions as ngs_exc |
27 | 28 |
|
28 | 29 | LOG = logging.getLogger(__name__)
|
29 | 30 |
|
@@ -371,15 +372,35 @@ def update_port_postcommit(self, context):
|
371 | 372 |
|
372 | 373 | # If segmentation ID is None, set vlan 1
|
373 | 374 | segmentation_id = network.get('provider:segmentation_id') or 1
|
| 375 | + trunk_details = port.get('trunk_details', {}) |
374 | 376 | LOG.debug("Putting switch port %(switch_port)s on "
|
375 | 377 | "%(switch_info)s in vlan %(segmentation_id)s",
|
376 | 378 | {'switch_port': port_id, 'switch_info': switch_info,
|
377 | 379 | 'segmentation_id': segmentation_id})
|
378 | 380 | # Move port to network
|
379 |
| - if is_802_3ad: |
380 |
| - switch.plug_bond_to_network(port_id, segmentation_id) |
381 |
| - else: |
382 |
| - switch.plug_port_to_network(port_id, segmentation_id) |
| 381 | + try: |
| 382 | + if trunk_details: |
| 383 | + vtr = self._is_vlan_translation_required(trunk_details) |
| 384 | + switch.plug_port_to_network_trunk( |
| 385 | + port_id, segmentation_id, trunk_details, vtr) |
| 386 | + elif is_802_3ad: |
| 387 | + switch.plug_bond_to_network(port_id, segmentation_id) |
| 388 | + else: |
| 389 | + switch.plug_port_to_network(port_id, segmentation_id) |
| 390 | + except ngs_exc.GenericSwitchNotSupported as e: |
| 391 | + LOG.warning("Operation is not supported by " |
| 392 | + "networking-generic-switch. %(err)s)", |
| 393 | + {'err': e}) |
| 394 | + raise e |
| 395 | + except Exception as e: |
| 396 | + LOG.error("Failed to plug port %(port_id)s in " |
| 397 | + "segment %(segment_id)s on device " |
| 398 | + "%(device)s due to error %(err)s", |
| 399 | + {'port_id': port['id'], |
| 400 | + 'device': switch_info, |
| 401 | + 'segment_id': segmentation_id, |
| 402 | + 'err': e}) |
| 403 | + raise e |
383 | 404 | LOG.info("Successfully plugged port %(port_id)s in segment "
|
384 | 405 | "%(segment_id)s on device %(device)s",
|
385 | 406 | {'port_id': port['id'], 'device': switch_info,
|
@@ -424,6 +445,14 @@ def delete_port_postcommit(self, context):
|
424 | 445 | if self._is_port_bound(port):
|
425 | 446 | self._unplug_port_from_network(port, context.network.current)
|
426 | 447 |
|
| 448 | + def _is_vlan_translation_required(self, trunk_details): |
| 449 | + """Check if vlan translation is required to configure specific trunk. |
| 450 | +
|
| 451 | + :returns: True if vlan translation is required, False otherwise. |
| 452 | + """ |
| 453 | + # FIXME: removed for simplicity |
| 454 | + return False |
| 455 | + |
427 | 456 | def bind_port(self, context):
|
428 | 457 | """Attempt to bind a port.
|
429 | 458 |
|
|
0 commit comments