opcodes.py 53.8 KB
Newer Older
Iustin Pop's avatar
Iustin Pop committed
1
#
Iustin Pop's avatar
Iustin Pop committed
2
3
#

4
# Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011 Google Inc.
Iustin Pop's avatar
Iustin Pop committed
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
# 02110-1301, USA.


"""OpCodes module

This module implements the data structures which define the cluster
operations - the so-called opcodes.

Iustin Pop's avatar
Iustin Pop committed
27
28
Every operation which modifies the cluster state is expressed via
opcodes.
Iustin Pop's avatar
Iustin Pop committed
29
30
31
32
33

"""

# this are practically structures, so disable the message about too
# few public methods:
34
# pylint: disable=R0903
Iustin Pop's avatar
Iustin Pop committed
35

36
import logging
37
import re
38

39
40
41
42
43
44
45
46
from ganeti import constants
from ganeti import errors
from ganeti import ht


# Common opcode attributes

#: output fields for a query operation
47
_POutputFields = ("output_fields", ht.NoDefault, ht.TListOf(ht.TNonEmptyString),
48
                  "Selected output fields")
49
50

#: the shutdown timeout
51
52
53
_PShutdownTimeout = \
  ("shutdown_timeout", constants.DEFAULT_SHUTDOWN_TIMEOUT, ht.TPositiveInt,
   "How long to wait for instance to shut down")
54
55

#: the force parameter
56
_PForce = ("force", False, ht.TBool, "Whether to force the operation")
57
58

#: a required instance name (for single-instance LUs)
59
60
_PInstanceName = ("instance_name", ht.NoDefault, ht.TNonEmptyString,
                  "Instance name")
61
62

#: Whether to ignore offline nodes
63
64
_PIgnoreOfflineNodes = ("ignore_offline_nodes", False, ht.TBool,
                        "Whether to ignore offline nodes")
65
66

#: a required node name (for single-node LUs)
67
_PNodeName = ("node_name", ht.NoDefault, ht.TNonEmptyString, "Node name")
68
69

#: a required node group name (for single-group LUs)
70
_PGroupName = ("group_name", ht.NoDefault, ht.TNonEmptyString, "Group name")
71
72
73

#: Migration type (live/non-live)
_PMigrationMode = ("mode", None,
74
                   ht.TOr(ht.TNone, ht.TElemOf(constants.HT_MIGRATION_MODES)),
75
                   "Migration mode")
76
77

#: Obsolete 'live' migration mode (boolean)
78
79
_PMigrationLive = ("live", None, ht.TMaybeBool,
                   "Legacy setting for live migration, do not use")
80
81

#: Tag type
82
_PTagKind = ("kind", ht.NoDefault, ht.TElemOf(constants.VALID_TAG_TYPES), None)
83
84

#: List of tag strings
85
_PTags = ("tags", ht.NoDefault, ht.TListOf(ht.TNonEmptyString), None)
86

87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
_PForceVariant = ("force_variant", False, ht.TBool,
                  "Whether to force an unknown OS variant")

_PWaitForSync = ("wait_for_sync", True, ht.TBool,
                 "Whether to wait for the disk to synchronize")

_PIgnoreConsistency = ("ignore_consistency", False, ht.TBool,
                       "Whether to ignore disk consistency")

_PStorageName = ("name", ht.NoDefault, ht.TMaybeString, "Storage name")

_PUseLocking = ("use_locking", False, ht.TBool,
                "Whether to use synchronization")

_PNameCheck = ("name_check", True, ht.TBool, "Whether to check name")

_PNodeGroupAllocPolicy = \
  ("alloc_policy", None,
   ht.TOr(ht.TNone, ht.TElemOf(constants.VALID_ALLOC_POLICIES)),
   "Instance allocation policy")

_PGroupNodeParams = ("ndparams", None, ht.TMaybeDict,
                     "Default node parameters for group")

111
_PQueryWhat = ("what", ht.NoDefault, ht.TElemOf(constants.QR_VIA_OP),
112
113
               "Resource(s) to query for")

114
115
116
_PEarlyRelease = ("early_release", False, ht.TBool,
                  "Whether to release locks as soon as possible")

117
118
_PIpCheckDoc = "Whether to ensure instance's IP address is inactive"

119
#: Do not remember instance state changes
120
121
_PNoRemember = ("no_remember", False, ht.TBool,
                "Do not remember the state change")
122

Michael Hanselmann's avatar
Michael Hanselmann committed
123
124
125
126
#: Target node for instance migration/failover
_PMigrationTargetNode = ("target_node", None, ht.TMaybeString,
                         "Target node for shared-storage instances")

127
128
129
_PStartupPaused = ("startup_paused", False, ht.TBool,
                   "Pause instance at startup")

130
131
132
133
134
135
136
137
138
_PVerbose = ("verbose", False, ht.TBool, "Verbose mode")

# Parameters for cluster verification
_PDebugSimulateErrors = ("debug_simulate_errors", False, ht.TBool,
                         "Whether to simulate errors (useful for debugging)")
_PErrorCodes = ("error_codes", False, ht.TBool, "Error codes")
_PSkipChecks = ("skip_checks", ht.EmptyList,
                ht.TListOf(ht.TElemOf(constants.VERIFY_OPTIONAL_CHECKS)),
                "Which checks to skip")
139
140
141
_PIgnoreErrors = ("ignore_errors", ht.EmptyList,
                  ht.TListOf(ht.TElemOf(constants.CV_ALL_ECODES_STRINGS)),
                  "List of error codes that should be treated as warnings")
142

143
144
145
146
147
148
149
# Disk parameters
_PDiskParams = ("diskparams", None,
                ht.TOr(
                  ht.TDictOf(ht.TElemOf(constants.DISK_TEMPLATES), ht.TDict),
                  ht.TNone),
                "Disk templates' parameter defaults")

150
151
152
153
# Parameters for node resource model
_PHvState = ("hv_state", None, ht.TMaybeDict, "Set hypervisor states")
_PDiskState = ("disk_state", None, ht.TMaybeDict, "Set disk states")

154
155
156
157

_PIgnoreIpolicy = ("ignore_ipolicy", False, ht.TBool,
                   "Whether to ignore ipolicy violations")

