1
# Copyright 2015 IBM Corp.
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
9
# http://www.apache.org/licenses/LICENSE-2.0
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
17
from networking_ibm.sdnve.ml2 import sdnve_driver
18
from oslo_log import log as logging
20
from neutron.common import constants as n_const
21
from neutron.extensions import portbindings
22
from neutron.plugins.ml2 import driver_api as api
24
LOG = logging.getLogger(__name__)
27
class SdnveMechanismDriver(api.MechanismDriver):
28
"""Ml2 Mechanism driver for IBM SDNVE Controller"""
30
self.vif_type = portbindings.VIF_TYPE_BRIDGE
31
self.vif_details = {portbindings.CAP_PORT_FILTER: False}
32
self.restrict_update_subnet = ['enable_dhcp',
35
self.restrict_update_network = ['router:external']
36
self.sdnve_drv = sdnve_driver.SdnveDriver()
39
def create_network_precommit(self, context):
40
self.sdnve_drv._pre_create_network(context)
42
def create_network_postcommit(self, context):
43
self.sdnve_drv._create_network(context)
45
def update_network_precommit(self, context):
46
self.sdnve_drv._pre_update_network(context)
48
def update_network_postcommit(self, context):
49
self.sdnve_drv._update_network(context)
51
def delete_network_postcommit(self, context):
52
self.sdnve_drv._delete_network(context)
55
def create_subnet_precommit(self, context):
56
self.sdnve_drv._pre_create_subnet(context)
58
def create_subnet_postcommit(self, context):
59
self.sdnve_drv._create_subnet(context)
61
def update_subnet_postcommit(self, context):
62
self.sdnve_drv._update_subnet(context)
64
def update_subnet_precommit(self, context):
65
self.sdnve_drv._pre_update_subnet(context)
67
def delete_subnet_postcommit(self, context):
68
self.sdnve_drv._delete_subnet(context)
71
def create_port_postcommit(self, context):
72
self.sdnve_drv._create_port(context)
74
def create_port_precommit(self, context):
75
self.sdnve_drv._pre_create_port(context)
77
def delete_port_precommit(self, context):
78
self.sdnve_drv._pre_delete_port(context)
80
def update_port_postcommit(self, context):
81
self.sdnve_drv._update_port(context)
83
def delete_port_postcommit(self, context):
84
self.sdnve_drv._delete_port(context)
86
def bind_port(self, context):
87
LOG.debug("Attempting to bind port %(port)s on "
88
"network %(network)s",
89
{'port': context.current['id'],
90
'network': context.network.current['id']})
91
for segment in context.network.network_segments:
92
if self.sdnve_drv._check_segment(segment):
93
context.set_binding(segment[api.ID],
96
status=n_const.PORT_STATUS_ACTIVE)
97
LOG.debug("Bound using segment: %s", segment)
100
LOG.debug("Refusing to bind port for segment ID %(id)s, "
101
"segment %(seg)s, phys net %(physnet)s, and "
102
"network type %(nettype)s",
103
{'id': segment[api.ID],
104
'seg': segment[api.SEGMENTATION_ID],
105
'physnet': segment[api.PHYSICAL_NETWORK],
106
'nettype': segment[api.NETWORK_TYPE]})