Revision ba174485 lib/constants.py

b/lib/constants.py
30 30
from ganeti import pathutils
31 31

  
32 32

  
33
# various versions
34 33
RELEASE_VERSION = _constants.RELEASE_VERSION
35 34
OS_API_V10 = _constants.OS_API_V10
36 35
OS_API_V15 = _constants.OS_API_V15
......
116 115

  
117 116
DAEMONS_LOGBASE = _constants.DAEMONS_LOGBASE
118 117

  
119
DAEMONS_LOGFILES = \
120
    dict((daemon, pathutils.GetLogFilename(DAEMONS_LOGBASE[daemon]))
121
         for daemon in DAEMONS_LOGBASE)
122

  
123 118
DAEMONS_EXTRA_LOGBASE = _constants.DAEMONS_EXTRA_LOGBASE
124 119

  
125
DAEMONS_EXTRA_LOGFILES = \
126
  dict((daemon, dict((extra,
127
       pathutils.GetLogFilename(DAEMONS_EXTRA_LOGBASE[daemon][extra]))
128
       for extra in DAEMONS_EXTRA_LOGBASE[daemon]))
129
         for daemon in DAEMONS_EXTRA_LOGBASE)
130

  
131 120
DEV_CONSOLE = _constants.DEV_CONSOLE
132 121

  
133 122
PROC_MOUNTS = _constants.PROC_MOUNTS
......
153 142
XEN_CMD_XL = _constants.XEN_CMD_XL
154 143
KNOWN_XEN_COMMANDS = _constants.KNOWN_XEN_COMMANDS
155 144

  
156
# When the Xen toolstack used is "xl", live migration requires the source host
157
# to connect to the target host via ssh (xl runs this command). We need to pass
158
# the command xl runs some extra info so that it can use Ganeti's key
159
# verification and not fail. Note that this string is incomplete: it must be
160
# filled with the cluster name before being used.
161
XL_SSH_CMD = ("ssh -l %s -oGlobalKnownHostsFile=%s"
162
              " -oUserKnownHostsFile=/dev/null"
163
              " -oCheckHostIp=no -oStrictHostKeyChecking=yes"
164
              " -oHostKeyAlias=%%s") % (SSH_LOGIN_USER,
165
                                        pathutils.SSH_KNOWN_HOSTS_FILE)
