Statistics
| Branch: | Tag: | Revision:

root / lib / opcodes.py @ 313bcead

History | View | Annotate | Download (19 kB)

1
#
2
#
3

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

    
21

    
22
"""OpCodes module
23

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

27
Every operation which modifies the cluster state is expressed via
28
opcodes.
29

30
"""
31

    
32
# this are practically structures, so disable the message about too
33
# few public methods:
34
# pylint: disable-msg=R0903
35

    
36

    
37
class BaseOpCode(object):
38
  """A simple serializable object.
39

40
  This object serves as a parent class for OpCode without any custom
41
  field handling.
42

43
  """
44
  __slots__ = []
45

    
46
  def __init__(self, **kwargs):
47
    """Constructor for BaseOpCode.
48

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

54
    """
55
    for key in kwargs:
56
      if key not in self.__slots__:
57
        raise TypeError("Object %s doesn't support the parameter '%s'" %
58
                        (self.__class__.__name__, key))
59
      setattr(self, key, kwargs[key])
60

    
61
  def __getstate__(self):
62
    """Generic serializer.
63

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

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

70
    """
71
    state = {}
72
    for name in self.__slots__:
73
      if hasattr(self, name):
74
        state[name] = getattr(self, name)
75
    return state
76

    
77
  def __setstate__(self, state):
78
    """Generic unserializer.
79

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

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

86
    """
87
    if not isinstance(state, dict):
88
      raise ValueError("Invalid data to __setstate__: expected dict, got %s" %
89
                       type(state))
90

    
91
    for name in self.__slots__:
92
      if name not in state:
93
        delattr(self, name)
94

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

    
98

    
99
class OpCode(BaseOpCode):
100
  """Abstract OpCode.
101

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

105
  @cvar OP_ID: The ID of this opcode. This should be unique amongst all
106
               children of this class.
107
  @ivar dry_run: Whether the LU should be run in dry-run mode, i.e. just
108
                 the check steps
109

110
  """
111
  OP_ID = "OP_ABSTRACT"
112
  __slots__ = BaseOpCode.__slots__ + ["dry_run"]
113

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

117
    This method adds to the state dictionary the OP_ID of the class,
118
    so that on unload we can identify the correct class for
119
    instantiating the opcode.
120

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

124
    """
125
    data = BaseOpCode.__getstate__(self)
126
    data["OP_ID"] = self.OP_ID
127
    return data
128

    
129
  @classmethod
130
  def LoadOpCode(cls, data):
131
    """Generic load opcode method.
132

133
    The method identifies the correct opcode class from the dict-form
134
    by looking for a OP_ID key, if this is not found, or its value is
135
    not available in this module as a child of this class, we fail.
136

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

140
    """
141
    if not isinstance(data, dict):
142
      raise ValueError("Invalid data to LoadOpCode (%s)" % type(data))
143
    if "OP_ID" not in data:
144
      raise ValueError("Invalid data to LoadOpcode, missing OP_ID")
145
    op_id = data["OP_ID"]
146
    op_class = None
147
    if op_id in OP_MAPPING:
148
      op_class = OP_MAPPING[op_id]
149
    else:
150
      raise ValueError("Invalid data to LoadOpCode: OP_ID %s unsupported" %
151
                       op_id)
152
    op = op_class()
153
    new_data = data.copy()
154
    del new_data["OP_ID"]
155
    op.__setstate__(new_data)
156
    return op
157

    
158
  def Summary(self):
159
    """Generates a summary description of this opcode.
160

161
    """
162
    # all OP_ID start with OP_, we remove that
163
    txt = self.OP_ID[3:]
164
    field_name = getattr(self, "OP_DSC_FIELD", None)
165
    if field_name:
166
      field_value = getattr(self, field_name, None)
167
      txt = "%s(%s)" % (txt, field_value)
168
    return txt
169

    
170

    
171
# cluster opcodes
172

    
173
class OpPostInitCluster(OpCode):
174
  """Post cluster initialization.
175

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

179
  """
180
  OP_ID = "OP_CLUSTER_POST_INIT"
181
  __slots__ = OpCode.__slots__ + []
182

    
183

    
184
class OpDestroyCluster(OpCode):
185
  """Destroy the cluster.
186

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

190
  """
191
  OP_ID = "OP_CLUSTER_DESTROY"
192
  __slots__ = OpCode.__slots__ + []
193

    
194

    
195
class OpQueryClusterInfo(OpCode):
196
  """Query cluster information."""
197
  OP_ID = "OP_CLUSTER_QUERY"
198
  __slots__ = OpCode.__slots__ + []
199

    
200

    
201
class OpVerifyCluster(OpCode):
202
  """Verify the cluster state.
