Revision bbcf7ad0 lib/hypervisor/hv_fake.py

b/lib/hypervisor/hv_fake.py
136 136
    finally:
137 137
      fh.close()
138 138

  
139
  def _MarkDown(self, instance):
139
  def _MarkDown(self, instance_name):
140 140
    """Mark the instance as running.
141 141

  
142 142
    This does no checks, which should be done by its callers.
143 143

  
144 144
    """
145
    file_name = self._InstanceFile(instance.name)
145
    file_name = self._InstanceFile(instance_name)
146 146
    utils.RemoveFile(file_name)
147 147

  
148 148
  def StartInstance(self, instance, block_devices):
......
162 162
      raise errors.HypervisorError("Failed to start instance %s: %s" %
163 163
                                   (instance.name, err))
164 164

  
165
  def StopInstance(self, instance, force=False, retry=False):
165
  def StopInstance(self, instance, force=False, retry=False, name=None):
166 166
    """Stop an instance.
167 167

  
168 168
    For the fake hypervisor, this just removes the file in the base
169 169
    dir, if it exist, otherwise we raise an exception.
170 170

  
171 171
    """
172
    if not self._IsAlive(instance.name):
172
    if name is None:
173
      name = instance.name
174
    if not self._IsAlive(name):
173 175
      raise errors.HypervisorError("Failed to stop instance %s: %s" %
174
                                   (instance.name, "not running"))
175
    self._MarkDown(instance)
176
                                   (name, "not running"))
177
    self._MarkDown(name)
176 178

  
177 179
  def RebootInstance(self, instance):
178 180
    """Reboot an instance.
......
252 254
    logging.debug("Fake hypervisor migrating %s to %s (live=%s)",
253 255
                  instance, target, live)
254 256

  
255
    self._MarkDown(instance)
257
    self._MarkDown(instance.name)
256 258

  
257 259
  def FinalizeMigration(self, instance, info, success):
258 260
    """Finalize an instance migration.
......
267 269
      self._MarkUp(instance)
268 270
    else:
269 271
      # ensure it's down
270
      self._MarkDown(instance)
272
      self._MarkDown(instance.name)

Also available in: Unified diff