158
159
160
161
162
# Allow runtime changes while migrating
_PAllowRuntimeChgs = ("allow_runtime_changes", True, ht.TBool,
                      "Allow runtime changes (eg. memory ballooning)")


163
164
165
#: OP_ID conversion regular expression
_OPID_RE = re.compile("([a-z])([A-Z])")

166
#: Utility function for L{OpClusterSetParams}
167
168
169
170
171
_TestClusterOsListItem = \
  ht.TAnd(ht.TIsLength(2), ht.TItems([
    ht.TElemOf(constants.DDMS_VALUES),
    ht.TNonEmptyString,
    ]))
172

173
_TestClusterOsList = ht.TMaybeListOf(_TestClusterOsListItem)
174

175
176
# TODO: Generate check from constants.INIC_PARAMS_TYPES
#: Utility function for testing NIC definitions
177
178
179
_TestNicDef = \
  ht.Comment("NIC parameters")(ht.TDictOf(ht.TElemOf(constants.INIC_PARAMS),
                                          ht.TOr(ht.TNone, ht.TNonEmptyString)))
180

181
182
_TSetParamsResultItemItems = [
  ht.Comment("name of changed parameter")(ht.TNonEmptyString),
183
  ht.Comment("new value")(ht.TAny),
184
185
186
187
188
189
  ]

_TSetParamsResult = \
  ht.TListOf(ht.TAnd(ht.TIsLength(len(_TSetParamsResultItemItems)),
                     ht.TItems(_TSetParamsResultItemItems)))

190
191
# TODO: Generate check from constants.IDISK_PARAMS_TYPES (however, not all users
# of this check support all parameters)
192
193
194
_TDiskParams = \
  ht.Comment("Disk parameters")(ht.TDictOf(ht.TElemOf(constants.IDISK_PARAMS),
                                           ht.TOr(ht.TNonEmptyString, ht.TInt)))
195

196
197
198
199
200
201
202
_SUMMARY_PREFIX = {
  "CLUSTER_": "C_",
  "GROUP_": "G_",
  "NODE_": "N_",
  "INSTANCE_": "I_",
  }

Michael Hanselmann's avatar
Michael Hanselmann committed
203
204
205
#: Attribute name for dependencies
DEPEND_ATTR = "depends"

206
207
208
#: Attribute name for comment
COMMENT_ATTR = "comment"

209

210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
def _NameToId(name):
  """Convert an opcode class name to an OP_ID.

  @type name: string
  @param name: the class name, as OpXxxYyy
  @rtype: string
  @return: the name in the OP_XXXX_YYYY format

  """
  if not name.startswith("Op"):
    return None
  # Note: (?<=[a-z])(?=[A-Z]) would be ideal, since it wouldn't
  # consume any input, and hence we would just have all the elements
  # in the list, one by one; but it seems that split doesn't work on
  # non-consuming input, hence we have to process the input string a
  # bit
  name = _OPID_RE.sub(r"\1,\2", name)
  elems = name.split(",")
  return "_".join(n.upper() for n in elems)

230
231
232
233
234
235
236
237
238
239
240
241
242
243
244

def RequireFileStorage():
  """Checks that file storage is enabled.

  While it doesn't really fit into this module, L{utils} was deemed too large
  of a dependency to be imported for just one or two functions.

  @raise errors.OpPrereqError: when file storage is disabled

  """
  if not constants.ENABLE_FILE_STORAGE:
    raise errors.OpPrereqError("File storage disabled at configure time",
                               errors.ECODE_INVAL)


245
246
247
248
249
250
251
252
253
254
255
256
257
258
def RequireSharedFileStorage():
  """Checks that shared file storage is enabled.

  While it doesn't really fit into this module, L{utils} was deemed too large
  of a dependency to be imported for just one or two functions.

  @raise errors.OpPrereqError: when shared file storage is disabled

  """
  if not constants.ENABLE_SHARED_FILE_STORAGE:
    raise errors.OpPrereqError("Shared file storage disabled at"
                               " configure time", errors.ECODE_INVAL)


259
260
261
@ht.WithDesc("CheckFileStorage")
def _CheckFileStorage(value):
  """Ensures file storage is enabled if used.
262
263

  """
264
  if value == constants.DT_FILE:
265
    RequireFileStorage()
266
267
  elif value == constants.DT_SHARED_FILE:
    RequireSharedFileStorage()
268
269
270
  return True


271
272
273
274
275
276
277
278
279
280
281
282
283
284
def _BuildDiskTemplateCheck(accept_none):
  """Builds check for disk template.

  @type accept_none: bool
  @param accept_none: whether to accept None as a correct value
  @rtype: callable

  """
  template_check = ht.TElemOf(constants.DISK_TEMPLATES)

  if accept_none:
    template_check = ht.TOr(template_check, ht.TNone)

  return ht.TAnd(template_check, _CheckFileStorage)
285
286


287
288
289
290
291
292
293
294
295
296
297
298
299
def _CheckStorageType(storage_type):
  """Ensure a given storage type is valid.

  """
  if storage_type not in constants.VALID_STORAGE_TYPES:
    raise errors.OpPrereqError("Unknown storage type: %s" % storage_type,
                               errors.ECODE_INVAL)
  if storage_type == constants.ST_FILE:
    RequireFileStorage()
  return True


#: Storage type parameter
300
301
_PStorageType = ("storage_type", ht.NoDefault, _CheckStorageType,
                 "Storage type")
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319


class _AutoOpParamSlots(type):
  """Meta class for opcode definitions.

  """
  def __new__(mcs, name, bases, attrs):
    """Called when a class should be created.

    @param mcs: The meta class
    @param name: Name of created class
    @param bases: Base classes
    @type attrs: dict
    @param attrs: Class attributes

    """
    assert "__slots__" not in attrs, \
      "Class '%s' defines __slots__ when it should use OP_PARAMS" % name
320
    assert "OP_ID" not in attrs, "Class '%s' defining OP_ID" % name
321

322
    attrs["OP_ID"] = _NameToId(name)
323
324
325
326
327

    # Always set OP_PARAMS to avoid duplicates in BaseOpCode.GetAllParams
    params = attrs.setdefault("OP_PARAMS", [])

    # Use parameter names as slots