203

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

210
  """
211
  OP_ID = "OP_CLUSTER_VERIFY"
212
  __slots__ = OpCode.__slots__ + ["skip_checks"]
213

    
214

    
215
class OpVerifyDisks(OpCode):
216
  """Verify the cluster disks.
217

218
  Parameters: none
219

220
  Result: a tuple of four elements:
221
    - list of node names with bad data returned (unreachable, etc.)
222
    - dict of node names with broken volume groups (values: error msg)
223
    - list of instances with degraded disks (that should be activated)
224
    - dict of instances with missing logical volumes (values: (node, vol)
225
      pairs with details about the missing volumes)
226

227
  In normal operation, all lists should be empty. A non-empty instance
228
  list (3rd element of the result) is still ok (errors were fixed) but
229
  non-empty node list means some node is down, and probably there are
230
  unfixable drbd errors.
231

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

235
  """
236
  OP_ID = "OP_CLUSTER_VERIFY_DISKS"
237
  __slots__ = OpCode.__slots__ + []
238

    
239

    
240
class OpRepairDiskSizes(OpCode):
241
  """Verify the disk sizes of the instances and fixes configuration
242
  mimatches.
243

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

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

250
  In normal operation, the list should be empty.
251

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

255
  """
256
  OP_ID = "OP_CLUSTER_REPAIR_DISK_SIZES"
257
  __slots__ = ["instances"]
258

    
259

    
260
class OpQueryConfigValues(OpCode):
261
  """Query cluster configuration values."""
262
  OP_ID = "OP_CLUSTER_CONFIG_QUERY"
263
  __slots__ = OpCode.__slots__ + ["output_fields"]
264

    
265

    
266
class OpRenameCluster(OpCode):
267
  """Rename the cluster.
268

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

274
  """
275
  OP_ID = "OP_CLUSTER_RENAME"
276
  OP_DSC_FIELD = "name"
277
  __slots__ = OpCode.__slots__ + ["name"]
278

    
279

    
280
class OpSetClusterParams(OpCode):
281
  """Change the parameters of the cluster.
282

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

286
  """
287
  OP_ID = "OP_CLUSTER_SET_PARAMS"
288
  __slots__ = OpCode.__slots__ + [
289
    "vg_name",
290
    "enabled_hypervisors",
291
    "hvparams",
292
    "beparams",
293
    "nicparams",
294
    "candidate_pool_size",
295
    ]
296

    
297

    
298
class OpRedistributeConfig(OpCode):
299
  """Force a full push of the cluster configuration.
300

301
  """
302
  OP_ID = "OP_CLUSTER_REDIST_CONF"
303
  __slots__ = OpCode.__slots__ + [
304
    ]
305

    
306
# node opcodes
307

    
308
class OpRemoveNode(OpCode):
309
  """Remove a node.
310

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

315
  """
316
  OP_ID = "OP_NODE_REMOVE"
317
  OP_DSC_FIELD = "node_name"
318
  __slots__ = OpCode.__slots__ + ["node_name"]
319

    
320

    
321
class OpAddNode(OpCode):
322
  """Add a node to the cluster.
323

324
  @type node_name: C{str}
325
  @ivar node_name: The name of the node to add. This can be a short name,
326
                   but it will be expanded to the FQDN.
327
  @type primary_ip: IP address
328
  @ivar primary_ip: The primary IP of the node. This will be ignored when the
329
                    opcode is submitted, but will be filled during the node
330
                    add (so it will be visible in the job query).
331
  @type secondary_ip: IP address
332
  @ivar secondary_ip: The secondary IP of the node. This needs to be passed
333
                      if the cluster has been initialized in 'dual-network'
334
                      mode, otherwise it must not be given.
335
  @type readd: C{bool}
336
  @ivar readd: Whether to re-add an existing node to the cluster. If
337
               this is not passed, then the operation will abort if the node
338
               name is already in the cluster; use this parameter to 'repair'
339
               a node that had its configuration broken, or was reinstalled
340
               without removal from the cluster.
341

