Statistics
| Branch: | Tag: | Revision:

root / lib / constants.py @ d00a730d

History | View | Annotate | Download (37.4 kB)

1 2f31098c Iustin Pop
#
2 a8083063 Iustin Pop
#
3 a8083063 Iustin Pop
4 dcb9946c Iustin Pop
# Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011 Google Inc.
5 a8083063 Iustin Pop
#
6 a8083063 Iustin Pop
# This program is free software; you can redistribute it and/or modify
7 a8083063 Iustin Pop
# it under the terms of the GNU General Public License as published by
8 a8083063 Iustin Pop
# the Free Software Foundation; either version 2 of the License, or
9 a8083063 Iustin Pop
# (at your option) any later version.
10 a8083063 Iustin Pop
#
11 a8083063 Iustin Pop
# This program is distributed in the hope that it will be useful, but
12 a8083063 Iustin Pop
# WITHOUT ANY WARRANTY; without even the implied warranty of
13 a8083063 Iustin Pop
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14 a8083063 Iustin Pop
# General Public License for more details.
15 a8083063 Iustin Pop
#
16 a8083063 Iustin Pop
# You should have received a copy of the GNU General Public License
17 a8083063 Iustin Pop
# along with this program; if not, write to the Free Software
18 a8083063 Iustin Pop
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
19 a8083063 Iustin Pop
# 02110-1301, USA.
20 a8083063 Iustin Pop
21 a8083063 Iustin Pop
22 a8083063 Iustin Pop
"""Module holding different constants."""
23 a8083063 Iustin Pop
24 4fe80ef2 Iustin Pop
import re
25 4fe80ef2 Iustin Pop
26 2ec08468 Michael Hanselmann
from ganeti import _autoconf
27 13aeae6a Iustin Pop
from ganeti import _vcsversion
28 7c18ef8e Michael Hanselmann
29 a8083063 Iustin Pop
# various versions
30 2ec08468 Michael Hanselmann
RELEASE_VERSION = _autoconf.PACKAGE_VERSION
31 d1a7d66f Guido Trotter
OS_API_V10 = 10
32 d1a7d66f Guido Trotter
OS_API_V15 = 15
33 b41b3516 Iustin Pop
OS_API_V20 = 20
34 b41b3516 Iustin Pop
OS_API_VERSIONS = frozenset([OS_API_V10, OS_API_V15, OS_API_V20])
35 13aeae6a Iustin Pop
VCS_VERSION = _vcsversion.VCS_VERSION
36 a8083063 Iustin Pop
EXPORT_VERSION = 0
37 bac5ffc3 Oleksiy Mishchenko
RAPI_VERSION = 2
38 a8083063 Iustin Pop
39 1b45f4e5 Michael Hanselmann
40 243cdbcc Michael Hanselmann
# Format for CONFIG_VERSION:
41 243cdbcc Michael Hanselmann
#   01 03 0123 = 01030123
42 243cdbcc Michael Hanselmann
#   ^^ ^^ ^^^^
43 243cdbcc Michael Hanselmann
#   |  |  + Configuration version/revision
44 243cdbcc Michael Hanselmann
#   |  + Minor version
45 243cdbcc Michael Hanselmann
#   + Major version
46 243cdbcc Michael Hanselmann
#
47 243cdbcc Michael Hanselmann
# It stored as an integer. Make sure not to write an octal number.
48 1b45f4e5 Michael Hanselmann
49 1b45f4e5 Michael Hanselmann
# BuildVersion and SplitVersion must be in here because we can't import other
50 1b45f4e5 Michael Hanselmann
# modules. The cfgupgrade tool must be able to read and write version numbers
51 1b45f4e5 Michael Hanselmann
# and thus requires these functions. To avoid code duplication, they're kept in
52 1b45f4e5 Michael Hanselmann
# here.
53 1b45f4e5 Michael Hanselmann
54 1b45f4e5 Michael Hanselmann
def BuildVersion(major, minor, revision):
55 1b45f4e5 Michael Hanselmann
  """Calculates int version number from major, minor and revision numbers.
56 1b45f4e5 Michael Hanselmann

57 1b45f4e5 Michael Hanselmann
  Returns: int representing version number
58 1b45f4e5 Michael Hanselmann

59 1b45f4e5 Michael Hanselmann
  """
60 1b45f4e5 Michael Hanselmann
  assert isinstance(major, int)
61 1b45f4e5 Michael Hanselmann
  assert isinstance(minor, int)
62 1b45f4e5 Michael Hanselmann
  assert isinstance(revision, int)
63 1b45f4e5 Michael Hanselmann
  return (1000000 * major +
64 1b45f4e5 Michael Hanselmann
            10000 * minor +
65 1b45f4e5 Michael Hanselmann
                1 * revision)
66 1b45f4e5 Michael Hanselmann
67 1b45f4e5 Michael Hanselmann
68 1b45f4e5 Michael Hanselmann
def SplitVersion(version):
69 1b45f4e5 Michael Hanselmann
  """Splits version number stored in an int.
70 1b45f4e5 Michael Hanselmann

71 1b45f4e5 Michael Hanselmann
  Returns: tuple; (major, minor, revision)
72 1b45f4e5 Michael Hanselmann

73 1b45f4e5 Michael Hanselmann
  """
74 1b45f4e5 Michael Hanselmann
  assert isinstance(version, int)
75 1b45f4e5 Michael Hanselmann
76 1b45f4e5 Michael Hanselmann
  (major, remainder) = divmod(version, 1000000)
77 1b45f4e5 Michael Hanselmann
  (minor, revision) = divmod(remainder, 10000)
78 1b45f4e5 Michael Hanselmann
79 1b45f4e5 Michael Hanselmann
  return (major, minor, revision)
80 1b45f4e5 Michael Hanselmann
81 1b45f4e5 Michael Hanselmann
82 243cdbcc Michael Hanselmann
CONFIG_MAJOR = int(_autoconf.VERSION_MAJOR)
83 243cdbcc Michael Hanselmann
CONFIG_MINOR = int(_autoconf.VERSION_MINOR)
84 243cdbcc Michael Hanselmann
CONFIG_REVISION = 0
85 1b45f4e5 Michael Hanselmann
CONFIG_VERSION = BuildVersion(CONFIG_MAJOR, CONFIG_MINOR, CONFIG_REVISION)
86 a8083063 Iustin Pop
87 cc7d6f1a Michael Hanselmann
#: RPC protocol version
88 cc7d6f1a Michael Hanselmann
PROTOCOL_VERSION = BuildVersion(CONFIG_MAJOR, CONFIG_MINOR, 0)
89 cc7d6f1a Michael Hanselmann
90 8b72b05c René Nussbaumer
# user separation
91 8b72b05c René Nussbaumer
DAEMONS_GROUP = _autoconf.DAEMONS_GROUP
92 f12e1736 René Nussbaumer
ADMIN_GROUP = _autoconf.ADMIN_GROUP
93 8b72b05c René Nussbaumer
MASTERD_USER = _autoconf.MASTERD_USER
94 f12e1736 René Nussbaumer
MASTERD_GROUP = _autoconf.MASTERD_GROUP
95 8b72b05c René Nussbaumer
RAPI_USER = _autoconf.RAPI_USER
96 f12e1736 René Nussbaumer
RAPI_GROUP = _autoconf.RAPI_GROUP
97 f12e1736 René Nussbaumer
CONFD_USER = _autoconf.CONFD_USER
98 f12e1736 René Nussbaumer
CONFD_GROUP = _autoconf.CONFD_GROUP
99 f12e1736 René Nussbaumer
NODED_USER = _autoconf.NODED_USER
100 03881cb0 René Nussbaumer
NODED_GROUP = _autoconf.NODED_GROUP
101 8b72b05c René Nussbaumer
102 a03fcb26 René Nussbaumer
103 6e991d0e René Nussbaumer
# Wipe
104 da63bb4e René Nussbaumer
DD_CMD = "dd"
105 da63bb4e René Nussbaumer
WIPE_BLOCK_SIZE = 1024**2
106 a03fcb26 René Nussbaumer
MAX_WIPE_CHUNK = 1024 # 1GB
107 a03fcb26 René Nussbaumer
MIN_WIPE_CHUNK_PERCENT = 10
108 a03fcb26 René Nussbaumer
109 6e991d0e René Nussbaumer
110 a8083063 Iustin Pop
# file paths
111 2ec08468 Michael Hanselmann
DATA_DIR = _autoconf.LOCALSTATEDIR + "/lib/ganeti"
112 1ed70996 Iustin Pop
RUN_DIR = _autoconf.LOCALSTATEDIR + "/run"
113 75afaefc Iustin Pop
RUN_GANETI_DIR = RUN_DIR + "/ganeti"
114 42ff3343 Guido Trotter
BDEV_CACHE_DIR = RUN_GANETI_DIR + "/bdev-cache"
115 75afaefc Iustin Pop
DISK_LINKS_DIR = RUN_GANETI_DIR + "/instance-disks"
116 8b72b05c René Nussbaumer
RUN_DIRS_MODE = 0775
117 b4442fd9 Guido Trotter
SOCKET_DIR = RUN_GANETI_DIR + "/socket"
118 5bae14d9 Guido Trotter
SECURE_DIR_MODE = 0700
119 637c8ab8 Balazs Lecz
SECURE_FILE_MODE = 0600
120 8b72b05c René Nussbaumer
SOCKET_DIR_MODE = 0750
121 f942a838 Michael Hanselmann
CRYPTO_KEYS_DIR = RUN_GANETI_DIR + "/crypto"
122 01144827 Guido Trotter
CRYPTO_KEYS_DIR_MODE = SECURE_DIR_MODE
123 1651d116 Michael Hanselmann
IMPORT_EXPORT_DIR = RUN_GANETI_DIR + "/import-export"
124 1651d116 Michael Hanselmann
IMPORT_EXPORT_DIR_MODE = 0755
125 b6135bbc Apollon Oikonomopoulos
ADOPTABLE_BLOCKDEV_ROOT = "/dev/disk/"
126 75afaefc Iustin Pop
# keep RUN_GANETI_DIR first here, to make sure all get created when the node
127 75afaefc Iustin Pop
# daemon is started (this takes care of RUN_DIR being tmpfs)
128 75afaefc Iustin Pop
SUB_RUN_DIRS = [ RUN_GANETI_DIR, BDEV_CACHE_DIR, DISK_LINKS_DIR ]
129 3aecd2c7 Iustin Pop
LOCK_DIR = _autoconf.LOCALSTATEDIR + "/lock"
130 0c223ea9 Michael Hanselmann
SSCONF_LOCK_FILE = LOCK_DIR + "/ganeti-ssconf.lock"
131 649bcdd8 Balazs Lecz
# User-id pool lock directory
132 649bcdd8 Balazs Lecz
# The user-ids that are in use have a corresponding lock file in this directory
133 649bcdd8 Balazs Lecz
UIDPOOL_LOCKDIR = RUN_GANETI_DIR + "/uid-pool"
134 a8083063 Iustin Pop
CLUSTER_CONF_FILE = DATA_DIR + "/config.data"
135 168c1de2 Michael Hanselmann
NODED_CERT_FILE = DATA_DIR + "/server.pem"
136 61a08fa3 Michael Hanselmann
RAPI_CERT_FILE = DATA_DIR + "/rapi.pem"
137 6b7d5878 Michael Hanselmann
CONFD_HMAC_KEY = DATA_DIR + "/hmac.key"
138 3db3eb2a Michael Hanselmann
CLUSTER_DOMAIN_SECRET_FILE = DATA_DIR + "/cluster-domain-secret"
139 bcf0450d Michael Hanselmann
INSTANCE_STATUS_FILE = RUN_GANETI_DIR + "/instance-status"
140 82122173 Iustin Pop
SSH_KNOWN_HOSTS_FILE = DATA_DIR + "/known_hosts"
141 fdd9ac5b Michael Hanselmann
RAPI_USERS_FILE = DATA_DIR + "/rapi/users"
142 f1da30e6 Michael Hanselmann
QUEUE_DIR = DATA_DIR + "/queue"
143 f154a7a3 Michael Hanselmann
DAEMON_UTIL = _autoconf.PKGLIBDIR + "/daemon-util"
144 2e6469a1 René Nussbaumer
SETUP_SSH = _autoconf.TOOLSDIR + "/setup-ssh"
145 26916aad Apollon Oikonomopoulos
KVM_IFUP = _autoconf.PKGLIBDIR + "/kvm-ifup"
146 2f4c951e Stephen Shirley
KVM_CONSOLE_WRAPPER = _autoconf.PKGLIBDIR + "/tools/kvm-console-wrapper"
147 61631293 Stephen Shirley
XM_CONSOLE_WRAPPER = _autoconf.PKGLIBDIR + "/tools/xm-console-wrapper"
148 c8a0948f Michael Hanselmann
ETC_HOSTS = "/etc/hosts"
149 1abbbbe2 Manuel Franceschini
DEFAULT_FILE_STORAGE_DIR = _autoconf.FILE_STORAGE_DIR
150 4b97f902 Apollon Oikonomopoulos
DEFAULT_SHARED_FILE_STORAGE_DIR = _autoconf.SHARED_FILE_STORAGE_DIR
151 cb7c0198 Iustin Pop
ENABLE_FILE_STORAGE = _autoconf.ENABLE_FILE_STORAGE
152 4b97f902 Apollon Oikonomopoulos
ENABLE_SHARED_FILE_STORAGE = _autoconf.ENABLE_SHARED_FILE_STORAGE
153 5420ffc9 Guido Trotter
SYSCONFDIR = _autoconf.SYSCONFDIR
154 bea60381 Michael Hanselmann
TOOLSDIR = _autoconf.TOOLSDIR
155 131178b9 Luca Bigliardi
CONF_DIR = SYSCONFDIR + "/ganeti"
156 9894ece7 Michael Hanselmann
157 9d7b1e53 Michael Hanselmann
#: Lock file for watcher, locked in shared mode by watcher; lock in exclusive
158 9d7b1e53 Michael Hanselmann
# mode to block watcher (see L{cli._RunWhileClusterStoppedHelper.Call}
159 9d7b1e53 Michael Hanselmann
WATCHER_LOCK_FILE = LOCK_DIR + "/ganeti-watcher.lock"
160 9d7b1e53 Michael Hanselmann
161 9d7b1e53 Michael Hanselmann
#: Status file for per-group watcher, locked in exclusive mode by watcher
162 9d7b1e53 Michael Hanselmann
WATCHER_GROUP_STATE_FILE = DATA_DIR + "/watcher.%s.data"
163 9d7b1e53 Michael Hanselmann
164 9bb69bb5 Michael Hanselmann
#: File for per-group instance status, merged into L{INSTANCE_STATUS_FILE} by
165 9bb69bb5 Michael Hanselmann
#: per-group processes
166 9bb69bb5 Michael Hanselmann
WATCHER_GROUP_INSTANCE_STATUS_FILE = DATA_DIR + "/watcher.%s.instance-status"
167 9bb69bb5 Michael Hanselmann
168 9d7b1e53 Michael Hanselmann
#: File containing Unix timestamp until which watcher should be paused
169 9d7b1e53 Michael Hanselmann
WATCHER_PAUSEFILE = DATA_DIR + "/watcher.pause"
170 9d7b1e53 Michael Hanselmann
171 168c1de2 Michael Hanselmann
ALL_CERT_FILES = frozenset([NODED_CERT_FILE, RAPI_CERT_FILE])
172 d3100055 Michael Hanselmann
173 227647ac Guido Trotter
MASTER_SOCKET = SOCKET_DIR + "/ganeti-master"
174 a8083063 Iustin Pop
175 cd50653c Guido Trotter
NODED = "ganeti-noded"
176 18679072 Guido Trotter
CONFD = "ganeti-confd"
177 8c96d01f Guido Trotter
RAPI = "ganeti-rapi"
178 dae3fdd2 Guido Trotter
MASTERD = "ganeti-masterd"
179 4d32feba Guido Trotter
# used in the ganeti-nbma project
180 4d32feba Guido Trotter
NLD = "ganeti-nld"
181 cd50653c Guido Trotter
182 cd50653c Guido Trotter
DAEMONS_PORTS = {
183 cd50653c Guido Trotter
  # daemon-name: ("proto", "default-port")
184 cd50653c Guido Trotter
  NODED: ("tcp", 1811),
185 18679072 Guido Trotter
  CONFD: ("udp", 1814),
186 8c96d01f Guido Trotter
  RAPI: ("tcp", 5080),
187 2089573e René Nussbaumer
  "ssh": ("tcp", 22),
188 4d32feba Guido Trotter
  # used in the ganeti-nbma project
189 4d32feba Guido Trotter
  NLD: ("udp", 1816),
190 cd50653c Guido Trotter
}
191 cd50653c Guido Trotter
DEFAULT_NODED_PORT = DAEMONS_PORTS[NODED][1]
192 18679072 Guido Trotter
DEFAULT_CONFD_PORT = DAEMONS_PORTS[CONFD][1]
193 8c96d01f Guido Trotter
DEFAULT_RAPI_PORT = DAEMONS_PORTS[RAPI][1]
194 4d32feba Guido Trotter
# used in the ganeti-nbma project
195 4d32feba Guido Trotter
DEFAULT_NLD_PORT = DAEMONS_PORTS[NLD][1]
196 cd50653c Guido Trotter
197 a8083063 Iustin Pop
FIRST_DRBD_PORT = 11000
198 a8083063 Iustin Pop
LAST_DRBD_PORT = 14999
199 880478f8 Iustin Pop
MASTER_SCRIPT = "ganeti-master"
200 a8083063 Iustin Pop
201 9936bd63 Iustin Pop
LOG_DIR = _autoconf.LOCALSTATEDIR + "/log/ganeti/"
202 dae3fdd2 Guido Trotter
DAEMONS_LOGFILES = {
203 d73ef63f Michael Hanselmann
  # "daemon-name": "logfile"
204 d73ef63f Michael Hanselmann
  NODED: LOG_DIR + "node-daemon.log",
205 d73ef63f Michael Hanselmann
  CONFD: LOG_DIR + "conf-daemon.log",
206 d73ef63f Michael Hanselmann
  RAPI: LOG_DIR + "rapi-daemon.log",
207 d73ef63f Michael Hanselmann
  MASTERD: LOG_DIR + "master-daemon.log",
208 4d32feba Guido Trotter
  # used in the ganeti-nbma project
209 4d32feba Guido Trotter
  NLD: LOG_DIR + "nl-daemon.log",
210 d73ef63f Michael Hanselmann
  }
