Skip to content

Instantly share code, notes, and snippets.

@mgagne
Created August 11, 2015 23:02
Show Gist options
  • Save mgagne/f38bfb96f4340e92f93b to your computer and use it in GitHub Desktop.
Save mgagne/f38bfb96f4340e92f93b to your computer and use it in GitHub Desktop.
from oslo_log import log
from neutron.common import constants
from neutron.extensions import portbindings
from neutron.plugins.ml2 import driver_api as api
LOG = log.getLogger(__name__)
VIF_TYPE_FOOBAR = 'foobar'
class FoobarMechanismDriver(api.MechanismDriver):
def initialize(self):
LOG.debug('Initializing driver')
self.vif_type = VIF_TYPE_FOOBAR
self.vif_details = {portbindings.CAP_PORT_FILTER: False}
LOG.debug('Initializing complete')
def bind_port(self, context):
LOG.debug("Attempting to bind port %(port)s on "
"network %(network)s",
{'port': context.current['id'],
'network': context.network.current['id']})
for segment in context.segments_to_bind:
context.set_binding(segment[api.ID],
self.vif_type,
self.vif_details,
status=constants.PORT_STATUS_ACTIVE)
LOG.debug("Bound using segment: %s", segment)
return
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment