Revision fcee765d

b/lib/bdev.py
1 1
#
2 2
#
3 3

  
4
# Copyright (C) 2006, 2007 Google Inc.
4
# Copyright (C) 2006, 2007, 2010 Google Inc.
5 5
#
6 6
# This program is free software; you can redistribute it and/or modify
7 7
# it under the terms of the GNU General Public License as published by
......
815 815
  0.7 and 8.x versions of DRBD.
816 816

  
817 817
  """
818
  _VERSION_RE = re.compile(r"^version: (\d+)\.(\d+)\.(\d+)"
818
  _VERSION_RE = re.compile(r"^version: (\d+)\.(\d+)\.(\d+)(?:\.\d+)?"
819 819
                           r" \(api:(\d+)/proto:(\d+)(?:-(\d+))?\)")
820 820
  _VALID_LINE_RE = re.compile("^ *([0-9]+): cs:([^ ]+).*$")
821 821
  _UNUSED_LINE_RE = re.compile("^ *([0-9]+): cs:Unconfigured$")
......
873 873
    return results
874 874

  
875 875
  @classmethod
876
  def _GetVersion(cls):
876
  def _GetVersion(cls, proc_data):
877 877
    """Return the DRBD version.
878 878

  
879 879
    This will return a dict with keys:
......
885 885
      - proto2 (only on drbd > 8.2.X)
886 886

  
887 887
    """
888
    proc_data = cls._GetProcData()
889 888
    first_line = proc_data[0].strip()
890 889
    version = cls._VERSION_RE.match(first_line)
891 890
    if not version:
......
1034 1033
        children = []
1035 1034
    super(DRBD8, self).__init__(unique_id, children, size)
1036 1035
    self.major = self._DRBD_MAJOR
1037
    version = self._GetVersion()
1036
    version = self._GetVersion(self._GetProcData())
1038 1037
    if version['k_major'] != 8 :
1039 1038
      _ThrowError("Mismatch in DRBD kernel version and requested ganeti"
1040 1039
                  " usage: kernel is %s.%s, ganeti wants 8.x",
......
1260 1259
    if size:
1261 1260
      args.extend(["-d", "%sm" % size])
1262 1261
    if not constants.DRBD_BARRIERS: # disable barriers, if configured so
1263
      version = cls._GetVersion()
1262
      version = cls._GetVersion(cls._GetProcData())
1264 1263
      # various DRBD versions support different disk barrier options;
1265 1264
      # what we aim here is to revert back to the 'drain' method of
1266 1265
      # disk flushes and to disable metadata barriers, in effect going
b/test/ganeti.bdev_unittest.py
1 1
#!/usr/bin/python
2 2
#
3 3

  
4
# Copyright (C) 2006, 2007 Google Inc.
4
# Copyright (C) 2006, 2007, 2010 Google Inc.
5 5
#
6 6
# This program is free software; you can redistribute it and/or modify
7 7
# it under the terms of the GNU General Public License as published by
......
31 31
import testutils
32 32

  
33 33

  
34
class TestBaseDRBD(testutils.GanetiTestCase):
35
  def testGetVersion(self):
36
    data = [
37
      ["version: 8.0.12 (api:76/proto:86-91)"],
38
      ["version: 8.2.7 (api:88/proto:0-100)"],
39
      ["version: 8.3.7.49 (api:188/proto:13-191)"],
40
    ]
41
    result = [
42
      {
43
      "k_major": 8,
44
      "k_minor": 0,
45
      "k_point": 12,
46
      "api": 76,
47
      "proto": 86,
48
      "proto2": "91",
49
      },
50
      {
51
      "k_major": 8,
52
      "k_minor": 2,
53
      "k_point": 7,
54
      "api": 88,
55
      "proto": 0,
56
      "proto2": "100",
57
      },
58
      {
59
      "k_major": 8,
60
      "k_minor": 3,
61
      "k_point": 7,
62
      "api": 188,
63
      "proto": 13,
64
      "proto2": "191",
65
      }
66
    ]
67
    for d,r in zip(data, result):
68
      self.assertEqual(bdev.BaseDRBD._GetVersion(d), r)
69

  
70

  
34 71
class TestDRBD8Runner(testutils.GanetiTestCase):
35 72
  """Testing case for DRBD8"""
36 73

  

Also available in: Unified diff