mocks.py 2.25 KB
Newer Older
Iustin Pop's avatar
Iustin Pop committed
1
#
Iustin Pop's avatar
Iustin Pop committed
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#

# Copyright (C) 2006, 2007 Google Inc.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
# 02110-1301, USA.


"""Module implementing a fake ConfigWriter"""

24
from ganeti import utils
Iustin Pop's avatar
Iustin Pop committed
25

26
27
28
29
30
31
32
33
34
35

FAKE_CLUSTER_KEY = ("AAAAB3NzaC1yc2EAAAABIwAAAQEAsuGLw70et3eApJ/ZEJkAVZogIrm"
                    "EYPQJvb1ll52Ti0nr80Wztxibaa8bYGzY22rQIAloIlePeTGcJceAYK"
                    "PZgm0I/Mp2EUGg2NVsQZIzasz6cW0vYuiUbF9GkVlROmvOAykT58RfM"
                    "L8RhPrjrQxZc+NXgZtgDugYSZcXHDLUyWM1xKUoYy0MqYG6ZXCC/Zno"
                    "RThhmjOJgEmvwrMcTWQjmzH3NeJAxaBsEHR8tiVZ/Y23C/ULWLyNT6R"
                    "fB+DE7IovsMQaS+83AK1Teg7RWNyQczachatf/JT8VjUqFYjJepPjMb"
                    "vYdB2nQds7/+Bf40C/OpbvnAxna1kVtgFHAo18cQ==")


Iustin Pop's avatar
Iustin Pop committed
36
37
38
39
40
41
42
43
44
45
class FakeConfig:
    """Fake configuration object"""

    def IsCluster(self):
        return True

    def GetNodeList(self):
        return ["a", "b", "c"]

    def GetMaster(self):
46
        return utils.HostInfo().name
47

48
49
50
    def GetHostKey(self):
        return FAKE_CLUSTER_KEY

Michael Hanselmann's avatar
Michael Hanselmann committed
51
52
53
54
55
56
    def GetClusterName(self):
        return "test.cluster"

    def GetMasterNode(self):
        return utils.HostInfo().name

57
58
59
60

class FakeSStore:
    """Fake simplestore object"""

61
62
63
    def GetClusterName(self):
        return "test.cluster"

64
    def GetMasterNode(self):
65
        return utils.HostInfo().name
66
67
68
69
70
71
72
73
74
75


class FakeProc:
    """Fake processor object"""

    def LogWarning(self, msg):
        pass

    def LogInfo(self, msg):
        pass
76
77
78
79
80
81
82
83
84

class FakeContext:
    """Fake context object"""

    def __init__(self):
        self.cfg = FakeConfig()
        # TODO: decide what features a mock Ganeti Lock Manager must have
        self.GLM = None