342
  """
343
  OP_ID = "OP_NODE_ADD"
344
  OP_DSC_FIELD = "node_name"
345
  __slots__ = OpCode.__slots__ + [
346
    "node_name", "primary_ip", "secondary_ip", "readd",
347
    ]
348

    
349

    
350
class OpQueryNodes(OpCode):
351
  """Compute the list of nodes."""
352
  OP_ID = "OP_NODE_QUERY"
353
  __slots__ = OpCode.__slots__ + ["output_fields", "names", "use_locking"]
354

    
355

    
356
class OpQueryNodeVolumes(OpCode):
357
  """Get list of volumes on node."""
358
  OP_ID = "OP_NODE_QUERYVOLS"
359
  __slots__ = OpCode.__slots__ + ["nodes", "output_fields"]
360

    
361

    
362
class OpQueryNodeStorage(OpCode):
363
  """Get information on storage for node(s)."""
364
  OP_ID = "OP_NODE_QUERY_STORAGE"
365
  __slots__ = OpCode.__slots__ + [
366
    "nodes",
367
    "storage_type",
368
    "name",
369
    "output_fields",
370
    ]
371

    
372

    
373
class OpModifyNodeStorage(OpCode):
374
  """"""
375
  OP_ID = "OP_NODE_MODIFY_STORAGE"
376
  __slots__ = OpCode.__slots__ + [
377
    "node_name",
378
    "storage_type",
379
    "name",
380
    "changes",
381
    ]
382

    
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

    
395
class OpSetNodeParams(OpCode):
396
  """Change the parameters of a node."""
397
  OP_ID = "OP_NODE_SET_PARAMS"
398
  OP_DSC_FIELD = "node_name"
399
  __slots__ = OpCode.__slots__ + [
400
    "node_name",
401
    "force",
402
    "master_candidate",
403
    "offline",
404
    "drained",
405
    ]
406

    
407

    
408
class OpPowercycleNode(OpCode):
409
  """Tries to powercycle a node."""
410
  OP_ID = "OP_NODE_POWERCYCLE"
411
  OP_DSC_FIELD = "node_name"
412
  __slots__ = OpCode.__slots__ + [
413
    "node_name",
414
    "force",
415
    ]
416

    
417

    
418
class OpEvacuateNode(OpCode):
419
  """Relocate secondary instances from a node."""
420
  OP_ID = "OP_NODE_EVACUATE"
421
  OP_DSC_FIELD = "node_name"
422
  __slots__ = OpCode.__slots__ + [
423
    "node_name", "remote_node", "iallocator",
424
    ]
425

    
426

    
427
class OpMigrateNode(OpCode):
428
  """Migrate all instances from a node."""
429
  OP_ID = "OP_NODE_MIGRATE"
430
  OP_DSC_FIELD = "node_name"
431
  __slots__ = OpCode.__slots__ + [
432
    "node_name",
433
    "live",
434
    ]
435

    
436

    
437
# instance opcodes
438

    
439
class OpCreateInstance(OpCode):
440
  """Create an instance."""
441
  OP_ID = "OP_INSTANCE_CREATE"
442
  OP_DSC_FIELD = "instance_name"
443
  __slots__ = OpCode.__slots__ + [
444
    "instance_name", "os_type", "pnode",
445
    "disk_template", "snode", "mode",
446
    "disks", "nics",
447
    "src_node", "src_path", "start",
448
    "wait_for_sync", "ip_check",
449
    "file_storage_dir", "file_driver",
450
    "iallocator",
451
    "hypervisor", "hvparams", "beparams",
452
    "dry_run",
453
    ]
454

    
455

    
456
class OpReinstallInstance(OpCode):
457
  """Reinstall an instance's OS."""
458
  OP_ID = "OP_INSTANCE_REINSTALL"
459
  OP_DSC_FIELD = "instance_name"
460
  __slots__ = OpCode.__slots__ + ["instance_name", "os_type"]
461

    
462

    
463
class OpRemoveInstance(OpCode):
464
  """Remove an instance."""
465
  OP_ID = "OP_INSTANCE_REMOVE"
466
  OP_DSC_FIELD = "instance_name"
467
  __slots__ = OpCode.__slots__ + ["instance_name", "ignore_failures"]
468

    
469

    
470
class OpRenameInstance(OpCode):
471
  """Rename an instance."""
472
  OP_ID = "OP_INSTANCE_RENAME"
473
  __slots__ = OpCode.__slots__ + [
474
    "instance_name", "ignore_ip", "new_name",
475
    ]
476

    
477

    
478
class OpStartupInstance(OpCode):
479
  """Startup an instance."""
480
  OP_ID = "OP_INSTANCE_STARTUP"
481
  OP_DSC_FIELD = "instance_name"
482
  __slots__ = OpCode.__slots__ + [
483
    "instance_name", "force", "hvparams", "beparams",
484
    ]
485

    
486

    
487
class OpShutdownInstance(OpCode):
488
  """Shutdown an instance."""
