Revision 1d67656e

b/doc/hooks.sgml
256 256
              <entry>Remove an instance</entry>
257 257
              <entry><computeroutput>gnt-instance remove</computeroutput></entry>
258 258
              <entry><constant>INSTANCE_NAME</constant>, <constant>INSTANCE_PRIMARY</constant>, <constant>INSTANCE_SECONDARIES</constant></entry>
259
              <entry spanname="bothhooks">master node</entry>
259 260
            </row>
260 261
            <row>
261 262
              <entry>OP_INSTANCE_ADD_MDDRBD</entry>
b/lib/cmdlib.py
2193 2193

  
2194 2194
    """
2195 2195
    env = _BuildInstanceHookEnvByObject(self.instance)
2196
    nl = ([self.sstore.GetMasterNode(), self.instance.primary_node] +
2197
          list(self.instance.secondary_nodes))
2196
    nl = [self.sstore.GetMasterNode()]
2198 2197
    return env, nl, nl
2199 2198

  
2200 2199
  def CheckPrereq(self):
......
2219 2218
                (instance.name, instance.primary_node))
2220 2219

  
2221 2220
    if not rpc.call_instance_shutdown(instance.primary_node, instance):
2222
      raise errors.OpExecError("Could not shutdown instance %s on node %s" %
2223
                               (instance.name, instance.primary_node))
2221
      if self.op.ignore_failures:
2222
        feedback_fn("Warning: can't shutdown instance")
2223
      else:
2224
        raise errors.OpExecError("Could not shutdown instance %s on node %s" %
2225
                                 (instance.name, instance.primary_node))
2224 2226

  
2225 2227
    logger.Info("removing block devices for instance %s" % instance.name)
2226 2228

  
2227
    _RemoveDisks(instance, self.cfg)
2229
    if not _RemoveDisks(instance, self.cfg):
2230
      if self.op.ignore_failures:
2231
        feedback_fn("Warning: can't remove instance's disks")
2232
      else:
2233
        raise errors.OpExecError("Can't remove instance's disks")
2228 2234

  
2229 2235
    logger.Info("removing instance %s out of cluster config" % instance.name)
2230 2236

  
......
2649 2655

  
2650 2656
  This abstracts away some work from `AddInstance()` and
2651 2657
  `RemoveInstance()`. Note that in case some of the devices couldn't
2652
  be remove, the removal will continue with the other ones (compare
2658
  be removed, the removal will continue with the other ones (compare
2653 2659
  with `_CreateDisks()`).
2654 2660

  
2655 2661
  Args:
b/lib/opcodes.py
150 150
class OpRemoveInstance(OpCode):
151 151
  """Remove an instance."""
152 152
  OP_ID = "OP_INSTANCE_REMOVE"
153
  __slots__ = ["instance_name"]
153
  __slots__ = ["instance_name", "ignore_failures"]
154 154

  
155 155

  
156 156
class OpRenameInstance(OpCode):
b/man/gnt-instance.sgml
196 196

  
197 197
        <cmdsynopsis>
198 198
          <command>remove</command>
199
          <arg>--ignore-failures</arg>
199 200
          <arg choice="req"><replaceable>instance</replaceable></arg>
200 201
        </cmdsynopsis>
201 202

  
......
205 206
          you are not sure if you use an instance again, use
206 207
          <command>shutdown</command> first and leave it in the
207 208
          shutdown state for a while.
209

  
210
        </para>
211

  
212
        <para>
213
          The <option>--ignore-failures</option> option will cause the
214
          removal to proceed even in the presence of errors during the
215
          removal of the instance (e.g. during the shutdown or the
216
          disk removal). If this option is not given, the command will
217
          stop at the first error.
208 218
        </para>
209 219

  
210 220
        <para>
b/scripts/gnt-instance
270 270
    if not AskUser(usertext):
271 271
      return 1
272 272

  
273
  op = opcodes.OpRemoveInstance(instance_name=instance_name)
273
  op = opcodes.OpRemoveInstance(instance_name=instance_name,
274
                                ignore_failures=opts.ignore_failures)
274 275
  SubmitOpCode(op)
275 276
  return 0
276 277

  
......
689 690
           "", "Lists the instances and their status"),
690 691
  'reinstall': (ReinstallInstance, ARGS_ONE, [DEBUG_OPT, FORCE_OPT, os_opt],
691 692
                "[-f] <instance>", "Reinstall the instance"),
692
  'remove': (RemoveInstance, ARGS_ONE, [DEBUG_OPT, FORCE_OPT],
693
  'remove': (RemoveInstance, ARGS_ONE,
694
             [DEBUG_OPT, FORCE_OPT,
695
              make_option("--ignore-failures", dest="ignore_failures",
696
                          action="store_true", default=False,
697
                          help=("Remove the instance from the cluster even"
698
                                " if there are failures during the removal"
699
                                " process (shutdown, disk removal, etc.)")),
700
              ],
693 701
             "[-f] <instance>", "Shuts down the instance and removes it"),
694 702
  'remove-mirror': (RemoveMDDRBDComponent, ARGS_ONE,
695 703
                   [DEBUG_OPT, node_opt,

Also available in: Unified diff