Revision 1c4910f7

b/lib/cmdlib/common.py
389 389
    if isinstance(osparams[key], Private):
390 390
      osparams[key] = osparams[key].Get()
391 391

  
392
  result = lu.rpc.call_os_validate(node_uuids, required, osname,
393
                                   [constants.OS_VALIDATE_PARAMETERS],
394
                                   osparams)
395
  for node_uuid, nres in result.items():
396
    # we don't check for offline cases since this should be run only
397
    # against the master node and/or an instance's nodes
398
    nres.Raise("OS Parameters validation failed on node %s" %
399
               lu.cfg.GetNodeName(node_uuid))
400
    if not nres.payload:
401
      lu.LogInfo("OS %s not found on node %s, validation skipped",
402
                 osname, lu.cfg.GetNodeName(node_uuid))
392
  if osname:
393
    result = lu.rpc.call_os_validate(node_uuids, required, osname,
394
                                     [constants.OS_VALIDATE_PARAMETERS],
395
                                     osparams)
396
    for node_uuid, nres in result.items():
397
      # we don't check for offline cases since this should be run only
398
      # against the master node and/or an instance's nodes
399
      nres.Raise("OS Parameters validation failed on node %s" %
400
                 lu.cfg.GetNodeName(node_uuid))
401
      if not nres.payload:
402
        lu.LogInfo("OS %s not found on node %s, validation skipped",
403
                   osname, lu.cfg.GetNodeName(node_uuid))
403 404

  
404 405

  
405 406
def CheckOSImage(op):
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:
b/lib/objects.py
1959 1959
        unless the respective optional parameters are supplied.
1960 1960

  
1961 1961
    """
1962
    name_only = OS.GetName(os_name)
1962
    if os_name is None:
1963
      name_only = None
1964
    else:
1965
      name_only = OS.GetName(os_name)
1963 1966

  
1964 1967
    defaults_base_public = self.osparams.get(name_only, {})
1965 1968
    defaults_public = FillDict(defaults_base_public,
b/test/py/cmdlib/instance_unittest.py
383 383
  def testMissingOsType(self):
384 384
    op = self.CopyOpCode(self.diskless_op,
385 385
                         os_type=self.REMOVE)
386
    self.ExecOpCodeExpectOpPrereqError(op, "No guest OS specified")
386
    self.ExecOpCodeExpectOpPrereqError(op, "No guest OS or OS image specified")
387 387

  
388 388
  def testBlacklistedOs(self):
389 389
    self.cluster.blacklisted_os = [self.os_name_variant]

Also available in: Unified diff