328
    slots = [pname for (pname, _, _, _) in params]
329
330
331
332
333
334
335
336

    assert "OP_DSC_FIELD" not in attrs or attrs["OP_DSC_FIELD"] in slots, \
      "Class '%s' uses unknown field in OP_DSC_FIELD" % name

    attrs["__slots__"] = slots

    return type.__new__(mcs, name, bases, attrs)

337

Iustin Pop's avatar
Iustin Pop committed
338
class BaseOpCode(object):
339
340
  """A simple serializable object.

Iustin Pop's avatar
Iustin Pop committed
341
342
343
  This object serves as a parent class for OpCode without any custom
  field handling.

344
  """
345
  # pylint: disable=E1101
346
  # as OP_ID is dynamically defined
347
348
  __metaclass__ = _AutoOpParamSlots

Iustin Pop's avatar
Iustin Pop committed
349
  def __init__(self, **kwargs):
Iustin Pop's avatar
Iustin Pop committed
350
351
352
353
354
355
356
357
    """Constructor for BaseOpCode.

    The constructor takes only keyword arguments and will set
    attributes on this object based on the passed arguments. As such,
    it means that you should not pass arguments which are not in the
    __slots__ attribute for this class.

    """
358
    slots = self._all_slots()
Iustin Pop's avatar
Iustin Pop committed
359
    for key in kwargs:
360
      if key not in slots:
361
        raise TypeError("Object %s doesn't support the parameter '%s'" %
362
                        (self.__class__.__name__, key))
Iustin Pop's avatar
Iustin Pop committed
363
364
      setattr(self, key, kwargs[key])

365
  def __getstate__(self):
Iustin Pop's avatar
Iustin Pop committed
366
367
368
369
370
371
372
373
374
    """Generic serializer.

    This method just returns the contents of the instance as a
    dictionary.

    @rtype:  C{dict}
    @return: the instance attributes and their values

    """
375
    state = {}
376
    for name in self._all_slots():
377
378
379
380
381
      if hasattr(self, name):
        state[name] = getattr(self, name)
    return state

  def __setstate__(self, state):
Iustin Pop's avatar
Iustin Pop committed
382
383
384
385
386
387
388
389
390
    """Generic unserializer.

    This method just restores from the serialized state the attributes
    of the current instance.

    @param state: the serialized opcode data
    @type state:  C{dict}

    """
391
392
393
394
    if not isinstance(state, dict):
      raise ValueError("Invalid data to __setstate__: expected dict, got %s" %
                       type(state))

395
    for name in self._all_slots():
Iustin Pop's avatar
Iustin Pop committed
396
      if name not in state and hasattr(self, name):
397
398
399
400
401
        delattr(self, name)

    for name in state:
      setattr(self, name, state[name])

402
403
404
405
406
407
408
409
410
411
  @classmethod
  def _all_slots(cls):
    """Compute the list of all declared slots for a class.

    """
    slots = []
    for parent in cls.__mro__:
      slots.extend(getattr(parent, "__slots__", []))
    return slots

412
413
414
415
416
417
418
419
420
421
  @classmethod
  def GetAllParams(cls):
    """Compute list of all parameters for an opcode.

    """
    slots = []
    for parent in cls.__mro__:
      slots.extend(getattr(parent, "OP_PARAMS", []))
    return slots

422
423
424
425
426
427
428
429
430
  def Validate(self, set_defaults):
    """Validate opcode parameters, optionally setting default values.

    @type set_defaults: bool
    @param set_defaults: Whether to set default values
    @raise errors.OpPrereqError: When a parameter value doesn't match
                                 requirements

    """
431
    for (attr_name, default, test, _) in self.GetAllParams():
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
      assert test == ht.NoType or callable(test)

      if not hasattr(self, attr_name):
        if default == ht.NoDefault:
          raise errors.OpPrereqError("Required parameter '%s.%s' missing" %
                                     (self.OP_ID, attr_name),
                                     errors.ECODE_INVAL)
        elif set_defaults:
          if callable(default):
            dval = default()
          else:
            dval = default
          setattr(self, attr_name, dval)

      if test == ht.NoType:
        # no tests here
        continue

      if set_defaults or hasattr(self, attr_name):
        attr_val = getattr(self, attr_name)
        if not test(attr_val):
          logging.error("OpCode %s, parameter %s, has invalid type %s/value %s",
                        self.OP_ID, attr_name, type(attr_val), attr_val)
          raise errors.OpPrereqError("Parameter '%s.%s' fails validation" %
                                     (self.OP_ID, attr_name),
                                     errors.ECODE_INVAL)

459

460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
def _BuildJobDepCheck(relative):
  """Builds check for job dependencies (L{DEPEND_ATTR}).

  @type relative: bool
  @param relative: Whether to accept relative job IDs (negative)
  @rtype: callable

  """
  if relative:
    job_id = ht.TOr(ht.TJobId, ht.TRelativeJobId)
  else:
    job_id = ht.TJobId

  job_dep = \
    ht.TAnd(ht.TIsLength(2),
            ht.TItems([job_id,
                       ht.TListOf(ht.TElemOf(constants.JOBS_FINALIZED))]))

478
  return ht.TMaybeListOf(job_dep)
479
480
481
482


TNoRelativeJobDependencies = _BuildJobDepCheck(False)

483
#: List of submission status and job ID as returned by C{SubmitManyJobs}
484
485
486
487
488
489
490
_TJobIdListItem = \
  ht.TAnd(ht.TIsLength(2),
          ht.TItems([ht.Comment("success")(ht.TBool),
                     ht.Comment("Job ID if successful, error message"
                                " otherwise")(ht.TOr(ht.TString,
                                                     ht.TJobId))]))
TJobIdList = ht.TListOf(_TJobIdListItem)
491

492
493
#: Result containing only list of submitted jobs
TJobIdListOnly = ht.TStrictDict(True, True, {
494
  constants.JOB_IDS_KEY: ht.Comment("List of submitted jobs")(TJobIdList),
495
496
  })

497

