Statistics
| Branch: | Tag: | Revision:

root / lib / constants.py @ 18682bca

History | View | Annotate | Download (6.8 kB)

1 2f31098c Iustin Pop
#
2 a8083063 Iustin Pop
#
3 a8083063 Iustin Pop
4 a8083063 Iustin Pop
# Copyright (C) 2006, 2007 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 2ec08468 Michael Hanselmann
from ganeti import _autoconf
25 7c18ef8e Michael Hanselmann
26 a8083063 Iustin Pop
# various versions
27 2a10865c Iustin Pop
PROTOCOL_VERSION = 13
28 2ec08468 Michael Hanselmann
RELEASE_VERSION = _autoconf.PACKAGE_VERSION
29 386b57af Iustin Pop
OS_API_VERSION = 5
30 a8083063 Iustin Pop
EXPORT_VERSION = 0
31 a8083063 Iustin Pop
32 1b45f4e5 Michael Hanselmann
33 243cdbcc Michael Hanselmann
# Format for CONFIG_VERSION:
34 243cdbcc Michael Hanselmann
#   01 03 0123 = 01030123
35 243cdbcc Michael Hanselmann
#   ^^ ^^ ^^^^
36 243cdbcc Michael Hanselmann
#   |  |  + Configuration version/revision
37 243cdbcc Michael Hanselmann
#   |  + Minor version
38 243cdbcc Michael Hanselmann
#   + Major version
39 243cdbcc Michael Hanselmann
#
40 243cdbcc Michael Hanselmann
# It stored as an integer. Make sure not to write an octal number.
41 1b45f4e5 Michael Hanselmann
42 1b45f4e5 Michael Hanselmann
# BuildVersion and SplitVersion must be in here because we can't import other
43 1b45f4e5 Michael Hanselmann
# modules. The cfgupgrade tool must be able to read and write version numbers
44 1b45f4e5 Michael Hanselmann
# and thus requires these functions. To avoid code duplication, they're kept in
45 1b45f4e5 Michael Hanselmann
# here.
46 1b45f4e5 Michael Hanselmann
47 1b45f4e5 Michael Hanselmann
def BuildVersion(major, minor, revision):
48 1b45f4e5 Michael Hanselmann
  """Calculates int version number from major, minor and revision numbers.
49 1b45f4e5 Michael Hanselmann

50 1b45f4e5 Michael Hanselmann
  Returns: int representing version number
51 1b45f4e5 Michael Hanselmann

52 1b45f4e5 Michael Hanselmann
  """
53 1b45f4e5 Michael Hanselmann
  assert isinstance(major, int)
54 1b45f4e5 Michael Hanselmann
  assert isinstance(minor, int)
55 1b45f4e5 Michael Hanselmann
  assert isinstance(revision, int)
56 1b45f4e5 Michael Hanselmann
  return (1000000 * major +
57 1b45f4e5 Michael Hanselmann
            10000 * minor +
58 1b45f4e5 Michael Hanselmann
                1 * revision)
59 1b45f4e5 Michael Hanselmann
60 1b45f4e5 Michael Hanselmann
61 1b45f4e5 Michael Hanselmann
def SplitVersion(version):
62 1b45f4e5 Michael Hanselmann
  """Splits version number stored in an int.
63 1b45f4e5 Michael Hanselmann

64 1b45f4e5 Michael Hanselmann
  Returns: tuple; (major, minor, revision)
65 1b45f4e5 Michael Hanselmann

66 1b45f4e5 Michael Hanselmann
  """
67 1b45f4e5 Michael Hanselmann
  assert isinstance(version, int)
68 1b45f4e5 Michael Hanselmann
69 1b45f4e5 Michael Hanselmann
  (major, remainder) = divmod(version, 1000000)
70 1b45f4e5 Michael Hanselmann
  (minor, revision) = divmod(remainder, 10000)
71 1b45f4e5 Michael Hanselmann
72 1b45f4e5 Michael Hanselmann
  return (major, minor, revision)