166

  
167 145
KVM_PATH = _constants.KVM_PATH
168 146
KVM_KERNEL = _constants.KVM_KERNEL
169 147
SOCAT_PATH = _constants.SOCAT_PATH
......
171 149
SOCAT_USE_COMPRESS = _constants.SOCAT_USE_COMPRESS
172 150
SOCAT_ESCAPE_CODE = _constants.SOCAT_ESCAPE_CODE
173 151

  
174

  
175 152
CONS_SSH = _constants.CONS_SSH
176 153
CONS_VNC = _constants.CONS_VNC
177 154
CONS_SPICE = _constants.CONS_SPICE
......
186 163
X509_CERT_CN = _constants.X509_CERT_CN
187 164
X509_CERT_SIGNATURE_HEADER = _constants.X509_CERT_SIGNATURE_HEADER
188 165

  
189
# Import/export daemon mode
190 166
IEM_IMPORT = _constants.IEM_IMPORT
191 167
IEM_EXPORT = _constants.IEM_EXPORT
192 168

  
193
# Import/export transport compression
194 169
IEC_NONE = _constants.IEC_NONE
195 170
IEC_GZIP = _constants.IEC_GZIP
196 171
IEC_ALL = _constants.IEC_ALL
197 172

  
198 173
IE_CUSTOM_SIZE = _constants.IE_CUSTOM_SIZE
199 174

  
200
IE_MAGIC_RE = re.compile(r"^[-_.a-zA-Z0-9]{5,100}$")
201

  
202 175
IEIO_FILE = _constants.IEIO_FILE
203 176
IEIO_RAW_DISK = _constants.IEIO_RAW_DISK
204 177
IEIO_SCRIPT = _constants.IEIO_SCRIPT
......
211 184
VALUE_FALSE = _constants.VALUE_FALSE
212 185
VALUE_HS_NOTHING = _constants.VALUE_HS_NOTHING
213 186

  
214
# External script validation mask
215
EXT_PLUGIN_MASK = re.compile("^[a-zA-Z0-9_-]+$")
216

  
217 187
HOOKS_PHASE_PRE = _constants.HOOKS_PHASE_PRE
218 188
HOOKS_PHASE_POST = _constants.HOOKS_PHASE_POST
219 189
HOOKS_NAME_CFGUPDATE = _constants.HOOKS_NAME_CFGUPDATE
......
241 211
STORAGE_TYPES = _constants.STORAGE_TYPES
242 212
STS_REPORT = _constants.STS_REPORT
243 213

  
244
# Storage fields
245
# first two are valid in LU context only, not passed to backend
246 214
SF_NODE = _constants.SF_NODE
247 215
SF_TYPE = _constants.SF_TYPE
248
# and the rest are valid in backend
249 216
SF_NAME = _constants.SF_NAME
250 217
SF_SIZE = _constants.SF_SIZE
251 218
SF_FREE = _constants.SF_FREE
......
362 329
DDMS_VALUES = _constants.DDMS_VALUES
363 330
DDMS_VALUES_WITH_MODIFY = _constants.DDMS_VALUES_WITH_MODIFY
364 331

  
365
# common exit codes
366 332
EXIT_SUCCESS = _constants.EXIT_SUCCESS
367 333
EXIT_FAILURE = _constants.EXIT_FAILURE
368 334
EXIT_NOTCLUSTER = _constants.EXIT_NOTCLUSTER
......
381 347
MAX_TAG_LEN = _constants.MAX_TAG_LEN
382 348
MAX_TAGS_PER_OBJ = _constants.MAX_TAGS_PER_OBJ
383 349

  
384
# others
385 350
DEFAULT_BRIDGE = _constants.DEFAULT_BRIDGE
386 351
DEFAULT_OVS = _constants.DEFAULT_OVS
387 352
CLASSIC_DRBD_SYNC_SPEED = _constants.CLASSIC_DRBD_SYNC_SPEED
......
392 357
IP4_VERSION = _constants.IP4_VERSION
393 358
IP6_VERSION = _constants.IP6_VERSION
394 359
VALID_IP_VERSIONS = _constants.VALID_IP_VERSIONS
395
# for export to htools
396
IP4_FAMILY = socket.AF_INET
397
IP6_FAMILY = socket.AF_INET6
398 360

  
399 361
TCP_PING_TIMEOUT = _constants.TCP_PING_TIMEOUT
400 362
DEFAULT_VG = _constants.DEFAULT_VG
......
955 917
JOB_QUEUE_SIZE_HARD_LIMIT = _constants.JOB_QUEUE_SIZE_HARD_LIMIT
956 918
JOB_QUEUE_FILES_PERMS = _constants.JOB_QUEUE_FILES_PERMS
957 919

  
958
JOB_ID_TEMPLATE = r"\d+"
959
JOB_FILE_RE = re.compile(r"^job-(%s)$" % JOB_ID_TEMPLATE)
960

  
961 920
JOB_NOTCHANGED = _constants.JOB_NOTCHANGED
962 921

  
963 922
JOB_STATUS_QUEUED = _constants.JOB_STATUS_QUEUED
......
1083 1042

  
1084 1043
DEFAULT_ENABLED_HYPERVISOR = _constants.DEFAULT_ENABLED_HYPERVISOR
1085 1044

  
1086
# HVC_DEFAULTS contains one value 'HV_VNC_PASSWORD_FILE' which is not
1087
# a constant because it depends on an environment variable that is
1088
# used for VClusters.  Therefore, it cannot be automatically generated
1089
# by Haskell at compilation time (given that this environment variable
1090
# might be different at runtime).
1091
HVC_DEFAULTS = _constants.HVC_DEFAULTS
1092
HVC_DEFAULTS[HT_XEN_HVM][HV_VNC_PASSWORD_FILE] = pathutils.VNC_PASSWORD_FILE
1093

  
1094 1045
HVC_GLOBALS = _constants.HVC_GLOBALS
1095 1046

  
1096 1047
BEC_DEFAULTS = _constants.BEC_DEFAULTS
......
1128 1079
CONFD_REQQ_IPLIST = _constants.CONFD_REQQ_IPLIST
1129 1080
CONFD_REQQ_FIELDS = _constants.CONFD_REQQ_FIELDS
1130 1081

  
1131
# FIXME: perhaps update code that uses these constants to deal with
1132
# integers instead of strings
1133
CONFD_REQFIELD_NAME = str(_constants.CONFD_REQFIELD_NAME)
1134
CONFD_REQFIELD_IP = str(_constants.CONFD_REQFIELD_IP)
1135
CONFD_REQFIELD_MNODE_PIP = str(_constants.CONFD_REQFIELD_MNODE_PIP)
1082
CONFD_REQFIELD_NAME = _constants.CONFD_REQFIELD_NAME
1083
CONFD_REQFIELD_IP = _constants.CONFD_REQFIELD_IP
1084
CONFD_REQFIELD_MNODE_PIP = _constants.CONFD_REQFIELD_MNODE_PIP
1136 1085

  
1137 1086
CONFD_REPL_STATUS_OK = _constants.CONFD_REPL_STATUS_OK
1138 1087
CONFD_REPL_STATUS_ERROR = _constants.CONFD_REPL_STATUS_ERROR
......
1205 1154

  
1206 1155
RANDOM_UUID_FILE = _constants.RANDOM_UUID_FILE
1207 1156

  
1208
# Regex string for verifying a UUID
1209
UUID_REGEX = "^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$"
1210

  
1211 1157
AUTO_REPAIR_TAG_PREFIX = _constants.AUTO_REPAIR_TAG_PREFIX
1212 1158
AUTO_REPAIR_TAG_ENABLED = _constants.AUTO_REPAIR_TAG_ENABLED
1213 1159
AUTO_REPAIR_TAG_SUSPENDED = _constants.AUTO_REPAIR_TAG_SUSPENDED
......
1245 1191
MOND_TIME_INTERVAL = _constants.MOND_TIME_INTERVAL
1246 1192
MOND_LATEST_API_VERSION = _constants.MOND_LATEST_API_VERSION
1247 1193

  
1248
# Timeouts for upgrades
1249

  
1250 1194
UPGRADE_QUEUE_DRAIN_TIMEOUT = _constants.UPGRADE_QUEUE_DRAIN_TIMEOUT
1251 1195
UPGRADE_QUEUE_POLL_INTERVAL = _constants.UPGRADE_QUEUE_POLL_INTERVAL
1252 1196

  
1253
# device types to hotplug
1254 1197
HOTPLUG_TARGET_DISK = _constants.HOTPLUG_TARGET_DISK
1255 1198
HOTPLUG_TARGET_NIC = _constants.HOTPLUG_TARGET_NIC
1256 1199
HOTPLUG_ALL_TARGETS = _constants.HOTPLUG_ALL_TARGETS
1257 1200

  
1258
# hotplug actions
1259 1201
HOTPLUG_ACTION_ADD = _constants.HOTPLUG_ACTION_ADD
1260 1202
HOTPLUG_ACTION_REMOVE = _constants.HOTPLUG_ACTION_REMOVE
1261 1203
HOTPLUG_ACTION_MODIFY = _constants.HOTPLUG_ACTION_MODIFY
1262 1204
HOTPLUG_ALL_ACTIONS = _constants.HOTPLUG_ALL_ACTIONS
1263 1205

  
1264
# disk removal timeouts
1265 1206
DISK_REMOVE_RETRY_INTERVAL = _constants.DISK_REMOVE_RETRY_INTERVAL
1266 1207
DISK_REMOVE_RETRY_TIMEOUT = _constants.DISK_REMOVE_RETRY_TIMEOUT
1267 1208

  
1268
# other constants
1269

  
1270 1209
HAS_GNU_LN = _constants.HAS_GNU_LN
1271 1210

  
1272
# Do not re-export imported modules
1273
del re, _vcsversion, _constants, socket, pathutils, compat
1274

  
1275

  
1276 1211
ALLOCATABLE_KEY = "allocatable"
1277 1212
FAILED_KEY = "failed"
1213

  
1214
DAEMONS_LOGFILES = \
1215
    dict((daemon, pathutils.GetLogFilename(DAEMONS_LOGBASE[daemon]))
1216
         for daemon in DAEMONS_LOGBASE)