211 57fd6d0b Michael Hanselmann
212 9936bd63 Iustin Pop
LOG_OS_DIR = LOG_DIR + "os"
213 9936bd63 Iustin Pop
LOG_WATCHER = LOG_DIR + "watcher.log"
214 9936bd63 Iustin Pop
LOG_COMMANDS = LOG_DIR + "commands.log"
215 6abe9194 Iustin Pop
LOG_BURNIN = LOG_DIR + "burnin.log"
216 2089573e René Nussbaumer
LOG_SETUP_SSH = LOG_DIR + "setup-ssh.log"
217 a8083063 Iustin Pop
218 481d47e8 Luca Bigliardi
DEV_CONSOLE = "/dev/console"
219 481d47e8 Luca Bigliardi
220 1b045f5d Balazs Lecz
PROC_MOUNTS = "/proc/mounts"
221 1b045f5d Balazs Lecz
222 3d5ebbf0 Stephen Shirley
# Local UniX Interface related constants
223 25942a6c Guido Trotter
LUXI_EOM = "\3"
224 e986f20c Michael Hanselmann
LUXI_VERSION = CONFIG_VERSION
225 25942a6c Guido Trotter
226 d0c8c01d Iustin Pop
# one of "no", "yes", "only"
227 551b6283 Iustin Pop
SYSLOG_USAGE = _autoconf.SYSLOG_USAGE
228 551b6283 Iustin Pop
SYSLOG_NO = "no"
229 551b6283 Iustin Pop
SYSLOG_YES = "yes"
230 551b6283 Iustin Pop
SYSLOG_ONLY = "only"
231 551b6283 Iustin Pop
SYSLOG_SOCKET = "/dev/log"
232 551b6283 Iustin Pop
233 7c3d51d4 Guido Trotter
OS_SEARCH_PATH = _autoconf.OS_SEARCH_PATH
234 68dccc07 Guido Trotter
EXPORT_DIR = _autoconf.EXPORT_DIR
235 a8083063 Iustin Pop
236 a8083063 Iustin Pop
EXPORT_CONF_FILE = "config.ini"
237 a8083063 Iustin Pop
238 2f2dbb4b Jun Futagawa
XEN_BOOTLOADER = _autoconf.XEN_BOOTLOADER
239 f00b46bc Michael Hanselmann
XEN_KERNEL = _autoconf.XEN_KERNEL
240 f00b46bc Michael Hanselmann
XEN_INITRD = _autoconf.XEN_INITRD
241 f00b46bc Michael Hanselmann
242 7e2c5b9e Guido Trotter
KVM_PATH = _autoconf.KVM_PATH
243 14aa53cb Guido Trotter
SOCAT_PATH = _autoconf.SOCAT_PATH
244 fe5b0c42 Michael Hanselmann
SOCAT_USE_ESCAPE = _autoconf.SOCAT_USE_ESCAPE
245 e90739d6 Michael Hanselmann
SOCAT_USE_COMPRESS = _autoconf.SOCAT_USE_COMPRESS
246 86d6bc2a Guido Trotter
SOCAT_ESCAPE_CODE = "0x1d"
247 7e2c5b9e Guido Trotter
248 25ce3ec4 Michael Hanselmann
#: Console as SSH command
249 25ce3ec4 Michael Hanselmann
CONS_SSH = "ssh"
250 25ce3ec4 Michael Hanselmann
251 25ce3ec4 Michael Hanselmann
#: Console as VNC server
252 25ce3ec4 Michael Hanselmann
CONS_VNC = "vnc"
253 25ce3ec4 Michael Hanselmann
254 25ce3ec4 Michael Hanselmann
#: Display a message for console access
255 25ce3ec4 Michael Hanselmann
CONS_MESSAGE = "msg"
256 25ce3ec4 Michael Hanselmann
257 25ce3ec4 Michael Hanselmann
#: All console types
258 25ce3ec4 Michael Hanselmann
CONS_ALL = frozenset([CONS_SSH, CONS_VNC, CONS_MESSAGE])
259 25ce3ec4 Michael Hanselmann
260 bdd5e420 Michael Hanselmann
# For RSA keys more bits are better, but they also make operations more
261 bdd5e420 Michael Hanselmann
# expensive. NIST SP 800-131 recommends a minimum of 2048 bits from the year
262 bdd5e420 Michael Hanselmann
# 2010 on.
263 bdd5e420 Michael Hanselmann
RSA_KEY_BITS = 2048
264 bdd5e420 Michael Hanselmann
265 971bbd84 Michael Hanselmann
# Ciphers allowed for SSL connections. For the format, see ciphers(1). A better
266 971bbd84 Michael Hanselmann
# way to disable ciphers would be to use the exclamation mark (!), but socat
267 971bbd84 Michael Hanselmann
# versions below 1.5 can't parse exclamation marks in options properly. When
268 7407c2d5 Adeodato Simo
# modifying the ciphers, ensure not to accidentially add something after it's
269 971bbd84 Michael Hanselmann
# been removed. Use the "openssl" utility to check the allowed ciphers, e.g.
270 971bbd84 Michael Hanselmann
# "openssl ciphers -v HIGH:-DES".
271 971bbd84 Michael Hanselmann
OPENSSL_CIPHERS = "HIGH:-DES:-3DES:-EXPORT:-ADH"
272 971bbd84 Michael Hanselmann
273 bdd5e420 Michael Hanselmann
# Digest used to sign certificates ("openssl x509" uses SHA1 by default)
274 bdd5e420 Michael Hanselmann
X509_CERT_SIGN_DIGEST = "SHA1"
275 bdd5e420 Michael Hanselmann
276 600535f0 Manuel Franceschini
# Default validity of certificates in days
277 600535f0 Manuel Franceschini
X509_CERT_DEFAULT_VALIDITY = 365 * 5
278 600535f0 Manuel Franceschini
279 600535f0 Manuel Franceschini
# commonName (CN) used in certificates
280 600535f0 Manuel Franceschini
X509_CERT_CN = "ganeti.example.com"
281 600535f0 Manuel Franceschini
282 68857643 Michael Hanselmann
X509_CERT_SIGNATURE_HEADER = "X-Ganeti-Signature"
283 68857643 Michael Hanselmann
284 2d76b580 Michael Hanselmann
IMPORT_EXPORT_DAEMON = _autoconf.PKGLIBDIR + "/import-export"
285 2d76b580 Michael Hanselmann
286 2d76b580 Michael Hanselmann
# Import/export daemon mode
287 2d76b580 Michael Hanselmann
IEM_IMPORT = "import"
288 2d76b580 Michael Hanselmann
IEM_EXPORT = "export"
289 2d76b580 Michael Hanselmann
290 7e3c1da6 Michael Hanselmann
# Import/export transport compression
291 7e3c1da6 Michael Hanselmann
IEC_NONE = "none"
292 7e3c1da6 Michael Hanselmann
IEC_GZIP = "gzip"
293 7e3c1da6 Michael Hanselmann
IEC_ALL = frozenset([
294 7e3c1da6 Michael Hanselmann
  IEC_NONE,
295 7e3c1da6 Michael Hanselmann
  IEC_GZIP,
296 7e3c1da6 Michael Hanselmann
  ])
297 7e3c1da6 Michael Hanselmann
298 f9323011 Michael Hanselmann
IE_CUSTOM_SIZE = "fd"
299 f9323011 Michael Hanselmann
300 1d3dfa29 Michael Hanselmann
IE_MAGIC_RE = re.compile(r"^[-_.a-zA-Z0-9]{5,100}$")
301 1d3dfa29 Michael Hanselmann
302 1651d116 Michael Hanselmann
# Import/export I/O
303 1651d116 Michael Hanselmann
# Direct file I/O, equivalent to a shell's I/O redirection using '<' or '>'
304 1651d116 Michael Hanselmann
IEIO_FILE = "file"
305 1651d116 Michael Hanselmann
# Raw block device I/O using "dd"
306 1651d116 Michael Hanselmann
IEIO_RAW_DISK = "raw"
307 1651d116 Michael Hanselmann
# OS definition import/export script
308 1651d116 Michael Hanselmann
IEIO_SCRIPT = "script"
309 1651d116 Michael Hanselmann
310 973d7867 Iustin Pop
VALUE_DEFAULT = "default"
311 4c566ede Guido Trotter
VALUE_AUTO = "auto"
312 4c566ede Guido Trotter
VALUE_GENERATE = "generate"
313 973d7867 Iustin Pop
VALUE_NONE = "none"
314 1817f49b Guido Trotter
VALUE_TRUE = "true"
315 1817f49b Guido Trotter
VALUE_FALSE = "false"
316 973d7867 Iustin Pop
317 4fe80ef2 Iustin Pop
# External script validation mask
318 4fe80ef2 Iustin Pop
EXT_PLUGIN_MASK = re.compile("^[a-zA-Z0-9_-]+$")
319 4fe80ef2 Iustin Pop
320 a8083063 Iustin Pop
# hooks-related constants
321 131178b9 Luca Bigliardi
HOOKS_BASE_DIR = CONF_DIR + "/hooks"
322 a8083063 Iustin Pop
HOOKS_PHASE_PRE = "pre"
323 a8083063 Iustin Pop
HOOKS_PHASE_POST = "post"
324 6a4aa7c1 Iustin Pop
HOOKS_NAME_CFGUPDATE = "config-update"
325 9e289e36 Guido Trotter
HOOKS_NAME_WATCHER = "watcher"
326 f3e2e4c6 Iustin Pop
HOOKS_VERSION = 2
327 a8083063 Iustin Pop
328 a8083063 Iustin Pop
# hooks subject type (what object type does the LU deal with)
329 a8083063 Iustin Pop
HTYPE_CLUSTER = "CLUSTER"
330 a8083063 Iustin Pop
HTYPE_NODE = "NODE"
331 b1ee5610 Adeodato Simo
HTYPE_GROUP = "GROUP"
332 a8083063 Iustin Pop
HTYPE_INSTANCE = "INSTANCE"
333 a8083063 Iustin Pop
334 a8083063 Iustin Pop
HKR_SKIP = 0
335 a8083063 Iustin Pop
HKR_FAIL = 1
336 a8083063 Iustin Pop
HKR_SUCCESS = 2
337 a8083063 Iustin Pop
338 ac2d0fe4 Michael Hanselmann
# Storage types
339 ac2d0fe4 Michael Hanselmann
ST_FILE = "file"
340 ac2d0fe4 Michael Hanselmann
ST_LVM_PV = "lvm-pv"
341 ac2d0fe4 Michael Hanselmann
ST_LVM_VG = "lvm-vg"
342 6032697c Michael Hanselmann
343 6032697c Michael Hanselmann
# Storage fields
344 620a85fd Iustin Pop
# first two are valid in LU context only, not passed to backend
345 620a85fd Iustin Pop
SF_NODE = "node"
346 620a85fd Iustin Pop
SF_TYPE = "type"
347 620a85fd Iustin Pop
# and the rest are valid in backend
348 6032697c Michael Hanselmann
SF_NAME = "name"
349 6032697c Michael Hanselmann
SF_SIZE = "size"
350 6032697c Michael Hanselmann
SF_FREE = "free"
351 6032697c Michael Hanselmann
SF_USED = "used"
352 6032697c Michael Hanselmann
SF_ALLOCATABLE = "allocatable"
353 6032697c Michael Hanselmann
354 6c3c6db9 Michael Hanselmann
# Storage operations
355 6c3c6db9 Michael Hanselmann
SO_FIX_CONSISTENCY = "fix-consistency"
356 6c3c6db9 Michael Hanselmann
357 6032697c Michael Hanselmann
# Available fields per storage type
358 21daa4a8 Stephen Shirley
VALID_STORAGE_FIELDS = frozenset([
359 21daa4a8 Stephen Shirley
  SF_NAME,
360 21daa4a8 Stephen Shirley
  SF_TYPE,
361 21daa4a8 Stephen Shirley
  SF_SIZE,
362 21daa4a8 Stephen Shirley
  SF_USED,
363 21daa4a8 Stephen Shirley
  SF_FREE,
364 21daa4a8 Stephen Shirley
  SF_ALLOCATABLE
365 21daa4a8 Stephen Shirley
  ])
