Revision 72080db1

b/lib/cmdlib/instance.py
327 327

  
328 328
    """
329 329
    cluster = self.cfg.GetClusterInfo()
330
    if self.op.disk_template is None:
331
      # FIXME: It would be better to take the default disk template from the
332
      # ipolicy, but for the ipolicy we need the primary node, which we get from
333
      # the iallocator, which wants the disk template as input. To solve this
334
      # chicken-and-egg problem, it should be possible to specify just a node
335
      # group from the iallocator and take the ipolicy from that.
336
      self.op.disk_template = cluster.enabled_disk_templates[0]
330 337
    if not self.op.disk_template in cluster.enabled_disk_templates:
331 338
      raise errors.OpPrereqError("Cannot create an instance with disk template"
332 339
                                 " '%s', because it is not enabled in the"
......
713 720
    """
714 721
    self.op.os_type = einfo.get(constants.INISECT_EXP, "os")
715 722

  
716
    if self.op.disk_template is None:
717
      if einfo.has_option(constants.INISECT_INS, "disk_template"):
718
        self.op.disk_template = einfo.get(constants.INISECT_INS,
719
                                          "disk_template")
720
        if self.op.disk_template not in constants.DISK_TEMPLATES:
721
          raise errors.OpPrereqError("Disk template specified in configuration"
722
                                     " file is not one of the allowed values:"
723
                                     " %s" %
724
                                     " ".join(constants.DISK_TEMPLATES),
725
                                     errors.ECODE_INVAL)
726
      else:
727
        raise errors.OpPrereqError("No disk template specified and the export"
728
                                   " is missing the disk_template information",
729
                                   errors.ECODE_INVAL)
730

  
731 723
    if not self.op.disks:
732 724
      disks = []
733 725
      # TODO: import the disk iv_name too

Also available in: Unified diff