#
#
-# Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011 Google Inc.
+# Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011, 2012 Google Inc.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
DT_FILE = "file"
DT_SHARED_FILE = "sharedfile"
DT_BLOCK = "blockdev"
+DT_RBD = "rbd"
# the set of network-mirrored disk templates
DTS_INT_MIRROR = frozenset([DT_DRBD8])
# the set of externally-mirrored disk templates (e.g. SAN, NAS)
-DTS_EXT_MIRROR = frozenset([DT_SHARED_FILE, DT_BLOCK])
+DTS_EXT_MIRROR = frozenset([DT_SHARED_FILE, DT_BLOCK, DT_RBD])
# the set of non-lvm-based disk templates
-DTS_NOT_LVM = frozenset([DT_DISKLESS, DT_FILE, DT_SHARED_FILE, DT_BLOCK])
+DTS_NOT_LVM = frozenset([DT_DISKLESS, DT_FILE, DT_SHARED_FILE,
+ DT_BLOCK, DT_RBD])
# the set of disk templates which can be grown
-DTS_GROWABLE = frozenset([DT_PLAIN, DT_DRBD8, DT_FILE, DT_SHARED_FILE])
+DTS_GROWABLE = frozenset([DT_PLAIN, DT_DRBD8, DT_FILE, DT_SHARED_FILE, DT_RBD])
# the set of disk templates that allow adoption
DTS_MAY_ADOPT = frozenset([DT_PLAIN, DT_BLOCK])
LD_DRBD8 = "drbd8"
LD_FILE = "file"
LD_BLOCKDEV = "blockdev"
+LD_RBD = "rbd"
LOGICAL_DISK_TYPES = frozenset([
LD_LV,
LD_DRBD8,
LD_FILE,
LD_BLOCKDEV,
+ LD_RBD,
])
-LDS_BLOCK = frozenset([LD_LV, LD_DRBD8, LD_BLOCKDEV])
+LDS_BLOCK = frozenset([LD_LV, LD_DRBD8, LD_BLOCKDEV, LD_RBD])
# drbd constants
DRBD_HMAC_ALG = "md5"
frozenset([DRBD_B_DISK_BARRIERS, DRBD_B_DISK_FLUSH, DRBD_B_DISK_DRAIN]),
])
+# rbd tool command
+RBD_CMD = "rbd"
+
# file backend driver
FD_LOOP = "loop"
FD_BLKTAP = "blktap"
DT_DRBD8,
DT_FILE,
DT_SHARED_FILE,
- DT_BLOCK
+ DT_BLOCK,
+ DT_RBD
])
FILE_DRIVER = frozenset([FD_LOOP, FD_BLKTAP])
# dynamic device modification
DDM_ADD = "add"
+DDM_MODIFY = "modify"
DDM_REMOVE = "remove"
DDMS_VALUES = frozenset([DDM_ADD, DDM_REMOVE])
+DDMS_VALUES_WITH_MODIFY = (DDMS_VALUES | frozenset([
+ DDM_MODIFY,
+ ]))
+# TODO: DDM_SWAP, DDM_MOVE?
# common exit codes
EXIT_SUCCESS = 0
BES_PARAMETERS = frozenset(BES_PARAMETER_TYPES.keys())
# instance specs
-MEM_SIZE_SPEC = "memory-size"
-CPU_COUNT_SPEC = "cpu-count"
-DISK_COUNT_SPEC = "disk-count"
-DISK_SIZE_SPEC = "disk-size"
-NIC_COUNT_SPEC = "nic-count"
+ISPEC_MEM_SIZE = "memory-size"
+ISPEC_CPU_COUNT = "cpu-count"
+ISPEC_DISK_COUNT = "disk-count"
+ISPEC_DISK_SIZE = "disk-size"
+ISPEC_NIC_COUNT = "nic-count"
ISPECS_PARAMETER_TYPES = {
- MEM_SIZE_SPEC: VTYPE_INT,
- CPU_COUNT_SPEC: VTYPE_INT,
- DISK_COUNT_SPEC: VTYPE_INT,
- DISK_SIZE_SPEC: VTYPE_INT,
- NIC_COUNT_SPEC: VTYPE_INT,
+ ISPEC_MEM_SIZE: VTYPE_INT,
+ ISPEC_CPU_COUNT: VTYPE_INT,
+ ISPEC_DISK_COUNT: VTYPE_INT,
+ ISPEC_DISK_SIZE: VTYPE_INT,
+ ISPEC_NIC_COUNT: VTYPE_INT,
}
ISPECS_PARAMETERS = frozenset(ISPECS_PARAMETER_TYPES.keys())
-MIN_ISPECS = "min"
-MAX_ISPECS = "max"
-STD_ISPECS = "std"
+ISPECS_MIN = "min"
+ISPECS_MAX = "max"
+ISPECS_STD = "std"
+IPOLICY_DTS = "disk-templates"
+IPOLICY_VCPU_RATIO = "vcpu-ratio"
+IPOLICY_SPINDLE_RATIO = "spindle-ratio"
+
+IPOLICY_ISPECS = frozenset([
+ ISPECS_MIN,
+ ISPECS_MAX,
+ ISPECS_STD,
+ ])
IPOLICY_PARAMETERS = frozenset([
- MIN_ISPECS,
- MAX_ISPECS,
- STD_ISPECS
+ IPOLICY_VCPU_RATIO,
+ IPOLICY_SPINDLE_RATIO,
])
+IPOLICY_ALL_KEYS = (IPOLICY_ISPECS |
+ IPOLICY_PARAMETERS |
+ frozenset([IPOLICY_DTS]))
+
# Node parameter names
ND_OOB_PROGRAM = "oob_program"
+ND_SPINDLE_COUNT = "spindle_count"
NDS_PARAMETER_TYPES = {
ND_OOB_PROGRAM: VTYPE_MAYBE_STRING,
+ ND_SPINDLE_COUNT: VTYPE_INT,
}
NDS_PARAMETERS = frozenset(NDS_PARAMETER_TYPES.keys())
LDP_DEFAULT_METAVG = "default-metavg"
LDP_DISK_CUSTOM = "disk-custom"
LDP_NET_CUSTOM = "net-custom"
+LDP_DYNAMIC_RESYNC = "dynamic-resync"
+LDP_PLAN_AHEAD = "c-plan-ahead"
+LDP_FILL_TARGET = "c-fill-target"
+LDP_DELAY_TARGET = "c-delay-target"
+LDP_MAX_RATE = "c-max-rate"
+LDP_MIN_RATE = "c-min-rate"
+LDP_POOL = "pool"
DISK_LD_TYPES = {
LDP_RESYNC_RATE: VTYPE_INT,
LDP_STRIPES: VTYPE_INT,
LDP_DEFAULT_METAVG: VTYPE_STRING,
LDP_DISK_CUSTOM: VTYPE_STRING,
LDP_NET_CUSTOM: VTYPE_STRING,
+ LDP_DYNAMIC_RESYNC: VTYPE_BOOL,
+ LDP_PLAN_AHEAD: VTYPE_INT,
+ LDP_FILL_TARGET: VTYPE_INT,
+ LDP_DELAY_TARGET: VTYPE_INT,
+ LDP_MAX_RATE: VTYPE_INT,
+ LDP_MIN_RATE: VTYPE_INT,
+ LDP_POOL: VTYPE_STRING,
}
DISK_LD_PARAMETERS = frozenset(DISK_LD_TYPES.keys())
-# Disk template parameters
+# Disk template parameters (can be set/changed by the user via gnt-cluster and
+# gnt-group)
DRBD_RESYNC_RATE = "resync-rate"
DRBD_DATA_STRIPES = "data-stripes"
DRBD_META_STRIPES = "meta-stripes"
DRBD_DEFAULT_METAVG = "metavg"
DRBD_DISK_CUSTOM = "disk-custom"
DRBD_NET_CUSTOM = "net-custom"
+DRBD_DYNAMIC_RESYNC = "dynamic-resync"
+DRBD_PLAN_AHEAD = "c-plan-ahead"
+DRBD_FILL_TARGET = "c-fill-target"
+DRBD_DELAY_TARGET = "c-delay-target"
+DRBD_MAX_RATE = "c-max-rate"
+DRBD_MIN_RATE = "c-min-rate"
LV_STRIPES = "stripes"
+RBD_POOL = "pool"
DISK_DT_TYPES = {
DRBD_RESYNC_RATE: VTYPE_INT,
DRBD_DATA_STRIPES: VTYPE_INT,
DRBD_DEFAULT_METAVG: VTYPE_STRING,
DRBD_DISK_CUSTOM: VTYPE_STRING,
DRBD_NET_CUSTOM: VTYPE_STRING,
+ DRBD_DYNAMIC_RESYNC: VTYPE_BOOL,
+ DRBD_PLAN_AHEAD: VTYPE_INT,
+ DRBD_FILL_TARGET: VTYPE_INT,
+ DRBD_DELAY_TARGET: VTYPE_INT,
+ DRBD_MAX_RATE: VTYPE_INT,
+ DRBD_MIN_RATE: VTYPE_INT,
LV_STRIPES: VTYPE_INT,
+ RBD_POOL: VTYPE_STRING,
}
DISK_DT_PARAMETERS = frozenset(DISK_DT_TYPES.keys())
NDC_DEFAULTS = {
ND_OOB_PROGRAM: None,
+ ND_SPINDLE_COUNT: 1,
}
DISK_LD_DEFAULTS = {
LDP_DEFAULT_METAVG: DEFAULT_VG,
LDP_DISK_CUSTOM: "",
LDP_NET_CUSTOM: "",
+ LDP_DYNAMIC_RESYNC: False,
+
+ # The default values for the DRBD dynamic resync speed algorithm are taken
+ # from the drbsetup 8.3.11 man page, except for c-plan-ahead (that we
+ # don't need to set to 0, because we have a separate option to enable it)
+ # and for c-max-rate, that we cap to the default value for the static resync
+ # rate.
+ LDP_PLAN_AHEAD: 20, # ds
+ LDP_FILL_TARGET: 0, # sectors
+ LDP_DELAY_TARGET: 1, # ds
+ LDP_MAX_RATE: CLASSIC_DRBD_SYNC_SPEED, # KiB/s
+ LDP_MIN_RATE: 4 * 1024, # KiB/s
},
LD_LV: {
LDP_STRIPES: _autoconf.LVM_STRIPECOUNT
},
LD_BLOCKDEV: {
},
+ LD_RBD: {
+ LDP_POOL: "rbd"
+ },
}
+# readability shortcuts
+_LV_DEFAULTS = DISK_LD_DEFAULTS[LD_LV]
+_DRBD_DEFAULTS = DISK_LD_DEFAULTS[LD_DRBD8]
+
DISK_DT_DEFAULTS = {
DT_PLAIN: {
LV_STRIPES: DISK_LD_DEFAULTS[LD_LV][LDP_STRIPES],
},
DT_DRBD8: {
- DRBD_RESYNC_RATE: DISK_LD_DEFAULTS[LD_DRBD8][LDP_RESYNC_RATE],
- DRBD_DATA_STRIPES: DISK_LD_DEFAULTS[LD_LV][LDP_STRIPES],
- DRBD_META_STRIPES: DISK_LD_DEFAULTS[LD_LV][LDP_STRIPES],
- DRBD_DISK_BARRIERS: DISK_LD_DEFAULTS[LD_DRBD8][LDP_BARRIERS],
- DRBD_META_BARRIERS: DISK_LD_DEFAULTS[LD_DRBD8][LDP_NO_META_FLUSH],
- DRBD_DEFAULT_METAVG: DISK_LD_DEFAULTS[LD_DRBD8][LDP_DEFAULT_METAVG],
- DRBD_DISK_CUSTOM: DISK_LD_DEFAULTS[LD_DRBD8][LDP_DISK_CUSTOM],
- DRBD_NET_CUSTOM: DISK_LD_DEFAULTS[LD_DRBD8][LDP_NET_CUSTOM],
+ DRBD_RESYNC_RATE: _DRBD_DEFAULTS[LDP_RESYNC_RATE],
+ DRBD_DATA_STRIPES: _LV_DEFAULTS[LDP_STRIPES],
+ DRBD_META_STRIPES: _LV_DEFAULTS[LDP_STRIPES],
+ DRBD_DISK_BARRIERS: _DRBD_DEFAULTS[LDP_BARRIERS],
+ DRBD_META_BARRIERS: _DRBD_DEFAULTS[LDP_NO_META_FLUSH],
+ DRBD_DEFAULT_METAVG: _DRBD_DEFAULTS[LDP_DEFAULT_METAVG],
+ DRBD_DISK_CUSTOM: _DRBD_DEFAULTS[LDP_DISK_CUSTOM],
+ DRBD_NET_CUSTOM: _DRBD_DEFAULTS[LDP_NET_CUSTOM],
+ DRBD_DYNAMIC_RESYNC: _DRBD_DEFAULTS[LDP_DYNAMIC_RESYNC],
+ DRBD_PLAN_AHEAD: _DRBD_DEFAULTS[LDP_PLAN_AHEAD],
+ DRBD_FILL_TARGET: _DRBD_DEFAULTS[LDP_FILL_TARGET],
+ DRBD_DELAY_TARGET: _DRBD_DEFAULTS[LDP_DELAY_TARGET],
+ DRBD_MAX_RATE: _DRBD_DEFAULTS[LDP_MAX_RATE],
+ DRBD_MIN_RATE: _DRBD_DEFAULTS[LDP_MIN_RATE],
},
DT_DISKLESS: {
},
},
DT_BLOCK: {
},
+ DT_RBD: {
+ RBD_POOL: DISK_LD_DEFAULTS[LD_RBD][LDP_POOL]
+ },
}
+# we don't want to export the shortcuts
+del _LV_DEFAULTS, _DRBD_DEFAULTS
+
NICC_DEFAULTS = {
NIC_MODE: NIC_MODE_BRIDGED,
NIC_LINK: DEFAULT_BRIDGE,
}
+# All of the following values are quite arbitrarily - there are no
+# "good" defaults, these must be customised per-site
IPOLICY_DEFAULTS = {
- MIN_ISPECS: {
- MEM_SIZE_SPEC: 128,
- CPU_COUNT_SPEC: 1,
- DISK_COUNT_SPEC: 1,
- DISK_SIZE_SPEC: 1024,
- NIC_COUNT_SPEC: 1,
+ ISPECS_MIN: {
+ ISPEC_MEM_SIZE: 128,
+ ISPEC_CPU_COUNT: 1,
+ ISPEC_DISK_COUNT: 1,
+ ISPEC_DISK_SIZE: 1024,
+ ISPEC_NIC_COUNT: 1,
+ },
+ ISPECS_MAX: {
+ ISPEC_MEM_SIZE: 32768,
+ ISPEC_CPU_COUNT: 8,
+ ISPEC_DISK_COUNT: MAX_DISKS,
+ ISPEC_DISK_SIZE: 1024 * 1024,
+ ISPEC_NIC_COUNT: MAX_NICS,
},
- MAX_ISPECS: {
- MEM_SIZE_SPEC: 128,
- CPU_COUNT_SPEC: 1,
- DISK_COUNT_SPEC: 1,
- DISK_SIZE_SPEC: 1024,
- NIC_COUNT_SPEC: 1,
+ ISPECS_STD: {
+ ISPEC_MEM_SIZE: 128,
+ ISPEC_CPU_COUNT: 1,
+ ISPEC_DISK_COUNT: 1,
+ ISPEC_DISK_SIZE: 1024,
+ ISPEC_NIC_COUNT: 1,
},
- STD_ISPECS: {
- MEM_SIZE_SPEC: 128,
- CPU_COUNT_SPEC: 1,
- DISK_COUNT_SPEC: 1,
- DISK_SIZE_SPEC: 1024,
- NIC_COUNT_SPEC: 1,
- }
+ IPOLICY_DTS: DISK_TEMPLATES,
+ IPOLICY_VCPU_RATIO: 4.0,
+ IPOLICY_SPINDLE_RATIO: 32.0,
}
MASTER_POOL_SIZE_DEFAULT = 10