366 620a85fd Iustin Pop
367 620a85fd Iustin Pop
VALID_STORAGE_TYPES = frozenset([ST_FILE, ST_LVM_PV, ST_LVM_VG])
368 a8083063 Iustin Pop
369 efb8da02 Michael Hanselmann
MODIFIABLE_STORAGE_FIELDS = {
370 efb8da02 Michael Hanselmann
  ST_LVM_PV: frozenset([SF_ALLOCATABLE]),
371 efb8da02 Michael Hanselmann
  }
372 efb8da02 Michael Hanselmann
373 4b37cac5 Michael Hanselmann
VALID_STORAGE_OPERATIONS = {
374 6c3c6db9 Michael Hanselmann
  ST_LVM_VG: frozenset([SO_FIX_CONSISTENCY]),
375 4b37cac5 Michael Hanselmann
  }
376 4b37cac5 Michael Hanselmann
377 74f37195 Michael Hanselmann
# Local disk status
378 74f37195 Michael Hanselmann
# Note: Code depends on LDS_OKAY < LDS_UNKNOWN < LDS_FAULTY
379 74f37195 Michael Hanselmann
(LDS_OKAY,
380 74f37195 Michael Hanselmann
 LDS_UNKNOWN,
381 74f37195 Michael Hanselmann
 LDS_FAULTY) = range(1, 4)
382 74f37195 Michael Hanselmann
383 a8083063 Iustin Pop
# disk template types
384 a8083063 Iustin Pop
DT_DISKLESS = "diskless"
385 a8083063 Iustin Pop
DT_PLAIN = "plain"
386 a1f445d3 Iustin Pop
DT_DRBD8 = "drbd"
387 04fa07f2 Manuel Franceschini
DT_FILE = "file"
388 4b97f902 Apollon Oikonomopoulos
DT_SHARED_FILE = "sharedfile"
389 b6135bbc Apollon Oikonomopoulos
DT_BLOCK = "blockdev"
390 a1f445d3 Iustin Pop
391 a1f445d3 Iustin Pop
# the set of network-mirrored disk templates
392 3429a076 Apollon Oikonomopoulos
DTS_INT_MIRROR = frozenset([DT_DRBD8])
393 a8083063 Iustin Pop
394 b6135bbc Apollon Oikonomopoulos
# the set of externally-mirrored disk templates (e.g. SAN, NAS)
395 b6135bbc Apollon Oikonomopoulos
DTS_EXT_MIRROR = frozenset([DT_SHARED_FILE, DT_BLOCK])
396 4b97f902 Apollon Oikonomopoulos
397 d63e148a Manuel Franceschini
# the set of non-lvm-based disk templates
398 b6135bbc Apollon Oikonomopoulos
DTS_NOT_LVM = frozenset([DT_DISKLESS, DT_FILE, DT_SHARED_FILE, DT_BLOCK])
399 d63e148a Manuel Franceschini
400 728489a3 Guido Trotter
# the set of disk templates which can be grown
401 4b97f902 Apollon Oikonomopoulos
DTS_GROWABLE = frozenset([DT_PLAIN, DT_DRBD8, DT_FILE, DT_SHARED_FILE])
402 728489a3 Guido Trotter
403 3b08cd1c Apollon Oikonomopoulos
# the set of disk templates that allow adoption
404 b6135bbc Apollon Oikonomopoulos
DTS_MAY_ADOPT = frozenset([DT_PLAIN, DT_BLOCK])
405 b6135bbc Apollon Oikonomopoulos
406 b6135bbc Apollon Oikonomopoulos
# the set of disk templates that *must* use adoption
407 b6135bbc Apollon Oikonomopoulos
DTS_MUST_ADOPT = frozenset([DT_BLOCK])
408 3b08cd1c Apollon Oikonomopoulos
409 85a0ff7e Apollon Oikonomopoulos
# the set of disk templates that allow migrations
410 3429a076 Apollon Oikonomopoulos
DTS_MIRRORED = frozenset.union(DTS_INT_MIRROR, DTS_EXT_MIRROR)
411 85a0ff7e Apollon Oikonomopoulos
412 c16915bd Guido Trotter
# the set of file based disk templates
413 c16915bd Guido Trotter
DTS_FILEBASED = frozenset([DT_FILE, DT_SHARED_FILE])
414 85a0ff7e Apollon Oikonomopoulos
415 fe96220b Iustin Pop
# logical disk types
416 fe96220b Iustin Pop
LD_LV = "lvm"
417 a1f445d3 Iustin Pop
LD_DRBD8 = "drbd8"
418 04fa07f2 Manuel Franceschini
LD_FILE = "file"
419 b6135bbc Apollon Oikonomopoulos
LD_BLOCKDEV = "blockdev"
420 b6135bbc Apollon Oikonomopoulos
LDS_BLOCK = frozenset([LD_LV, LD_DRBD8, LD_BLOCKDEV])
421 04fa07f2 Manuel Franceschini
422 2899d9de Iustin Pop
# drbd constants
423 2899d9de Iustin Pop
DRBD_HMAC_ALG = "md5"
424 3c03759a Iustin Pop
DRBD_NET_PROTOCOL = "C"
425 89b70f39 Iustin Pop
DRBD_BARRIERS = _autoconf.DRBD_BARRIERS
426 2899d9de Iustin Pop
427 04fa07f2 Manuel Franceschini
# file backend driver
428 04fa07f2 Manuel Franceschini
FD_LOOP = "loop"
429 04fa07f2 Manuel Franceschini
FD_BLKTAP = "blktap"
430 a1f445d3 Iustin Pop
431 a1f445d3 Iustin Pop
# the set of drbd-like disk types
432 abdf0113 Iustin Pop
LDS_DRBD = frozenset([LD_DRBD8])
433 fe96220b Iustin Pop
434 08db7c5c Iustin Pop
# disk access mode
435 24991749 Iustin Pop
DISK_RDONLY = "ro"
436 24991749 Iustin Pop
DISK_RDWR = "rw"
437 08db7c5c Iustin Pop
DISK_ACCESS_SET = frozenset([DISK_RDONLY, DISK_RDWR])
438 08db7c5c Iustin Pop
439 a9e0c397 Iustin Pop
# disk replacement mode
440 cfacfd6e Iustin Pop
REPLACE_DISK_PRI = "replace_on_primary"    # replace disks on primary
441 cfacfd6e Iustin Pop
REPLACE_DISK_SEC = "replace_on_secondary"  # replace disks on secondary
442 cfacfd6e Iustin Pop
REPLACE_DISK_CHG = "replace_new_secondary" # change secondary node
443 942be002 Michael Hanselmann
REPLACE_DISK_AUTO = "replace_auto"
444 3636400f Iustin Pop
REPLACE_MODES = frozenset([
445 3636400f Iustin Pop
  REPLACE_DISK_PRI,
446 3636400f Iustin Pop
  REPLACE_DISK_SEC,
447 3636400f Iustin Pop
  REPLACE_DISK_CHG,
448 3636400f Iustin Pop
  REPLACE_DISK_AUTO,
449 3636400f Iustin Pop
  ])
450 a9e0c397 Iustin Pop
451 4a96f1d1 Michael Hanselmann
# Instance export mode
452 4a96f1d1 Michael Hanselmann
EXPORT_MODE_LOCAL = "local"
453 4a96f1d1 Michael Hanselmann
EXPORT_MODE_REMOTE = "remote"
454 4a96f1d1 Michael Hanselmann
EXPORT_MODES = frozenset([
455 4a96f1d1 Michael Hanselmann
  EXPORT_MODE_LOCAL,
456 4a96f1d1 Michael Hanselmann
  EXPORT_MODE_REMOTE,
457 4a96f1d1 Michael Hanselmann
  ])
458 4a96f1d1 Michael Hanselmann
459 d385a174 Iustin Pop
# Lock recalculate mode
460 d0c8c01d Iustin Pop
LOCKS_REPLACE = "replace"
461 d0c8c01d Iustin Pop
LOCKS_APPEND = "append"
462 f6d9a522 Guido Trotter
463 d385a174 Iustin Pop
# Lock timeout (sum) before we should go into blocking acquire (still
464 d385a174 Iustin Pop
# can be reset by priority change); computed as max time (10 hours)
465 d385a174 Iustin Pop
# before we should actually go into blocking acquire given that we
466 d385a174 Iustin Pop
# start from default priority level; in seconds
467 d385a174 Iustin Pop
LOCK_ATTEMPTS_TIMEOUT = 10 * 3600 / 20.0
468 d385a174 Iustin Pop
LOCK_ATTEMPTS_MAXWAIT = 15.0
469 d385a174 Iustin Pop
LOCK_ATTEMPTS_MINWAIT = 1.0
470 d385a174 Iustin Pop
471 2f6eebee Guido Trotter
# instance creation modes
472 a8083063 Iustin Pop
INSTANCE_CREATE = "create"
473 a8083063 Iustin Pop
INSTANCE_IMPORT = "import"
474 9bf56d77 Michael Hanselmann
INSTANCE_REMOTE_IMPORT = "remote-import"
475 9bf56d77 Michael Hanselmann
INSTANCE_CREATE_MODES = frozenset([
476 9bf56d77 Michael Hanselmann
  INSTANCE_CREATE,
477 9bf56d77 Michael Hanselmann
  INSTANCE_IMPORT,
478 9bf56d77 Michael Hanselmann
  INSTANCE_REMOTE_IMPORT,
479 9bf56d77 Michael Hanselmann
  ])
480 a8083063 Iustin Pop
481 1410fa8d Michael Hanselmann
# Remote import/export handshake message and version
482 1410fa8d Michael Hanselmann
RIE_VERSION = 0
483 1410fa8d Michael Hanselmann
RIE_HANDSHAKE = "Hi, I'm Ganeti"
484 1410fa8d Michael Hanselmann
485 1410fa8d Michael Hanselmann
# Remote import/export certificate validity in seconds
486 1410fa8d Michael Hanselmann
RIE_CERT_VALIDITY = 24 * 60 * 60
487 1410fa8d Michael Hanselmann
488 4478301b Michael Hanselmann
# Overall timeout for establishing connection
489 8fd2e34c Michael Hanselmann
RIE_CONNECT_TIMEOUT = 180
490 4a96f1d1 Michael Hanselmann
491 4478301b Michael Hanselmann
# Export only: how long to wait per connection attempt (seconds)
492 4478301b Michael Hanselmann
RIE_CONNECT_ATTEMPT_TIMEOUT = 20
493 4478301b Michael Hanselmann
494 4478301b Michael Hanselmann
# Export only: number of attempts to connect
495 4478301b Michael Hanselmann
RIE_CONNECT_RETRIES = 10
496 4478301b Michael Hanselmann
497 c74cda62 René Nussbaumer
#: Give child process up to 5 seconds to exit after sending a signal
498 c74cda62 René Nussbaumer
CHILD_LINGER_TIMEOUT = 5.0
499 4a96f1d1 Michael Hanselmann
500 21daa4a8 Stephen Shirley
DISK_TEMPLATES = frozenset([
501 21daa4a8 Stephen Shirley
  DT_DISKLESS,
502 21daa4a8 Stephen Shirley
  DT_PLAIN,
503 21daa4a8 Stephen Shirley
  DT_DRBD8,
504 21daa4a8 Stephen Shirley
  DT_FILE,
505 21daa4a8 Stephen Shirley
  DT_SHARED_FILE,
506 21daa4a8 Stephen Shirley
  DT_BLOCK
507 21daa4a8 Stephen Shirley
  ])
508 04fa07f2 Manuel Franceschini
509 04fa07f2 Manuel Franceschini
FILE_DRIVER = frozenset([FD_LOOP, FD_BLKTAP])
510 a8083063 Iustin Pop
511 a8083063 Iustin Pop
# import/export config options
512 a8083063 Iustin Pop
INISECT_EXP = "export"
513 a8083063 Iustin Pop
INISECT_INS = "instance"
514 3c8954ad Iustin Pop
INISECT_HYP = "hypervisor"
515 3c8954ad Iustin Pop
INISECT_BEP = "backend"
516 535b49cb Iustin Pop
INISECT_OSP = "os"
517 38242904 Iustin Pop
518 24991749 Iustin Pop
# dynamic device modification
519 61a14bb3 Iustin Pop
DDM_ADD = "add"
520 61a14bb3 Iustin Pop
DDM_REMOVE = "remove"
521 61a14bb3 Iustin Pop
DDMS_VALUES = frozenset([DDM_ADD, DDM_REMOVE])
522 24991749 Iustin Pop
523 38242904 Iustin Pop
# common exit codes
524 a5bc662a Iustin Pop
EXIT_SUCCESS = 0
525 438b45d4 Michael Hanselmann
EXIT_FAILURE = 1
526 46479775 Guido Trotter
EXIT_NOTCLUSTER = 5
527 38242904 Iustin Pop
EXIT_NOTMASTER = 11
528 619fdc8e Iustin Pop
EXIT_NODESETUP_ERROR = 12
529 a5bc662a Iustin Pop
EXIT_CONFIRMATION = 13 # need user confirmation
530 cf62a272 Michael Hanselmann
531 ee3aedff Michael Hanselmann
#: Exit code for query operations with unknown fields
532 ee3aedff Michael Hanselmann
EXIT_UNKNOWN_FIELD = 14
533 ee3aedff Michael Hanselmann
534 5c947f38 Iustin Pop
# tags
535 5c947f38 Iustin Pop
TAG_CLUSTER = "cluster"
536 1ffd2673 Michael Hanselmann
TAG_NODEGROUP = "nodegroup"
537 5c947f38 Iustin Pop
TAG_NODE = "node"
538 5c947f38 Iustin Pop
TAG_INSTANCE = "instance"
539 3636400f Iustin Pop
VALID_TAG_TYPES = frozenset([
540 3636400f Iustin Pop
  TAG_CLUSTER,
541 1ffd2673 Michael Hanselmann
  TAG_NODEGROUP,
542 3636400f Iustin Pop
  TAG_NODE,
543 3636400f Iustin Pop
  TAG_INSTANCE,
544 3636400f Iustin Pop
  ])
