Revision 7b195d9b

b/daemons/ganeti-watcher
47 47
HELPLESS_STATES = ['(node down)']
48 48
NOTICE = 'NOTICE'
49 49
ERROR = 'ERROR'
50
KEY_RESTART_COUNT = "restart_count"
51
KEY_RESTART_WHEN = "restart_when"
52
KEY_BOOT_ID = "bootid"
50 53

  
51 54

  
52 55
class Error(Exception):
......
151 154
    """
152 155
    ndata = self.data["node"]
153 156

  
154
    if name in ndata and "bootid" in ndata[name]:
155
      return ndata[name]["bootid"]
157
    if name in ndata and KEY_BOOT_ID in ndata[name]:
158
      return ndata[name][KEY_BOOT_ID]
156 159
    return None
157 160

  
158 161
  def SetNodeBootID(self, name, bootid):
......
166 169
    if name not in ndata:
167 170
      ndata[name] = {}
168 171

  
169
    ndata[name]["bootid"] = bootid
172
    ndata[name][KEY_BOOT_ID] = bootid
170 173

  
171 174
  def NumberOfRestartAttempts(self, instance):
172 175
    """Returns number of previous restart attempts.
......
178 181
    idata = self.data["instance"]
179 182

  
180 183
    if instance.name in idata:
181
      return idata[instance.name]["restart_count"]
184
      return idata[instance.name][KEY_RESTART_COUNT]
182 185

  
183 186
    return 0
184 187

  
......
196 199
    else:
197 200
      inst = idata[instance.name]
198 201

  
199
    inst["restart_when"] = time.time()
200
    inst["restart_count"] = idata.get("restart_count", 0) + 1
202
    inst[KEY_RESTART_WHEN] = time.time()
203
    inst[KEY_RESTART_COUNT] = inst.get(KEY_RESTART_COUNT, 0) + 1
201 204

  
202 205
  def RemoveInstance(self, instance):
203 206
    """Update state to reflect that a machine is running, i.e. remove record.

Also available in: Unified diff