Iustin Pop's avatar
Iustin Pop committed
498
class OpCode(BaseOpCode):
Iustin Pop's avatar
Iustin Pop committed
499
500
501
502
503
504
  """Abstract OpCode.

  This is the root of the actual OpCode hierarchy. All clases derived
  from this class should override OP_ID.

  @cvar OP_ID: The ID of this opcode. This should be unique amongst all
505
               children of this class.
506
507
508
  @cvar OP_DSC_FIELD: The name of a field whose value will be included in the
                      string returned by Summary(); see the docstring of that
                      method for details).
509
510
  @cvar OP_PARAMS: List of opcode attributes, the default values they should
                   get if not already defined, and types they must match.
511
  @cvar OP_RESULT: Callable to verify opcode result
512
513
  @cvar WITH_LU: Boolean that specifies whether this should be included in
      mcpu's dispatch table
514
515
  @ivar dry_run: Whether the LU should be run in dry-run mode, i.e. just
                 the check steps
516
  @ivar priority: Opcode priority for queue
Iustin Pop's avatar
Iustin Pop committed
517
518

  """
519
  # pylint: disable=E1101
520
  # as OP_ID is dynamically defined
521
  WITH_LU = True
522
  OP_PARAMS = [
523
524
    ("dry_run", None, ht.TMaybeBool, "Run checks only, don't execute"),
    ("debug_level", None, ht.TOr(ht.TNone, ht.TPositiveInt), "Debug level"),
525
    ("priority", constants.OP_PRIO_DEFAULT,
526
     ht.TElemOf(constants.OP_PRIO_SUBMIT_VALID), "Opcode priority"),
527
528
    (DEPEND_ATTR, None, _BuildJobDepCheck(True),
     "Job dependencies; if used through ``SubmitManyJobs`` relative (negative)"
529
530
     " job IDs can be used; see :doc:`design document <design-chained-jobs>`"
     " for details"),
531
532
    (COMMENT_ATTR, None, ht.TMaybeString,
     "Comment describing the purpose of the opcode"),
533
    ]
534
  OP_RESULT = None
535
536
537
538

  def __getstate__(self):
    """Specialized getstate for opcodes.

Iustin Pop's avatar
Iustin Pop committed
539
540
541
542
543
544
545
    This method adds to the state dictionary the OP_ID of the class,
    so that on unload we can identify the correct class for
    instantiating the opcode.

    @rtype:   C{dict}
    @return:  the state as a dictionary

546
    """
Iustin Pop's avatar
Iustin Pop committed
547
    data = BaseOpCode.__getstate__(self)
548
549
550
551
    data["OP_ID"] = self.OP_ID
    return data

  @classmethod
552
  def LoadOpCode(cls, data):
553
554
    """Generic load opcode method.

Iustin Pop's avatar
Iustin Pop committed
555
556
557
558
559
560
561
    The method identifies the correct opcode class from the dict-form
    by looking for a OP_ID key, if this is not found, or its value is
    not available in this module as a child of this class, we fail.

    @type data:  C{dict}
    @param data: the serialized opcode

562
563
564
565
566
567
568
    """
    if not isinstance(data, dict):
      raise ValueError("Invalid data to LoadOpCode (%s)" % type(data))
    if "OP_ID" not in data:
      raise ValueError("Invalid data to LoadOpcode, missing OP_ID")
    op_id = data["OP_ID"]
    op_class = None
Iustin Pop's avatar
Iustin Pop committed
569
570
571
    if op_id in OP_MAPPING:
      op_class = OP_MAPPING[op_id]
    else:
572
573
574
575
576
577
578
579
      raise ValueError("Invalid data to LoadOpCode: OP_ID %s unsupported" %
                       op_id)
    op = op_class()
    new_data = data.copy()
    del new_data["OP_ID"]
    op.__setstate__(new_data)
    return op

580
581
582
  def Summary(self):
    """Generates a summary description of this opcode.

583
584
585
586
587
    The summary is the value of the OP_ID attribute (without the "OP_"
    prefix), plus the value of the OP_DSC_FIELD attribute, if one was
    defined; this field should allow to easily identify the operation
    (for an instance creation job, e.g., it would be the instance
    name).
588

589
    """
590
    assert self.OP_ID is not None and len(self.OP_ID) > 3
591
592
593
594
595
    # all OP_ID start with OP_, we remove that
    txt = self.OP_ID[3:]
    field_name = getattr(self, "OP_DSC_FIELD", None)
    if field_name:
      field_value = getattr(self, field_name, None)
596
597
      if isinstance(field_value, (list, tuple)):
        field_value = ",".join(str(i) for i in field_value)
598
599
600
      txt = "%s(%s)" % (txt, field_value)
    return txt

601
602
603
604
605
606
607
608
609
610
611
612
613
614
  def TinySummary(self):
    """Generates a compact summary description of the opcode.

    """
    assert self.OP_ID.startswith("OP_")

    text = self.OP_ID[3:]

    for (prefix, supplement) in _SUMMARY_PREFIX.items():
      if text.startswith(prefix):
        return supplement + text[len(prefix):]

    return text

Iustin Pop's avatar
Iustin Pop committed
615

616
617
# cluster opcodes

618
class OpClusterPostInit(OpCode):
619
620
621
622
623
624
625
626
  """Post cluster initialization.

  This opcode does not touch the cluster at all. Its purpose is to run hooks
  after the cluster has been initialized.

  """


627
class OpClusterDestroy(OpCode):
Iustin Pop's avatar
Iustin Pop committed
628
629
630
631
632
633
  """Destroy the cluster.

  This opcode has no other parameters. All the state is irreversibly
  lost after the execution of this opcode.

  """
Iustin Pop's avatar
Iustin Pop committed
634
635


636
class OpClusterQuery(OpCode):
Iustin Pop's avatar
Iustin Pop committed
637
  """Query cluster information."""
Iustin Pop's avatar
Iustin Pop committed
638
639


640
641
642
643
644
645
646
647
class OpClusterVerify(OpCode):
  """Submits all jobs necessary to verify the cluster.

  """
  OP_PARAMS = [
    _PDebugSimulateErrors,
    _PErrorCodes,
    _PSkipChecks,
648
    _PIgnoreErrors,
649
650
651
    _PVerbose,
    ("group_name", None, ht.TMaybeString, "Group to verify")
    ]
652
  OP_RESULT = TJobIdListOnly
653
654


