Revision dab6ea3d

b/lib/cmdlib/instance.py
322 322
  HTYPE = constants.HTYPE_INSTANCE
323 323
  REQ_BGL = False
324 324

  
325
  def CheckArguments(self):
326
    """Check arguments.
325
  def _CheckDiskTemplateValid(self):
326
    """Checks validity of disk template.
327 327

  
328 328
    """
329
    # do not require name_check to ease forward/backward compatibility
330
    # for tools
331
    if self.op.no_install and self.op.start:
332
      self.LogInfo("No-installation mode selected, disabling startup")
333
      self.op.start = False
334
    # validate/normalize the instance name
335
    self.op.instance_name = \
336
      netutils.Hostname.GetNormalizedName(self.op.instance_name)
337

  
338
    if self.op.ip_check and not self.op.name_check:
339
      # TODO: make the ip check more flexible and not depend on the name check
340
      raise errors.OpPrereqError("Cannot do IP address check without a name"
341
                                 " check", errors.ECODE_INVAL)
342

  
343
    # check nics' parameter names
344
    for nic in self.op.nics:
345
      utils.ForceDictType(nic, constants.INIC_PARAMS_TYPES)
346
    # check that NIC's parameters names are unique and valid
347
    utils.ValidateDeviceNames("NIC", self.op.nics)
348

  
349
    # check that disk's names are unique and valid
350
    utils.ValidateDeviceNames("disk", self.op.disks)
351

  
352 329
    cluster = self.cfg.GetClusterInfo()
353 330
    if not self.op.disk_template in cluster.enabled_disk_templates:
354 331
      raise errors.OpPrereqError("Cannot create an instance with disk template"
......
357 334
                                 (self.op.disk_template,
358 335
                                  ",".join(cluster.enabled_disk_templates)))
359 336

  
337
  def _CheckDiskArguments(self):
338
    """Checks validity of disk-related arguments.
339

  
340
    """
341
    # check that disk's names are unique and valid
342
    utils.ValidateDeviceNames("disk", self.op.disks)
343

  
344
    self._CheckDiskTemplateValid()
345

  
360 346
    # check disks. parameter names and consistent adopt/no-adopt strategy
361 347
    has_adopt = has_no_adopt = False
362 348
    for disk in self.op.disks:
......
390 376

  
391 377
    self.adopt_disks = has_adopt
392 378

  
379
  def CheckArguments(self):
380
    """Check arguments.
381

  
382
    """
383
    # do not require name_check to ease forward/backward compatibility
384
    # for tools
385
    if self.op.no_install and self.op.start:
386
      self.LogInfo("No-installation mode selected, disabling startup")
387
      self.op.start = False
388
    # validate/normalize the instance name
389
    self.op.instance_name = \
390
      netutils.Hostname.GetNormalizedName(self.op.instance_name)
391

  
392
    if self.op.ip_check and not self.op.name_check:
393
      # TODO: make the ip check more flexible and not depend on the name check
394
      raise errors.OpPrereqError("Cannot do IP address check without a name"
395
                                 " check", errors.ECODE_INVAL)
396

  
397
    # check nics' parameter names
398
    for nic in self.op.nics:
399
      utils.ForceDictType(nic, constants.INIC_PARAMS_TYPES)
400
    # check that NIC's parameters names are unique and valid
401
    utils.ValidateDeviceNames("NIC", self.op.nics)
402

  
403
    self._CheckDiskArguments()
404

  
393 405
    # instance name verification
394 406
    if self.op.name_check:
395 407
      self.hostname = _CheckHostnameSane(self, self.op.instance_name)

Also available in: Unified diff