73 1b45f4e5 Michael Hanselmann
74 1b45f4e5 Michael Hanselmann
75 243cdbcc Michael Hanselmann
CONFIG_MAJOR = int(_autoconf.VERSION_MAJOR)
76 243cdbcc Michael Hanselmann
CONFIG_MINOR = int(_autoconf.VERSION_MINOR)
77 243cdbcc Michael Hanselmann
CONFIG_REVISION = 0
78 1b45f4e5 Michael Hanselmann
CONFIG_VERSION = BuildVersion(CONFIG_MAJOR, CONFIG_MINOR, CONFIG_REVISION)
79 a8083063 Iustin Pop
80 a8083063 Iustin Pop
# file paths
81 2ec08468 Michael Hanselmann
DATA_DIR = _autoconf.LOCALSTATEDIR + "/lib/ganeti"
82 1ed70996 Iustin Pop
RUN_DIR = _autoconf.LOCALSTATEDIR + "/run"
83 75afaefc Iustin Pop
RUN_GANETI_DIR = RUN_DIR + "/ganeti"
84 75afaefc Iustin Pop
BDEV_CACHE_DIR = RUN_GANETI_DIR # TODO(2.0): move deeper
85 75afaefc Iustin Pop
DISK_LINKS_DIR = RUN_GANETI_DIR + "/instance-disks"
86 75afaefc Iustin Pop
# keep RUN_GANETI_DIR first here, to make sure all get created when the node
87 75afaefc Iustin Pop
# daemon is started (this takes care of RUN_DIR being tmpfs)
88 75afaefc Iustin Pop
SUB_RUN_DIRS = [ RUN_GANETI_DIR, BDEV_CACHE_DIR, DISK_LINKS_DIR ]
89 3aecd2c7 Iustin Pop
LOCK_DIR = _autoconf.LOCALSTATEDIR + "/lock"
90 a8083063 Iustin Pop
CLUSTER_CONF_FILE = DATA_DIR + "/config.data"
91 a8083063 Iustin Pop
SSL_CERT_FILE = DATA_DIR + "/server.pem"
92 5a3103e9 Michael Hanselmann
WATCHER_STATEFILE = DATA_DIR + "/watcher.data"
93 82122173 Iustin Pop
SSH_KNOWN_HOSTS_FILE = DATA_DIR + "/known_hosts"
94 c8a0948f Michael Hanselmann
ETC_HOSTS = "/etc/hosts"
95 1abbbbe2 Manuel Franceschini
DEFAULT_FILE_STORAGE_DIR = _autoconf.FILE_STORAGE_DIR
96 68676a00 Iustin Pop
MASTER_SOCKET = RUN_GANETI_DIR + "/master.sock"
97 a8083063 Iustin Pop
98 2ec08468 Michael Hanselmann
NODE_INITD_SCRIPT = _autoconf.SYSCONFDIR + "/init.d/ganeti"
99 a8083063 Iustin Pop
DEFAULT_NODED_PORT = 1811
100 a8083063 Iustin Pop
FIRST_DRBD_PORT = 11000
101 a8083063 Iustin Pop
LAST_DRBD_PORT = 14999
102 880478f8 Iustin Pop
MASTER_SCRIPT = "ganeti-master"
103 a8083063 Iustin Pop
104 2ec08468 Michael Hanselmann
LOG_DIR = _autoconf.LOCALSTATEDIR + "/log/ganeti"
105 a8083063 Iustin Pop
LOG_OS_DIR = LOG_DIR + "/os"
106 a8083063 Iustin Pop
LOG_NODESERVER = LOG_DIR + "/node-daemon.log"
107 5a3103e9 Michael Hanselmann
LOG_WATCHER = LOG_DIR + "/watcher.log"
108 c1f2901b Iustin Pop
LOG_MASTERDAEMON = LOG_DIR + "/master-daemon.log"
109 a8083063 Iustin Pop
110 7c3d51d4 Guido Trotter
OS_SEARCH_PATH = _autoconf.OS_SEARCH_PATH
111 68dccc07 Guido Trotter
EXPORT_DIR = _autoconf.EXPORT_DIR
112 a8083063 Iustin Pop
113 a8083063 Iustin Pop
EXPORT_CONF_FILE = "config.ini"
114 a8083063 Iustin Pop
115 f00b46bc Michael Hanselmann
XEN_KERNEL = _autoconf.XEN_KERNEL
116 f00b46bc Michael Hanselmann
XEN_INITRD = _autoconf.XEN_INITRD
117 f00b46bc Michael Hanselmann
118 973d7867 Iustin Pop
VALUE_DEFAULT = "default"
119 973d7867 Iustin Pop
VALUE_NONE = "none"
120 973d7867 Iustin Pop
121 a8083063 Iustin Pop
# hooks-related constants
122 2ec08468 Michael Hanselmann
HOOKS_BASE_DIR = _autoconf.SYSCONFDIR + "/ganeti/hooks"
123 a8083063 Iustin Pop
HOOKS_PHASE_PRE = "pre"
124 a8083063 Iustin Pop
HOOKS_PHASE_POST = "post"
125 6a4aa7c1 Iustin Pop
HOOKS_NAME_CFGUPDATE = "config-update"
126 a8083063 Iustin Pop
HOOKS_VERSION = 1
127 a8083063 Iustin Pop
128 a8083063 Iustin Pop
# hooks subject type (what object type does the LU deal with)
129 a8083063 Iustin Pop
HTYPE_CLUSTER = "CLUSTER"
130 a8083063 Iustin Pop
HTYPE_NODE = "NODE"
131 a8083063 Iustin Pop
HTYPE_INSTANCE = "INSTANCE"
132 a8083063 Iustin Pop
133 a8083063 Iustin Pop
HKR_SKIP = 0
134 a8083063 Iustin Pop
HKR_FAIL = 1
135 a8083063 Iustin Pop
HKR_SUCCESS = 2
136 a8083063 Iustin Pop
137 a8083063 Iustin Pop
# disk template types
138 a8083063 Iustin Pop
DT_DISKLESS = "diskless"
139 a8083063 Iustin Pop
DT_PLAIN = "plain"
140 a1f445d3 Iustin Pop
DT_DRBD8 = "drbd"
141 04fa07f2 Manuel Franceschini
DT_FILE = "file"
142 a1f445d3 Iustin Pop
143 a1f445d3 Iustin Pop
# the set of network-mirrored disk templates
144 abdf0113 Iustin Pop
DTS_NET_MIRROR = frozenset([DT_DRBD8])
145 a8083063 Iustin Pop
146 d63e148a Manuel Franceschini
# the set of non-lvm-based disk templates
147 d63e148a Manuel Franceschini
DTS_NOT_LVM = frozenset([DT_DISKLESS, DT_FILE])
148 d63e148a Manuel Franceschini
149 fe96220b Iustin Pop
# logical disk types
150 fe96220b Iustin Pop
LD_LV = "lvm"
151 a1f445d3 Iustin Pop
LD_DRBD8 = "drbd8"
152 04fa07f2 Manuel Franceschini
LD_FILE = "file"
153 04fa07f2 Manuel Franceschini
154 04fa07f2 Manuel Franceschini
# file backend driver
155 04fa07f2 Manuel Franceschini
FD_LOOP = "loop"
156 04fa07f2 Manuel Franceschini
FD_BLKTAP = "blktap"
157 a1f445d3 Iustin Pop
158 a1f445d3 Iustin Pop
# the set of drbd-like disk types
159 abdf0113 Iustin Pop
LDS_DRBD = frozenset([LD_DRBD8])
160 fe96220b Iustin Pop
161 a9e0c397 Iustin Pop
# disk replacement mode
162 a9e0c397 Iustin Pop
REPLACE_DISK_PRI = "replace_primary"
163 a9e0c397 Iustin Pop
REPLACE_DISK_SEC = "replace_secondary"
164 a9e0c397 Iustin Pop
REPLACE_DISK_ALL = "replace_all"
165 a9e0c397 Iustin Pop
166 2f6eebee Guido Trotter
# instance creation modes
167 a8083063 Iustin Pop
INSTANCE_CREATE = "create"
168 a8083063 Iustin Pop
INSTANCE_IMPORT = "import"
169 a8083063 Iustin Pop
170 a8083063 Iustin Pop
DISK_TEMPLATES = frozenset([DT_DISKLESS, DT_PLAIN,
171 04fa07f2 Manuel Franceschini
                            DT_DRBD8, DT_FILE])
