Revision 7dd106d3 lib/hypervisor/hv_xen.py

b/lib/hypervisor/hv_xen.py
42 42
  all the functionality that is identical for both.
43 43

  
44 44
  """
45
  REBOOT_RETRY_COUNT = 60
46
  REBOOT_RETRY_INTERVAL = 10
45 47

  
46 48
  @classmethod
47 49
  def _WriteConfigFile(cls, instance, block_devices):
......
191 193
    """Reboot an instance.
192 194

  
193 195
    """
196
    ini_info = self.GetInstanceInfo(instance.name)
194 197
    result = utils.RunCmd(["xm", "reboot", instance.name])
195 198

  
196 199
    if result.failed:
197 200
      raise errors.HypervisorError("Failed to reboot instance %s: %s, %s" %
198 201
                                   (instance.name, result.fail_reason,
199 202
                                    result.output))
203
    done = False
204
    retries = self.REBOOT_RETRY_COUNT
205
    while retries > 0:
206
      new_info = self.GetInstanceInfo(instance.name)
207
      # check if the domain ID has changed or the run time has
208
      # decreased
209
      if new_info[1] != ini_info[1] or new_info[5] < ini_info[5]:
210
        done = True
211
        break
212
      time.sleep(self.REBOOT_RETRY_INTERVAL)
213
      retries -= 1
214

  
215
    if not done:
216
      raise errors.HypervisorError("Failed to reboot instance %s: instance"
217
                                   " did not reboot in the expected interval" %
218
                                   (instance.name, ))
200 219

  
201 220
  def GetNodeInfo(self):
202 221
    """Return information about the node.

Also available in: Unified diff