Revision 27c7d9c3

b/lib/block/drbd.py
34 34
from ganeti.block import base
35 35
from ganeti.block.drbd_info import DRBD8Info
36 36
from ganeti.block.drbd_info import DRBD83ShowInfo
37
from ganeti.block.drbd_info import DRBD84ShowInfo
37 38

  
38 39

  
39 40
# Size of reads in _CanReadDevice
......
93 94
                      " usage: kernel is %s.%s, ganeti wants 8.x",
94 95
                      version["k_major"], version["k_minor"])
95 96

  
97
    if version["k_minor"] <= 3:
98
      self._show_info_cls = DRBD83ShowInfo
99
    else:
100
      self._show_info_cls = DRBD84ShowInfo
101

  
96 102
    if (self._lhost is not None and self._lhost == self._rhost and
97 103
            self._lport == self._rport):
98 104
      raise ValueError("Invalid configuration data, same local/remote %s" %
......
236 242
      return None
237 243
    return result.stdout
238 244

  
245
  def _GetShowInfo(self, minor):
246
    return self._show_info_cls.GetDevInfo(self._GetShowData(minor))
247

  
239 248
  def _MatchesLocal(self, info):
240 249
    """Test if our local config matches with an existing device.
241 250

  
......
452 461
                      minor, result.fail_reason, result.output)
453 462

  
454 463
    def _CheckNetworkConfig():
455
      info = DRBD83ShowInfo.GetDevInfo(self._GetShowData(minor))
464
      info = self._GetShowInfo(minor)
456 465
      if not "local_addr" in info or not "remote_addr" in info:
457 466
        raise utils.RetryAgain()
458 467

  
......
474 483
                      self._aminor)
475 484
    if len(devices) != 2:
476 485
      base.ThrowError("drbd%d: need two devices for AddChildren", self.minor)
477
    info = DRBD83ShowInfo.GetDevInfo(self._GetShowData(self.minor))
486
    info = self._GetShowInfo(self.minor)
478 487
    if "local_dev" in info:
479 488
      base.ThrowError("drbd%d: already attached to a local disk", self.minor)
480 489
    backend, meta = devices
......
497 506
      base.ThrowError("drbd%d: can't attach to drbd8 during RemoveChildren",
498 507
                      self._aminor)
499 508
    # early return if we don't actually have backing storage
500
    info = DRBD83ShowInfo.GetDevInfo(self._GetShowData(self.minor))
509
    info = self._GetShowInfo(self.minor)
501 510
    if "local_dev" not in info:
502 511
      return
503 512
    if len(self._children) != 2:
......
849 858
    # pylint: disable=W0631
850 859
    net_data = (self._lhost, self._lport, self._rhost, self._rport)
851 860
    for minor in (self._aminor,):
852
      info = DRBD83ShowInfo.GetDevInfo(self._GetShowData(minor))
861
      info = self._GetShowInfo(minor)
853 862
      match_l = self._MatchesLocal(info)
854 863
      match_r = self._MatchesNet(info)
855 864

  
......
861 870
        # disk matches, but not attached to network, attach and recheck
862 871
        self._AssembleNet(minor, net_data, constants.DRBD_NET_PROTOCOL,
863 872
                          hmac=constants.DRBD_HMAC_ALG, secret=self._secret)
864
        if self._MatchesNet(DRBD83ShowInfo.GetDevInfo(
865
            self._GetShowData(minor))):
873
        if self._MatchesNet(self._GetShowInfo(minor)):
866 874
          break
867 875
        else:
868 876
          base.ThrowError("drbd%d: network attach successful, but 'drbdsetup"
......
872 880
        # no local disk, but network attached and it matches
873 881
        self._AssembleLocal(minor, self._children[0].dev_path,
874 882
                            self._children[1].dev_path, self.size)
875
        if self._MatchesNet(DRBD83ShowInfo.GetDevInfo(
876
            self._GetShowData(minor))):
883
        if self._MatchesNet(self._GetShowInfo(minor)):
877 884
          break
878 885
        else:
879 886
          base.ThrowError("drbd%d: disk attach successful, but 'drbdsetup"
......
900 907
        # None)
901 908
        self._AssembleNet(minor, net_data, constants.DRBD_NET_PROTOCOL,
902 909
                          hmac=constants.DRBD_HMAC_ALG, secret=self._secret)
903
        if self._MatchesNet(DRBD83ShowInfo.GetDevInfo(
904
            self._GetShowData(minor))):
910
        if self._MatchesNet(self._GetShowInfo(minor)):
905 911
          break
906 912
        else:
907 913
          base.ThrowError("drbd%d: network attach successful, but 'drbdsetup"

Also available in: Unified diff