root / lib / constants.py @ bc57fa8d
History | View | Annotate | Download (2.9 kB)
1 | 2f31098c | Iustin Pop | #
|
---|---|---|---|
2 | a8083063 | Iustin Pop | #
|
3 | a8083063 | Iustin Pop | |
4 | 7e7fa841 | Iustin Pop | # Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013 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 | ffab1490 | Jose A. Lopes | # pylint: disable=W0401,W0614
|
25 | ffab1490 | Jose A. Lopes | #
|
26 | ffab1490 | Jose A. Lopes | # The modules 'ganeti._constants' and 'ganeti._vcsversion' are meant
|
27 | ffab1490 | Jose A. Lopes | # to be re-exported but pylint complains because the imported names
|
28 | ffab1490 | Jose A. Lopes | # are not actually used in this module.
|
29 | ffab1490 | Jose A. Lopes | |
30 | 4fe80ef2 | Iustin Pop | import re |
31 | 47334810 | Iustin Pop | import socket |
32 | 4fe80ef2 | Iustin Pop | |
33 | ffab1490 | Jose A. Lopes | from ganeti._constants import * |
34 | ffab1490 | Jose A. Lopes | from ganeti._vcsversion import * |
35 | b8028dcf | Michael Hanselmann | from ganeti import compat |
36 | 9f2265bc | Michael Hanselmann | from ganeti import pathutils |
37 | 3329f4de | Michael Hanselmann | |
38 | 884dc063 | Jose A. Lopes | ALLOCATABLE_KEY = "allocatable"
|
39 | 884dc063 | Jose A. Lopes | FAILED_KEY = "failed"
|
40 | ba174485 | Jose A. Lopes | |
41 | ba174485 | Jose A. Lopes | DAEMONS_LOGFILES = \ |
42 | ba174485 | Jose A. Lopes | dict((daemon, pathutils.GetLogFilename(DAEMONS_LOGBASE[daemon]))
|
43 | ba174485 | Jose A. Lopes | for daemon in DAEMONS_LOGBASE) |
44 | ba174485 | Jose A. Lopes | |
45 | ba174485 | Jose A. Lopes | DAEMONS_EXTRA_LOGFILES = \ |
46 | ba174485 | Jose A. Lopes | dict((daemon, dict((extra, |
47 | ba174485 | Jose A. Lopes | pathutils.GetLogFilename(DAEMONS_EXTRA_LOGBASE[daemon][extra])) |
48 | ba174485 | Jose A. Lopes | for extra in DAEMONS_EXTRA_LOGBASE[daemon])) |
49 | ba174485 | Jose A. Lopes | for daemon in DAEMONS_EXTRA_LOGBASE) |
50 | ba174485 | Jose A. Lopes | |
51 | ba174485 | Jose A. Lopes | # When the Xen toolstack used is "xl", live migration requires the source host
|
52 | ba174485 | Jose A. Lopes | # to connect to the target host via ssh (xl runs this command). We need to pass
|
53 | ba174485 | Jose A. Lopes | # the command xl runs some extra info so that it can use Ganeti's key
|
54 | ba174485 | Jose A. Lopes | # verification and not fail. Note that this string is incomplete: it must be
|
55 | ba174485 | Jose A. Lopes | # filled with the cluster name before being used.
|
56 | ba174485 | Jose A. Lopes | XL_SSH_CMD = ("ssh -l %s -oGlobalKnownHostsFile=%s"
|
57 | ba174485 | Jose A. Lopes | " -oUserKnownHostsFile=/dev/null"
|
58 | ba174485 | Jose A. Lopes | " -oCheckHostIp=no -oStrictHostKeyChecking=yes"
|
59 | ba174485 | Jose A. Lopes | " -oHostKeyAlias=%%s") % (SSH_LOGIN_USER,
|
60 | ba174485 | Jose A. Lopes | pathutils.SSH_KNOWN_HOSTS_FILE) |
61 | ba174485 | Jose A. Lopes | |
62 | ba174485 | Jose A. Lopes | IE_MAGIC_RE = re.compile(r"^[-_.a-zA-Z0-9]{5,100}$")
|
63 | ba174485 | Jose A. Lopes | |
64 | ba174485 | Jose A. Lopes | # External script validation mask
|
65 | ba174485 | Jose A. Lopes | EXT_PLUGIN_MASK = re.compile("^[a-zA-Z0-9_-]+$")
|
66 | ba174485 | Jose A. Lopes | |
67 | ba174485 | Jose A. Lopes | JOB_ID_TEMPLATE = r"\d+"
|
68 | ba174485 | Jose A. Lopes | JOB_FILE_RE = re.compile(r"^job-(%s)$" % JOB_ID_TEMPLATE)
|
69 | ba174485 | Jose A. Lopes | |
70 | ba174485 | Jose A. Lopes | # HVC_DEFAULTS contains one value 'HV_VNC_PASSWORD_FILE' which is not
|
71 | ba174485 | Jose A. Lopes | # a constant because it depends on an environment variable that is
|
72 | ba174485 | Jose A. Lopes | # used for VClusters. Therefore, it cannot be automatically generated
|
73 | ba174485 | Jose A. Lopes | # by Haskell at compilation time (given that this environment variable
|
74 | ba174485 | Jose A. Lopes | # might be different at runtime).
|
75 | ba174485 | Jose A. Lopes | HVC_DEFAULTS[HT_XEN_HVM][HV_VNC_PASSWORD_FILE] = pathutils.VNC_PASSWORD_FILE |
76 | ba174485 | Jose A. Lopes | |
77 | ba174485 | Jose A. Lopes | # Do not re-export imported modules
|
78 | ffab1490 | Jose A. Lopes | del re, socket, pathutils, compat |