original_docstring: Create a bridge unless it already exists.
docstring: Create a bridge unless it already exists.
docstring_tokens: Create a bridge unless it already exists .
code: def ensure_kernel_bridge(self, bridge_name):
          """Create a bridge unless it already exists."""
          # _bridge_exists_and_ensure_up instead of device_exists is used here
          # because there are cases where the bridge exists but it's not UP,
          # for example:
          # 1) A greenthread was executing this function and had not yet executed
          # "ip link set bridge_name up" before eventlet switched to this
          # thread running the same function
          # 2) The Nova VIF driver was running concurrently and had just created
          #    the bridge, but had not yet put it UP
          if not self._bridge_exists_and_ensure_up(bridge_name):
              bridge_device = bridge_lib.BridgeDevice.addbr(bridge_name)
              bridge_device.setfd(0)
              bridge_device.disable_stp()
              bridge_device.disable_ipv6()
              bridge_device.link.set_up()
          else:
              bridge_device = bridge_lib.BridgeDevice(bridge_name)
          return bridge_device
  
          # TODO(ijw): should be checking this all succeeded
code_tokens: def ensure_kernel_bridge ( self , bridge_name ) : if not self . _bridge_exists_and_ensure_up ( bridge_name ) : bridge_device = bridge_lib . BridgeDevice . addbr ( bridge_name ) bridge_device . setfd ( 0 ) bridge_device . disable_stp ( ) bridge_device . disable_ipv6 ( ) bridge_device . link . set_up ( ) else : bridge_device = bridge_lib . BridgeDevice ( bridge_name ) return bridge_device
short_docstring: Create a bridge unless it already exists.
short_docstring_tokens: Create a bridge unless it already exists .
comment: """Create a bridge unless it already exists."""$SEP$# _bridge_exists_and_ensure_up instead of device_exists is used here$SEP$# because there are cases where the bridge exists but it's not UP,$SEP$# for example:$SEP$# 1) A greenthread was executing this function and had not yet executed$SEP$# "ip link set bridge_name up" before eventlet switched to this$SEP$# thread running the same function$SEP$# 2) The Nova VIF driver was running concurrently and had just created$SEP$#    the bridge, but had not yet put it UP$SEP$# TODO(ijw): should be checking this all succeeded