mocks.py 2.1 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
class FakeConfig:
    """Fake configuration object"""

    def IsCluster(self):
        return True

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

45
46
47
    def GetHostKey(self):
        return FAKE_CLUSTER_KEY

Michael Hanselmann's avatar
Michael Hanselmann committed
48
49
50
51
52
53
    def GetClusterName(self):
        return "test.cluster"

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

54

55
56
57
class FakeProc:
    """Fake processor object"""

58
    def LogWarning(self, msg, *args, **kwargs):
59
60
        pass

61
    def LogInfo(self, msg, *args, **kwargs):
62
        pass
63

64
65
66
67
    def LogStep(self, current, total, message):
        pass


68
69
70
71
72
73
74
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