Revision 2cfbc784 lib/cmdlib.py

b/lib/cmdlib.py
1655 1655
                                 " cluster-wide default iallocator found;"
1656 1656
                                 " please specify either an iallocator or a"
1657 1657
                                 " node, or set a cluster-wide default"
1658
                                 " iallocator")
1658
                                 " iallocator", errors.ECODE_INVAL)
1659 1659

  
1660 1660

  
1661 1661
def _GetDefaultIAllocator(cfg, iallocator):
......
3827 3827
    ipcls = netutils.IPAddress.GetClassFromIpFamily(ip_family)
3828 3828
  except errors.ProgrammerError:
3829 3829
    raise errors.OpPrereqError("Invalid primary ip family: %s." %
3830
                               ip_family)
3830
                               ip_family, errors.ECODE_INVAL)
3831 3831
  if not ipcls.ValidateNetmask(netmask):
3832 3832
    raise errors.OpPrereqError("CIDR netmask (%s) not valid" %
3833
                                (netmask))
3833
                                (netmask), errors.ECODE_INVAL)
3834 3834

  
3835 3835

  
3836 3836
class LUClusterSetParams(LogicalUnit):
......
4029 4029
                              " address" % (instance.name, nic_idx))
4030 4030
      if nic_errors:
4031 4031
        raise errors.OpPrereqError("Cannot apply the change, errors:\n%s" %
4032
                                   "\n".join(nic_errors))
4032
                                   "\n".join(nic_errors), errors.ECODE_INVAL)
4033 4033

  
4034 4034
    # hypervisor list/parameters
4035 4035
    self.new_hvparams = new_hvp = objects.FillDict(cluster.hvparams, {})
......
5957 5957
                                           self.op.powered == True):
5958 5958
        raise errors.OpPrereqError(("Node %s needs to be turned on before its"
5959 5959
                                    " offline status can be reset") %
5960
                                   self.op.node_name)
5960
                                   self.op.node_name, errors.ECODE_STATE)
5961 5961
    elif self.op.powered is not None:
5962 5962
      raise errors.OpPrereqError(("Unable to change powered state for node %s"
5963 5963
                                  " as it does not support out-of-band"
5964
                                  " handling") % self.op.node_name)
5964
                                  " handling") % self.op.node_name,
5965
                                 errors.ECODE_STATE)
5965 5966

  
5966 5967
    # If we're being deofflined/drained, we'll MC ourself if needed
5967 5968
    if (self.op.drained == False or self.op.offline == False or
......
6038 6039

  
6039 6040
      if node.offline:
6040 6041
        if affected_instances:
6041
          raise errors.OpPrereqError("Cannot change secondary IP address:"
6042
                                     " offline node has instances (%s)"
6043
                                     " configured to use it" %
6044
                                     utils.CommaJoin(affected_instances.keys()))
6042
          msg = ("Cannot change secondary IP address: offline node has"
6043
                 " instances (%s) configured to use it" %
6044
                 utils.CommaJoin(affected_instances.keys()))
6045
          raise errors.OpPrereqError(msg, errors.ECODE_STATE)
6045 6046
      else:
6046 6047
        # On online nodes, check that no instances are running, and that
6047 6048
        # the node has the new ip and we can reach it.
......
8142 8143
      if self.target_node == instance.primary_node:
8143 8144
        raise errors.OpPrereqError("Cannot migrate instance %s"
8144 8145
                                   " to its primary (%s)" %
8145
                                   (instance.name, instance.primary_node))
8146
                                   (instance.name, instance.primary_node),
8147
                                   errors.ECODE_STATE)
8146 8148

  
8147 8149
      if len(self.lu.tasklets) == 1:
8148 8150
        # It is safe to release locks only when we're the only tasklet
......
9670 9672
        if self.op.disk_template not in constants.DISK_TEMPLATES:
9671 9673
          raise errors.OpPrereqError("Disk template specified in configuration"
9672 9674
                                     " file is not one of the allowed values:"
9673
                                     " %s" % " ".join(constants.DISK_TEMPLATES))
9675
                                     " %s" %
9676
                                     " ".join(constants.DISK_TEMPLATES),
9677
                                     errors.ECODE_INVAL)
9674 9678
      else:
