Merge branch 'stable-2.11' into stable-2.12
authorKlaus Aehlig <aehlig@google.com>
Tue, 31 Mar 2015 13:10:44 +0000 (15:10 +0200)
committerKlaus Aehlig <aehlig@google.com>
Tue, 31 Mar 2015 13:28:33 +0000 (15:28 +0200)
* stable-2.11
  (no changes)

* stable-2.10
  Fixed typos
  Pass correct params in move-instance
  In CanTieredAlloc test set IPolicy
  Make genInstanceMaybeBiggerThanNode honor policy lower bound
  Also export a null ISpec
  Support instance generation within ranges
  Add a function to leave the list monad

Conflicts:
tools/move-instance
Resolution:
manually apply 6f918cb2c97 to version on 2.12

Signed-off-by: Klaus Aehlig <aehlig@google.com>
Reviewed-by: Hrvoje Ribicic <riba@google.com>

1  2 
man/gnt-instance.rst
test/hs/Test/Ganeti/HTools/Instance.hs
tools/move-instance

Simple merge
@@@ -490,58 -454,18 +490,58 @@@ class MoveDestExecutor(object)
  
      logging.info("Creating instance %s in remote-import mode",
                   mrt.move.dest_instance_name)
 -    job_id = self._CreateInstance(dest_client, mrt.move.dest_instance_name,
 -                                  mrt.move.dest_pnode, mrt.move.dest_snode,
 -                                  mrt.move.compress,
 -                                  mrt.move.dest_iallocator,
 -                                  mrt.move.dest_disk_template,
 -                                  mrt.src_instinfo, mrt.src_expinfo,
 -                                  mrt.move.hvparams, mrt.move.beparams,
 -                                  mrt.move.osparams, mrt.move.nics)
 -    mrt.PollJob(dest_client, job_id,
 -                remote_import_fn=compat.partial(self._SetImportInfo, mrt))
 -
 -    logging.info("Import successful")
 +
 +    # Depending on whether opportunistic tries are enabled, we may have to
 +    # make multiple creation attempts
 +    creation_attempts = [True] * mrt.move.opportunistic_tries
 +
 +    # But the last one is never opportunistic, and will block until completion
 +    # or failure
 +    creation_attempts.append(False)
 +
 +    # Initiate the RNG for the variations
 +    random.seed()
 +
 +    for is_attempt_opportunistic in creation_attempts:
 +      job_id = self._CreateInstance(dest_client, mrt.move.dest_instance_name,
 +                                    mrt.move.dest_pnode, mrt.move.dest_snode,
 +                                    mrt.move.compress,
 +                                    mrt.move.dest_iallocator,
 +                                    mrt.move.dest_disk_template,
 +                                    mrt.src_instinfo, mrt.src_expinfo,
 +                                    mrt.move.hvparams, mrt.move.beparams,
-                                     mrt.move.beparams, mrt.move.nics,
++                                    mrt.move.osparams, mrt.move.nics,
 +                                    is_attempt_opportunistic
 +                                    )
 +
 +      try:
 +        # The completion of this block signifies that the import has been
 +        # completed successfullly
 +        mrt.PollJob(dest_client, job_id,
 +                    remote_import_fn=compat.partial(self._SetImportInfo, mrt))
 +        logging.info("Import successful")
 +        return
 +      except errors.OpPrereqError, err:
 +        # Any exception in the non-opportunistic creation is to be passed on,
 +        # as well as exceptions apart from resources temporarily unavailable
 +        if not is_attempt_opportunistic or \
 +           err.args[1] != rapi.client.ECODE_TEMP_NORES:
 +          raise
 +
 +      delay_to_use = MoveDestExecutor._VaryDelay(mrt)
 +      logging.info("Opportunistic attempt unsuccessful, waiting %.2f seconds"
 +                   " before another creation attempt is made",
 +                   delay_to_use)
 +      time.sleep(delay_to_use)
 +
 +  @staticmethod
 +  def _VaryDelay(mrt):
 +    """ Varies the opportunistic delay by a small amount.
 +
 +    """
 +    MAX_VARIATION = 0.15
 +    variation_factor = (1.0 + random.uniform(-MAX_VARIATION, MAX_VARIATION))
 +    return mrt.move.opportunistic_delay * variation_factor
  
    @staticmethod
    def _SetImportInfo(mrt, impinfo):