Add HVM device type flags 2/4
[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 from ganeti import _autoconf
25
26 # various versions
27 CONFIG_VERSION = 3
28 PROTOCOL_VERSION = 13
29 RELEASE_VERSION = _autoconf.PACKAGE_VERSION
30 OS_API_VERSION = 5
31 EXPORT_VERSION = 0
32 RAPI_VERSION = 1
33
34
35 # file paths
36 DATA_DIR = _autoconf.LOCALSTATEDIR + "/lib/ganeti"
37 RUN_DIR = _autoconf.LOCALSTATEDIR + "/run"
38 RUN_GANETI_DIR = RUN_DIR + "/ganeti"
39 BDEV_CACHE_DIR = RUN_GANETI_DIR # TODO(2.0): move deeper
40 DISK_LINKS_DIR = RUN_GANETI_DIR + "/instance-disks"
41 # keep RUN_GANETI_DIR first here, to make sure all get created when the node
42 # daemon is started (this takes care of RUN_DIR being tmpfs)
43 SUB_RUN_DIRS = [ RUN_GANETI_DIR, BDEV_CACHE_DIR, DISK_LINKS_DIR ]
44 LOCK_DIR = _autoconf.LOCALSTATEDIR + "/lock"
45 CLUSTER_CONF_FILE = DATA_DIR + "/config.data"
46 SSL_CERT_FILE = DATA_DIR + "/server.pem"
47 WATCHER_STATEFILE = DATA_DIR + "/watcher.data"
48 SSH_KNOWN_HOSTS_FILE = DATA_DIR + "/known_hosts"
49 ETC_HOSTS = "/etc/hosts"
50
51 NODE_INITD_SCRIPT = _autoconf.SYSCONFDIR + "/init.d/ganeti"
52 DEFAULT_NODED_PORT = 1811
53 FIRST_DRBD_PORT = 11000
54 LAST_DRBD_PORT = 14999
55 MASTER_SCRIPT = "ganeti-master"
56
57 LOG_DIR = _autoconf.LOCALSTATEDIR + "/log/ganeti"
58 LOG_OS_DIR = LOG_DIR + "/os"
59 LOG_NODESERVER = LOG_DIR + "/node-daemon.log"
60 LOG_RAPISERVER = LOG_DIR + "/rapi-daemon.log"
61 LOG_RAPIACCESS = LOG_DIR + "/rapi-access.log"
62 LOG_WATCHER = LOG_DIR + "/watcher.log"
63
64 OS_SEARCH_PATH = _autoconf.OS_SEARCH_PATH
65 EXPORT_DIR = _autoconf.EXPORT_DIR
66
67 EXPORT_CONF_FILE = "config.ini"
68
69 XEN_KERNEL = _autoconf.XEN_KERNEL
70 XEN_INITRD = _autoconf.XEN_INITRD
71
72 VALUE_DEFAULT = "default"
73 VALUE_NONE = "none"
74
75 # hooks-related constants
76 HOOKS_BASE_DIR = _autoconf.SYSCONFDIR + "/ganeti/hooks"
77 HOOKS_PHASE_PRE = "pre"
78 HOOKS_PHASE_POST = "post"
79 HOOKS_NAME_CFGUPDATE = "config-update"
80 HOOKS_VERSION = 1
81
82 # hooks subject type (what object type does the LU deal with)
83 HTYPE_CLUSTER = "CLUSTER"
84 HTYPE_NODE = "NODE"
85 HTYPE_INSTANCE = "INSTANCE"
86
87 HKR_SKIP = 0
88 HKR_FAIL = 1
89 HKR_SUCCESS = 2
90
91 # disk template types
92 DT_DISKLESS = "diskless"
93 DT_PLAIN = "plain"
94 DT_LOCAL_RAID1 = "local_raid1"
95 DT_REMOTE_RAID1 = "remote_raid1"
96 DT_DRBD8 = "drbd"
97
98 # the set of network-mirrored disk templates
99 DTS_NET_MIRROR = frozenset([DT_REMOTE_RAID1, DT_DRBD8])
100
101 # logical disk types
102 LD_LV = "lvm"
103 LD_MD_R1 = "md_raid1"
104 LD_DRBD7 = "drbd"
105 LD_DRBD8 = "drbd8"
106
107 # the set of drbd-like disk types
108 LDS_DRBD = frozenset([LD_DRBD7, LD_DRBD8])
109
110 # disk replacement mode
111 REPLACE_DISK_PRI = "replace_primary"
112 REPLACE_DISK_SEC = "replace_secondary"
113 REPLACE_DISK_ALL = "replace_all"
114
115 # instance creation modes
116 INSTANCE_CREATE = "create"
117 INSTANCE_IMPORT = "import"
118
119 DISK_TEMPLATES = frozenset([DT_DISKLESS, DT_PLAIN,
120                             DT_LOCAL_RAID1, DT_REMOTE_RAID1,
121                             DT_DRBD8])
122
123 # import/export config options
124 INISECT_EXP = "export"
125 INISECT_INS = "instance"
126
127 # common exit codes
128 EXIT_SUCCESS = 0
129 EXIT_FAILURE = 1
130 EXIT_NOTMASTER = 11
131 EXIT_NODESETUP_ERROR = 12
132 EXIT_CONFIRMATION = 13 # need user confirmation
133
134 # tags
135 TAG_CLUSTER = "cluster"
136 TAG_NODE = "node"
137 TAG_INSTANCE = "instance"
138 MAX_TAG_LEN = 64
139 MAX_TAGS_PER_OBJ = 48
140
141 # others
142 DEFAULT_BRIDGE = "xen-br0"
143 SYNC_SPEED = 30 * 1024
144 LOCALHOST_IP_ADDRESS = "127.0.0.1"
145 TCP_PING_TIMEOUT = 10
146 GANETI_RUNAS = "root"
147 BIND_ADDRESS_GLOBAL = "0.0.0.0"
148
149 # migration rpc steps
150 (DRBD_RECONF_RPC_INIT,
151  DRBD_RECONF_RPC_DISCONNECT,
152  DRBD_RECONF_RPC_RECONNECT,
153  DRBD_RECONF_RPC_SECONDARY,
154  DRBD_RECONF_RPC_WFSYNC,
155  ) = range(5)
156
157 # valid os status
158 OS_VALID_STATUS = "VALID"
159
160 # ssh constants
161 SSH_INITD_SCRIPT = _autoconf.SSH_INITD_SCRIPT
162 SSH_CONFIG_DIR = "/etc/ssh/"
163 SSH_HOST_DSA_PRIV = SSH_CONFIG_DIR + "ssh_host_dsa_key"
164 SSH_HOST_DSA_PUB = SSH_HOST_DSA_PRIV + ".pub"
165 SSH_HOST_RSA_PRIV = SSH_CONFIG_DIR + "ssh_host_rsa_key"
166 SSH_HOST_RSA_PUB = SSH_HOST_RSA_PRIV + ".pub"
167
168 # reboot types
169 INSTANCE_REBOOT_SOFT = "soft"
170 INSTANCE_REBOOT_HARD = "hard"
171 INSTANCE_REBOOT_FULL = "full"
172
173 # Hypervisor constants
174 HT_XEN_PVM30 = "xen-3.0"
175 HT_FAKE = "fake"
176 HT_XEN_HVM31 = "xen-hvm-3.1"
177 HYPER_TYPES = frozenset([HT_XEN_PVM30, HT_FAKE, HT_XEN_HVM31])
178 HTS_REQ_PORT = frozenset([HT_XEN_HVM31])
179
180 HT_HVM_VNC_BASE_PORT = 5900
181 HT_HVM_DEFAULT_BOOT_ORDER = 'dc'
182 HT_HVM_DEFAULT_ACPI_MODE = '1'
183 HT_HVM_DEFAULT_PAE_MODE = '1'
184 VNC_PASSWORD_FILE = _autoconf.SYSCONFDIR + "/ganeti/vnc-cluster-password"
185 VNC_DEFAULT_BIND_ADDRESS = '0.0.0.0'
186
187 # HVM NIC types
188 HT_HVM_NIC_RTL8139 = "rtl8139"
189 HT_HVM_NIC_NE2K_PCI = "ne2k_pci"
190 HT_HVM_NIC_NE2K_ISA = "ne2k_isa"
191 HT_HVM_DEV_PARAVIRTUAL = "paravirtual"
192 HT_HVM_DEV_IOEMU = "ioemu"
193 HT_HVM_VALID_NIC_TYPES = frozenset([HT_HVM_NIC_RTL8139, HT_HVM_NIC_NE2K_PCI,
194                                     HT_HVM_NIC_NE2K_ISA,
195                                     HT_HVM_DEV_PARAVIRTUAL])
196 HT_HVM_VALID_DISK_TYPES = frozenset([HT_HVM_DEV_PARAVIRTUAL, HT_HVM_DEV_IOEMU])
197
198 # Cluster Verify steps
199 VERIFY_NPLUSONE_MEM = 'nplusone_mem'
200 VERIFY_OPTIONAL_CHECKS = frozenset([VERIFY_NPLUSONE_MEM])
201
202 # Allocator framework constants
203 IALLOCATOR_DIR_IN = "in"
204 IALLOCATOR_DIR_OUT = "out"
205 IALLOCATOR_MODE_ALLOC = "allocate"
206 IALLOCATOR_MODE_RELOC = "relocate"
207 IALLOCATOR_SEARCH_PATH = _autoconf.IALLOCATOR_SEARCH_PATH
208 IARUN_NOTFOUND = 1
209 IARUN_FAILURE = 2
210 IARUN_SUCCESS = 3
211
212 # Remote API constants
213 RAPI_ENABLE = _autoconf.RAPI_ENABLE
214 RAPI_PORT = 5080