655
656
657
658
659
class OpClusterVerifyConfig(OpCode):
  """Verify the cluster config.

  """
  OP_PARAMS = [
660
661
    _PDebugSimulateErrors,
    _PErrorCodes,
662
    _PIgnoreErrors,
663
    _PVerbose,
664
    ]
665
  OP_RESULT = ht.TBool
666
667
668
669


class OpClusterVerifyGroup(OpCode):
  """Run verify on a node group from the cluster.
Iustin Pop's avatar
Iustin Pop committed
670
671
672
673
674
675
676
677

  @type skip_checks: C{list}
  @ivar skip_checks: steps to be skipped from the verify process; this
                     needs to be a subset of
                     L{constants.VERIFY_OPTIONAL_CHECKS}; currently
                     only L{constants.VERIFY_NPLUSONE_MEM} can be passed

  """
678
  OP_DSC_FIELD = "group_name"
679
  OP_PARAMS = [
680
681
682
683
    _PGroupName,
    _PDebugSimulateErrors,
    _PErrorCodes,
    _PSkipChecks,
684
    _PIgnoreErrors,
685
    _PVerbose,
686
    ]
687
  OP_RESULT = ht.TBool
Iustin Pop's avatar
Iustin Pop committed
688
689


690
class OpClusterVerifyDisks(OpCode):
Iustin Pop's avatar
Iustin Pop committed
691
692
  """Verify the cluster disks.

693
  """
694
  OP_RESULT = TJobIdListOnly
695
696
697
698


class OpGroupVerifyDisks(OpCode):
  """Verifies the status of all disks in a node group.
Iustin Pop's avatar
Iustin Pop committed
699

700
701
  Result: a tuple of three elements:
    - dict of node names with issues (values: error msg)
Iustin Pop's avatar
Iustin Pop committed
702
    - list of instances with degraded disks (that should be activated)
703
704
    - dict of instances with missing logical volumes (values: (node, vol)
      pairs with details about the missing volumes)
Iustin Pop's avatar
Iustin Pop committed
705

706
707
708
709
  In normal operation, all lists should be empty. A non-empty instance
  list (3rd element of the result) is still ok (errors were fixed) but
  non-empty node list means some node is down, and probably there are
  unfixable drbd errors.
Iustin Pop's avatar
Iustin Pop committed
710
711
712
713
714

  Note that only instances that are drbd-based are taken into
  consideration. This might need to be revisited in the future.

  """
715
716
717
718
  OP_DSC_FIELD = "group_name"
  OP_PARAMS = [
    _PGroupName,
    ]
719
720
721
722
  OP_RESULT = \
    ht.TAnd(ht.TIsLength(3),
            ht.TItems([ht.TDictOf(ht.TString, ht.TString),
                       ht.TListOf(ht.TString),
723
724
                       ht.TDictOf(ht.TString,
                                  ht.TListOf(ht.TListOf(ht.TString)))]))
Iustin Pop's avatar
Iustin Pop committed
725
726


727
class OpClusterRepairDiskSizes(OpCode):
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
  """Verify the disk sizes of the instances and fixes configuration
  mimatches.

  Parameters: optional instances list, in case we want to restrict the
  checks to only a subset of the instances.

  Result: a list of tuples, (instance, disk, new-size) for changed
  configurations.

  In normal operation, the list should be empty.

  @type instances: list
  @ivar instances: the list of instances to check, or empty for all instances

  """
743
  OP_PARAMS = [
744
    ("instances", ht.EmptyList, ht.TListOf(ht.TNonEmptyString), None),
745
    ]
746
747


748
class OpClusterConfigQuery(OpCode):
749
  """Query cluster configuration values."""
750
751
752
  OP_PARAMS = [
    _POutputFields
    ]
Iustin Pop's avatar
Iustin Pop committed
753
754


755
class OpClusterRename(OpCode):
Iustin Pop's avatar
Iustin Pop committed
756
757
758
759
760
761
762
763
  """Rename the cluster.

  @type name: C{str}
  @ivar name: The new name of the cluster. The name and/or the master IP
              address will be changed to match the new name and its IP
              address.

  """
764
  OP_DSC_FIELD = "name"
765
  OP_PARAMS = [
766
    ("name", ht.NoDefault, ht.TNonEmptyString, None),
767
    ]
768
769


770
class OpClusterSetParams(OpCode):
Iustin Pop's avatar
Iustin Pop committed
771
772
773
774
775
776
  """Change the parameters of the cluster.

  @type vg_name: C{str} or C{None}
  @ivar vg_name: The new volume group name or None to disable LVM usage.

  """
