Revision b76f660d

b/daemons/ganeti-watcher
124 124
    LockFile(self.statefile.fileno())
125 125

  
126 126
    try:
127
      self.data = serializer.Load(self.statefile.read())
127
      self._data = serializer.Load(self.statefile.read())
128 128
    except Exception, msg:
129 129
      # Ignore errors while loading the file and treat it as empty
130
      self.data = {}
130
      self._data = {}
131 131
      logging.warning(("Empty or invalid state file. Using defaults."
132 132
                       " Error message: %s"), msg)
133 133

  
134
    if "instance" not in self.data:
135
      self.data["instance"] = {}
136
    if "node" not in self.data:
137
      self.data["node"] = {}
134
    if "instance" not in self._data:
135
      self._data["instance"] = {}
136
    if "node" not in self._data:
137
      self._data["node"] = {}
138 138

  
139 139
  def Save(self):
140 140
    """Save state to file, then unlock and close it.
......
145 145
    # We need to make sure the file is locked before renaming it, otherwise
146 146
    # starting ganeti-watcher again at the same time will create a conflict.
147 147
    fd = utils.WriteFile(constants.WATCHER_STATEFILE,
148
                         data=serializer.Dump(self.data),
148
                         data=serializer.Dump(self._data),
149 149
                         prewrite=LockFile, close=False)
150 150
    self.statefile = os.fdopen(fd, 'w+')
151 151

  
......
163 163
    """Returns the last boot ID of a node or None.
164 164

  
165 165
    """
166
    ndata = self.data["node"]
166
    ndata = self._data["node"]
167 167

  
168 168
    if name in ndata and KEY_BOOT_ID in ndata[name]:
169 169
      return ndata[name][KEY_BOOT_ID]
......
175 175
    """
176 176
    assert bootid
177 177

  
178
    ndata = self.data["node"]
178
    ndata = self._data["node"]
179 179

  
180 180
    if name not in ndata:
181 181
      ndata[name] = {}
......
189 189
      instance - the instance to look up.
190 190

  
191 191
    """
192
    idata = self.data["instance"]
192
    idata = self._data["instance"]
193 193

  
194 194
    if instance.name in idata:
195 195
      return idata[instance.name][KEY_RESTART_COUNT]
......
203 203
      instance - the instance being restarted
204 204

  
205 205
    """
206
    idata = self.data["instance"]
206
    idata = self._data["instance"]
207 207

  
208 208
    if instance.name not in idata:
209 209
      inst = idata[instance.name] = {}
......
222 222
    This method removes the record for a named instance.
223 223

  
224 224
    """
225
    idata = self.data["instance"]
225
    idata = self._data["instance"]
226 226

  
227 227
    if instance.name in idata:
228 228
      del idata[instance.name]

Also available in: Unified diff