545 5c947f38 Iustin Pop
MAX_TAG_LEN = 128
546 5c947f38 Iustin Pop
MAX_TAGS_PER_OBJ = 4096
547 5c947f38 Iustin Pop
548 cf62a272 Michael Hanselmann
# others
549 cf62a272 Michael Hanselmann
DEFAULT_BRIDGE = "xen-br0"
550 24b0d752 Iustin Pop
SYNC_SPEED = 60 * 1024
551 9769bb78 Manuel Franceschini
IP4_ADDRESS_LOCALHOST = "127.0.0.1"
552 9769bb78 Manuel Franceschini
IP4_ADDRESS_ANY = "0.0.0.0"
553 0d2cd893 Manuel Franceschini
IP6_ADDRESS_LOCALHOST = "::1"
554 0d2cd893 Manuel Franceschini
IP6_ADDRESS_ANY = "::"
555 2f20d07b Manuel Franceschini
IP4_VERSION = 4
556 2f20d07b Manuel Franceschini
IP6_VERSION = 6
557 b1cb62bd Andrea Spadaccini
VALID_IP_VERSIONS = frozenset([IP4_VERSION, IP6_VERSION])
558 16abfbc2 Alexander Schreiber
TCP_PING_TIMEOUT = 10
559 7900ed01 Iustin Pop
GANETI_RUNAS = "root"
560 d63e148a Manuel Franceschini
DEFAULT_VG = "xenvg"
561 ee2f0ed4 Luca Bigliardi
DEFAULT_DRBD_HELPER = "/bin/true"
562 8d1a2a64 Michael Hanselmann
MIN_VG_SIZE = 20480
563 c5e489f7 Iustin Pop
DEFAULT_MAC_PREFIX = "aa:00:00"
564 3736cb6b Iustin Pop
LVM_STRIPECOUNT = _autoconf.LVM_STRIPECOUNT
565 88cd08aa Guido Trotter
# default maximum instance wait time, in seconds.
566 88cd08aa Guido Trotter
DEFAULT_SHUTDOWN_TIMEOUT = 120
567 313b2dd4 Michael Hanselmann
NODE_MAX_CLOCK_SKEW = 150
568 033a1d00 Michael Hanselmann
# Time for an intra-cluster disk transfer to wait for a connection
569 81635b5a Iustin Pop
DISK_TRANSFER_CONNECT_TIMEOUT = 60
570 3536c792 Iustin Pop
# Disk index separator
571 3536c792 Iustin Pop
DISK_SEPARATOR = _autoconf.DISK_SEPARATOR
572 c4dfb0b6 Andrea Spadaccini
IP_COMMAND_PATH = _autoconf.IP_PATH
573 7900ed01 Iustin Pop
574 6a373640 Michael Hanselmann
#: Key for job IDs in opcode result
575 6a373640 Michael Hanselmann
JOB_IDS_KEY = "jobs"
576 6a373640 Michael Hanselmann
577 6bb65e3a Guido Trotter
# runparts results
578 6bb65e3a Guido Trotter
(RUNPARTS_SKIP,
579 6bb65e3a Guido Trotter
 RUNPARTS_RUN,
580 6bb65e3a Guido Trotter
 RUNPARTS_ERR) = range(3)
581 6bb65e3a Guido Trotter
582 6bb65e3a Guido Trotter
RUNPARTS_STATUS = frozenset([RUNPARTS_SKIP, RUNPARTS_RUN, RUNPARTS_ERR])
583 6bb65e3a Guido Trotter
584 12bce260 Michael Hanselmann
# RPC constants
585 12bce260 Michael Hanselmann
(RPC_ENCODING_NONE,
586 12bce260 Michael Hanselmann
 RPC_ENCODING_ZLIB_BASE64) = range(2)
587 12bce260 Michael Hanselmann
588 ded1c679 Guido Trotter
# os related constants
589 d0c8c01d Iustin Pop
OS_SCRIPT_CREATE = "create"
590 d0c8c01d Iustin Pop
OS_SCRIPT_IMPORT = "import"
591 d0c8c01d Iustin Pop
OS_SCRIPT_EXPORT = "export"
592 d0c8c01d Iustin Pop
OS_SCRIPT_RENAME = "rename"
593 d0c8c01d Iustin Pop
OS_SCRIPT_VERIFY = "verify"
594 21daa4a8 Stephen Shirley
OS_SCRIPTS = frozenset([
595 21daa4a8 Stephen Shirley
  OS_SCRIPT_CREATE,
596 21daa4a8 Stephen Shirley
  OS_SCRIPT_IMPORT,
597 21daa4a8 Stephen Shirley
  OS_SCRIPT_EXPORT,
598 21daa4a8 Stephen Shirley
  OS_SCRIPT_RENAME,
599 21daa4a8 Stephen Shirley
  OS_SCRIPT_VERIFY
600 21daa4a8 Stephen Shirley
  ])
601 37482e7b Guido Trotter
602 d0c8c01d Iustin Pop
OS_API_FILE = "ganeti_api_version"
603 d0c8c01d Iustin Pop
OS_VARIANTS_FILE = "variants.list"
604 d0c8c01d Iustin Pop
OS_PARAMETERS_FILE = "parameters.list"
605 b41b3516 Iustin Pop
606 d0c8c01d Iustin Pop
OS_VALIDATE_PARAMETERS = "parameters"
607 acd9ff9e Iustin Pop
OS_VALIDATE_CALLS = frozenset([OS_VALIDATE_PARAMETERS])
608 b6b45e0d Guido Trotter
609 70d9e3d8 Iustin Pop
# ssh constants
610 553bd93f Vitaly Kuznetsov
SSH_CONFIG_DIR = _autoconf.SSH_CONFIG_DIR
611 553bd93f Vitaly Kuznetsov
SSH_HOST_DSA_PRIV = SSH_CONFIG_DIR + "/ssh_host_dsa_key"
612 70d9e3d8 Iustin Pop
SSH_HOST_DSA_PUB = SSH_HOST_DSA_PRIV + ".pub"
613 553bd93f Vitaly Kuznetsov
SSH_HOST_RSA_PRIV = SSH_CONFIG_DIR + "/ssh_host_rsa_key"
614 70d9e3d8 Iustin Pop
SSH_HOST_RSA_PUB = SSH_HOST_RSA_PRIV + ".pub"
615 fff33d70 Michael Hanselmann
SSH = "ssh"
616 fff33d70 Michael Hanselmann
SCP = "scp"
617 007a2f3e Alexander Schreiber
618 007a2f3e Alexander Schreiber
# reboot types
619 007a2f3e Alexander Schreiber
INSTANCE_REBOOT_SOFT = "soft"
620 007a2f3e Alexander Schreiber
INSTANCE_REBOOT_HARD = "hard"
621 007a2f3e Alexander Schreiber
INSTANCE_REBOOT_FULL = "full"
622 2584d4a4 Alexander Schreiber
623 990ade2d Stephen Shirley
REBOOT_TYPES = frozenset([
624 990ade2d Stephen Shirley
  INSTANCE_REBOOT_SOFT,
625 990ade2d Stephen Shirley
  INSTANCE_REBOOT_HARD,
626 990ade2d Stephen Shirley
  INSTANCE_REBOOT_FULL
627 990ade2d Stephen Shirley
  ])
628 990ade2d Stephen Shirley
629 990ade2d Stephen Shirley
# instance reboot behaviors
630 990ade2d Stephen Shirley
INSTANCE_REBOOT_ALLOWED = "reboot"
631 990ade2d Stephen Shirley
INSTANCE_REBOOT_EXIT = "exit"
632 990ade2d Stephen Shirley
633 990ade2d Stephen Shirley
REBOOT_BEHAVIORS = frozenset([
634 990ade2d Stephen Shirley
  INSTANCE_REBOOT_ALLOWED,
635 990ade2d Stephen Shirley
  INSTANCE_REBOOT_EXIT
636 990ade2d Stephen Shirley
  ])
637 00f91f29 Iustin Pop
638 d0c8c01d Iustin Pop
VTYPE_STRING = "string"
639 59525e1f Michael Hanselmann
VTYPE_MAYBE_STRING = "maybe-string"
640 d0c8c01d Iustin Pop
VTYPE_BOOL = "bool"
641 d0c8c01d Iustin Pop
VTYPE_SIZE = "size" # size, in MiBs
642 d0c8c01d Iustin Pop
VTYPE_INT = "int"
643 a5728081 Guido Trotter
ENFORCEABLE_TYPES = frozenset([
644 21daa4a8 Stephen Shirley
  VTYPE_STRING,
645 21daa4a8 Stephen Shirley
  VTYPE_MAYBE_STRING,
646 21daa4a8 Stephen Shirley
  VTYPE_BOOL,
647 21daa4a8 Stephen Shirley
  VTYPE_SIZE,
648 21daa4a8 Stephen Shirley
  VTYPE_INT,
649 21daa4a8 Stephen Shirley
  ])
650 a5728081 Guido Trotter
651 b1cb62bd Andrea Spadaccini
# Constant representing that the user does not specify any IP version
652 b1cb62bd Andrea Spadaccini
IFACE_NO_IP_VERSION_SPECIFIED = 0
653 b1cb62bd Andrea Spadaccini
654 e64b8beb Iustin Pop
# HV parameter names (global namespace)
655 e64b8beb Iustin Pop
HV_BOOT_ORDER = "boot_order"
656 e64b8beb Iustin Pop
HV_CDROM_IMAGE_PATH = "cdrom_image_path"
657 cc130cc7 Marco Casavecchia
HV_KVM_CDROM2_IMAGE_PATH = "cdrom2_image_path"
658 cc130cc7 Marco Casavecchia
HV_KVM_FLOPPY_IMAGE_PATH = "floppy_image_path"
659 e64b8beb Iustin Pop
HV_NIC_TYPE = "nic_type"
660 e64b8beb Iustin Pop
HV_DISK_TYPE = "disk_type"
661 cc130cc7 Marco Casavecchia
HV_KVM_CDROM_DISK_TYPE = "cdrom_disk_type"
662 e64b8beb Iustin Pop
HV_VNC_BIND_ADDRESS = "vnc_bind_address"
663 6e6bb8d5 Guido Trotter
HV_VNC_PASSWORD_FILE = "vnc_password_file"
664 8b2d1013 Guido Trotter
HV_VNC_TLS = "vnc_tls"
665 8b2d1013 Guido Trotter
HV_VNC_X509 = "vnc_x509_path"
666 8b2d1013 Guido Trotter
HV_VNC_X509_VERIFY = "vnc_x509_verify"
667 b1cb62bd Andrea Spadaccini
HV_KVM_SPICE_BIND = "spice_bind"
668 b1cb62bd Andrea Spadaccini
HV_KVM_SPICE_IP_VERSION = "spice_ip_version"
669 e64b8beb Iustin Pop
HV_ACPI = "acpi"
670 e64b8beb Iustin Pop
HV_PAE = "pae"
671 2f2dbb4b Jun Futagawa
HV_USE_BOOTLOADER = "use_bootloader"
672 2f2dbb4b Jun Futagawa
HV_BOOTLOADER_ARGS = "bootloader_args"
673 2f2dbb4b Jun Futagawa
HV_BOOTLOADER_PATH = "bootloader_path"
674 f9d6542d Iustin Pop
HV_KERNEL_ARGS = "kernel_args"
675 e64b8beb Iustin Pop
HV_KERNEL_PATH = "kernel_path"
676 e64b8beb Iustin Pop
HV_INITRD_PATH = "initrd_path"
677 074ca009 Guido Trotter
HV_ROOT_PATH = "root_path"
678 a2faf9ee Guido Trotter
HV_SERIAL_CONSOLE = "serial_console"
679 11344a50 Guido Trotter
HV_USB_MOUSE = "usb_mouse"
680 4f580fef Sébastien Bocahu
HV_KEYMAP = "keymap"
681 09ea8710 Iustin Pop
HV_DEVICE_MODEL = "device_model"
682 48297fa2 Iustin Pop
HV_INIT_SCRIPT = "init_script"
683 78411c60 Iustin Pop
HV_MIGRATION_PORT = "migration_port"
684 e43d4f9f Apollon Oikonomopoulos
HV_MIGRATION_BANDWIDTH = "migration_bandwidth"
685 e43d4f9f Apollon Oikonomopoulos
HV_MIGRATION_DOWNTIME = "migration_downtime"
686 783a6c0b Iustin Pop
HV_MIGRATION_MODE = "migration_mode"
687 6b970cef Jun Futagawa
HV_USE_LOCALTIME = "use_localtime"
688 ea0f3d7a Iustin Pop
HV_DISK_CACHE = "disk_cache"
689 3424767f Guido Trotter
HV_SECURITY_MODEL = "security_model"
690 3424767f Guido Trotter
HV_SECURITY_DOMAIN = "security_domain"
691 7ba594c0 Guido Trotter
HV_KVM_FLAG = "kvm_flag"
692 fbe27e2b Guido Trotter
HV_VHOST_NET = "vhost_net"
693 84c08e4e Balazs Lecz
HV_KVM_USE_CHROOT = "use_chroot"
694 e3ed5316 Balazs Lecz
HV_CPU_MASK = "cpu_mask"
695 4f958b0b Miguel Di Ciurcio Filho
HV_MEM_PATH = "mem_path"
696 525011bc Maciej Bliziński
HV_BLOCKDEV_PREFIX = "blockdev_prefix"
697 990ade2d Stephen Shirley
HV_REBOOT_BEHAVIOR = "reboot_behavior"
698 e64b8beb Iustin Pop
699 a5728081 Guido Trotter
HVS_PARAMETER_TYPES = {
700 a5728081 Guido Trotter
  HV_BOOT_ORDER: VTYPE_STRING,
701 cc130cc7 Marco Casavecchia
  HV_KVM_FLOPPY_IMAGE_PATH: VTYPE_STRING,
702 a5728081 Guido Trotter
  HV_CDROM_IMAGE_PATH: VTYPE_STRING,
703 cc130cc7 Marco Casavecchia
  HV_KVM_CDROM2_IMAGE_PATH: VTYPE_STRING,
704 a5728081 Guido Trotter
  HV_NIC_TYPE: VTYPE_STRING,
705 a5728081 Guido Trotter
  HV_DISK_TYPE: VTYPE_STRING,
706 cc130cc7 Marco Casavecchia
  HV_KVM_CDROM_DISK_TYPE: VTYPE_STRING,
707 6e6bb8d5 Guido Trotter
  HV_VNC_PASSWORD_FILE: VTYPE_STRING,
708 a5728081 Guido Trotter
  HV_VNC_BIND_ADDRESS: VTYPE_STRING,
709 a5728081 Guido Trotter
  HV_VNC_TLS: VTYPE_BOOL,
710 a5728081 Guido Trotter
  HV_VNC_X509: VTYPE_STRING,
711 a5728081 Guido Trotter
  HV_VNC_X509_VERIFY: VTYPE_BOOL,
712 b1cb62bd Andrea Spadaccini
  HV_KVM_SPICE_BIND: VTYPE_STRING,
713 b1cb62bd Andrea Spadaccini
  HV_KVM_SPICE_IP_VERSION: VTYPE_INT,
714 a5728081 Guido Trotter
  HV_ACPI: VTYPE_BOOL,
715 a5728081 Guido Trotter
  HV_PAE: VTYPE_BOOL,
716 2f2dbb4b Jun Futagawa
  HV_USE_BOOTLOADER: VTYPE_BOOL,
717 2f2dbb4b Jun Futagawa
  HV_BOOTLOADER_PATH: VTYPE_STRING,
718 2f2dbb4b Jun Futagawa
  HV_BOOTLOADER_ARGS: VTYPE_STRING,
719 a5728081 Guido Trotter
  HV_KERNEL_PATH: VTYPE_STRING,
720 f9d6542d Iustin Pop
  HV_KERNEL_ARGS: VTYPE_STRING,
721 a5728081 Guido Trotter
  HV_INITRD_PATH: VTYPE_STRING,
722 7adf7814 René Nussbaumer
  HV_ROOT_PATH: VTYPE_MAYBE_STRING,
723 a5728081 Guido Trotter
  HV_SERIAL_CONSOLE: VTYPE_BOOL,
724 a5728081 Guido Trotter
  HV_USB_MOUSE: VTYPE_STRING,
725 4f580fef Sébastien Bocahu
  HV_KEYMAP: VTYPE_STRING,
726 09ea8710 Iustin Pop
  HV_DEVICE_MODEL: VTYPE_STRING,
727 48297fa2 Iustin Pop
  HV_INIT_SCRIPT: VTYPE_STRING,
728 78411c60 Iustin Pop
  HV_MIGRATION_PORT: VTYPE_INT,
729 e43d4f9f Apollon Oikonomopoulos
  HV_MIGRATION_BANDWIDTH: VTYPE_INT,
730 e43d4f9f Apollon Oikonomopoulos
  HV_MIGRATION_DOWNTIME: VTYPE_INT,
731 783a6c0b Iustin Pop
  HV_MIGRATION_MODE: VTYPE_STRING,
732 6b970cef Jun Futagawa
  HV_USE_LOCALTIME: VTYPE_BOOL,
733 ea0f3d7a Iustin Pop
  HV_DISK_CACHE: VTYPE_STRING,
734 3424767f Guido Trotter
  HV_SECURITY_MODEL: VTYPE_STRING,
735 3424767f Guido Trotter
  HV_SECURITY_DOMAIN: VTYPE_STRING,
736 7ba594c0 Guido Trotter
  HV_KVM_FLAG: VTYPE_STRING,
737 fbe27e2b Guido Trotter
  HV_VHOST_NET: VTYPE_BOOL,
738 84c08e4e Balazs Lecz
  HV_KVM_USE_CHROOT: VTYPE_BOOL,
739 e3ed5316 Balazs Lecz
  HV_CPU_MASK: VTYPE_STRING,
740 4f958b0b Miguel Di Ciurcio Filho
  HV_MEM_PATH: VTYPE_STRING,
741 525011bc Maciej Bliziński
  HV_BLOCKDEV_PREFIX: VTYPE_STRING,
742 990ade2d Stephen Shirley
  HV_REBOOT_BEHAVIOR: VTYPE_STRING,
743 a5728081 Guido Trotter
  }
