original_docstring: Bind the subport of a bound parent vhostuser port.
docstring: Bind the subport of a bound parent vhostuser port.
docstring_tokens: Bind the subport of a bound parent vhostuser port .
code: def bind_subport_on_host(self, parent_port, subport_data):
          """Bind the subport of a bound parent vhostuser port."""
          # We ensure parent port binding before calling this method.
          subport_uuid = subport_data['port_id']
          subport_seg_id = subport_data['segmentation_id']
  
          # parent vhostuser intf
          parent_props = self.interfaces[parent_port]
          parent_if_idx = parent_props['iface_idx']
          # Ensure that the uplink and the BD's are setup
          physnet = subport_data['physnet']
          uplink_seg_type = subport_data['uplink_seg_type']
          uplink_seg_id = subport_data['uplink_seg_id']
          LOG.debug('trunk: ensuring subport network on host '
                    'physnet %s, uplink_seg_type %s, uplink_seg_id %s',
                    physnet, uplink_seg_type, uplink_seg_id)
          # Ensure an uplink for the subport
          # Use the uplink physnet, uplink_seg_id & seg_type
          net_data = self.net_driver.ensure_network(physnet,
                                                    uplink_seg_type,
                                                    uplink_seg_id)
          if net_data is None:
              LOG.error('trunk sub-port binding is not possible as the '
                        'physnet could not be configured for subport')
              return None
  
          # fetch if the subport interface already in vpp
          subport_tag = port_tag(subport_uuid)
          subport_if_idx = self.vpp.get_ifidx_by_tag(subport_tag)
          net_br_idx = net_data['bridge_domain_id']
          if subport_if_idx is not None:
              # It's already there and we created it
              LOG.debug('Recovering existing trunk subport %s in VPP',
                        subport_uuid)
              # Ensure that the recovered subport is in vpp bridge
              self.ensure_interface_in_vpp_bridge(net_br_idx, subport_if_idx)
          else:
              # create subport vhostuser intf and ensure it's in vpp bridge
              LOG.debug('trunk: ensuring subport interface on host '
                        'parent_if_idx %s, seg_id %s', parent_if_idx,
                        subport_seg_id)
              subport_if_idx = self.vpp.create_vlan_subif(parent_if_idx,
                                                          subport_seg_id)
              self.ensure_interface_in_vpp_bridge(net_br_idx, subport_if_idx)
              # set subport tag, so we can find it during resyncs
              self.vpp.set_interface_tag(subport_if_idx, subport_tag)
              LOG.debug("Bound subport in vpp with sw_idx: %s on BD: %s ",
                        subport_if_idx, net_br_idx)
          # Add subport props to interfaces along with parent port uuid
          self.interfaces[subport_uuid] = {'iface_idx': subport_if_idx,
                                           'net_data': net_data,
                                           'mac': parent_props['mac'],
                                           'bind_type': 'vhostuser',
                                           'path': parent_props['path'],
                                           'parent_uuid': parent_port
                                           }
  
          if 'trunk' not in parent_props:
              LOG.debug('Setting trunk attr value in parent port props for '
                        'subport %s', subport_uuid)
              parent_props['trunk'] = set([subport_uuid])
          else:
              LOG.debug('Adding subport to trunk parent props for subport %s ',
                        subport_uuid)
              parent_props['trunk'].add(subport_uuid)
          return self.interfaces[subport_uuid]
code_tokens: def bind_subport_on_host ( self , parent_port , subport_data ) : subport_uuid = subport_data [ 'port_id' ] subport_seg_id = subport_data [ 'segmentation_id' ] parent_props = self . interfaces [ parent_port ] parent_if_idx = parent_props [ 'iface_idx' ] physnet = subport_data [ 'physnet' ] uplink_seg_type = subport_data [ 'uplink_seg_type' ] uplink_seg_id = subport_data [ 'uplink_seg_id' ] LOG . debug ( 'trunk: ensuring subport network on host ' 'physnet %s, uplink_seg_type %s, uplink_seg_id %s' , physnet , uplink_seg_type , uplink_seg_id ) net_data = self . net_driver . ensure_network ( physnet , uplink_seg_type , uplink_seg_id ) if net_data is None : LOG . error ( 'trunk sub-port binding is not possible as the ' 'physnet could not be configured for subport' ) return None subport_tag = port_tag ( subport_uuid ) subport_if_idx = self . vpp . get_ifidx_by_tag ( subport_tag ) net_br_idx = net_data [ 'bridge_domain_id' ] if subport_if_idx is not None : LOG . debug ( 'Recovering existing trunk subport %s in VPP' , subport_uuid ) self . ensure_interface_in_vpp_bridge ( net_br_idx , subport_if_idx ) else : LOG . debug ( 'trunk: ensuring subport interface on host ' 'parent_if_idx %s, seg_id %s' , parent_if_idx , subport_seg_id ) subport_if_idx = self . vpp . create_vlan_subif ( parent_if_idx , subport_seg_id ) self . ensure_interface_in_vpp_bridge ( net_br_idx , subport_if_idx ) self . vpp . set_interface_tag ( subport_if_idx , subport_tag ) LOG . debug ( "Bound subport in vpp with sw_idx: %s on BD: %s " , subport_if_idx , net_br_idx ) self . interfaces [ subport_uuid ] = { 'iface_idx' : subport_if_idx , 'net_data' : net_data , 'mac' : parent_props [ 'mac' ] , 'bind_type' : 'vhostuser' , 'path' : parent_props [ 'path' ] , 'parent_uuid' : parent_port } if 'trunk' not in parent_props : LOG . debug ( 'Setting trunk attr value in parent port props for ' 'subport %s' , subport_uuid ) parent_props [ 'trunk' ] = set ( [ subport_uuid ] ) else : LOG . debug ( 'Adding subport to trunk parent props for subport %s ' , subport_uuid ) parent_props [ 'trunk' ] . add ( subport_uuid ) return self . interfaces [ subport_uuid ]
short_docstring: Bind the subport of a bound parent vhostuser port.
short_docstring_tokens: Bind the subport of a bound parent vhostuser port .
comment: """Bind the subport of a bound parent vhostuser port."""$SEP$# We ensure parent port binding before calling this method.$SEP$# parent vhostuser intf$SEP$# Ensure that the uplink and the BD's are setup$SEP$# Ensure an uplink for the subport$SEP$# Use the uplink physnet, uplink_seg_id & seg_type$SEP$# fetch if the subport interface already in vpp$SEP$# It's already there and we created it$SEP$# Ensure that the recovered subport is in vpp bridge$SEP$# create subport vhostuser intf and ensure it's in vpp bridge$SEP$# set subport tag, so we can find it during resyncs$SEP$# Add subport props to interfaces along with parent port uuid