root / test / mocks.py @ 5d672980
History | View | Annotate | Download (2.1 kB)
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 implementing a fake ConfigWriter"""
|
23 |
|
24 |
from ganeti import utils |
25 |
|
26 |
|
27 |
FAKE_CLUSTER_KEY = ("AAAAB3NzaC1yc2EAAAABIwAAAQEAsuGLw70et3eApJ/ZEJkAVZogIrm"
|
28 |
"EYPQJvb1ll52Ti0nr80Wztxibaa8bYGzY22rQIAloIlePeTGcJceAYK"
|
29 |
"PZgm0I/Mp2EUGg2NVsQZIzasz6cW0vYuiUbF9GkVlROmvOAykT58RfM"
|
30 |
"L8RhPrjrQxZc+NXgZtgDugYSZcXHDLUyWM1xKUoYy0MqYG6ZXCC/Zno"
|
31 |
"RThhmjOJgEmvwrMcTWQjmzH3NeJAxaBsEHR8tiVZ/Y23C/ULWLyNT6R"
|
32 |
"fB+DE7IovsMQaS+83AK1Teg7RWNyQczachatf/JT8VjUqFYjJepPjMb"
|
33 |
"vYdB2nQds7/+Bf40C/OpbvnAxna1kVtgFHAo18cQ==")
|
34 |
|
35 |
|
36 |
class FakeConfig: |
37 |
"""Fake configuration object"""
|
38 |
|
39 |
def IsCluster(self): |
40 |
return True |
41 |
|
42 |
def GetNodeList(self): |
43 |
return ["a", "b", "c"] |
44 |
|
45 |
def GetMaster(self): |
46 |
return utils.HostInfo().name
|
47 |
|
48 |
def GetHostKey(self): |
49 |
return FAKE_CLUSTER_KEY
|
50 |
|
51 |
def GetClusterName(self): |
52 |
return "test.cluster" |
53 |
|
54 |
def GetMasterNode(self): |
55 |
return utils.HostInfo().name
|
56 |
|
57 |
|
58 |
class FakeProc: |
59 |
"""Fake processor object"""
|
60 |
|
61 |
def LogWarning(self, msg): |
62 |
pass
|
63 |
|
64 |
def LogInfo(self, msg): |
65 |
pass
|
66 |
|
67 |
class FakeContext: |
68 |
"""Fake context object"""
|
69 |
|
70 |
def __init__(self): |
71 |
self.cfg = FakeConfig()
|
72 |
# TODO: decide what features a mock Ganeti Lock Manager must have
|
73 |
self.GLM = None |
74 |
|