744 a5728081 Guido Trotter
745 a5728081 Guido Trotter
HVS_PARAMETERS = frozenset(HVS_PARAMETER_TYPES.keys())
746 5018a335 Iustin Pop
747 3d5ebbf0 Stephen Shirley
# Backend parameter names
748 cd3ab26e Iustin Pop
BE_MEMORY = "memory"
749 e64b8beb Iustin Pop
BE_VCPUS = "vcpus"
750 c0f2b229 Iustin Pop
BE_AUTO_BALANCE = "auto_balance"
751 e64b8beb Iustin Pop
752 a5728081 Guido Trotter
BES_PARAMETER_TYPES = {
753 a5728081 Guido Trotter
    BE_MEMORY: VTYPE_SIZE,
754 a5728081 Guido Trotter
    BE_VCPUS: VTYPE_INT,
755 a5728081 Guido Trotter
    BE_AUTO_BALANCE: VTYPE_BOOL,
756 a5728081 Guido Trotter
    }
757 a5728081 Guido Trotter
758 a5728081 Guido Trotter
BES_PARAMETERS = frozenset(BES_PARAMETER_TYPES.keys())
759 cd3ab26e Iustin Pop
760 095e71aa René Nussbaumer
# Node parameter names
761 095e71aa René Nussbaumer
ND_OOB_PROGRAM = "oob_program"
762 095e71aa René Nussbaumer
763 095e71aa René Nussbaumer
NDS_PARAMETER_TYPES = {
764 095e71aa René Nussbaumer
    ND_OOB_PROGRAM: VTYPE_MAYBE_STRING,
765 095e71aa René Nussbaumer
    }
766 095e71aa René Nussbaumer
767 095e71aa René Nussbaumer
NDS_PARAMETERS = frozenset(NDS_PARAMETER_TYPES.keys())
768 095e71aa René Nussbaumer
769 b2f29800 René Nussbaumer
# OOB supported commands
770 b2f29800 René Nussbaumer
OOB_POWER_ON = "power-on"
771 b2f29800 René Nussbaumer
OOB_POWER_OFF = "power-off"
772 b2f29800 René Nussbaumer
OOB_POWER_CYCLE = "power-cycle"
773 b2f29800 René Nussbaumer
OOB_POWER_STATUS = "power-status"
774 b2f29800 René Nussbaumer
OOB_HEALTH = "health"
775 b2f29800 René Nussbaumer
776 21daa4a8 Stephen Shirley
OOB_COMMANDS = frozenset([
777 21daa4a8 Stephen Shirley
  OOB_POWER_ON,
778 21daa4a8 Stephen Shirley
  OOB_POWER_OFF,
779 21daa4a8 Stephen Shirley
  OOB_POWER_CYCLE,
780 21daa4a8 Stephen Shirley
  OOB_POWER_STATUS,
781 21daa4a8 Stephen Shirley
  OOB_HEALTH
782 21daa4a8 Stephen Shirley
  ])
783 b2f29800 René Nussbaumer
784 b528a12d René Nussbaumer
OOB_POWER_STATUS_POWERED = "powered"
785 b528a12d René Nussbaumer
786 445f735d René Nussbaumer
OOB_TIMEOUT = 60 # 60 seconds
787 beff3779 René Nussbaumer
OOB_POWER_DELAY = 2.0 # 2 seconds
788 445f735d René Nussbaumer
789 445f735d René Nussbaumer
OOB_STATUS_OK = "OK"
790 445f735d René Nussbaumer
OOB_STATUS_WARNING = "WARNING"
791 445f735d René Nussbaumer
OOB_STATUS_CRITICAL = "CRITICAL"
792 445f735d René Nussbaumer
OOB_STATUS_UNKNOWN = "UNKNOWN"
793 445f735d René Nussbaumer
794 445f735d René Nussbaumer
OOB_STATUSES = frozenset([
795 445f735d René Nussbaumer
  OOB_STATUS_OK,
796 445f735d René Nussbaumer
  OOB_STATUS_WARNING,
797 445f735d René Nussbaumer
  OOB_STATUS_CRITICAL,
798 445f735d René Nussbaumer
  OOB_STATUS_UNKNOWN,
799 445f735d René Nussbaumer
  ])
800 445f735d René Nussbaumer
801 4ef7f423 Guido Trotter
# Instance Parameters Profile
802 4ef7f423 Guido Trotter
PP_DEFAULT = "default"
803 e64b8beb Iustin Pop
804 246f4067 Guido Trotter
# NIC_* constants are used inside the ganeti config
805 ac061be9 Guido Trotter
NIC_MODE = "mode"
806 ac061be9 Guido Trotter
NIC_LINK = "link"
807 ac061be9 Guido Trotter
808 ac061be9 Guido Trotter
NIC_MODE_BRIDGED = "bridged"
809 ac061be9 Guido Trotter
NIC_MODE_ROUTED = "routed"
810 ac061be9 Guido Trotter
811 ac061be9 Guido Trotter
NIC_VALID_MODES = frozenset([NIC_MODE_BRIDGED, NIC_MODE_ROUTED])
812 ac061be9 Guido Trotter
813 ac061be9 Guido Trotter
NICS_PARAMETER_TYPES = {
814 ac061be9 Guido Trotter
    NIC_MODE: VTYPE_STRING,
815 ac061be9 Guido Trotter
    NIC_LINK: VTYPE_STRING,
816 ac061be9 Guido Trotter
    }
817 ac061be9 Guido Trotter
818 ac061be9 Guido Trotter
NICS_PARAMETERS = frozenset(NICS_PARAMETER_TYPES.keys())
819 e64b8beb Iustin Pop
820 246f4067 Guido Trotter
# IDISK_* constants are used in opcodes, to create/change disks
821 bd061c35 Guido Trotter
IDISK_SIZE = "size"
822 bd061c35 Guido Trotter
IDISK_MODE = "mode"
823 8494604f Apollon Oikonomopoulos
IDISK_ADOPT = "adopt"
824 7af3534e Dmitry Chernyak
IDISK_VG = "vg"
825 87001920 Iustin Pop
IDISK_METAVG = "metavg"
826 8494604f Apollon Oikonomopoulos
IDISK_PARAMS_TYPES = {
827 8494604f Apollon Oikonomopoulos
  IDISK_SIZE: VTYPE_SIZE,
828 8494604f Apollon Oikonomopoulos
  IDISK_MODE: VTYPE_STRING,
829 8494604f Apollon Oikonomopoulos
  IDISK_ADOPT: VTYPE_STRING,
830 7af3534e Dmitry Chernyak
  IDISK_VG: VTYPE_STRING,
831 87001920 Iustin Pop
  IDISK_METAVG: VTYPE_STRING,
832 8494604f Apollon Oikonomopoulos
  }
833 cc87d736 Michael Hanselmann
IDISK_PARAMS = frozenset(IDISK_PARAMS_TYPES.keys())
834 cc87d736 Michael Hanselmann
835 246f4067 Guido Trotter
# INIC_* constants are used in opcodes, to create/change nics
836 bd061c35 Guido Trotter
INIC_MAC = "mac"
837 bd061c35 Guido Trotter
INIC_IP = "ip"
838 bd061c35 Guido Trotter
INIC_MODE = "mode"
839 bd061c35 Guido Trotter
INIC_LINK = "link"
840 cc87d736 Michael Hanselmann
INIC_PARAMS_TYPES = {
841 cc87d736 Michael Hanselmann
  INIC_IP: VTYPE_MAYBE_STRING,
842 cc87d736 Michael Hanselmann
  INIC_LINK: VTYPE_STRING,
843 cc87d736 Michael Hanselmann
  INIC_MAC: VTYPE_STRING,
844 cc87d736 Michael Hanselmann
  INIC_MODE: VTYPE_STRING,
845 cc87d736 Michael Hanselmann
  }
846 cc87d736 Michael Hanselmann
INIC_PARAMS = frozenset(INIC_PARAMS_TYPES.keys())
847 bd061c35 Guido Trotter
848 2584d4a4 Alexander Schreiber
# Hypervisor constants
849 00cd937c Iustin Pop
HT_XEN_PVM = "xen-pvm"
850 2584d4a4 Alexander Schreiber
HT_FAKE = "fake"
851 00cd937c Iustin Pop
HT_XEN_HVM = "xen-hvm"
852 550e49b9 Guido Trotter
HT_KVM = "kvm"
853 48297fa2 Iustin Pop
HT_CHROOT = "chroot"
854 4b5e40a5 Iustin Pop
HT_LXC = "lxc"
855 4b5e40a5 Iustin Pop
HYPER_TYPES = frozenset([
856 4b5e40a5 Iustin Pop
  HT_XEN_PVM,
857 4b5e40a5 Iustin Pop
  HT_FAKE,
858 4b5e40a5 Iustin Pop
  HT_XEN_HVM,
859 4b5e40a5 Iustin Pop
  HT_KVM,
860 4b5e40a5 Iustin Pop
  HT_CHROOT,
861 4b5e40a5 Iustin Pop
  HT_LXC,
862 4b5e40a5 Iustin Pop
  ])
863 fd4daa3a Guido Trotter
HTS_REQ_PORT = frozenset([HT_XEN_HVM, HT_KVM])
864 2584d4a4 Alexander Schreiber
865 377d74c9 Guido Trotter
VNC_BASE_PORT = 5900
866 131178b9 Luca Bigliardi
VNC_PASSWORD_FILE = CONF_DIR + "/vnc-cluster-password"
867 0d2cd893 Manuel Franceschini
VNC_DEFAULT_BIND_ADDRESS = IP4_ADDRESS_ANY
868 e54c4c5e Guido Trotter
869 835528af Iustin Pop
# NIC types
870 d08f6067 Guido Trotter
HT_NIC_RTL8139 = "rtl8139"
871 d08f6067 Guido Trotter
HT_NIC_NE2K_PCI = "ne2k_pci"
872 d08f6067 Guido Trotter
HT_NIC_NE2K_ISA = "ne2k_isa"
873 43440815 Guido Trotter
HT_NIC_I82551 = "i82551"
874 43440815 Guido Trotter
HT_NIC_I85557B = "i82557b"
875 43440815 Guido Trotter
HT_NIC_I8259ER = "i82559er"
876 43440815 Guido Trotter
HT_NIC_PCNET = "pcnet"
877 43440815 Guido Trotter
HT_NIC_E1000 = "e1000"
878 d08f6067 Guido Trotter
HT_NIC_PARAVIRTUAL = HT_DISK_PARAVIRTUAL = "paravirtual"
879 43440815 Guido Trotter
880 21daa4a8 Stephen Shirley
HT_HVM_VALID_NIC_TYPES = frozenset([
881 21daa4a8 Stephen Shirley
  HT_NIC_RTL8139,
882 21daa4a8 Stephen Shirley
  HT_NIC_NE2K_PCI,
883 21daa4a8 Stephen Shirley
  HT_NIC_E1000,
884 21daa4a8 Stephen Shirley
  HT_NIC_NE2K_ISA,
885 21daa4a8 Stephen Shirley
  HT_NIC_PARAVIRTUAL
886 21daa4a8 Stephen Shirley
  ])
887 21daa4a8 Stephen Shirley
HT_KVM_VALID_NIC_TYPES = frozenset([
888 21daa4a8 Stephen Shirley
  HT_NIC_RTL8139,
889 21daa4a8 Stephen Shirley
  HT_NIC_NE2K_PCI,
890 21daa4a8 Stephen Shirley
  HT_NIC_NE2K_ISA,
891 21daa4a8 Stephen Shirley
  HT_NIC_I82551,
892 21daa4a8 Stephen Shirley
  HT_NIC_I85557B,
893 21daa4a8 Stephen Shirley
  HT_NIC_I8259ER,
894 21daa4a8 Stephen Shirley
  HT_NIC_PCNET,
895 21daa4a8 Stephen Shirley
  HT_NIC_E1000,
896 21daa4a8 Stephen Shirley
  HT_NIC_PARAVIRTUAL
897 21daa4a8 Stephen Shirley
  ])
898 21daa4a8 Stephen Shirley
899 835528af Iustin Pop
# Disk types
900 835528af Iustin Pop
HT_DISK_IOEMU = "ioemu"
901 835528af Iustin Pop
HT_DISK_IDE = "ide"
902 835528af Iustin Pop
HT_DISK_SCSI = "scsi"
903 835528af Iustin Pop
HT_DISK_SD = "sd"
904 835528af Iustin Pop
HT_DISK_MTD = "mtd"
905 835528af Iustin Pop
HT_DISK_PFLASH = "pflash"
906 835528af Iustin Pop
907 ea0f3d7a Iustin Pop
HT_CACHE_DEFAULT = "default"
908 ea0f3d7a Iustin Pop
HT_CACHE_NONE = "none"
909 ea0f3d7a Iustin Pop
HT_CACHE_WTHROUGH = "writethrough"
910 ea0f3d7a Iustin Pop
HT_CACHE_WBACK = "writeback"
911 21daa4a8 Stephen Shirley
HT_VALID_CACHE_TYPES = frozenset([
912 21daa4a8 Stephen Shirley
  HT_CACHE_DEFAULT,
913 21daa4a8 Stephen Shirley
  HT_CACHE_NONE,
914 21daa4a8 Stephen Shirley
  HT_CACHE_WTHROUGH,
915 21daa4a8 Stephen Shirley
  HT_CACHE_WBACK
916 21daa4a8 Stephen Shirley
  ])
