root / test / mocks.py @ 6760e4ed
History | View | Annotate | Download (2.3 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 implementing a fake ConfigWriter"""
|
23 | a8083063 | Iustin Pop | |
24 | 89e1fc26 | Iustin Pop | from ganeti import utils |
25 | a744b676 | Manuel Franceschini | from ganeti import netutils |
26 | a8083063 | Iustin Pop | |
27 | 75a5f456 | Michael Hanselmann | |
28 | 75a5f456 | Michael Hanselmann | FAKE_CLUSTER_KEY = ("AAAAB3NzaC1yc2EAAAABIwAAAQEAsuGLw70et3eApJ/ZEJkAVZogIrm"
|
29 | 75a5f456 | Michael Hanselmann | "EYPQJvb1ll52Ti0nr80Wztxibaa8bYGzY22rQIAloIlePeTGcJceAYK"
|
30 | 75a5f456 | Michael Hanselmann | "PZgm0I/Mp2EUGg2NVsQZIzasz6cW0vYuiUbF9GkVlROmvOAykT58RfM"
|
31 | 75a5f456 | Michael Hanselmann | "L8RhPrjrQxZc+NXgZtgDugYSZcXHDLUyWM1xKUoYy0MqYG6ZXCC/Zno"
|
32 | 75a5f456 | Michael Hanselmann | "RThhmjOJgEmvwrMcTWQjmzH3NeJAxaBsEHR8tiVZ/Y23C/ULWLyNT6R"
|
33 | 75a5f456 | Michael Hanselmann | "fB+DE7IovsMQaS+83AK1Teg7RWNyQczachatf/JT8VjUqFYjJepPjMb"
|
34 | 75a5f456 | Michael Hanselmann | "vYdB2nQds7/+Bf40C/OpbvnAxna1kVtgFHAo18cQ==")
|
35 | 75a5f456 | Michael Hanselmann | |
36 | 75a5f456 | Michael Hanselmann | |
37 | a8083063 | Iustin Pop | class FakeConfig: |
38 | a8083063 | Iustin Pop | """Fake configuration object"""
|
39 | a8083063 | Iustin Pop | |
40 | a8083063 | Iustin Pop | def IsCluster(self): |
41 | a8083063 | Iustin Pop | return True |
42 | a8083063 | Iustin Pop | |
43 | a8083063 | Iustin Pop | def GetNodeList(self): |
44 | a8083063 | Iustin Pop | return ["a", "b", "c"] |
45 | a8083063 | Iustin Pop | |
46 | 75a5f456 | Michael Hanselmann | def GetHostKey(self): |
47 | 75a5f456 | Michael Hanselmann | return FAKE_CLUSTER_KEY
|
48 | 75a5f456 | Michael Hanselmann | |
49 | 437138c9 | Michael Hanselmann | def GetClusterName(self): |
50 | 437138c9 | Michael Hanselmann | return "test.cluster" |
51 | 437138c9 | Michael Hanselmann | |
52 | 437138c9 | Michael Hanselmann | def GetMasterNode(self): |
53 | a744b676 | Manuel Franceschini | return netutils.HostInfo().name
|
54 | 437138c9 | Michael Hanselmann | |
55 | bd5f214b | Apollon Oikonomopoulos | def GetDefaultIAllocator(Self): |
56 | bd5f214b | Apollon Oikonomopoulos | return "testallocator" |
57 | bd5f214b | Apollon Oikonomopoulos | |
58 | 880478f8 | Iustin Pop | |
59 | 2395c322 | Iustin Pop | class FakeProc: |
60 | 2395c322 | Iustin Pop | """Fake processor object"""
|
61 | 2395c322 | Iustin Pop | |
62 | 7b4c1cb9 | Michael Hanselmann | def Log(self, msg, *args, **kwargs): |
63 | 7b4c1cb9 | Michael Hanselmann | pass
|
64 | 7b4c1cb9 | Michael Hanselmann | |
65 | 3fb4f740 | Iustin Pop | def LogWarning(self, msg, *args, **kwargs): |
66 | 2395c322 | Iustin Pop | pass
|
67 | 2395c322 | Iustin Pop | |
68 | 3fb4f740 | Iustin Pop | def LogInfo(self, msg, *args, **kwargs): |
69 | 2395c322 | Iustin Pop | pass
|
70 | f4555db2 | Guido Trotter | |
71 | c071c5b3 | Michael Hanselmann | def LogStep(self, current, total, message): |
72 | c071c5b3 | Michael Hanselmann | pass
|
73 | c071c5b3 | Michael Hanselmann | |
74 | c071c5b3 | Michael Hanselmann | |
75 | f4555db2 | Guido Trotter | class FakeContext: |
76 | f4555db2 | Guido Trotter | """Fake context object"""
|
77 | f4555db2 | Guido Trotter | |
78 | f4555db2 | Guido Trotter | def __init__(self): |
79 | f4555db2 | Guido Trotter | self.cfg = FakeConfig()
|
80 | f4555db2 | Guido Trotter | # TODO: decide what features a mock Ganeti Lock Manager must have
|
81 | f4555db2 | Guido Trotter | self.GLM = None |