777
  OP_PARAMS = [
778
779
    _PHvState,
    _PDiskState,
780
    ("vg_name", None, ht.TMaybeString, "Volume group name"),
781
782
    ("enabled_hypervisors", None,
     ht.TOr(ht.TAnd(ht.TListOf(ht.TElemOf(constants.HYPER_TYPES)), ht.TTrue),
783
784
            ht.TNone),
     "List of enabled hypervisors"),
785
    ("hvparams", None, ht.TOr(ht.TDictOf(ht.TNonEmptyString, ht.TDict),
786
787
788
789
                              ht.TNone),
     "Cluster-wide hypervisor parameter defaults, hypervisor-dependent"),
    ("beparams", None, ht.TOr(ht.TDict, ht.TNone),
     "Cluster-wide backend parameter defaults"),
790
    ("os_hvp", None, ht.TOr(ht.TDictOf(ht.TNonEmptyString, ht.TDict),
791
792
                            ht.TNone),
     "Cluster-wide per-OS hypervisor parameter defaults"),
793
    ("osparams", None, ht.TOr(ht.TDictOf(ht.TNonEmptyString, ht.TDict),
794
795
                              ht.TNone),
     "Cluster-wide OS parameter defaults"),
796
    _PDiskParams,
797
    ("candidate_pool_size", None, ht.TOr(ht.TStrictPositiveInt, ht.TNone),
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
     "Master candidate pool size"),
    ("uid_pool", None, ht.NoType,
     "Set UID pool, must be list of lists describing UID ranges (two items,"
     " start and end inclusive)"),
    ("add_uids", None, ht.NoType,
     "Extend UID pool, must be list of lists describing UID ranges (two"
     " items, start and end inclusive) to be added"),
    ("remove_uids", None, ht.NoType,
     "Shrink UID pool, must be list of lists describing UID ranges (two"
     " items, start and end inclusive) to be removed"),
    ("maintain_node_health", None, ht.TMaybeBool,
     "Whether to automatically maintain node health"),
    ("prealloc_wipe_disks", None, ht.TMaybeBool,
     "Whether to wipe disks before allocating them to instances"),
    ("nicparams", None, ht.TMaybeDict, "Cluster-wide NIC parameter defaults"),
    ("ndparams", None, ht.TMaybeDict, "Cluster-wide node parameter defaults"),
814
815
    ("ipolicy", None, ht.TMaybeDict,
     "Cluster-wide :ref:`instance policy <rapi-ipolicy>` specs"),
816
817
818
819
820
    ("drbd_helper", None, ht.TOr(ht.TString, ht.TNone), "DRBD helper program"),
    ("default_iallocator", None, ht.TOr(ht.TString, ht.TNone),
     "Default iallocator for cluster"),
    ("master_netdev", None, ht.TOr(ht.TString, ht.TNone),
     "Master network device"),
821
822
    ("master_netmask", None, ht.TOr(ht.TInt, ht.TNone),
     "Netmask of the master IP"),
823
    ("reserved_lvs", None, ht.TMaybeListOf(ht.TNonEmptyString),
824
825
826
827
828
829
830
831
832
     "List of reserved LVs"),
    ("hidden_os", None, _TestClusterOsList,
     "Modify list of hidden operating systems. Each modification must have"
     " two items, the operation and the OS name. The operation can be"
     " ``%s`` or ``%s``." % (constants.DDM_ADD, constants.DDM_REMOVE)),
    ("blacklisted_os", None, _TestClusterOsList,
     "Modify list of blacklisted operating systems. Each modification must have"
     " two items, the operation and the OS name. The operation can be"
     " ``%s`` or ``%s``." % (constants.DDM_ADD, constants.DDM_REMOVE)),
833
834
    ("use_external_mip_script", None, ht.TMaybeBool,
     "Whether to use an external master IP address setup script"),
835
    ]
836
837


838
class OpClusterRedistConf(OpCode):
839
840
841
842
  """Force a full push of the cluster configuration.

  """

Michael Hanselmann's avatar
Michael Hanselmann committed
843

844
845
846
847
848
849
850
851
852
853
854
855
class OpClusterActivateMasterIp(OpCode):
  """Activate the master IP on the master node.

  """


class OpClusterDeactivateMasterIp(OpCode):
  """Deactivate the master IP on the master node.

  """


Michael Hanselmann's avatar
Michael Hanselmann committed
856
857
858
class OpQuery(OpCode):
  """Query for resources/items.

859
  @ivar what: Resources to query for, must be one of L{constants.QR_VIA_OP}
Michael Hanselmann's avatar
Michael Hanselmann committed
860
  @ivar fields: List of fields to retrieve
861
  @ivar qfilter: Query filter
Michael Hanselmann's avatar
Michael Hanselmann committed
862
863

  """
864
  OP_DSC_FIELD = "what"
865
  OP_PARAMS = [
866
    _PQueryWhat,
867
    _PUseLocking,
868
869
    ("fields", ht.NoDefault, ht.TListOf(ht.TNonEmptyString),
     "Requested fields"),
870
    ("qfilter", None, ht.TOr(ht.TNone, ht.TListOf),
871
     "Query filter"),
Michael Hanselmann's avatar
Michael Hanselmann committed
872
873
874
875
876
877
    ]


class OpQueryFields(OpCode):
  """Query for available resource/item fields.

878
  @ivar what: Resources to query for, must be one of L{constants.QR_VIA_OP}
Michael Hanselmann's avatar
Michael Hanselmann committed
879
880
881
  @ivar fields: List of fields to retrieve

  """
882
  OP_DSC_FIELD = "what"
883
  OP_PARAMS = [
884
    _PQueryWhat,
885
    ("fields", None, ht.TMaybeListOf(ht.TNonEmptyString),
886
     "Requested fields; if not given, all are returned"),
Michael Hanselmann's avatar
Michael Hanselmann committed
887
888
889
    ]


890
class OpOobCommand(OpCode):
René Nussbaumer's avatar
René Nussbaumer committed
891
  """Interact with OOB."""
892
  OP_PARAMS = [
893
894
895
896
897
898
899
900
    ("node_names", ht.EmptyList, ht.TListOf(ht.TNonEmptyString),
     "List of nodes to run the OOB command against"),
    ("command", None, ht.TElemOf(constants.OOB_COMMANDS),
     "OOB command to be run"),
    ("timeout", constants.OOB_TIMEOUT, ht.TInt,
     "Timeout before the OOB helper will be terminated"),
    ("ignore_status", False, ht.TBool,
     "Ignores the node offline status for power off"),
901
902
    ("power_delay", constants.OOB_POWER_DELAY, ht.TPositiveFloat,
     "Time in seconds to wait between powering on nodes"),
René Nussbaumer's avatar
René Nussbaumer committed
903
904
905
    ]


906
907
# node opcodes

908
class OpNodeRemove(OpCode):
Iustin Pop's avatar
Iustin Pop committed
909
910
911
912
913
914
915
  """Remove a node.

  @type node_name: C{str}
  @ivar node_name: The name of the node to remove. If the node still has
                   instances on it, the operation will fail.

  """
916
  OP_DSC_FIELD = "node_name"
917
918
919
  OP_PARAMS = [
    _PNodeName,
    ]
Iustin Pop's avatar
Iustin Pop committed
920
921


