Logo Search packages:      
Sourcecode: ganeti version File versions  Download package

def lib::bdev::DRBD8::Attach (   self  ) 

Find a DRBD device which matches our config and attach to it.

In case of partially attached (local device matches but no network
setup), we perform the network attach. If successful, we re-test
the attach if can return success.

Reimplemented from lib::bdev::BlockDev.

Definition at line 2077 of file bdev.py.

02077                   :
    """Find a DRBD device which matches our config and attach to it.

    In case of partially attached (local device matches but no network
    setup), we perform the network attach. If successful, we re-test
    the attach if can return success.

    """
    for minor in self._GetUsedDevs():
      info = self._GetDevInfo(minor)
      match_l = self._MatchesLocal(info)
      match_r = self._MatchesNet(info)
      if match_l and match_r:
        break
      if match_l and not match_r and "local_addr" not in info:
        res_r = self._AssembleNet(minor,
                                  (self._lhost, self._lport,
                                   self._rhost, self._rport),
                                  "C")
        if res_r and self._MatchesNet(self._GetDevInfo(minor)):
          break
      # the weakest case: we find something that is only net attached
      # even though we were passed some children at init time
      if match_r and "local_dev" not in info:
        break
      if match_l and not match_r and "local_addr" in info:
        # strange case - the device network part points to somewhere
        # else, even though its local storage is ours; as we own the
        # drbd space, we try to disconnect from the remote peer and
        # reconnect to our correct one
        if not self._ShutdownNet(minor):
          raise errors.BlockDeviceError("Device has correct local storage,"
                                        " wrong remote peer and is unable to"
                                        " disconnect in order to attach to"
                                        " the correct peer")
        # note: _AssembleNet also handles the case when we don't want
        # local storage (i.e. one or more of the _[lr](host|port) is
        # None)
        if (self._AssembleNet(minor, (self._lhost, self._lport,
                                      self._rhost, self._rport), "C") and
            self._MatchesNet(self._GetDevInfo(minor))):
          break

    else:
      minor = None

    self._SetFromMinor(minor)
    return minor is not None

  def Assemble(self):


Generated by  Doxygen 1.6.0   Back to index