Revision 76aef8fc

b/lib/cmdlib.py
6441 6441
    self._RemoveOldStorage(self.target_node, iv_names)
6442 6442

  
6443 6443

  
6444
class LURepairNodeStorage(NoHooksLU):
6445
  """Repairs the volume group on a node.
6446

  
6447
  """
6448
  _OP_REQP = ["node_name"]
6449
  REQ_BGL = False
6450

  
6451
  def CheckArguments(self):
6452
    node_name = self.cfg.ExpandNodeName(self.op.node_name)
6453
    if node_name is None:
6454
      raise errors.OpPrereqError("Invalid node name '%s'" % self.op.node_name)
6455

  
6456
    self.op.node_name = node_name
6457

  
6458
  def ExpandNames(self):
6459
    self.needed_locks = {
6460
      locking.LEVEL_NODE: [self.op.node_name],
6461
      }
6462

  
6463
  def _CheckFaultyDisks(self, instance, node_name):
6464
    if _FindFaultyInstanceDisks(self.cfg, self.rpc, instance,
6465
                                node_name, True):
6466
      raise errors.OpPrereqError("Instance '%s' has faulty disks on"
6467
                                 " node '%s'" % (inst.name, node_name))
6468

  
6469
  def CheckPrereq(self):
6470
    """Check prerequisites.
6471

  
6472
    """
6473
    storage_type = self.op.storage_type
6474

  
6475
    if (constants.SO_FIX_CONSISTENCY not in
6476
        constants.VALID_STORAGE_OPERATIONS.get(storage_type, [])):
6477
      raise errors.OpPrereqError("Storage units of type '%s' can not be"
6478
                                 " repaired" % storage_type)
6479

  
6480
    # Check whether any instance on this node has faulty disks
6481
    for inst in _GetNodeInstances(self.cfg, self.op.node_name):
6482
      check_nodes = set(inst.all_nodes)
6483
      check_nodes.discard(self.op.node_name)
6484
      for inst_node_name in check_nodes:
6485
        self._CheckFaultyDisks(inst, inst_node_name)
6486

  
6487
  def Exec(self, feedback_fn):
6488
    feedback_fn("Repairing storage unit '%s' on %s ..." %
6489
                (self.op.name, self.op.node_name))
6490

  
6491
    st_args = _GetStorageTypeArgs(self.cfg, self.op.storage_type)
6492
    result = self.rpc.call_storage_execute(self.op.node_name,
6493
                                           self.op.storage_type, st_args,
6494
                                           self.op.name,
6495
                                           constants.SO_FIX_CONSISTENCY)
6496
    result.Raise("Failed to repair storage unit '%s' on %s" %
6497
                 (self.op.name, self.op.node_name))
6498

  
6499

  
6444 6500
class LUGrowDisk(LogicalUnit):
6445 6501
  """Grow a disk of an instance.
6446 6502

  
b/lib/mcpu.py
58 58
    opcodes.OpQueryNodeVolumes: cmdlib.LUQueryNodeVolumes,
59 59
    opcodes.OpQueryNodeStorage: cmdlib.LUQueryNodeStorage,
60 60
    opcodes.OpModifyNodeStorage: cmdlib.LUModifyNodeStorage,
61
    opcodes.OpRepairNodeStorage: cmdlib.LURepairNodeStorage,
61 62
    opcodes.OpRemoveNode: cmdlib.LURemoveNode,
62 63
    opcodes.OpSetNodeParams: cmdlib.LUSetNodeParams,
63 64
    opcodes.OpPowercycleNode: cmdlib.LUPowercycleNode,
b/lib/opcodes.py
381 381
    ]
382 382

  
383 383

  
384
class OpRepairNodeStorage(OpCode):
385
  """Repairs the volume group on a node."""
386
  OP_ID = "OP_REPAIR_NODE_STORAGE"
387
  OP_DSC_FIELD = "node_name"
388
  __slots__ = OpCode.__slots__ + [
389
    "node_name",
390
    "storage_type",
391
    "name",
392
    ]
393

  
394

  
384 395
class OpSetNodeParams(OpCode):
385 396
  """Change the parameters of a node."""
386 397
  OP_ID = "OP_NODE_SET_PARAMS"
......
680 691
    "os", "tags", "nics", "vcpus", "hypervisor",
681 692
    ]
682 693

  
694

  
683 695
OP_MAPPING = dict([(v.OP_ID, v) for v in globals().values()
684 696
                   if (isinstance(v, type) and issubclass(v, OpCode) and
685 697
                       hasattr(v, "OP_ID"))])

Also available in: Unified diff