Skip to content

Commit

Permalink
Do not bind VM ports directly
Browse files Browse the repository at this point in the history
The hypervisor agent is hopefully named as the host it is running on,
and we still want to bind the native vlan for ironic directly,
but we do not want the VMs VLAN running on the host natively for
the host.
  • Loading branch information
fwiesel committed Jun 17, 2024
1 parent acf44a7 commit fa03095
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions networking_ccloud/ml2/mech_driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,23 @@ def get_workers(self):
"""
return [service.RpcWorker([self], worker_process_count=0)]

def _should_bind_directly(self, context, hg_config):
# No direct binding here
if not hg_config.direct_binding:
return False

# Now we likely want a direct binding, unless the binding request
# comes for a VM on the given host
port = context.current
# We only want to override it for compute
device_owner = port.get('device_owner', None)
if not device_owner or not device_owner.startswith(
nl_const.DEVICE_OWNER_COMPUTE_PREFIX):
return

# So, it is for nova. We only do direct bindings for ironic.
return port.get(pb_api.VNIC_TYPE) == pb_api.VNIC_BAREMETAL

def bind_port(self, context):
"""Attempt to bind a port.
Expand Down Expand Up @@ -187,7 +204,7 @@ def bind_port(self, context):
if not context.binding_levels:
# Port has not been bound to any segment --> top level binding --> hpb
self._bind_port_hierarchical(context, binding_host, hg_config)
elif hg_config.direct_binding:
elif self._should_bind_directly(context, hg_config):
self._bind_port_direct(context, binding_host, hg_config)

def _bind_port_hierarchical(self, context, binding_host, hg_config):
Expand All @@ -213,7 +230,7 @@ def _bind_port_hierarchical(self, context, binding_host, hg_config):
next_segment = context.allocate_dynamic_segment(segment_spec)

# config update (direct bindings are handled in the next step)
if not hg_config.direct_binding:
if not self._should_bind_directly(context, hg_config):
# send rpc call to agent
net_external = context.network.current[extnet_api.EXTERNAL]
self.handle_binding_host_changed(context._plugin_context, context.current['network_id'],
Expand Down

0 comments on commit fa03095

Please sign in to comment.