Small fixup to rapi docstrings
[ganeti-local] / lib / constants.py
index 64669cc..2fd5432 100644 (file)
@@ -1,7 +1,7 @@
 #
 #
 
-# 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
@@ -430,18 +430,20 @@ DT_DRBD8 = "drbd"
 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])
@@ -460,14 +462,16 @@ LD_LV = "lvm"
 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"
@@ -492,6 +496,9 @@ DRBD_VALID_BARRIER_OPT = frozenset([
   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"
@@ -571,7 +578,8 @@ DISK_TEMPLATES = frozenset([
   DT_DRBD8,
   DT_FILE,
   DT_SHARED_FILE,
-  DT_BLOCK
+  DT_BLOCK,
+  DT_RBD
   ])
 
 FILE_DRIVER = frozenset([FD_LOOP, FD_BLKTAP])
@@ -585,8 +593,13 @@ INISECT_OSP = "os"
 
 # 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
@@ -941,18 +954,32 @@ ISPECS_PARAMETERS = frozenset(ISPECS_PARAMETER_TYPES.keys())
 ISPECS_MIN = "min"
 ISPECS_MAX = "max"
 ISPECS_STD = "std"
+IPOLICY_DTS = "disk-templates"
+IPOLICY_VCPU_RATIO = "vcpu-ratio"
+IPOLICY_SPINDLE_RATIO = "spindle-ratio"
 
-IPOLICY_PARAMETERS = frozenset([
+IPOLICY_ISPECS = frozenset([
   ISPECS_MIN,
   ISPECS_MAX,
   ISPECS_STD,
   ])
 
+IPOLICY_PARAMETERS = frozenset([
+  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())
@@ -971,6 +998,7 @@ 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,
@@ -985,6 +1013,7 @@ DISK_LD_TYPES = {
   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())
 
@@ -1005,6 +1034,7 @@ 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,
@@ -1021,6 +1051,7 @@ DISK_DT_TYPES = {
   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())
@@ -1790,6 +1821,7 @@ BEC_DEFAULTS = {
 
 NDC_DEFAULTS = {
   ND_OOB_PROGRAM: None,
+  ND_SPINDLE_COUNT: 1,
   }
 
 DISK_LD_DEFAULTS = {
@@ -1820,6 +1852,9 @@ DISK_LD_DEFAULTS = {
     },
   LD_BLOCKDEV: {
     },
+  LD_RBD: {
+    LDP_POOL: "rbd"
+    },
   }
 
 # readability shortcuts
@@ -1854,6 +1889,9 @@ DISK_DT_DEFAULTS = {
     },
   DT_BLOCK: {
     },
+  DT_RBD: {
+    RBD_POOL: DISK_LD_DEFAULTS[LD_RBD][LDP_POOL]
+    },
   }
 
 # we don't want to export the shortcuts
@@ -1864,6 +1902,8 @@ NICC_DEFAULTS = {
   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 = {
   ISPECS_MIN: {
     ISPEC_MEM_SIZE: 128,
@@ -1873,11 +1913,11 @@ IPOLICY_DEFAULTS = {
     ISPEC_NIC_COUNT: 1,
     },
   ISPECS_MAX: {
-    ISPEC_MEM_SIZE: 128,
-    ISPEC_CPU_COUNT: 1,
-    ISPEC_DISK_COUNT: 1,
-    ISPEC_DISK_SIZE: 1024,
-    ISPEC_NIC_COUNT: 1,
+    ISPEC_MEM_SIZE: 32768,
+    ISPEC_CPU_COUNT: 8,
+    ISPEC_DISK_COUNT: MAX_DISKS,
+    ISPEC_DISK_SIZE: 1024 * 1024,
+    ISPEC_NIC_COUNT: MAX_NICS,
     },
   ISPECS_STD: {
     ISPEC_MEM_SIZE: 128,
@@ -1885,7 +1925,10 @@ IPOLICY_DEFAULTS = {
     ISPEC_DISK_COUNT: 1,
     ISPEC_DISK_SIZE: 1024,
     ISPEC_NIC_COUNT: 1,
-    }
+    },
+  IPOLICY_DTS: DISK_TEMPLATES,
+  IPOLICY_VCPU_RATIO: 4.0,
+  IPOLICY_SPINDLE_RATIO: 32.0,
   }
 
 MASTER_POOL_SIZE_DEFAULT = 10