Revision c3f9340c

b/lib/bdev.py
980 980

  
981 981
  """
982 982
  _VERSION_RE = re.compile(r"^version: (\d+)\.(\d+)\.(\d+)"
983
                           r" \(api:(\d+)/proto:(\d+)\)")
983
                           r" \(api:(\d+)/proto:(\d+)(?:-(\d+))?\)")
984

  
984 985
  _DRBD_MAJOR = 147
985 986
  _ST_UNCONFIGURED = "Unconfigured"
986 987
  _ST_WFCONNECTION = "WFConnection"
......
1030 1031
  def _GetVersion(cls):
1031 1032
    """Return the DRBD version.
1032 1033

  
1033
    This will return a list [k_major, k_minor, k_point, api, proto].
1034
    This will return a dict with keys:
1035
      k_major,
1036
      k_minor,
1037
      k_point,
1038
      api,
1039
      proto,
1040
      proto2 (only on drbd > 8.2.X)
1034 1041

  
1035 1042
    """
1036 1043
    proc_data = cls._GetProcData()
......
1039 1046
    if not version:
1040 1047
      raise errors.BlockDeviceError("Can't parse DRBD version from '%s'" %
1041 1048
                                    first_line)
1042
    return [int(val) for val in version.groups()]
1049

  
1050
    values = version.groups()
1051
    retval = {'k_major': int(values[0]),
1052
              'k_minor': int(values[1]),
1053
              'k_point': int(values[2]),
1054
              'api': int(values[3]),
1055
              'proto': int(values[4]),
1056
             }
1057
    if values[5] is not None:
1058
      retval['proto2'] = values[5]
1059

  
1060
    return retval
1043 1061

  
1044 1062
  @staticmethod
1045 1063
  def _DevPath(minor):
......
1132 1150
  def __init__(self, unique_id, children):
1133 1151
    super(DRBDev, self).__init__(unique_id, children)
1134 1152
    self.major = self._DRBD_MAJOR
1135
    [kmaj, kmin, kfix, api, proto] = self._GetVersion()
1136
    if kmaj != 0 and kmin != 7:
1153
    version = self._GetVersion()
1154
    if version['k_major'] != 0 and version['k_minor'] != 7:
1137 1155
      raise errors.BlockDeviceError("Mismatch in DRBD kernel version and"
1138 1156
                                    " requested ganeti usage: kernel is"
1139
                                    " %s.%s, ganeti wants 0.7" % (kmaj, kmin))
1140

  
1157
                                    " %s.%s, ganeti wants 0.7" %
1158
                                    (version['k_major'], version['k_minor']))
1141 1159
    if len(children) != 2:
1142 1160
      raise ValueError("Invalid configuration data %s" % str(children))
1143 1161
    if not isinstance(unique_id, (tuple, list)) or len(unique_id) != 4:
......
1629 1647
      children = []
1630 1648
    super(DRBD8, self).__init__(unique_id, children)
1631 1649
    self.major = self._DRBD_MAJOR
1632
    [kmaj, kmin, kfix, api, proto] = self._GetVersion()
1633
    if kmaj != 8:
1650
    version = self._GetVersion()
1651
    if version['k_major'] != 8 :
1634 1652
      raise errors.BlockDeviceError("Mismatch in DRBD kernel version and"
1635 1653
                                    " requested ganeti usage: kernel is"
1636
                                    " %s.%s, ganeti wants 8.x" % (kmaj, kmin))
1654
                                    " %s.%s, ganeti wants 8.x" %
1655
                                    (version['k_major'], version['k_minor']))
1637 1656

  
1638 1657
    if len(children) not in (0, 2):
1639 1658
      raise ValueError("Invalid configuration data %s" % str(children))

Also available in: Unified diff