917 ea0f3d7a Iustin Pop
918 835528af Iustin Pop
HT_HVM_VALID_DISK_TYPES = frozenset([HT_DISK_PARAVIRTUAL, HT_DISK_IOEMU])
919 21daa4a8 Stephen Shirley
HT_KVM_VALID_DISK_TYPES = frozenset([
920 21daa4a8 Stephen Shirley
  HT_DISK_PARAVIRTUAL,
921 21daa4a8 Stephen Shirley
  HT_DISK_IDE,
922 21daa4a8 Stephen Shirley
  HT_DISK_SCSI,
923 21daa4a8 Stephen Shirley
  HT_DISK_SD,
924 21daa4a8 Stephen Shirley
  HT_DISK_MTD,
925 21daa4a8 Stephen Shirley
  HT_DISK_PFLASH
926 21daa4a8 Stephen Shirley
  ])
927 b894f5a8 Alexander Schreiber
928 835528af Iustin Pop
# Mouse types:
929 835528af Iustin Pop
HT_MOUSE_MOUSE = "mouse"
930 835528af Iustin Pop
HT_MOUSE_TABLET = "tablet"
931 835528af Iustin Pop
932 835528af Iustin Pop
HT_KVM_VALID_MOUSE_TYPES = frozenset([HT_MOUSE_MOUSE, HT_MOUSE_TABLET])
933 835528af Iustin Pop
934 835528af Iustin Pop
# Boot order
935 cc130cc7 Marco Casavecchia
HT_BO_FLOPPY = "floppy"
936 835528af Iustin Pop
HT_BO_CDROM = "cdrom"
937 835528af Iustin Pop
HT_BO_DISK = "disk"
938 835528af Iustin Pop
HT_BO_NETWORK = "network"
939 835528af Iustin Pop
940 21daa4a8 Stephen Shirley
HT_KVM_VALID_BO_TYPES = frozenset([
941 21daa4a8 Stephen Shirley
  HT_BO_FLOPPY,
942 21daa4a8 Stephen Shirley
  HT_BO_CDROM,
943 21daa4a8 Stephen Shirley
  HT_BO_DISK,
944 21daa4a8 Stephen Shirley
  HT_BO_NETWORK
945 21daa4a8 Stephen Shirley
  ])
946 835528af Iustin Pop
947 3424767f Guido Trotter
# Security models
948 3424767f Guido Trotter
HT_SM_NONE = "none"
949 3424767f Guido Trotter
HT_SM_USER = "user"
950 3424767f Guido Trotter
HT_SM_POOL = "pool"
951 3424767f Guido Trotter
952 3424767f Guido Trotter
HT_KVM_VALID_SM_TYPES = frozenset([HT_SM_NONE, HT_SM_USER, HT_SM_POOL])
953 3424767f Guido Trotter
954 7ba594c0 Guido Trotter
# Kvm flag values
955 7ba594c0 Guido Trotter
HT_KVM_ENABLED = "enabled"
956 7ba594c0 Guido Trotter
HT_KVM_DISABLED = "disabled"
957 7ba594c0 Guido Trotter
958 7ba594c0 Guido Trotter
HT_KVM_FLAG_VALUES = frozenset([HT_KVM_ENABLED, HT_KVM_DISABLED])
959 7ba594c0 Guido Trotter
960 e71b9ef4 Iustin Pop
# Migration type
961 e71b9ef4 Iustin Pop
HT_MIGRATION_LIVE = "live"
962 e71b9ef4 Iustin Pop
HT_MIGRATION_NONLIVE = "non-live"
963 783a6c0b Iustin Pop
HT_MIGRATION_MODES = frozenset([HT_MIGRATION_LIVE, HT_MIGRATION_NONLIVE])
964 e71b9ef4 Iustin Pop
965 e54c4c5e Guido Trotter
# Cluster Verify steps
966 d0c8c01d Iustin Pop
VERIFY_NPLUSONE_MEM = "nplusone_mem"
967 e54c4c5e Guido Trotter
VERIFY_OPTIONAL_CHECKS = frozenset([VERIFY_NPLUSONE_MEM])
968 e54c4c5e Guido Trotter
969 25361b9a Iustin Pop
# Node verify constants
970 7ef40fbe Luca Bigliardi
NV_DRBDHELPER = "drbd-helper"
971 b0d85178 Iustin Pop
NV_DRBDLIST = "drbd-list"
972 25361b9a Iustin Pop
NV_FILELIST = "filelist"
973 25361b9a Iustin Pop
NV_HVINFO = "hvinfo"
974 25361b9a Iustin Pop
NV_HYPERVISOR = "hypervisor"
975 58a59652 Iustin Pop
NV_HVPARAMS = "hvparms"
976 25361b9a Iustin Pop
NV_INSTANCELIST = "instancelist"
977 b0d85178 Iustin Pop
NV_LVLIST = "lvlist"
978 b0d85178 Iustin Pop
NV_MASTERIP = "master-ip"
979 25361b9a Iustin Pop
NV_NODELIST = "nodelist"
980 25361b9a Iustin Pop
NV_NODENETTEST = "node-net-test"
981 7c0aa8e9 Iustin Pop
NV_NODESETUP = "nodesetup"
982 b0d85178 Iustin Pop
NV_OSLIST = "oslist"
983 b0d85178 Iustin Pop
NV_PVLIST = "pvlist"
984 313b2dd4 Michael Hanselmann
NV_TIME = "time"
985 b0d85178 Iustin Pop
NV_VERSION = "version"
986 b0d85178 Iustin Pop
NV_VGLIST = "vglist"
987 8964ee14 Iustin Pop
NV_VMNODES = "vmnodes"
988 16f41f24 René Nussbaumer
NV_OOB_PATHS = "oob-paths"
989 20d317d4 Iustin Pop
NV_BRIDGES = "bridges"
990 25361b9a Iustin Pop
991 61a980a9 Michael Hanselmann
# Instance status
992 61a980a9 Michael Hanselmann
INSTST_RUNNING = "running"
993 61a980a9 Michael Hanselmann
INSTST_ADMINDOWN = "ADMIN_down"
994 61a980a9 Michael Hanselmann
INSTST_NODEOFFLINE = "ERROR_nodeoffline"
995 61a980a9 Michael Hanselmann
INSTST_NODEDOWN = "ERROR_nodedown"
996 61a980a9 Michael Hanselmann
INSTST_WRONGNODE = "ERROR_wrongnode"
997 61a980a9 Michael Hanselmann
INSTST_ERRORUP = "ERROR_up"
998 61a980a9 Michael Hanselmann
INSTST_ERRORDOWN = "ERROR_down"
999 61a980a9 Michael Hanselmann
INSTST_ALL = frozenset([
1000 61a980a9 Michael Hanselmann
  INSTST_RUNNING,
1001 61a980a9 Michael Hanselmann
  INSTST_ADMINDOWN,
1002 61a980a9 Michael Hanselmann
  INSTST_NODEOFFLINE,
1003 61a980a9 Michael Hanselmann
  INSTST_NODEDOWN,
1004 61a980a9 Michael Hanselmann
  INSTST_WRONGNODE,
1005 61a980a9 Michael Hanselmann
  INSTST_ERRORUP,
1006 61a980a9 Michael Hanselmann
  INSTST_ERRORDOWN,
1007 61a980a9 Michael Hanselmann
  ])
1008 61a980a9 Michael Hanselmann
1009 1e28e3b8 Michael Hanselmann
# Node roles
1010 1e28e3b8 Michael Hanselmann
NR_REGULAR = "R"
1011 1e28e3b8 Michael Hanselmann
NR_MASTER = "M"
1012 1e28e3b8 Michael Hanselmann
NR_MCANDIDATE = "C"
1013 1e28e3b8 Michael Hanselmann
NR_DRAINED = "D"
1014 1e28e3b8 Michael Hanselmann
NR_OFFLINE = "O"
1015 1e28e3b8 Michael Hanselmann
NR_ALL = frozenset([
1016 1e28e3b8 Michael Hanselmann
  NR_REGULAR,
1017 1e28e3b8 Michael Hanselmann
  NR_MASTER,
1018 1e28e3b8 Michael Hanselmann
  NR_MCANDIDATE,
1019 1e28e3b8 Michael Hanselmann
  NR_DRAINED,
1020 1e28e3b8 Michael Hanselmann
  NR_OFFLINE,
1021 1e28e3b8 Michael Hanselmann
  ])
1022 1e28e3b8 Michael Hanselmann
1023 b98bf262 Michael Hanselmann
# SSL certificate check constants (in days)
1024 b98bf262 Michael Hanselmann
SSL_CERT_EXPIRATION_WARN = 30
1025 b98bf262 Michael Hanselmann
SSL_CERT_EXPIRATION_ERROR = 7
1026 b98bf262 Michael Hanselmann
1027 d61df03e Iustin Pop
# Allocator framework constants
1028 77031881 Iustin Pop
IALLOCATOR_VERSION = 2
1029 298fe380 Iustin Pop
IALLOCATOR_DIR_IN = "in"
1030 298fe380 Iustin Pop
IALLOCATOR_DIR_OUT = "out"
1031 3636400f Iustin Pop
VALID_IALLOCATOR_DIRECTIONS = frozenset([
1032 3636400f Iustin Pop
  IALLOCATOR_DIR_IN,
1033 3636400f Iustin Pop
  IALLOCATOR_DIR_OUT,
1034 3636400f Iustin Pop
  ])
1035 298fe380 Iustin Pop
IALLOCATOR_MODE_ALLOC = "allocate"
1036 298fe380 Iustin Pop
IALLOCATOR_MODE_RELOC = "relocate"
1037 60152bbe Michael Hanselmann
IALLOCATOR_MODE_CHG_GROUP = "change-group"
1038 60152bbe Michael Hanselmann
IALLOCATOR_MODE_NODE_EVAC = "node-evacuate"
1039 3636400f Iustin Pop
VALID_IALLOCATOR_MODES = frozenset([
1040 3636400f Iustin Pop
  IALLOCATOR_MODE_ALLOC,
1041 3636400f Iustin Pop
  IALLOCATOR_MODE_RELOC,
1042 60152bbe Michael Hanselmann
  IALLOCATOR_MODE_CHG_GROUP,
1043 60152bbe Michael Hanselmann
  IALLOCATOR_MODE_NODE_EVAC,
1044 3636400f Iustin Pop
  ])
1045 298fe380 Iustin Pop
IALLOCATOR_SEARCH_PATH = _autoconf.IALLOCATOR_SEARCH_PATH
1046 5f33b613 Michael Hanselmann
1047 60152bbe Michael Hanselmann
IALLOCATOR_NEVAC_PRI = "primary-only"
1048 60152bbe Michael Hanselmann
IALLOCATOR_NEVAC_SEC = "secondary-only"
1049 60152bbe Michael Hanselmann
IALLOCATOR_NEVAC_ALL = "all"
1050 60152bbe Michael Hanselmann
IALLOCATOR_NEVAC_MODES = frozenset([
1051 60152bbe Michael Hanselmann
  IALLOCATOR_NEVAC_PRI,
1052 60152bbe Michael Hanselmann
  IALLOCATOR_NEVAC_SEC,
1053 60152bbe Michael Hanselmann
  IALLOCATOR_NEVAC_ALL,
1054 60152bbe Michael Hanselmann
  ])
1055 60152bbe Michael Hanselmann
1056 f1da30e6 Michael Hanselmann
# Job queue
1057 f1da30e6 Michael Hanselmann
JOB_QUEUE_VERSION = 1
1058 f1da30e6 Michael Hanselmann
JOB_QUEUE_LOCK_FILE = QUEUE_DIR + "/lock"
1059 f1da30e6 Michael Hanselmann
JOB_QUEUE_VERSION_FILE = QUEUE_DIR + "/version"
1060 f1da30e6 Michael Hanselmann
JOB_QUEUE_SERIAL_FILE = QUEUE_DIR + "/serial"
1061 0cb94105 Michael Hanselmann
JOB_QUEUE_ARCHIVE_DIR = QUEUE_DIR + "/archive"
1062 686d7433 Iustin Pop
JOB_QUEUE_DRAIN_FILE = QUEUE_DIR + "/drain"
1063 f87b405e Michael Hanselmann
JOB_QUEUE_SIZE_HARD_LIMIT = 5000
1064 c33549ef Guido Trotter
JOB_QUEUE_DIRS = [QUEUE_DIR, JOB_QUEUE_ARCHIVE_DIR]
1065 5bae14d9 Guido Trotter
JOB_QUEUE_DIRS_MODE = SECURE_DIR_MODE
1066 f1da30e6 Michael Hanselmann
1067 bac5ffc3 Oleksiy Mishchenko
JOB_ID_TEMPLATE = r"\d+"
1068 cb66225d Michael Hanselmann
JOB_FILE_RE = re.compile(r"^job-(%s)$" % JOB_ID_TEMPLATE)
1069 bac5ffc3 Oleksiy Mishchenko
1070 5c735209 Iustin Pop
# unchanged job return
1071 5c735209 Iustin Pop
JOB_NOTCHANGED = "nochange"
1072 5c735209 Iustin Pop
1073 5f33b613 Michael Hanselmann
# Job status
1074 5f33b613 Michael Hanselmann
JOB_STATUS_QUEUED = "queued"
1075 47099cd1 Michael Hanselmann
JOB_STATUS_WAITING = "waiting"
1076 fbf0262f Michael Hanselmann
JOB_STATUS_CANCELING = "canceling"
1077 5f33b613 Michael Hanselmann
JOB_STATUS_RUNNING = "running"
1078 5f33b613 Michael Hanselmann
JOB_STATUS_CANCELED = "canceled"
1079 5f33b613 Michael Hanselmann
JOB_STATUS_SUCCESS = "success"
1080 5f33b613 Michael Hanselmann
JOB_STATUS_ERROR = "error"
1081 989a8bee Michael Hanselmann
JOBS_FINALIZED = frozenset([
1082 989a8bee Michael Hanselmann
  JOB_STATUS_CANCELED,
1083 989a8bee Michael Hanselmann
  JOB_STATUS_SUCCESS,
1084 989a8bee Michael Hanselmann
  JOB_STATUS_ERROR,
1085 989a8bee Michael Hanselmann
  ])
1086 db5bce34 Michael Hanselmann
JOB_STATUS_ALL = frozenset([
1087 db5bce34 Michael Hanselmann
  JOB_STATUS_QUEUED,
1088 47099cd1 Michael Hanselmann
  JOB_STATUS_WAITING,
1089 db5bce34 Michael Hanselmann
  JOB_STATUS_CANCELING,
1090 db5bce34 Michael Hanselmann
  JOB_STATUS_RUNNING,
1091 db5bce34 Michael Hanselmann
  ]) | JOBS_FINALIZED
1092 5f33b613 Michael Hanselmann
1093 34327f51 Iustin Pop
# OpCode status
1094 34327f51 Iustin Pop
# not yet finalized
1095 5f33b613 Michael Hanselmann
OP_STATUS_QUEUED = "queued"
1096 47099cd1 Michael Hanselmann
OP_STATUS_WAITING = "waiting"
1097 fbf0262f Michael Hanselmann
OP_STATUS_CANCELING = "canceling"
1098 5f33b613 Michael Hanselmann
OP_STATUS_RUNNING = "running"
1099 34327f51 Iustin Pop
# finalized
1100 4cb1d919 Michael Hanselmann
OP_STATUS_CANCELED = "canceled"
1101 5f33b613 Michael Hanselmann
OP_STATUS_SUCCESS = "success"
1102 5f33b613 Michael Hanselmann
OP_STATUS_ERROR = "error"
1103 21daa4a8 Stephen Shirley
OPS_FINALIZED = frozenset([
1104 21daa4a8 Stephen Shirley
  OP_STATUS_CANCELED,
1105 21daa4a8 Stephen Shirley
  OP_STATUS_SUCCESS,
1106 21daa4a8 Stephen Shirley
  OP_STATUS_ERROR
1107 21daa4a8 Stephen Shirley
  ])