489
  OP_ID = "OP_INSTANCE_SHUTDOWN"
490
  OP_DSC_FIELD = "instance_name"
491
  __slots__ = OpCode.__slots__ + ["instance_name"]
492

    
493

    
494
class OpRebootInstance(OpCode):
495
  """Reboot an instance."""
496
  OP_ID = "OP_INSTANCE_REBOOT"
497
  OP_DSC_FIELD = "instance_name"
498
  __slots__ = OpCode.__slots__ + [
499
    "instance_name", "reboot_type", "ignore_secondaries",
500
    ]
501

    
502

    
503
class OpReplaceDisks(OpCode):
504
  """Replace the disks of an instance."""
505
  OP_ID = "OP_INSTANCE_REPLACE_DISKS"
506
  OP_DSC_FIELD = "instance_name"
507
  __slots__ = OpCode.__slots__ + [
508
    "instance_name", "remote_node", "mode", "disks", "iallocator",
509
    ]
510

    
511

    
512
class OpFailoverInstance(OpCode):
513
  """Failover an instance."""
514
  OP_ID = "OP_INSTANCE_FAILOVER"
515
  OP_DSC_FIELD = "instance_name"
516
  __slots__ = OpCode.__slots__ + ["instance_name", "ignore_consistency"]
517

    
518

    
519
class OpMigrateInstance(OpCode):
520
  """Migrate an instance.
521

522
  This migrates (without shutting down an instance) to its secondary
523
  node.
524

525
  @ivar instance_name: the name of the instance
526

527
  """
528
  OP_ID = "OP_INSTANCE_MIGRATE"
529
  OP_DSC_FIELD = "instance_name"
530
  __slots__ = OpCode.__slots__ + ["instance_name", "live", "cleanup"]
531

    
532

    
533
class OpMoveInstance(OpCode):
534
  """Move an instance.
535

536
  This move (with shutting down an instance and data copying) to an
537
  arbitrary node.
538

539
  @ivar instance_name: the name of the instance
540
  @ivar target_node: the destination node
541

542
  """
543
  OP_ID = "OP_INSTANCE_MOVE"
544
  OP_DSC_FIELD = "instance_name"
545
  __slots__ = OpCode.__slots__ + ["instance_name", "target_node"]
546

    
547

    
548
class OpConnectConsole(OpCode):
549
  """Connect to an instance's console."""
550
  OP_ID = "OP_INSTANCE_CONSOLE"
551
  OP_DSC_FIELD = "instance_name"
552
  __slots__ = OpCode.__slots__ + ["instance_name"]
553

    
554

    
555
class OpActivateInstanceDisks(OpCode):
556
  """Activate an instance's disks."""
557
  OP_ID = "OP_INSTANCE_ACTIVATE_DISKS"
558
  OP_DSC_FIELD = "instance_name"
559
  __slots__ = OpCode.__slots__ + ["instance_name", "ignore_size"]
560

    
561

    
562
class OpDeactivateInstanceDisks(OpCode):
563
  """Deactivate an instance's disks."""
564
  OP_ID = "OP_INSTANCE_DEACTIVATE_DISKS"
565
  OP_DSC_FIELD = "instance_name"
566
  __slots__ = OpCode.__slots__ + ["instance_name"]
567

    
568

    
569
class OpRecreateInstanceDisks(OpCode):
570
  """Deactivate an instance's disks."""
571
  OP_ID = "OP_INSTANCE_RECREATE_DISKS"
572
  OP_DSC_FIELD = "instance_name"
573
  __slots__ = OpCode.__slots__ + ["instance_name", "disks"]
574

    
575

    
576
class OpQueryInstances(OpCode):
577
  """Compute the list of instances."""
578
  OP_ID = "OP_INSTANCE_QUERY"
579
  __slots__ = OpCode.__slots__ + ["output_fields", "names", "use_locking"]
580

    
581

    
582
class OpQueryInstanceData(OpCode):
583
  """Compute the run-time status of instances."""
584
  OP_ID = "OP_INSTANCE_QUERY_DATA"
585
  __slots__ = OpCode.__slots__ + ["instances", "static"]
586

    
587

    
588
class OpSetInstanceParams(OpCode):
589
  """Change the parameters of an instance."""
590
  OP_ID = "OP_INSTANCE_SET_PARAMS"
591
  OP_DSC_FIELD = "instance_name"
592
  __slots__ = OpCode.__slots__ + [
593
    "instance_name",
594
    "hvparams", "beparams", "force",
595
    "nics", "disks",
596
    ]
597

    
598

    
599
class OpGrowDisk(OpCode):
600
  """Grow a disk of an instance."""