1217

  
1218
DAEMONS_EXTRA_LOGFILES = \
1219
  dict((daemon, dict((extra,
1220
       pathutils.GetLogFilename(DAEMONS_EXTRA_LOGBASE[daemon][extra]))
1221
       for extra in DAEMONS_EXTRA_LOGBASE[daemon]))
1222
         for daemon in DAEMONS_EXTRA_LOGBASE)
1223

  
1224
# When the Xen toolstack used is "xl", live migration requires the source host
1225
# to connect to the target host via ssh (xl runs this command). We need to pass
1226
# the command xl runs some extra info so that it can use Ganeti's key
1227
# verification and not fail. Note that this string is incomplete: it must be
1228
# filled with the cluster name before being used.
1229
XL_SSH_CMD = ("ssh -l %s -oGlobalKnownHostsFile=%s"
1230
              " -oUserKnownHostsFile=/dev/null"
1231
              " -oCheckHostIp=no -oStrictHostKeyChecking=yes"
1232
              " -oHostKeyAlias=%%s") % (SSH_LOGIN_USER,
1233
                                        pathutils.SSH_KNOWN_HOSTS_FILE)
1234

  
1235
IE_MAGIC_RE = re.compile(r"^[-_.a-zA-Z0-9]{5,100}$")
1236

  
1237
# External script validation mask
1238
EXT_PLUGIN_MASK = re.compile("^[a-zA-Z0-9_-]+$")
1239

  
1240
# for export to htools
1241
IP4_FAMILY = socket.AF_INET
1242
IP6_FAMILY = socket.AF_INET6
1243

  
1244
JOB_ID_TEMPLATE = r"\d+"
1245
JOB_FILE_RE = re.compile(r"^job-(%s)$" % JOB_ID_TEMPLATE)
1246

  
1247
# HVC_DEFAULTS contains one value 'HV_VNC_PASSWORD_FILE' which is not
1248
# a constant because it depends on an environment variable that is
1249
# used for VClusters.  Therefore, it cannot be automatically generated
1250
# by Haskell at compilation time (given that this environment variable
1251
# might be different at runtime).
1252
HVC_DEFAULTS = _constants.HVC_DEFAULTS
1253
HVC_DEFAULTS[HT_XEN_HVM][HV_VNC_PASSWORD_FILE] = pathutils.VNC_PASSWORD_FILE
1254

  
1255
# Regex string for verifying a UUID
1256
UUID_REGEX = "^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$"
1257

  
1258
# Do not re-export imported modules
1259
del re, _vcsversion, _constants, socket, pathutils, compat

Also available in: Unified diff