Revision d0c8c01d lib/bdev.py

b/lib/bdev.py
600 600
                # one line for any non-empty string
601 601
      logging.error("Can't parse LVS output, no lines? Got '%s'", str(out))
602 602
      return False
603
    out = out[-1].strip().rstrip(',')
603
    out = out[-1].strip().rstrip(",")
604 604
    out = out.split(",")
605 605
    if len(out) != 5:
606 606
      logging.error("Can't parse LVS output, len(%s) != 5", str(out))
......
633 633
    self.minor = minor
634 634
    self.pe_size = pe_size
635 635
    self.stripe_count = stripes
636
    self._degraded = status[0] == 'v' # virtual volume, i.e. doesn't backing
636
    self._degraded = status[0] == "v" # virtual volume, i.e. doesn't backing
637 637
                                      # storage
638 638
    self.attached = True
639 639
    return True
......
745 745
    BlockDev.SetInfo(self, text)
746 746

  
747 747
    # Replace invalid characters
748
    text = re.sub('^[^A-Za-z0-9_+.]', '_', text)
749
    text = re.sub('[^-A-Za-z0-9_+.]', '_', text)
748
    text = re.sub("^[^A-Za-z0-9_+.]", "_", text)
749
    text = re.sub("[^-A-Za-z0-9_+.]", "_", text)
750 750

  
751 751
    # Only up to 128 characters are allowed
752 752
    text = text[:128]
......
971 971
                                    first_line)
972 972

  
973 973
    values = version.groups()
974
    retval = {'k_major': int(values[0]),
975
              'k_minor': int(values[1]),
976
              'k_point': int(values[2]),
977
              'api': int(values[3]),
978
              'proto': int(values[4]),
974
    retval = {"k_major": int(values[0]),
975
              "k_minor": int(values[1]),
976
              "k_point": int(values[2]),
977
              "api": int(values[3]),
978
              "proto": int(values[4]),
979 979
             }
980 980
    if values[5] is not None:
981
      retval['proto2'] = values[5]
981
      retval["proto2"] = values[5]
982 982

  
983 983
    return retval
984 984

  
......
1113 1113
    super(DRBD8, self).__init__(unique_id, children, size)
1114 1114
    self.major = self._DRBD_MAJOR
1115 1115
    version = self._GetVersion(self._GetProcData())
1116
    if version['k_major'] != 8 :
1116
    if version["k_major"] != 8 :
1117 1117
      _ThrowError("Mismatch in DRBD kernel version and requested ganeti"
1118 1118
                  " usage: kernel is %s.%s, ganeti wants 8.x",
1119
                  version['k_major'], version['k_minor'])
1119
                  version["k_major"], version["k_minor"])
1120 1120

  
1121 1121
    if (self._lhost is not None and self._lhost == self._rhost and
1122 1122
        self._lport == self._rport):
......
1210 1210
            pyp.Optional(pyp.restOfLine).suppress())
1211 1211

  
1212 1212
    # an entire section
1213
    section_name = pyp.Word(pyp.alphas + '_')
1213
    section_name = pyp.Word(pyp.alphas + "_")
1214 1214
    section = section_name + lbrace + pyp.ZeroOrMore(pyp.Group(stmt)) + rbrace
1215 1215

  
1216 1216
    bnf = pyp.ZeroOrMore(pyp.Group(section ^ stmt))
......
1343 1343
      # what we aim here is to revert back to the 'drain' method of
1344 1344
      # disk flushes and to disable metadata barriers, in effect going
1345 1345
      # back to pre-8.0.7 behaviour
1346
      vmaj = version['k_major']
1347
      vmin = version['k_minor']
1348
      vrel = version['k_point']
1346
      vmaj = version["k_major"]
1347
      vmin = version["k_minor"]
1348
      vrel = version["k_point"]
1349 1349
      assert vmaj == 8
1350 1350
      if vmin == 0: # 8.0.x
1351 1351
        if vrel >= 12:
1352
          args.extend(['-i', '-m'])
1352
          args.extend(["-i", "-m"])
1353 1353
      elif vmin == 2: # 8.2.x
1354 1354
        if vrel >= 7:
1355
          args.extend(['-i', '-m'])
1355
          args.extend(["-i", "-m"])
1356 1356
      elif vmaj >= 3: # 8.3.x or newer
1357
        args.extend(['-i', '-a', 'm'])
1357
        args.extend(["-i", "-a", "m"])
1358 1358
    result = utils.RunCmd(args)
1359 1359
    if result.failed:
1360 1360
      _ThrowError("drbd%d: can't attach local disk: %s", minor, result.output)
......
2102 2102
    if not isinstance(unique_id, (tuple, list)) or len(unique_id) != 2:
2103 2103
      raise ValueError("Invalid configuration data %s" % str(unique_id))
2104 2104
    self.dev_path = unique_id[1]
2105
    if not os.path.realpath(self.dev_path).startswith('/dev/'):
2105
    if not os.path.realpath(self.dev_path).startswith("/dev/"):
2106 2106
      raise ValueError("Full path '%s' lies outside /dev" %
2107 2107
                              os.path.realpath(self.dev_path))
2108 2108
    # TODO: this is just a safety guard checking that we only deal with devices

Also available in: Unified diff