Move the hooks file mask into constants.py
[ganeti-local] / lib / constants.py
1 #
2 #
3
4 # Copyright (C) 2006, 2007 Google Inc.
5 #
6 # This program is free software; you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation; either version 2 of the License, or
9 # (at your option) any later version.
10 #
11 # This program is distributed in the hope that it will be useful, but
12 # WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14 # General Public License for more details.
15 #
16 # You should have received a copy of the GNU General Public License
17 # along with this program; if not, write to the Free Software
18 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
19 # 02110-1301, USA.
20
21
22 """Module holding different constants."""
23
24 import re
25
26 from ganeti import _autoconf
27
28 # various versions
29 CONFIG_VERSION = 3
30 PROTOCOL_VERSION = 15
31 RELEASE_VERSION = _autoconf.PACKAGE_VERSION
32 OS_API_VERSION = 5
33 EXPORT_VERSION = 0
34 RAPI_VERSION = 1
35
36
37 # file paths
38 DATA_DIR = _autoconf.LOCALSTATEDIR + "/lib/ganeti"
39 RUN_DIR = _autoconf.LOCALSTATEDIR + "/run"
40 RUN_GANETI_DIR = RUN_DIR + "/ganeti"
41 BDEV_CACHE_DIR = RUN_GANETI_DIR # TODO(2.0): move deeper
42 DISK_LINKS_DIR = RUN_GANETI_DIR + "/instance-disks"
43 # keep RUN_GANETI_DIR first here, to make sure all get created when the node
44 # daemon is started (this takes care of RUN_DIR being tmpfs)
45 SUB_RUN_DIRS = [ RUN_GANETI_DIR, BDEV_CACHE_DIR, DISK_LINKS_DIR ]
46 LOCK_DIR = _autoconf.LOCALSTATEDIR + "/lock"
47 CLUSTER_CONF_FILE = DATA_DIR + "/config.data"
48 SSL_CERT_FILE = DATA_DIR + "/server.pem"
49 WATCHER_STATEFILE = DATA_DIR + "/watcher.data"
50 SSH_KNOWN_HOSTS_FILE = DATA_DIR + "/known_hosts"
51 ETC_HOSTS = "/etc/hosts"
52
53 NODE_INITD_SCRIPT = _autoconf.SYSCONFDIR + "/init.d/ganeti"
54 DEFAULT_NODED_PORT = 1811
55 FIRST_DRBD_PORT = 11000
56 LAST_DRBD_PORT = 14999
57 MASTER_SCRIPT = "ganeti-master"
58
59 LOG_DIR = _autoconf.LOCALSTATEDIR + "/log/ganeti"
60 LOG_OS_DIR = LOG_DIR + "/os"
61 LOG_NODESERVER = LOG_DIR + "/node-daemon.log"
62 LOG_RAPISERVER = LOG_DIR + "/rapi-daemon.log"
63 LOG_RAPIACCESS = LOG_DIR + "/rapi-access.log"
64 LOG_WATCHER = LOG_DIR + "/watcher.log"
65
66 OS_SEARCH_PATH = _autoconf.OS_SEARCH_PATH
67 EXPORT_DIR = _autoconf.EXPORT_DIR
68
69 EXPORT_CONF_FILE = "config.ini"
70
71 XEN_KERNEL = _autoconf.XEN_KERNEL
72 XEN_INITRD = _autoconf.XEN_INITRD
73
74 VALUE_DEFAULT = "default"
75 VALUE_AUTO = "auto"
76 VALUE_GENERATE = "generate"
77 VALUE_NONE = "none"
78
79 # External script validation mask
80 EXT_PLUGIN_MASK = re.compile("^[a-zA-Z0-9_-]+$")
81
82 # hooks-related constants
83 HOOKS_BASE_DIR = _autoconf.SYSCONFDIR + "/ganeti/hooks"
84 HOOKS_PHASE_PRE = "pre"
85 HOOKS_PHASE_POST = "post"
86 HOOKS_NAME_CFGUPDATE = "config-update"
87 HOOKS_VERSION = 1
88
89 # hooks subject type (what object type does the LU deal with)
90 HTYPE_CLUSTER = "CLUSTER"
91 HTYPE_NODE = "NODE"
92 HTYPE_INSTANCE = "INSTANCE"
93
94 HKR_SKIP = 0
95 HKR_FAIL = 1
96 HKR_SUCCESS = 2
97
98 # disk template types
99 DT_DISKLESS = "diskless"
100 DT_PLAIN = "plain"
101 DT_LOCAL_RAID1 = "local_raid1"
102 DT_REMOTE_RAID1 = "remote_raid1"
103 DT_DRBD8 = "drbd"
104
105 # the set of network-mirrored disk templates
106 DTS_NET_MIRROR = frozenset([DT_REMOTE_RAID1, DT_DRBD8])
107
108 # logical disk types
109 LD_LV = "lvm"
110 LD_MD_R1 = "md_raid1"
111 LD_DRBD7 = "drbd"
112 LD_DRBD8 = "drbd8"
113
114 # the set of drbd-like disk types
115 LDS_DRBD = frozenset([LD_DRBD7, LD_DRBD8])
116
117 # disk replacement mode
118 REPLACE_DISK_PRI = "replace_primary"
119 REPLACE_DISK_SEC = "replace_secondary"
120 REPLACE_DISK_ALL = "replace_all"
121
122 # instance creation modes
123 INSTANCE_CREATE = "create"
124 INSTANCE_IMPORT = "import"
125
126 DISK_TEMPLATES = frozenset([DT_DISKLESS, DT_PLAIN,
127                             DT_LOCAL_RAID1, DT_REMOTE_RAID1,
128                             DT_DRBD8])
129
130 # import/export config options
131 INISECT_EXP = "export"
132 INISECT_INS = "instance"
133
134 # common exit codes
135 EXIT_SUCCESS = 0
136 EXIT_FAILURE = 1
137 EXIT_NOTMASTER = 11
138 EXIT_NODESETUP_ERROR = 12
139 EXIT_CONFIRMATION = 13 # need user confirmation
140
141 # tags
142 TAG_CLUSTER = "cluster"
143 TAG_NODE = "node"
144 TAG_INSTANCE = "instance"
145 MAX_TAG_LEN = 64
146 MAX_TAGS_PER_OBJ = 48
147
148 # others
149 DEFAULT_BRIDGE = "xen-br0"
150 SYNC_SPEED = 60 * 1024
151 LOCALHOST_IP_ADDRESS = "127.0.0.1"
152 TCP_PING_TIMEOUT = 10
153 GANETI_RUNAS = "root"
154 BIND_ADDRESS_GLOBAL = "0.0.0.0"
155
156 # migration rpc steps
157 (DRBD_RECONF_RPC_INIT,
158  DRBD_RECONF_RPC_DISCONNECT,
159  DRBD_RECONF_RPC_RECONNECT,
160  DRBD_RECONF_RPC_SECONDARY,
161  DRBD_RECONF_RPC_WFSYNC,
162  ) = range(5)
163
164 # valid os status
165 OS_VALID_STATUS = "VALID"
166
167 # ssh constants
168 SSH_INITD_SCRIPT = _autoconf.SSH_INITD_SCRIPT
169 SSH_CONFIG_DIR = "/etc/ssh/"
170 SSH_HOST_DSA_PRIV = SSH_CONFIG_DIR + "ssh_host_dsa_key"
171 SSH_HOST_DSA_PUB = SSH_HOST_DSA_PRIV + ".pub"
172 SSH_HOST_RSA_PRIV = SSH_CONFIG_DIR + "ssh_host_rsa_key"
173 SSH_HOST_RSA_PUB = SSH_HOST_RSA_PRIV + ".pub"
174
175 # reboot types
176 INSTANCE_REBOOT_SOFT = "soft"
177 INSTANCE_REBOOT_HARD = "hard"
178 INSTANCE_REBOOT_FULL = "full"
179
180 # Hypervisor constants
181 HT_XEN_PVM30 = "xen-3.0"
182 HT_FAKE = "fake"
183 HT_XEN_HVM31 = "xen-hvm-3.1"
184 HYPER_TYPES = frozenset([HT_XEN_PVM30, HT_FAKE, HT_XEN_HVM31])
185 HTS_REQ_PORT = frozenset([HT_XEN_HVM31])
186
187 HT_HVM_VNC_BASE_PORT = 5900
188 HT_HVM_DEFAULT_BOOT_ORDER = 'dc'
189 HT_HVM_DEFAULT_ACPI_MODE = '1'
190 HT_HVM_DEFAULT_PAE_MODE = '1'
191 VNC_PASSWORD_FILE = _autoconf.SYSCONFDIR + "/ganeti/vnc-cluster-password"
192 VNC_DEFAULT_BIND_ADDRESS = '0.0.0.0'
193
194 # HVM NIC types
195 HT_HVM_NIC_RTL8139 = "rtl8139"
196 HT_HVM_NIC_NE2K_PCI = "ne2k_pci"
197 HT_HVM_NIC_NE2K_ISA = "ne2k_isa"
198 HT_HVM_DEV_PARAVIRTUAL = "paravirtual"
199 HT_HVM_DEV_IOEMU = "ioemu"
200 HT_HVM_VALID_NIC_TYPES = frozenset([HT_HVM_NIC_RTL8139, HT_HVM_NIC_NE2K_PCI,
201                                     HT_HVM_NIC_NE2K_ISA,
202                                     HT_HVM_DEV_PARAVIRTUAL])
203 HT_HVM_VALID_DISK_TYPES = frozenset([HT_HVM_DEV_PARAVIRTUAL, HT_HVM_DEV_IOEMU])
204
205 # Cluster Verify steps
206 VERIFY_NPLUSONE_MEM = 'nplusone_mem'
207 VERIFY_OPTIONAL_CHECKS = frozenset([VERIFY_NPLUSONE_MEM])
208
209 # Allocator framework constants
210 IALLOCATOR_DIR_IN = "in"
211 IALLOCATOR_DIR_OUT = "out"
212 IALLOCATOR_MODE_ALLOC = "allocate"
213 IALLOCATOR_MODE_RELOC = "relocate"
214 IALLOCATOR_SEARCH_PATH = _autoconf.IALLOCATOR_SEARCH_PATH
215 IARUN_NOTFOUND = 1
216 IARUN_FAILURE = 2
217 IARUN_SUCCESS = 3
218
219 # Remote API constants
220 RAPI_ENABLE = _autoconf.RAPI_ENABLE
221 RAPI_PORT = 5080