Revision 6e9814a1
b/lib/bdev.py | ||
---|---|---|
1373 | 1373 |
if result.failed: |
1374 | 1374 |
_ThrowError("drbd%d: can't attach local disk: %s", minor, result.output) |
1375 | 1375 |
|
1376 |
@classmethod |
|
1377 |
def _AssembleNet(cls, minor, net_info, protocol, |
|
1376 |
def _AssembleNet(self, minor, net_info, protocol, |
|
1378 | 1377 |
dual_pri=False, hmac=None, secret=None): |
1379 | 1378 |
"""Configure the network part of the device. |
1380 | 1379 |
|
... | ... | |
1383 | 1382 |
if None in net_info: |
1384 | 1383 |
# we don't want network connection and actually want to make |
1385 | 1384 |
# sure its shutdown |
1386 |
cls._ShutdownNet(minor)
|
|
1385 |
self._ShutdownNet(minor)
|
|
1387 | 1386 |
return |
1388 | 1387 |
|
1389 | 1388 |
# Workaround for a race condition. When DRBD is doing its dance to |
... | ... | |
1392 | 1391 |
# sync speed only after setting up both sides can race with DRBD |
1393 | 1392 |
# connecting, hence we set it here before telling DRBD anything |
1394 | 1393 |
# about its peer. |
1395 |
cls._SetMinorSyncSpeed(minor, constants.SYNC_SPEED) |
|
1394 |
sync_speed = self.params.get(constants.RESYNC_RATE) |
|
1395 |
self._SetMinorSyncSpeed(minor, sync_speed) |
|
1396 | 1396 |
|
1397 | 1397 |
if netutils.IP6Address.IsValid(lhost): |
1398 | 1398 |
if not netutils.IP6Address.IsValid(rhost): |
... | ... | |
1407 | 1407 |
else: |
1408 | 1408 |
_ThrowError("drbd%d: Invalid ip %s" % (minor, lhost)) |
1409 | 1409 |
|
1410 |
args = ["drbdsetup", cls._DevPath(minor), "net",
|
|
1410 |
args = ["drbdsetup", self._DevPath(minor), "net",
|
|
1411 | 1411 |
"%s:%s:%s" % (family, lhost, lport), |
1412 | 1412 |
"%s:%s:%s" % (family, rhost, rport), protocol, |
1413 | 1413 |
"-A", "discard-zero-changes", |
... | ... | |
1424 | 1424 |
minor, result.fail_reason, result.output) |
1425 | 1425 |
|
1426 | 1426 |
def _CheckNetworkConfig(): |
1427 |
info = cls._GetDevInfo(cls._GetShowData(minor))
|
|
1427 |
info = self._GetDevInfo(self._GetShowData(minor))
|
|
1428 | 1428 |
if not "local_addr" in info or not "remote_addr" in info: |
1429 | 1429 |
raise utils.RetryAgain() |
1430 | 1430 |
|
... | ... | |
1758 | 1758 |
# the device |
1759 | 1759 |
self._SlowAssemble() |
1760 | 1760 |
|
1761 |
self.SetSyncSpeed(constants.SYNC_SPEED) |
|
1761 |
sync_speed = self.params.get(constants.RESYNC_RATE) |
|
1762 |
self.SetSyncSpeed(sync_speed) |
|
1762 | 1763 |
|
1763 | 1764 |
def _SlowAssemble(self): |
1764 | 1765 |
"""Assembles the DRBD device from a (partially) configured device. |
b/lib/cmdlib.py | ||
---|---|---|
8055 | 8055 |
raise errors.ProgrammerError("Unknown disk template %s" % disk_template) |
8056 | 8056 |
|
8057 | 8057 |
result = list() |
8058 |
dt_params = disk_params[disk_template] |
|
8058 | 8059 |
if disk_template == constants.DT_DRBD8: |
8059 |
result.append(constants.DISK_LD_DEFAULTS[constants.LD_DRBD8]) |
|
8060 |
params = { |
|
8061 |
constants.RESYNC_RATE: dt_params[constants.DRBD_RESYNC_RATE] |
|
8062 |
} |
|
8063 |
|
|
8064 |
drbd_params = \ |
|
8065 |
objects.FillDict(constants.DISK_LD_DEFAULTS[constants.LD_DRBD8], params) |
|
8066 |
|
|
8067 |
result.append(drbd_params) |
|
8060 | 8068 |
result.append(constants.DISK_LD_DEFAULTS[constants.LD_LV]) |
8061 | 8069 |
result.append(constants.DISK_LD_DEFAULTS[constants.LD_LV]) |
8070 |
|
|
8062 | 8071 |
elif (disk_template == constants.DT_FILE or |
8063 | 8072 |
disk_template == constants.DT_SHARED_FILE): |
8064 | 8073 |
result.append(constants.DISK_LD_DEFAULTS[constants.LD_FILE]) |
b/lib/constants.py | ||
---|---|---|
597 | 597 |
|
598 | 598 |
# others |
599 | 599 |
DEFAULT_BRIDGE = "xen-br0" |
600 |
SYNC_SPEED = 60 * 1024
|
|
600 |
CLASSIC_DRBD_SYNC_SPEED = 60 * 1024 # 60 MiB, expressed in KiB
|
|
601 | 601 |
IP4_ADDRESS_LOCALHOST = "127.0.0.1" |
602 | 602 |
IP4_ADDRESS_ANY = "0.0.0.0" |
603 | 603 |
IP6_ADDRESS_LOCALHOST = "::1" |
... | ... | |
897 | 897 |
NDS_PARAMETERS = frozenset(NDS_PARAMETER_TYPES.keys()) |
898 | 898 |
|
899 | 899 |
# Logical Disks parameters |
900 |
RESYNC_RATE = "resync-rate" |
|
900 | 901 |
DISK_LD_TYPES = { |
902 |
RESYNC_RATE: VTYPE_INT, |
|
901 | 903 |
} |
902 | 904 |
DISK_LD_PARAMETERS = frozenset(DISK_LD_TYPES.keys()) |
903 | 905 |
|
904 | 906 |
# Disk template parameters |
907 |
DRBD_RESYNC_RATE = "resync-rate" |
|
905 | 908 |
DISK_DT_TYPES = { |
909 |
DRBD_RESYNC_RATE: VTYPE_INT, |
|
906 | 910 |
} |
907 | 911 |
|
908 | 912 |
DISK_DT_PARAMETERS = frozenset(DISK_DT_TYPES.keys()) |
... | ... | |
1671 | 1675 |
|
1672 | 1676 |
DISK_LD_DEFAULTS = { |
1673 | 1677 |
LD_DRBD8: { |
1678 |
RESYNC_RATE: CLASSIC_DRBD_SYNC_SPEED, |
|
1674 | 1679 |
}, |
1675 | 1680 |
LD_LV: { |
1676 | 1681 |
}, |
... | ... | |
1684 | 1689 |
DT_PLAIN: { |
1685 | 1690 |
}, |
1686 | 1691 |
DT_DRBD8: { |
1692 |
DRBD_RESYNC_RATE: DISK_LD_DEFAULTS[LD_DRBD8][RESYNC_RATE] |
|
1687 | 1693 |
}, |
1688 | 1694 |
DT_DISKLESS: { |
1689 | 1695 |
}, |
Also available in: Unified diff