Revision 445f735d lib/cmdlib.py

b/lib/cmdlib.py
3184 3184
  return result
3185 3185

  
3186 3186

  
3187
class LUOutOfBand(NoHooksLU):
3188
  """Logical unit for OOB handling.
3189

  
3190
  """
3191
  _OP_PARAMS = [
3192
    _PNodeName,
3193
    ("command", None, ht.TElemOf(constants.OOB_COMMANDS)),
3194
    ("timeout", constants.OOB_TIMEOUT, ht.TInt),
3195
    ]
3196
  REG_BGL = False
3197

  
3198
  def CheckPrereq(self):
3199
    """Check prerequisites.
3200

  
3201
    This checks:
3202
     - the node exists in the configuration
3203
     - OOB is supported
3204

  
3205
    Any errors are signaled by raising errors.OpPrereqError.
3206

  
3207
    """
3208
    self.op.node_name = _ExpandNodeName(self.cfg, self.op.node_name)
3209
    node = self.cfg.GetNodeInfo(self.op.node_name)
3210

  
3211
    if node is None:
3212
      raise errors.OpPrereqError("Node %s not found" % self.op.node_name)
3213

  
3214
    self.oob_program = self.cfg.GetOobProgram(node)
3215

  
3216
    if not self.oob_program:
3217
      raise errors.OpPrereqError("OOB is not supported for node %s" %
3218
                                 self.op.node_name)
3219

  
3220
    self.op.node_name = node.name
3221
    self.node = node
3222

  
3223
  def ExpandNames(self):
3224
    """Gather locks we need.
3225

  
3226
    """
3227
    self.needed_locks = {
3228
      locking.LEVEL_NODE: [self.op.node_name],
3229
      }
3230

  
3231
  def Exec(self, feedback_fn):
3232
    """Execute OOB and return result if we expect any.
3233

  
3234
    """
3235
    master_node = self.cfg.GetMasterNode()
3236

  
3237
    logging.info("Executing out-of-band command '%s' using '%s' on %s",
3238
                 self.op.command, self.oob_program, self.op.node_name)
3239
    result = self.rpc.call_run_oob(master_node, self.oob_program,
3240
                                   self.op.command, self.op.node_name,
3241
                                   self.op.timeout)
3242

  
3243
    result.Raise("An error occurred on execution of OOB helper")
3244

  
3245
    if self.op.command == constants.OOB_HEALTH:
3246
      # For health we should log important events
3247
      for item, status in result.payload:
3248
        if status in [constants.OOB_STATUS_WARNING,
3249
                      constants.OOB_STATUS_CRITICAL]:
3250
          logging.warning("On node '%s' item '%s' has status '%s'",
3251
                          self.op.node_name, item, status)
3252

  
3253
    return result.payload
3254

  
3255

  
3187 3256
class LUDiagnoseOS(NoHooksLU):
3188 3257
  """Logical unit for OS diagnose/query.
3189 3258

  

Also available in: Unified diff