Iustin Pop's avatar
Iustin Pop committed
922
class OpNodeAdd(OpCode):
Iustin Pop's avatar
Iustin Pop committed
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
  """Add a node to the cluster.

  @type node_name: C{str}
  @ivar node_name: The name of the node to add. This can be a short name,
                   but it will be expanded to the FQDN.
  @type primary_ip: IP address
  @ivar primary_ip: The primary IP of the node. This will be ignored when the
                    opcode is submitted, but will be filled during the node
                    add (so it will be visible in the job query).
  @type secondary_ip: IP address
  @ivar secondary_ip: The secondary IP of the node. This needs to be passed
                      if the cluster has been initialized in 'dual-network'
                      mode, otherwise it must not be given.
  @type readd: C{bool}
  @ivar readd: Whether to re-add an existing node to the cluster. If
               this is not passed, then the operation will abort if the node
               name is already in the cluster; use this parameter to 'repair'
               a node that had its configuration broken, or was reinstalled
               without removal from the cluster.
942
943
  @type group: C{str}
  @ivar group: The node group to which this node will belong.
944
945
946
947
  @type vm_capable: C{bool}
  @ivar vm_capable: The vm_capable node attribute
  @type master_capable: C{bool}
  @ivar master_capable: The master_capable node attribute
Iustin Pop's avatar
Iustin Pop committed
948
949

  """
950
  OP_DSC_FIELD = "node_name"
951
952
  OP_PARAMS = [
    _PNodeName,
953
954
    _PHvState,
    _PDiskState,
955
956
957
958
959
960
961
962
963
    ("primary_ip", None, ht.NoType, "Primary IP address"),
    ("secondary_ip", None, ht.TMaybeString, "Secondary IP address"),
    ("readd", False, ht.TBool, "Whether node is re-added to cluster"),
    ("group", None, ht.TMaybeString, "Initial node group"),
    ("master_capable", None, ht.TMaybeBool,
     "Whether node can become master or master candidate"),
    ("vm_capable", None, ht.TMaybeBool,
     "Whether node can host instances"),
    ("ndparams", None, ht.TMaybeDict, "Node parameters"),
964
    ]
Iustin Pop's avatar
Iustin Pop committed
965
966


967
class OpNodeQuery(OpCode):
Iustin Pop's avatar
Iustin Pop committed
968
  """Compute the list of nodes."""
969
970
  OP_PARAMS = [
    _POutputFields,
971
972
973
    _PUseLocking,
    ("names", ht.EmptyList, ht.TListOf(ht.TNonEmptyString),
     "Empty list to query all nodes, node names otherwise"),
974
    ]
Iustin Pop's avatar
Iustin Pop committed
975
976


977
class OpNodeQueryvols(OpCode):
978
  """Get list of volumes on node."""
979
980
  OP_PARAMS = [
    _POutputFields,
981
982
    ("nodes", ht.EmptyList, ht.TListOf(ht.TNonEmptyString),
     "Empty list to query all nodes, node names otherwise"),
983
    ]
984
985


986
class OpNodeQueryStorage(OpCode):
987
  """Get information on storage for node(s)."""
988
989
990
  OP_PARAMS = [
    _POutputFields,
    _PStorageType,
991
992
    ("nodes", ht.EmptyList, ht.TListOf(ht.TNonEmptyString), "List of nodes"),
    ("name", None, ht.TMaybeString, "Storage name"),
993
994
995
    ]


996
class OpNodeModifyStorage(OpCode):
997
  """Modifies the properies of a storage unit"""
998
999
1000
  OP_PARAMS = [
    _PNodeName,
    _PStorageType,
1001
1002
    _PStorageName,
    ("changes", ht.NoDefault, ht.TDict, "Requested changes"),
1003
1004
1005
    ]


1006
1007
1008
class OpRepairNodeStorage(OpCode):
  """Repairs the volume group on a node."""
  OP_DSC_FIELD = "node_name"
1009
1010
1011
  OP_PARAMS = [
    _PNodeName,
    _PStorageType,
1012
1013
    _PStorageName,
    _PIgnoreConsistency,
1014
1015
1016
    ]


1017
class OpNodeSetParams(OpCode):
Iustin Pop's avatar
Iustin Pop committed
1018
1019
  """Change the parameters of a node."""
  OP_DSC_FIELD = "node_name"
1020
1021
1022
  OP_PARAMS = [
    _PNodeName,
    _PForce,
1023
1024
    _PHvState,
    _PDiskState,
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
    ("master_candidate", None, ht.TMaybeBool,
     "Whether the node should become a master candidate"),
    ("offline", None, ht.TMaybeBool,
     "Whether the node should be marked as offline"),
    ("drained", None, ht.TMaybeBool,
     "Whether the node should be marked as drained"),
    ("auto_promote", False, ht.TBool,
     "Whether node(s) should be promoted to master candidate if necessary"),
    ("master_capable", None, ht.TMaybeBool,
     "Denote whether node can become master or master candidate"),
    ("vm_capable", None, ht.TMaybeBool,
     "Denote whether node can host instances"),
    ("secondary_ip", None, ht.TMaybeString,
     "Change node's secondary IP address"),
    ("ndparams", None, ht.TMaybeDict, "Set node parameters"),
    ("powered", None, ht.TMaybeBool,
     "Whether the node should be marked as powered"),
Iustin Pop's avatar
Iustin Pop committed
1042
    ]
1043
  OP_RESULT = _TSetParamsResult
Iustin Pop's avatar
Iustin Pop committed
1044

Iustin Pop's avatar
Iustin Pop committed
1045

1046
class OpNodePowercycle(OpCode):
Iustin Pop's avatar
Iustin Pop committed
1047
1048
  """Tries to powercycle a node."""
  OP_DSC_FIELD = "node_name"
1049
1050
1051
  OP_PARAMS = [
    _PNodeName,
    _PForce,
Iustin Pop's avatar
Iustin Pop committed
1052
1053
    ]

1054

1055
class OpNodeMigrate(OpCode):
1056
1057
  """Migrate all instances from a node."""
  OP_DSC_FIELD = "node_name"
1058
1059
1060
1061
  OP_PARAMS = [
    _PNodeName,
    _PMigrationMode,
    _PMigrationLive,
Michael Hanselmann's avatar
Michael Hanselmann committed
1062
    _PMigrationTargetNode,
1063
    _PAllowRuntimeChgs,
1064
    _PIgnoreIpolicy,
1065
1066
    ("iallocator", None, ht.TMaybeString,
     "Iallocator for deciding the target node for shared-storage instances"),
1067
    ]
1068
  OP_RESULT = TJobIdListOnly
1069
1070