1108 f1048938 Iustin Pop
1109 e5d8774b Michael Hanselmann
# OpCode priority
1110 e5d8774b Michael Hanselmann
OP_PRIO_LOWEST = +19
1111 e5d8774b Michael Hanselmann
OP_PRIO_HIGHEST = -20
1112 e5d8774b Michael Hanselmann
1113 e5d8774b Michael Hanselmann
OP_PRIO_LOW = +10
1114 e5d8774b Michael Hanselmann
OP_PRIO_NORMAL = 0
1115 e5d8774b Michael Hanselmann
OP_PRIO_HIGH = -10
1116 e5d8774b Michael Hanselmann
1117 e71c8147 Michael Hanselmann
OP_PRIO_SUBMIT_VALID = frozenset([
1118 e71c8147 Michael Hanselmann
  OP_PRIO_LOW,
1119 e71c8147 Michael Hanselmann
  OP_PRIO_NORMAL,
1120 e71c8147 Michael Hanselmann
  OP_PRIO_HIGH,
1121 e71c8147 Michael Hanselmann
  ])
1122 e71c8147 Michael Hanselmann
1123 e5d8774b Michael Hanselmann
OP_PRIO_DEFAULT = OP_PRIO_NORMAL
1124 e5d8774b Michael Hanselmann
1125 f1048938 Iustin Pop
# Execution log types
1126 f1048938 Iustin Pop
ELOG_MESSAGE = "message"
1127 f1048938 Iustin Pop
ELOG_PROGRESS = "progress"
1128 9bf56d77 Michael Hanselmann
ELOG_REMOTE_IMPORT = "remote-import"
1129 e58f87a9 Michael Hanselmann
ELOG_JQUEUE_TEST = "jqueue-test"
1130 e58f87a9 Michael Hanselmann
1131 19ddc57a René Nussbaumer
# /etc/hosts modification
1132 19ddc57a René Nussbaumer
ETC_HOSTS_ADD = "add"
1133 19ddc57a René Nussbaumer
ETC_HOSTS_REMOVE = "remove"
1134 19ddc57a René Nussbaumer
1135 e58f87a9 Michael Hanselmann
# Job queue test
1136 e58f87a9 Michael Hanselmann
JQT_MSGPREFIX = "TESTMSG="
1137 e58f87a9 Michael Hanselmann
JQT_EXPANDNAMES = "expandnames"
1138 e58f87a9 Michael Hanselmann
JQT_EXEC = "exec"
1139 e58f87a9 Michael Hanselmann
JQT_LOGMSG = "logmsg"
1140 f99010b2 Michael Hanselmann
JQT_STARTMSG = "startmsg"
1141 e58f87a9 Michael Hanselmann
JQT_ALL = frozenset([
1142 e58f87a9 Michael Hanselmann
  JQT_EXPANDNAMES,
1143 e58f87a9 Michael Hanselmann
  JQT_EXEC,
1144 e58f87a9 Michael Hanselmann
  JQT_LOGMSG,
1145 f99010b2 Michael Hanselmann
  JQT_STARTMSG,
1146 e58f87a9 Michael Hanselmann
  ])
1147 d4104181 Iustin Pop
1148 4a917de6 Michael Hanselmann
# Query resources
1149 4a917de6 Michael Hanselmann
QR_INSTANCE = "instance"
1150 4a917de6 Michael Hanselmann
QR_NODE = "node"
1151 24d16f76 Michael Hanselmann
QR_LOCK = "lock"
1152 e070c663 Adeodato Simo
QR_GROUP = "group"
1153 be3a4b14 Michael Hanselmann
QR_OS = "os"
1154 4a917de6 Michael Hanselmann
1155 4a917de6 Michael Hanselmann
#: List of resources which can be queried using L{opcodes.OpQuery}
1156 abd66bf8 Michael Hanselmann
QR_VIA_OP = frozenset([QR_INSTANCE, QR_NODE, QR_GROUP, QR_OS])
1157 4a917de6 Michael Hanselmann
1158 3d5ebbf0 Stephen Shirley
#: List of resources which can be queried using Local UniX Interface
1159 abd66bf8 Michael Hanselmann
QR_VIA_LUXI = QR_VIA_OP.union([
1160 24d16f76 Michael Hanselmann
  QR_LOCK,
1161 28b71a76 Michael Hanselmann
  ])
1162 28b71a76 Michael Hanselmann
1163 abd66bf8 Michael Hanselmann
#: List of resources which can be queried using RAPI
1164 abd66bf8 Michael Hanselmann
QR_VIA_RAPI = QR_VIA_LUXI
1165 abd66bf8 Michael Hanselmann
1166 4a917de6 Michael Hanselmann
# Query field types
1167 4a917de6 Michael Hanselmann
QFT_UNKNOWN = "unknown"
1168 4a917de6 Michael Hanselmann
QFT_TEXT = "text"
1169 4a917de6 Michael Hanselmann
QFT_BOOL = "bool"
1170 4a917de6 Michael Hanselmann
QFT_NUMBER = "number"
1171 4a917de6 Michael Hanselmann
QFT_UNIT = "unit"
1172 4a917de6 Michael Hanselmann
QFT_TIMESTAMP = "timestamp"
1173 4a917de6 Michael Hanselmann
QFT_OTHER = "other"
1174 4a917de6 Michael Hanselmann
1175 4a917de6 Michael Hanselmann
#: All query field types
1176 4a917de6 Michael Hanselmann
QFT_ALL = frozenset([
1177 4a917de6 Michael Hanselmann
  QFT_UNKNOWN,
1178 4a917de6 Michael Hanselmann
  QFT_TEXT,
1179 4a917de6 Michael Hanselmann
  QFT_BOOL,
1180 4a917de6 Michael Hanselmann
  QFT_NUMBER,
1181 4a917de6 Michael Hanselmann
  QFT_UNIT,
1182 4a917de6 Michael Hanselmann
  QFT_TIMESTAMP,
1183 4a917de6 Michael Hanselmann
  QFT_OTHER,
1184 4a917de6 Michael Hanselmann
  ])
1185 4a917de6 Michael Hanselmann
1186 a6070ef7 Michael Hanselmann
# Query result field status (don't change or reuse values as they're used by
1187 a6070ef7 Michael Hanselmann
# clients)
1188 4a917de6 Michael Hanselmann
#: Normal field status
1189 cfb084ae René Nussbaumer
RS_NORMAL = 0
1190 4a917de6 Michael Hanselmann
#: Unknown field
1191 cfb084ae René Nussbaumer
RS_UNKNOWN = 1
1192 cfb084ae René Nussbaumer
#: No data (e.g. RPC error), can be used instead of L{RS_OFFLINE}
1193 cfb084ae René Nussbaumer
RS_NODATA = 2
1194 dcb9946c Iustin Pop
#: Value unavailable/unsupported for item; if this field is supported
1195 e18c6c47 Iustin Pop
#: but we cannot get the data for the moment, RS_NODATA or
1196 e18c6c47 Iustin Pop
#: RS_OFFLINE should be used
1197 cfb084ae René Nussbaumer
RS_UNAVAIL = 3
1198 a6070ef7 Michael Hanselmann
#: Resource marked offline
1199 cfb084ae René Nussbaumer
RS_OFFLINE = 4
1200 cfb084ae René Nussbaumer
1201 cfb084ae René Nussbaumer
RS_ALL = frozenset([
1202 cfb084ae René Nussbaumer
  RS_NORMAL,
1203 cfb084ae René Nussbaumer
  RS_UNKNOWN,
1204 cfb084ae René Nussbaumer
  RS_NODATA,
1205 cfb084ae René Nussbaumer
  RS_UNAVAIL,
1206 cfb084ae René Nussbaumer
  RS_OFFLINE,
1207 ee3aedff Michael Hanselmann
  ])
1208 ee3aedff Michael Hanselmann
1209 f0b1bafe Iustin Pop
#: Dictionary with special field cases and their verbose/terse formatting
1210 f0b1bafe Iustin Pop
RSS_DESCRIPTION = {
1211 f0b1bafe Iustin Pop
  RS_UNKNOWN: ("(unknown)", "??"),
1212 f0b1bafe Iustin Pop
  RS_NODATA:  ("(nodata)",  "?"),
1213 f0b1bafe Iustin Pop
  RS_OFFLINE: ("(offline)", "*"),
1214 f0b1bafe Iustin Pop
  RS_UNAVAIL: ("(unavail)", "-"),
1215 f0b1bafe Iustin Pop
  }
1216 f0b1bafe Iustin Pop
1217 c5e489f7 Iustin Pop
# max dynamic devices
1218 24991749 Iustin Pop
MAX_NICS = 8
1219 24991749 Iustin Pop
MAX_DISKS = 16
1220 24991749 Iustin Pop
1221 93384844 Iustin Pop
# SSCONF keys
1222 93384844 Iustin Pop
SS_CLUSTER_NAME = "cluster_name"
1223 5d60b3bd Iustin Pop
SS_CLUSTER_TAGS = "cluster_tags"
1224 93384844 Iustin Pop
SS_FILE_STORAGE_DIR = "file_storage_dir"
1225 4b97f902 Apollon Oikonomopoulos
SS_SHARED_FILE_STORAGE_DIR = "shared_file_storage_dir"
1226 f56618e0 Iustin Pop
SS_MASTER_CANDIDATES = "master_candidates"
1227 8113a52e Luca Bigliardi
SS_MASTER_CANDIDATES_IPS = "master_candidates_ips"
1228 93384844 Iustin Pop
SS_MASTER_IP = "master_ip"
1229 93384844 Iustin Pop
SS_MASTER_NETDEV = "master_netdev"
1230 93384844 Iustin Pop
SS_MASTER_NODE = "master_node"
1231 93384844 Iustin Pop
SS_NODE_LIST = "node_list"
1232 f9780ccd Luca Bigliardi
SS_NODE_PRIMARY_IPS = "node_primary_ips"
1233 f9780ccd Luca Bigliardi
SS_NODE_SECONDARY_IPS = "node_secondary_ips"
1234 a3316e4a Iustin Pop
SS_OFFLINE_NODES = "offline_nodes"
1235 81a49123 Iustin Pop
SS_ONLINE_NODES = "online_nodes"
1236 868a98ca Manuel Franceschini
SS_PRIMARY_IP_FAMILY = "primary_ip_family"
1237 81a49123 Iustin Pop
SS_INSTANCE_LIST = "instance_list"
1238 8a113c7a Iustin Pop
SS_RELEASE_VERSION = "release_version"
1239 4f7a6a10 Iustin Pop
SS_HYPERVISOR_LIST = "hypervisor_list"
1240 5c465a95 Iustin Pop
SS_MAINTAIN_NODE_HEALTH = "maintain_node_health"
1241 0fbae49a Balazs Lecz
SS_UID_POOL = "uid_pool"
1242 6f076453 Guido Trotter
SS_NODEGROUPS = "nodegroups"
1243 93384844 Iustin Pop
1244 cd57bab6 Michael Hanselmann
SS_FILE_PERMS = 0444
1245 cd57bab6 Michael Hanselmann
1246 7888a614 Alexander Schreiber
# cluster wide default parameters
1247 7888a614 Alexander Schreiber
DEFAULT_ENABLED_HYPERVISOR = HT_XEN_PVM
1248 7888a614 Alexander Schreiber
1249 7888a614 Alexander Schreiber
HVC_DEFAULTS = {
1250 bd0ff7c2 Iustin Pop
  HT_XEN_PVM: {
1251 2f2dbb4b Jun Futagawa
    HV_USE_BOOTLOADER: False,
1252 2f2dbb4b Jun Futagawa
    HV_BOOTLOADER_PATH: XEN_BOOTLOADER,
1253 d0c8c01d Iustin Pop
    HV_BOOTLOADER_ARGS: "",
1254 bd0ff7c2 Iustin Pop
    HV_KERNEL_PATH: "/boot/vmlinuz-2.6-xenU",
1255 d0c8c01d Iustin Pop
    HV_INITRD_PATH: "",
1256 d0c8c01d Iustin Pop
    HV_ROOT_PATH: "/dev/sda1",
1257 d0c8c01d Iustin Pop
    HV_KERNEL_ARGS: "ro",
1258 78411c60 Iustin Pop
    HV_MIGRATION_PORT: 8002,
1259 783a6c0b Iustin Pop
    HV_MIGRATION_MODE: HT_MIGRATION_LIVE,
1260 525011bc Maciej Bliziński
    HV_BLOCKDEV_PREFIX: "sd",
1261 990ade2d Stephen Shirley
    HV_REBOOT_BEHAVIOR: INSTANCE_REBOOT_ALLOWED,
1262 bd0ff7c2 Iustin Pop
    },
1263 bd0ff7c2 Iustin Pop
  HT_XEN_HVM: {
1264 bd0ff7c2 Iustin Pop
    HV_BOOT_ORDER: "cd",
1265 d0c8c01d Iustin Pop
    HV_CDROM_IMAGE_PATH: "",
1266 d08f6067 Guido Trotter
    HV_NIC_TYPE: HT_NIC_RTL8139,
1267 43440815 Guido Trotter
    HV_DISK_TYPE: HT_DISK_PARAVIRTUAL,
1268 9769bb78 Manuel Franceschini
    HV_VNC_BIND_ADDRESS: IP4_ADDRESS_ANY,
1269 6e6bb8d5 Guido Trotter
    HV_VNC_PASSWORD_FILE: VNC_PASSWORD_FILE,
1270 bd0ff7c2 Iustin Pop
    HV_ACPI: True,
1271 bd0ff7c2 Iustin Pop
    HV_PAE: True,
1272 e2ee1cea Iustin Pop
    HV_KERNEL_PATH: "/usr/lib/xen/boot/hvmloader",
1273 09ea8710 Iustin Pop
    HV_DEVICE_MODEL: "/usr/lib/xen/bin/qemu-dm",
1274 78411c60 Iustin Pop
    HV_MIGRATION_PORT: 8002,
1275 783a6c0b Iustin Pop
    HV_MIGRATION_MODE: HT_MIGRATION_NONLIVE,
1276 6b970cef Jun Futagawa
    HV_USE_LOCALTIME: False,
1277 525011bc Maciej Bliziński
    HV_BLOCKDEV_PREFIX: "hd",
1278 990ade2d Stephen Shirley
    HV_REBOOT_BEHAVIOR: INSTANCE_REBOOT_ALLOWED,
1279 bd0ff7c2 Iustin Pop
    },
1280 bd0ff7c2 Iustin Pop
  HT_KVM: {
1281 bd0ff7c2 Iustin Pop
    HV_KERNEL_PATH: "/boot/vmlinuz-2.6-kvmU",
1282 d0c8c01d Iustin Pop
    HV_INITRD_PATH: "",
1283 d0c8c01d Iustin Pop
    HV_KERNEL_ARGS: "ro",
1284 d0c8c01d Iustin Pop
    HV_ROOT_PATH: "/dev/vda1",
1285 bd0ff7c2 Iustin Pop
    HV_ACPI: True,
1286 bd0ff7c2 Iustin Pop
    HV_SERIAL_CONSOLE: True,
1287 d0c8c01d Iustin Pop
    HV_VNC_BIND_ADDRESS: "",
1288 8b2d1013 Guido Trotter
    HV_VNC_TLS: False,
1289 d0c8c01d Iustin Pop
    HV_VNC_X509: "",
1290 8b2d1013 Guido Trotter
    HV_VNC_X509_VERIFY: False,
1291 d0c8c01d Iustin Pop
    HV_VNC_PASSWORD_FILE: "",
1292 b1cb62bd Andrea Spadaccini
    HV_KVM_SPICE_BIND: "",
1293 b1cb62bd Andrea Spadaccini
    HV_KVM_SPICE_IP_VERSION: IFACE_NO_IP_VERSION_SPECIFIED,
1294 d0c8c01d Iustin Pop
    HV_KVM_FLOPPY_IMAGE_PATH: "",
1295 d0c8c01d Iustin Pop
    HV_CDROM_IMAGE_PATH: "",
1296 d0c8c01d Iustin Pop
    HV_KVM_CDROM2_IMAGE_PATH: "",
1297 835528af Iustin Pop
    HV_BOOT_ORDER: HT_BO_DISK,
1298 43440815 Guido Trotter
    HV_NIC_TYPE: HT_NIC_PARAVIRTUAL,
1299 43440815 Guido Trotter
    HV_DISK_TYPE: HT_DISK_PARAVIRTUAL,
1300 d0c8c01d Iustin Pop
    HV_KVM_CDROM_DISK_TYPE: "",
1301 d0c8c01d Iustin Pop
    HV_USB_MOUSE: "",
1302 4f580fef Sébastien Bocahu
    HV_KEYMAP: "",
1303 3c075436 Iustin Pop
    HV_MIGRATION_PORT: 8102,
1304 e43d4f9f Apollon Oikonomopoulos
    HV_MIGRATION_BANDWIDTH: 32, # MiB/s
1305 e43d4f9f Apollon Oikonomopoulos
    HV_MIGRATION_DOWNTIME: 30,  # ms
1306 783a6c0b Iustin Pop
    HV_MIGRATION_MODE: HT_MIGRATION_LIVE,
1307 6b970cef Jun Futagawa
    HV_USE_LOCALTIME: False,
1308 ea0f3d7a Iustin Pop
    HV_DISK_CACHE: HT_CACHE_DEFAULT,
1309 d19d94db Guido Trotter
    HV_SECURITY_MODEL: HT_SM_NONE,
1310 d0c8c01d Iustin Pop
    HV_SECURITY_DOMAIN: "",
1311 7ba594c0 Guido Trotter
    HV_KVM_FLAG: "",
1312 fbe27e2b Guido Trotter
    HV_VHOST_NET: False,
1313 84c08e4e Balazs Lecz
    HV_KVM_USE_CHROOT: False,
1314 4f958b0b Miguel Di Ciurcio Filho
    HV_MEM_PATH: "",
1315 990ade2d Stephen Shirley
    HV_REBOOT_BEHAVIOR: INSTANCE_REBOOT_ALLOWED,
1316 bd0ff7c2 Iustin Pop
    },
1317 bd0ff7c2 Iustin Pop
  HT_FAKE: {
1318 bd0ff7c2 Iustin Pop
    },
1319 48297fa2 Iustin Pop
  HT_CHROOT: {
1320 48297fa2 Iustin Pop
    HV_INIT_SCRIPT: "/ganeti-chroot",
1321 48297fa2 Iustin Pop
    },
1322 4b5e40a5 Iustin Pop
  HT_LXC: {
1323 e3ed5316 Balazs Lecz
    HV_CPU_MASK: "",
1324 4b5e40a5 Iustin Pop
    },
1325 bd0ff7c2 Iustin Pop
  }
