Revision 1c4910f7 lib/cmdlib/instance.py

b/lib/cmdlib/instance.py
48 48
  INSTANCE_NOT_RUNNING, CAN_CHANGE_INSTANCE_OFFLINE, CheckNodeOnline, \
49 49
  ShareAll, GetDefaultIAllocator, CheckInstanceNodeGroups, \
50 50
  LoadNodeEvacResult, CheckIAllocatorOrNode, CheckParamsNotGlobal, \
51
  IsExclusiveStorageEnabledNode, CheckHVParams, CheckOSParams, \
51
  IsExclusiveStorageEnabledNode, CheckHVParams, CheckOSParams, CheckOSImage, \
52 52
  AnnotateDiskParams, GetUpdatedParams, ExpandInstanceUuidAndName, \
53 53
  ComputeIPolicySpecViolation, CheckInstanceState, ExpandNodeUuidAndName, \
54 54
  CheckDiskTemplateEnabled, IsValidDiskAccessModeCombination
......
494 494
      if self.op.no_install:
495 495
        self.LogInfo("No-installation mode has no effect during import")
496 496

  
497
      if objects.GetOSImage(self.op.osparams):
498
        self.LogInfo("OS image has no effect during import")
497 499
    elif self.op.mode == constants.INSTANCE_CREATE:
498
      if self.op.os_type is None:
499
        raise errors.OpPrereqError("No guest OS specified",
500
      os_image = CheckOSImage(self.op)
501

  
502
      if self.op.os_type is None and os_image is None:
503
        raise errors.OpPrereqError("No guest OS or OS image specified",
500 504
                                   errors.ECODE_INVAL)
501
      if self.op.os_type in self.cfg.GetClusterInfo().blacklisted_os:
505

  
506
      if self.op.os_type is not None \
507
            and self.op.os_type in self.cfg.GetClusterInfo().blacklisted_os:
502 508
        raise errors.OpPrereqError("Guest OS '%s' is not allowed for"
503 509
                                   " installation" % self.op.os_type,
504 510
                                   errors.ECODE_STATE)
505 511
    elif self.op.mode == constants.INSTANCE_REMOTE_IMPORT:
512
      if objects.GetOSImage(self.op.osparams):
513
        self.LogInfo("OS image has no effect during import")
514

  
506 515
      self._cds = GetClusterDomainSecret()
507 516

  
508 517
      # Check handshake to ensure both clusters have the same domain secret
......
1301 1310

  
1302 1311
    CheckHVParams(self, node_uuids, self.op.hypervisor, self.op.hvparams)
1303 1312

  
1304
    CheckNodeHasOS(self, pnode.uuid, self.op.os_type, self.op.force_variant)
1313
    if self.op.os_type is not None:
1314
      CheckNodeHasOS(self, pnode.uuid, self.op.os_type, self.op.force_variant)
1315

  
1305 1316
    # check OS parameters (remotely)
1306 1317
    CheckOSParams(self, True, node_uuids, self.op.os_type, self.os_full)
1307 1318

  
......
1403 1414
                                 feedback_fn,
1404 1415
                                 self.cfg.GetGroupDiskParams(nodegroup))
1405 1416

  
1417
    if self.op.os_type is None:
1418
      os_type = ""
1419
    else:
1420
      os_type = self.op.os_type
1421

  
1406 1422
    iobj = objects.Instance(name=self.op.instance_name,
1407 1423
                            uuid=instance_uuid,
1408
                            os=self.op.os_type,
1424
                            os=os_type,
1409 1425
                            primary_node=self.pnode.uuid,
1410 1426
                            nics=self.nics, disks=disks,
1411 1427
                            disk_template=self.op.disk_template,
......
1502 1518

  
1503 1519
    if iobj.disk_template != constants.DT_DISKLESS and not self.adopt_disks:
1504 1520
      if self.op.mode == constants.INSTANCE_CREATE:
1505
        if not self.op.no_install:
1521
        os_image = objects.GetOSImage(self.op.osparams)
1522

  
1523
        if os_image is None and not self.op.no_install:
1506 1524
          pause_sync = (iobj.disk_template in constants.DTS_INT_MIRROR and
1507 1525
                        not self.op.wait_for_sync)
1508 1526
          if pause_sync:

Also available in: Unified diff