1071
1072
1073
1074
1075
1076
1077
1078
class OpNodeEvacuate(OpCode):
  """Evacuate instances off a number of nodes."""
  OP_DSC_FIELD = "node_name"
  OP_PARAMS = [
    _PEarlyRelease,
    _PNodeName,
    ("remote_node", None, ht.TMaybeString, "New secondary node"),
    ("iallocator", None, ht.TMaybeString, "Iallocator for computing solution"),
1079
    ("mode", ht.NoDefault, ht.TElemOf(constants.NODE_EVAC_MODES),
1080
1081
     "Node evacuation mode"),
    ]
1082
  OP_RESULT = TJobIdListOnly
1083
1084


Iustin Pop's avatar
Iustin Pop committed
1085
1086
# instance opcodes

1087
class OpInstanceCreate(OpCode):
1088
1089
1090
1091
1092
1093
1094
  """Create an instance.

  @ivar instance_name: Instance name
  @ivar mode: Instance creation mode (one of L{constants.INSTANCE_CREATE_MODES})
  @ivar source_handshake: Signed handshake from source (remote import only)
  @ivar source_x509_ca: Source X509 CA in PEM format (remote import only)
  @ivar source_instance_name: Previous name of instance (remote import only)
1095
1096
  @ivar source_shutdown_timeout: Shutdown timeout used for source instance
    (remote import only)
1097
1098

  """
1099
  OP_DSC_FIELD = "instance_name"
1100
1101
  OP_PARAMS = [
    _PInstanceName,
1102
1103
1104
    _PForceVariant,
    _PWaitForSync,
    _PNameCheck,
1105
    _PIgnoreIpolicy,
1106
    ("beparams", ht.EmptyDict, ht.TDict, "Backend parameters for instance"),
1107
    ("disks", ht.NoDefault, ht.TListOf(_TDiskParams),
1108
1109
1110
1111
1112
1113
1114
     "Disk descriptions, for example ``[{\"%s\": 100}, {\"%s\": 5}]``;"
     " each disk definition must contain a ``%s`` value and"
     " can contain an optional ``%s`` value denoting the disk access mode"
     " (%s)" %
     (constants.IDISK_SIZE, constants.IDISK_SIZE, constants.IDISK_SIZE,
      constants.IDISK_MODE,
      " or ".join("``%s``" % i for i in sorted(constants.DISK_ACCESS_SET)))),
1115
1116
    ("disk_template", ht.NoDefault, _BuildDiskTemplateCheck(True),
     "Disk template"),
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
    ("file_driver", None, ht.TOr(ht.TNone, ht.TElemOf(constants.FILE_DRIVER)),
     "Driver for file-backed disks"),
    ("file_storage_dir", None, ht.TMaybeString,
     "Directory for storing file-backed disks"),
    ("hvparams", ht.EmptyDict, ht.TDict,
     "Hypervisor parameters for instance, hypervisor-dependent"),
    ("hypervisor", None, ht.TMaybeString, "Hypervisor"),
    ("iallocator", None, ht.TMaybeString,
     "Iallocator for deciding which node(s) to use"),
    ("identify_defaults", False, ht.TBool,
     "Reset instance parameters to default if equal"),
    ("ip_check", True, ht.TBool, _PIpCheckDoc),
    ("mode", ht.NoDefault, ht.TElemOf(constants.INSTANCE_CREATE_MODES),
     "Instance creation mode"),
1131
1132
1133
1134
1135
1136
    ("nics", ht.NoDefault, ht.TListOf(_TestNicDef),
     "List of NIC (network interface) definitions, for example"
     " ``[{}, {}, {\"%s\": \"198.51.100.4\"}]``; each NIC definition can"
     " contain the optional values %s" %
     (constants.INIC_IP,
      ", ".join("``%s``" % i for i in sorted(constants.INIC_PARAMS)))),
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
    ("no_install", None, ht.TMaybeBool,
     "Do not install the OS (will disable automatic start)"),
    ("osparams", ht.EmptyDict, ht.TDict, "OS parameters for instance"),
    ("os_type", None, ht.TMaybeString, "Operating system"),
    ("pnode", None, ht.TMaybeString, "Primary node"),
    ("snode", None, ht.TMaybeString, "Secondary node"),
    ("source_handshake", None, ht.TOr(ht.TList, ht.TNone),
     "Signed handshake from source (remote import only)"),
    ("source_instance_name", None, ht.TMaybeString,
     "Source instance name (remote import only)"),
1147
    ("source_shutdown_timeout", constants.DEFAULT_SHUTDOWN_TIMEOUT,
1148
1149
     ht.TPositiveInt,
     "How long source instance was given to shut down (remote import only)"),
1150
1151
1152
1153
1154
    ("source_x509_ca", None, ht.TMaybeString,
     "Source X509 CA in PEM format (remote import only)"),
    ("src_node", None, ht.TMaybeString, "Source node for import"),
    ("src_path", None, ht.TMaybeString, "Source directory for import"),
    ("start", True, ht.TBool, "Whether to start instance after creation"),
1155
    ("tags", ht.EmptyList, ht.TListOf(ht.TNonEmptyString), "Instance tags"),
1156
    ]
1157
  OP_RESULT = ht.Comment("instance nodes")(ht.TListOf(ht.TNonEmptyString))
Iustin Pop's avatar
Iustin Pop committed
1158
1159


1160
class OpInstanceReinstall(OpCode):
Iustin Pop's avatar
Iustin Pop committed
1161
  """Reinstall an instance's OS."""
1162
  OP_DSC_FIELD = "instance_name"
1163
1164
  OP_PARAMS = [
    _PInstanceName,
1165
1166
1167
    _PForceVariant,
    ("os_type", None, ht.TMaybeString, "Instance operating system"),
    ("osparams", None, ht.TMaybeDict, "Temporary OS parameters"),
1168
    ]
1169
1170


1171
class OpInstanceRemove(OpCode):
Iustin Pop's avatar
Iustin Pop committed
1172
  """Remove an instance."""
1173
  OP_DSC_FIELD = "instance_name"
1174
1175
1176
  OP_PARAMS = [
    _PInstanceName,
    _PShutdownTimeout,
1177
1178
    ("ignore_failures", False, ht.TBool,
     "Whether to ignore failures during removal"),
1179
    ]
Iustin Pop's avatar
Iustin Pop committed
1180
1181


Iustin Pop's avatar