1326 7888a614 Alexander Schreiber
1327 7736a5f2 Iustin Pop
HVC_GLOBALS = frozenset([
1328 7736a5f2 Iustin Pop
  HV_MIGRATION_PORT,
1329 e43d4f9f Apollon Oikonomopoulos
  HV_MIGRATION_BANDWIDTH,
1330 783a6c0b Iustin Pop
  HV_MIGRATION_MODE,
1331 7736a5f2 Iustin Pop
  ])
1332 7736a5f2 Iustin Pop
1333 7888a614 Alexander Schreiber
BEC_DEFAULTS = {
1334 bd0ff7c2 Iustin Pop
  BE_MEMORY: 128,
1335 bd0ff7c2 Iustin Pop
  BE_VCPUS: 1,
1336 bd0ff7c2 Iustin Pop
  BE_AUTO_BALANCE: True,
1337 bd0ff7c2 Iustin Pop
  }
1338 c3e618cc Guido Trotter
1339 095e71aa René Nussbaumer
NDC_DEFAULTS = {
1340 095e71aa René Nussbaumer
  ND_OOB_PROGRAM: None,
1341 095e71aa René Nussbaumer
  }
1342 095e71aa René Nussbaumer
1343 ac061be9 Guido Trotter
NICC_DEFAULTS = {
1344 ac061be9 Guido Trotter
  NIC_MODE: NIC_MODE_BRIDGED,
1345 ac061be9 Guido Trotter
  NIC_LINK: DEFAULT_BRIDGE,
1346 ac061be9 Guido Trotter
  }
1347 ac061be9 Guido Trotter
1348 c3e618cc Guido Trotter
MASTER_POOL_SIZE_DEFAULT = 10
1349 ea1518af Guido Trotter
1350 ea1518af Guido Trotter
CONFD_PROTOCOL_VERSION = 1
1351 ea1518af Guido Trotter
1352 09444532 Guido Trotter
CONFD_REQ_PING = 0
1353 ea1518af Guido Trotter
CONFD_REQ_NODE_ROLE_BYNAME = 1
1354 ea1518af Guido Trotter
CONFD_REQ_NODE_PIP_BY_INSTANCE_IP = 2
1355 48166551 Guido Trotter
CONFD_REQ_CLUSTER_MASTER = 3
1356 efbb4fd2 Luca Bigliardi
CONFD_REQ_NODE_PIP_LIST = 4
1357 efbb4fd2 Luca Bigliardi
CONFD_REQ_MC_PIP_LIST = 5
1358 d01ae714 Luca Bigliardi
CONFD_REQ_INSTANCES_IPS_LIST = 6
1359 ea1518af Guido Trotter
1360 19351457 Guido Trotter
# Confd request query fields. These are used to narrow down queries.
1361 19351457 Guido Trotter
# These must be strings rather than integers, because json-encoding
1362 19351457 Guido Trotter
# converts them to strings anyway, as they're used as dict-keys.
1363 19351457 Guido Trotter
CONFD_REQQ_LINK = "0"
1364 19351457 Guido Trotter
CONFD_REQQ_IP = "1"
1365 19351457 Guido Trotter
CONFD_REQQ_IPLIST = "2"
1366 250554a9 Guido Trotter
CONFD_REQQ_FIELDS = "3"
1367 250554a9 Guido Trotter
1368 250554a9 Guido Trotter
CONFD_REQFIELD_NAME = "0"
1369 250554a9 Guido Trotter
CONFD_REQFIELD_IP = "1"
1370 43dc8496 Guido Trotter
CONFD_REQFIELD_MNODE_PIP = "2"
1371 19351457 Guido Trotter
1372 ea1518af Guido Trotter
CONFD_REQS = frozenset([
1373 09444532 Guido Trotter
  CONFD_REQ_PING,
1374 ea1518af Guido Trotter
  CONFD_REQ_NODE_ROLE_BYNAME,
1375 ea1518af Guido Trotter
  CONFD_REQ_NODE_PIP_BY_INSTANCE_IP,
1376 48166551 Guido Trotter
  CONFD_REQ_CLUSTER_MASTER,
1377 efbb4fd2 Luca Bigliardi
  CONFD_REQ_NODE_PIP_LIST,
1378 efbb4fd2 Luca Bigliardi
  CONFD_REQ_MC_PIP_LIST,
1379 d01ae714 Luca Bigliardi
  CONFD_REQ_INSTANCES_IPS_LIST,
1380 ea1518af Guido Trotter
  ])
1381 ea1518af Guido Trotter
1382 31c2a99e Guido Trotter
CONFD_REPL_STATUS_OK = 0
1383 31c2a99e Guido Trotter
CONFD_REPL_STATUS_ERROR = 1
1384 31c2a99e Guido Trotter
CONFD_REPL_STATUS_NOTIMPLEMENTED = 2
1385 31c2a99e Guido Trotter
1386 31c2a99e Guido Trotter
CONFD_REPL_STATUSES = frozenset([
1387 31c2a99e Guido Trotter
  CONFD_REPL_STATUS_OK,
1388 31c2a99e Guido Trotter
  CONFD_REPL_STATUS_ERROR,
1389 31c2a99e Guido Trotter
  CONFD_REPL_STATUS_NOTIMPLEMENTED,
1390 31c2a99e Guido Trotter
  ])
1391 31c2a99e Guido Trotter
1392 89c52785 Guido Trotter
(CONFD_NODE_ROLE_MASTER,
1393 89c52785 Guido Trotter
 CONFD_NODE_ROLE_CANDIDATE,
1394 89c52785 Guido Trotter
 CONFD_NODE_ROLE_OFFLINE,
1395 197b0f5d Guido Trotter
 CONFD_NODE_ROLE_DRAINED,
1396 197b0f5d Guido Trotter
 CONFD_NODE_ROLE_REGULAR,
1397 197b0f5d Guido Trotter
 ) = range(5)
1398 89c52785 Guido Trotter
1399 ca2a5b13 Guido Trotter
# A few common errors for confd
1400 ca2a5b13 Guido Trotter
CONFD_ERROR_UNKNOWN_ENTRY = 1
1401 7189e790 Guido Trotter
CONFD_ERROR_INTERNAL = 2
1402 19351457 Guido Trotter
CONFD_ERROR_ARGUMENT = 3
1403 ca2a5b13 Guido Trotter
1404 71f27d19 Guido Trotter
# Each request is "salted" by the current timestamp.
1405 71f27d19 Guido Trotter
# This constants decides how many seconds of skew to accept.
1406 71f27d19 Guido Trotter
# TODO: make this a default and allow the value to be more configurable
1407 313b2dd4 Michael Hanselmann
CONFD_MAX_CLOCK_SKEW = 2 * NODE_MAX_CLOCK_SKEW
1408 84c3ab28 Guido Trotter
1409 84c3ab28 Guido Trotter
# When we haven't reloaded the config for more than this amount of seconds, we
1410 84c3ab28 Guido Trotter
# force a test to see if inotify is betraying us.
1411 84c3ab28 Guido Trotter
CONFD_CONFIG_RELOAD_TIMEOUT = 60
1412 84c3ab28 Guido Trotter
1413 84c3ab28 Guido Trotter
# If we receive more than one update in this amount of seconds, we move to
1414 84c3ab28 Guido Trotter
# polling every RATELIMIT seconds, rather than relying on inotify, to be able
1415 84c3ab28 Guido Trotter
# to serve more requests.
1416 84c3ab28 Guido Trotter
CONFD_CONFIG_RELOAD_RATELIMIT = 2
1417 c8eded0b Guido Trotter
1418 a3758ab2 Guido Trotter
# Magic number prepended to all confd queries.
1419 a3758ab2 Guido Trotter
# This allows us to distinguish different types of confd protocols and handle
1420 a3758ab2 Guido Trotter
# them. For example by changing this we can move the whole payload to be
1421 a3758ab2 Guido Trotter
# compressed, or move away from json.
1422 d0c8c01d Iustin Pop
CONFD_MAGIC_FOURCC = "plj0"
1423 a3758ab2 Guido Trotter
1424 e4ccf6cd Guido Trotter
# By default a confd request is sent to the minimum between this number and all
1425 e4ccf6cd Guido Trotter
# MCs. 6 was chosen because even in the case of a disastrous 50% response rate,
1426 e4ccf6cd Guido Trotter
# we should have enough answers to be able to compare more than one.
1427 e4ccf6cd Guido Trotter
CONFD_DEFAULT_REQ_COVERAGE = 6
1428 e4ccf6cd Guido Trotter
1429 e4ccf6cd Guido Trotter
# Timeout in seconds to expire pending query request in the confd client
1430 e4ccf6cd Guido Trotter
# library. We don't actually expect any answer more than 10 seconds after we
1431 e4ccf6cd Guido Trotter
# sent a request.
1432 e4ccf6cd Guido Trotter
CONFD_CLIENT_EXPIRE_TIMEOUT = 10
1433 e4ccf6cd Guido Trotter
1434 c8eded0b Guido Trotter
# Maximum UDP datagram size.
1435 c8eded0b Guido Trotter
# On IPv4: 64K - 20 (ip header size) - 8 (udp header size) = 65507
1436 c8eded0b Guido Trotter
# On IPv6: 64K - 40 (ip6 header size) - 8 (udp header size) = 65487
1437 c8eded0b Guido Trotter
#   (assuming we can't use jumbo frames)
1438 c8eded0b Guido Trotter
# We just set this to 60K, which should be enough
1439 c8eded0b Guido Trotter
MAX_UDP_DATA_SIZE = 61440
1440 6d127406 Balazs Lecz
1441 6d127406 Balazs Lecz
# User-id pool minimum/maximum acceptable user-ids.
1442 6d127406 Balazs Lecz
UIDPOOL_UID_MIN = 0
1443 6d127406 Balazs Lecz
UIDPOOL_UID_MAX = 2**32-1 # Assuming 32 bit user-ids
1444 649bcdd8 Balazs Lecz
1445 649bcdd8 Balazs Lecz
# Name or path of the pgrep command
1446 649bcdd8 Balazs Lecz
PGREP = "pgrep"
1447 75cf411a Adeodato Simo
1448 75cf411a Adeodato Simo
# Name of the node group that gets created at cluster init or upgrade
1449 75cf411a Adeodato Simo
INITIAL_NODE_GROUP_NAME = "default"
1450 90e99856 Adeodato Simo
1451 90e99856 Adeodato Simo
# Possible values for NodeGroup.alloc_policy
1452 90e99856 Adeodato Simo
ALLOC_POLICY_PREFERRED = "preferred"
1453 90e99856 Adeodato Simo
ALLOC_POLICY_LAST_RESORT = "last_resort"
1454 90e99856 Adeodato Simo
ALLOC_POLICY_UNALLOCABLE = "unallocable"
1455 90e99856 Adeodato Simo
VALID_ALLOC_POLICIES = [
1456 90e99856 Adeodato Simo
  ALLOC_POLICY_PREFERRED,
1457 90e99856 Adeodato Simo
  ALLOC_POLICY_LAST_RESORT,
1458 90e99856 Adeodato Simo
  ALLOC_POLICY_UNALLOCABLE,
1459 90e99856 Adeodato Simo
  ]
1460 b6135bbc Apollon Oikonomopoulos
1461 b6135bbc Apollon Oikonomopoulos
# Temporary external/shared storage parameters
1462 b6135bbc Apollon Oikonomopoulos
BLOCKDEV_DRIVER_MANUAL = "manual"
1463 e5395072 Iustin Pop
1464 e5395072 Iustin Pop
# Whether htools was enabled at compilation time
1465 e5395072 Iustin Pop
HTOOLS = _autoconf.HTOOLS
1466 e5395072 Iustin Pop
# The hail iallocator
1467 e5395072 Iustin Pop
IALLOC_HAIL = "hail"