9675 9679
        raise errors.OpPrereqError("No disk template specified and the export"
9676 9680
                                   " is missing the disk_template information",
......
9783 9787

  
9784 9788
      cfg_storagedir = get_fsd_fn()
9785 9789
      if not cfg_storagedir:
9786
        raise errors.OpPrereqError("Cluster file storage dir not defined")
9790
        raise errors.OpPrereqError("Cluster file storage dir not defined",
9791
                                   errors.ECODE_STATE)
9787 9792
      joinargs.append(cfg_storagedir)
9788 9793

  
9789 9794
      if self.op.file_storage_dir is not None:
......
12654 12659
            raise errors.OpPrereqError("This change will prevent the instance"
12655 12660
                                       " from starting, due to %d MB of memory"
12656 12661
                                       " missing on its primary node" %
12657
                                       miss_mem,
12658
                                       errors.ECODE_NORES)
12662
                                       miss_mem, errors.ECODE_NORES)
12659 12663

  
12660 12664
      if be_new[constants.BE_AUTO_BALANCE]:
12661 12665
        for node, nres in nodeinfo.items():
......
12681 12685
                                                instance.hypervisor)
12682 12686
      remote_info.Raise("Error checking node %s" % instance.primary_node)
12683 12687
      if not remote_info.payload: # not running already
12684
        raise errors.OpPrereqError("Instance %s is not running" % instance.name,
12685
                                   errors.ECODE_STATE)
12688
        raise errors.OpPrereqError("Instance %s is not running" %
12689
                                   instance.name, errors.ECODE_STATE)
12686 12690

  
12687 12691
      current_memory = remote_info.payload["memory"]
12688 12692
      if (not self.op.force and
......
12704 12708

  
12705 12709
    if self.op.disks and instance.disk_template == constants.DT_DISKLESS:
12706 12710
      raise errors.OpPrereqError("Disk operations not supported for"
12707
                                 " diskless instances",
12708
                                 errors.ECODE_INVAL)
12711
                                 " diskless instances", errors.ECODE_INVAL)
12709 12712

  
12710 12713
    def _PrepareNicCreate(_, params, private):
12711 12714
      self._PrepareNicModification(params, private, None, {}, cluster, pnode)
......
13212 13215
      raise errors.OpPrereqError("Can't compute solution for changing group of"
13213 13216
                                 " instance '%s' using iallocator '%s': %s" %
13214 13217
                                 (self.op.instance_name, self.op.iallocator,
13215
                                  ial.info),
13216
                                 errors.ECODE_NORES)
13218
                                  ial.info), errors.ECODE_NORES)
13217 13219

  
13218 13220
    jobs = _LoadNodeEvacResult(self, ial.result, self.op.early_release, False)
13219 13221

  
......
13442 13444
        self.instance.admin_state == constants.ADMINST_UP and
13443 13445
        not self.op.shutdown):
13444 13446
      raise errors.OpPrereqError("Can not remove instance without shutting it"
13445
                                 " down before")
13447
                                 " down before", errors.ECODE_STATE)
13446 13448

  
13447 13449
    if self.op.mode == constants.EXPORT_MODE_LOCAL:
13448 13450
      self.op.target_node = _ExpandNodeName(self.cfg, self.op.target_node)
......
13472 13474
      try:
13473 13475
        (key_name, hmac_digest, hmac_salt) = self.x509_key_name
13474 13476
      except (TypeError, ValueError), err:
13475
        raise errors.OpPrereqError("Invalid data for X509 key name: %s" % err)
13477
        raise errors.OpPrereqError("Invalid data for X509 key name: %s" % err,
13478
                                   errors.ECODE_INVAL)
13476 13479

  
13477 13480
      if not utils.VerifySha1Hmac(cds, key_name, hmac_digest, salt=hmac_salt):
13478 13481
        raise errors.OpPrereqError("HMAC for X509 key name is wrong",
......
14227 14230

  
14228 14231
    # Verify the cluster would not be left group-less.
14229 14232
    if len(self.cfg.GetNodeGroupList()) == 1:
14230
      raise errors.OpPrereqError("Group '%s' is the only group,"
14231
                                 " cannot be removed" %
14232
                                 self.op.group_name,
14233
      raise errors.OpPrereqError("Group '%s' is the only group, cannot be"
14234
                                 " removed" % self.op.group_name,
14233 14235
                                 errors.ECODE_STATE)
14234 14236

  
14235 14237
  def BuildHooksEnv(self):

Also available in: Unified diff