601
  OP_ID = "OP_INSTANCE_GROW_DISK"
602
  OP_DSC_FIELD = "instance_name"
603
  __slots__ = OpCode.__slots__ + [
604
    "instance_name", "disk", "amount", "wait_for_sync",
605
    ]
606

    
607

    
608
# OS opcodes
609
class OpDiagnoseOS(OpCode):
610
  """Compute the list of guest operating systems."""
611
  OP_ID = "OP_OS_DIAGNOSE"
612
  __slots__ = OpCode.__slots__ + ["output_fields", "names"]
613

    
614

    
615
# Exports opcodes
616
class OpQueryExports(OpCode):
617
  """Compute the list of exported images."""
618
  OP_ID = "OP_BACKUP_QUERY"
619
  __slots__ = OpCode.__slots__ + ["nodes", "use_locking"]
620

    
621

    
622
class OpExportInstance(OpCode):
623
  """Export an instance."""
624
  OP_ID = "OP_BACKUP_EXPORT"
625
  OP_DSC_FIELD = "instance_name"
626
  __slots__ = OpCode.__slots__ + ["instance_name", "target_node", "shutdown"]
627

    
628

    
629
class OpRemoveExport(OpCode):
630
  """Remove an instance's export."""
631
  OP_ID = "OP_BACKUP_REMOVE"
632
  OP_DSC_FIELD = "instance_name"
633
  __slots__ = OpCode.__slots__ + ["instance_name"]
634

    
635

    
636
# Tags opcodes
637
class OpGetTags(OpCode):
638
  """Returns the tags of the given object."""
639
  OP_ID = "OP_TAGS_GET"
640
  OP_DSC_FIELD = "name"
641
  __slots__ = OpCode.__slots__ + ["kind", "name"]
642

    
643

    
644
class OpSearchTags(OpCode):
645
  """Searches the tags in the cluster for a given pattern."""
646
  OP_ID = "OP_TAGS_SEARCH"
647
  OP_DSC_FIELD = "pattern"
648
  __slots__ = OpCode.__slots__ + ["pattern"]
649

    
650

    
651
class OpAddTags(OpCode):
652
  """Add a list of tags on a given object."""
653
  OP_ID = "OP_TAGS_SET"
654
  __slots__ = OpCode.__slots__ + ["kind", "name", "tags"]
655

    
656

    
657
class OpDelTags(OpCode):
658
  """Remove a list of tags from a given object."""
659
  OP_ID = "OP_TAGS_DEL"
660
  __slots__ = OpCode.__slots__ + ["kind", "name", "tags"]
661

    
662

    
663
# Test opcodes
664
class OpTestDelay(OpCode):
665
  """Sleeps for a configured amount of time.
666

667
  This is used just for debugging and testing.
668

669
  Parameters:
670
    - duration: the time to sleep
671
    - on_master: if true, sleep on the master
672
    - on_nodes: list of nodes in which to sleep
673

674
  If the on_master parameter is true, it will execute a sleep on the
675
  master (before any node sleep).
676

677
  If the on_nodes list is not empty, it will sleep on those nodes
678
  (after the sleep on the master, if that is enabled).
679

680
  As an additional feature, the case of duration < 0 will be reported
681
  as an execution error, so this opcode can be used as a failure
682
  generator. The case of duration == 0 will not be treated specially.
683

684
  """
685
  OP_ID = "OP_TEST_DELAY"
686
  OP_DSC_FIELD = "duration"
687
  __slots__ = OpCode.__slots__ + ["duration", "on_master", "on_nodes"]
688

    
689

    
690
class OpTestAllocator(OpCode):
691
  """Allocator framework testing.
692

693
  This opcode has two modes:
694
    - gather and return allocator input for a given mode (allocate new
695
      or replace secondary) and a given instance definition (direction
696
      'in')
697
    - run a selected allocator for a given operation (as above) and
698
      return the allocator output (direction 'out')
699

700
  """
701
  OP_ID = "OP_TEST_ALLOCATOR"
702
  OP_DSC_FIELD = "allocator"
703
  __slots__ = OpCode.__slots__ + [
704
    "direction", "mode", "allocator", "name",
705
    "mem_size", "disks", "disk_template",
706
    "os", "tags", "nics", "vcpus", "hypervisor",
707
    ]
708

    
709

    
710
OP_MAPPING = dict([(v.OP_ID, v) for v in globals().values()
711
                   if (isinstance(v, type) and issubclass(v, OpCode) and
712
                       hasattr(v, "OP_ID"))])