172 04fa07f2 Manuel Franceschini
173 04fa07f2 Manuel Franceschini
FILE_DRIVER = frozenset([FD_LOOP, FD_BLKTAP])
174 a8083063 Iustin Pop
175 a8083063 Iustin Pop
# import/export config options
176 a8083063 Iustin Pop
INISECT_EXP = "export"
177 a8083063 Iustin Pop
INISECT_INS = "instance"
178 38242904 Iustin Pop
179 38242904 Iustin Pop
# common exit codes
180 a5bc662a Iustin Pop
EXIT_SUCCESS = 0
181 438b45d4 Michael Hanselmann
EXIT_FAILURE = 1
182 38242904 Iustin Pop
EXIT_NOTMASTER = 11
183 619fdc8e Iustin Pop
EXIT_NODESETUP_ERROR = 12
184 a5bc662a Iustin Pop
EXIT_CONFIRMATION = 13 # need user confirmation
185 cf62a272 Michael Hanselmann
186 5c947f38 Iustin Pop
# tags
187 5c947f38 Iustin Pop
TAG_CLUSTER = "cluster"
188 5c947f38 Iustin Pop
TAG_NODE = "node"
189 5c947f38 Iustin Pop
TAG_INSTANCE = "instance"
190 5c947f38 Iustin Pop
MAX_TAG_LEN = 128
191 5c947f38 Iustin Pop
MAX_TAGS_PER_OBJ = 4096
192 5c947f38 Iustin Pop
193 cf62a272 Michael Hanselmann
# others
194 cf62a272 Michael Hanselmann
DEFAULT_BRIDGE = "xen-br0"
195 e31c43f7 Michael Hanselmann
SYNC_SPEED = 30 * 1024
196 aa4260ca Iustin Pop
LOCALHOST_IP_ADDRESS = "127.0.0.1"
197 16abfbc2 Alexander Schreiber
TCP_PING_TIMEOUT = 10
198 7900ed01 Iustin Pop
GANETI_RUNAS = "root"
199 d63e148a Manuel Franceschini
DEFAULT_VG = "xenvg"
200 31a853d2 Iustin Pop
BIND_ADDRESS_GLOBAL = "0.0.0.0"
201 8d1a2a64 Michael Hanselmann
MIN_VG_SIZE = 20480
202 7900ed01 Iustin Pop
203 37482e7b Guido Trotter
# valid os status
204 37482e7b Guido Trotter
OS_VALID_STATUS = "VALID"
205 37482e7b Guido Trotter
206 70d9e3d8 Iustin Pop
# ssh constants
207 7900ed01 Iustin Pop
SSH_INITD_SCRIPT = _autoconf.SSH_INITD_SCRIPT
208 70d9e3d8 Iustin Pop
SSH_CONFIG_DIR = "/etc/ssh/"
209 70d9e3d8 Iustin Pop
SSH_HOST_DSA_PRIV = SSH_CONFIG_DIR + "ssh_host_dsa_key"
210 70d9e3d8 Iustin Pop
SSH_HOST_DSA_PUB = SSH_HOST_DSA_PRIV + ".pub"
211 70d9e3d8 Iustin Pop
SSH_HOST_RSA_PRIV = SSH_CONFIG_DIR + "ssh_host_rsa_key"
212 70d9e3d8 Iustin Pop
SSH_HOST_RSA_PUB = SSH_HOST_RSA_PRIV + ".pub"
213 fff33d70 Michael Hanselmann
SSH = "ssh"
214 fff33d70 Michael Hanselmann
SCP = "scp"
215 007a2f3e Alexander Schreiber
216 007a2f3e Alexander Schreiber
# reboot types
217 007a2f3e Alexander Schreiber
INSTANCE_REBOOT_SOFT = "soft"
218 007a2f3e Alexander Schreiber
INSTANCE_REBOOT_HARD = "hard"
219 007a2f3e Alexander Schreiber
INSTANCE_REBOOT_FULL = "full"
220 2584d4a4 Alexander Schreiber
221 2584d4a4 Alexander Schreiber
# Hypervisor constants
222 631eb662 Alexander Schreiber
HT_XEN_PVM30 = "xen-3.0"
223 2584d4a4 Alexander Schreiber
HT_FAKE = "fake"
224 2a6469d5 Alexander Schreiber
HT_XEN_HVM31 = "xen-hvm-3.1"
225 2a6469d5 Alexander Schreiber
HYPER_TYPES = frozenset([HT_XEN_PVM30, HT_FAKE, HT_XEN_HVM31])
226 2a6469d5 Alexander Schreiber
HTS_REQ_PORT = frozenset([HT_XEN_HVM31])
227 2584d4a4 Alexander Schreiber
228 2a6469d5 Alexander Schreiber
HT_HVM_VNC_BASE_PORT = 5900
229 25c5878d Alexander Schreiber
HT_HVM_DEFAULT_BOOT_ORDER = 'dc'
230 2a6469d5 Alexander Schreiber
VNC_PASSWORD_FILE = _autoconf.SYSCONFDIR + "/ganeti/vnc-cluster-password"
231 31a853d2 Iustin Pop
VNC_DEFAULT_BIND_ADDRESS = '0.0.0.0'
232 e54c4c5e Guido Trotter
233 e54c4c5e Guido Trotter
# Cluster Verify steps
234 e54c4c5e Guido Trotter
VERIFY_NPLUSONE_MEM = 'nplusone_mem'
235 e54c4c5e Guido Trotter
VERIFY_OPTIONAL_CHECKS = frozenset([VERIFY_NPLUSONE_MEM])
236 e54c4c5e Guido Trotter
237 d61df03e Iustin Pop
# Allocator framework constants
238 298fe380 Iustin Pop
IALLOCATOR_DIR_IN = "in"
239 298fe380 Iustin Pop
IALLOCATOR_DIR_OUT = "out"
240 298fe380 Iustin Pop
IALLOCATOR_MODE_ALLOC = "allocate"
241 298fe380 Iustin Pop
IALLOCATOR_MODE_RELOC = "relocate"
242 298fe380 Iustin Pop
IALLOCATOR_SEARCH_PATH = _autoconf.IALLOCATOR_SEARCH_PATH
243 8d528b7c Iustin Pop
IARUN_NOTFOUND = 1
244 8d528b7c Iustin Pop
IARUN_FAILURE = 2
245 8d528b7c Iustin Pop
IARUN_SUCCESS = 3
246 5f33b613 Michael Hanselmann
247 5f33b613 Michael Hanselmann
# Job status
248 5f33b613 Michael Hanselmann
JOB_STATUS_QUEUED = "queued"
249 5f33b613 Michael Hanselmann
JOB_STATUS_RUNNING = "running"
250 5f33b613 Michael Hanselmann
JOB_STATUS_CANCELED = "canceled"
251 5f33b613 Michael Hanselmann
JOB_STATUS_SUCCESS = "success"
252 5f33b613 Michael Hanselmann
JOB_STATUS_ERROR = "error"
253 5f33b613 Michael Hanselmann
254 5f33b613 Michael Hanselmann
OP_STATUS_QUEUED = "queued"
255 5f33b613 Michael Hanselmann
OP_STATUS_RUNNING = "running"
256 5f33b613 Michael Hanselmann
OP_STATUS_SUCCESS = "success"
257 5f33b613 Michael Hanselmann
OP_STATUS_ERROR = "error"