Revision 2d91e6ae test/mocks.py

b/test/mocks.py
38 38

  
39 39

  
40 40
class FakeConfig:
41
    """Fake configuration object"""
41
  """Fake configuration object"""
42 42

  
43
    def IsCluster(self):
44
        return True
43
  def IsCluster(self):
44
    return True
45 45

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

  
49
    def GetHostKey(self):
50
        return FAKE_CLUSTER_KEY
49
  def GetHostKey(self):
50
    return FAKE_CLUSTER_KEY
51 51

  
52
    def GetClusterName(self):
53
        return "test.cluster"
52
  def GetClusterName(self):
53
    return "test.cluster"
54 54

  
55
    def GetMasterNode(self):
56
        return netutils.Hostname.GetSysName()
55
  def GetMasterNode(self):
56
    return netutils.Hostname.GetSysName()
57 57

  
58
    def GetDefaultIAllocator(Self):
59
        return "testallocator"
58
  def GetDefaultIAllocator(Self):
59
    return "testallocator"
60 60

  
61 61

  
62 62
class FakeProc:
63
    """Fake processor object"""
63
  """Fake processor object"""
64 64

  
65
    def Log(self, msg, *args, **kwargs):
66
        pass
65
  def Log(self, msg, *args, **kwargs):
66
    pass
67 67

  
68
    def LogWarning(self, msg, *args, **kwargs):
69
        pass
68
  def LogWarning(self, msg, *args, **kwargs):
69
    pass
70 70

  
71
    def LogInfo(self, msg, *args, **kwargs):
72
        pass
71
  def LogInfo(self, msg, *args, **kwargs):
72
    pass
73 73

  
74
    def LogStep(self, current, total, message):
75
        pass
74
  def LogStep(self, current, total, message):
75
    pass
76 76

  
77 77

  
78 78
class FakeContext:
79
    """Fake context object"""
79
  """Fake context object"""
80 80

  
81
    def __init__(self):
82
        self.cfg = FakeConfig()
83
        self.glm = None
81
  def __init__(self):
82
    self.cfg = FakeConfig()
83
    self.glm = None
84 84

  
85 85

  
86 86
class FakeGetentResolver:
87
    """Fake runtime.GetentResolver"""
88

  
89
    def __init__(self):
90
        # As we nomally don't run under root we use our own uid/gid for all
91
        # fields. This way we don't run into permission denied problems.
92
        uid = os.getuid()
93
        gid = os.getgid()
94

  
95
        self.masterd_uid = uid
96
        self.masterd_gid = gid
97
        self.confd_uid = uid
98
        self.confd_gid = gid
99
        self.rapi_uid = uid
100
        self.rapi_gid = gid
101
        self.noded_uid = uid
102

  
103
        self.daemons_gid = gid
104
        self.admin_gid = gid
87
  """Fake runtime.GetentResolver"""
88

  
89
  def __init__(self):
90
    # As we nomally don't run under root we use our own uid/gid for all
91
    # fields. This way we don't run into permission denied problems.
92
    uid = os.getuid()
93
    gid = os.getgid()
94

  
95
    self.masterd_uid = uid
96
    self.masterd_gid = gid
97
    self.confd_uid = uid
98
    self.confd_gid = gid
99
    self.rapi_uid = uid
100
    self.rapi_gid = gid
101
    self.noded_uid = uid
102

  
103
    self.daemons_gid = gid
104
    self.admin_gid = gid

Also available in: Unified diff