Unify the query fields for the storage framework
[ganeti-local] / lib / constants.py
index e374983..815e666 100644 (file)
@@ -196,6 +196,10 @@ ST_LVM_PV = "lvm-pv"
 ST_LVM_VG = "lvm-vg"
 
 # Storage fields
+# first two are valid in LU context only, not passed to backend
+SF_NODE = "node"
+SF_TYPE = "type"
+# and the rest are valid in backend
 SF_NAME = "name"
 SF_SIZE = "size"
 SF_FREE = "free"
@@ -206,11 +210,10 @@ SF_ALLOCATABLE = "allocatable"
 SO_FIX_CONSISTENCY = "fix-consistency"
 
 # Available fields per storage type
-VALID_STORAGE_FIELDS = {
-  ST_FILE: frozenset([SF_NAME, SF_USED, SF_FREE]),
-  ST_LVM_PV: frozenset([SF_NAME, SF_SIZE, SF_USED, SF_FREE, SF_ALLOCATABLE]),
-  ST_LVM_VG: frozenset([SF_NAME, SF_SIZE]),
-  }
+VALID_STORAGE_FIELDS = frozenset([SF_NAME, SF_TYPE, SF_SIZE,
+                                  SF_USED, SF_FREE, SF_ALLOCATABLE])
+
+VALID_STORAGE_TYPES = frozenset([ST_FILE, ST_LVM_PV, ST_LVM_VG])
 
 MODIFIABLE_STORAGE_FIELDS = {
   ST_LVM_PV: frozenset([SF_ALLOCATABLE]),
@@ -664,6 +667,13 @@ CONFD_REQ_NODE_PIP_LIST = 4
 CONFD_REQ_MC_PIP_LIST = 5
 CONFD_REQ_INSTANCES_IPS_LIST = 6
 
+# Confd request query fields. These are used to narrow down queries.
+# These must be strings rather than integers, because json-encoding
+# converts them to strings anyway, as they're used as dict-keys.
+CONFD_REQQ_LINK = "0"
+CONFD_REQQ_IP = "1"
+CONFD_REQQ_IPLIST = "2"
+
 CONFD_REQS = frozenset([
   CONFD_REQ_PING,
   CONFD_REQ_NODE_ROLE_BYNAME,
@@ -694,6 +704,7 @@ CONFD_REPL_STATUSES = frozenset([
 # A few common errors for confd
 CONFD_ERROR_UNKNOWN_ENTRY = 1
 CONFD_ERROR_INTERNAL = 2
+CONFD_ERROR_ARGUMENT = 3
 
 # Each request is "salted" by the current timestamp.
 # This constants decides how many seconds of skew to accept.