Revision 9f039737

b/lib/cmdlib.py
63 63
import ganeti.masterd.instance # pylint: disable-msg=W0611
64 64

  
65 65

  
66
def _SupportsOob(cfg, node):
67
  """Tells if node supports OOB.
68

  
69
  @type cfg: L{config.ConfigWriter}
70
  @param cfg: The cluster configuration
71
  @type node: L{objects.Node}
72
  @param node: The node
73
  @return: The OOB script if supported or an empty string otherwise
74

  
75
  """
76
  return cfg.GetNdParams(node)[constants.ND_OOB_PROGRAM]
77

  
78

  
79 66
class ResultWithJobs:
80 67
  """Data container for LU results with jobs.
81 68

  
......
561 548
                                    sort_by_name=self.sort_by_name)
562 549

  
563 550

  
551
def _ShareAll():
552
  """Returns a dict declaring all lock levels shared.
553

  
554
  """
555
  return dict.fromkeys(locking.LEVELS, 1)
556

  
557

  
558
def _SupportsOob(cfg, node):
559
  """Tells if node supports OOB.
560

  
561
  @type cfg: L{config.ConfigWriter}
562
  @param cfg: The cluster configuration
563
  @type node: L{objects.Node}
564
  @param node: The node
565
  @return: The OOB script if supported or an empty string otherwise
566

  
567
  """
568
  return cfg.GetNdParams(node)[constants.ND_OOB_PROGRAM]
569

  
570

  
564 571
def _GetWantedNodes(lu, nodes):
565 572
  """Returns list of checked and expanded node names.
566 573

  
......
1584 1591
      locking.LEVEL_NODE: [],
1585 1592
      }
1586 1593

  
1587
    self.share_locks = dict.fromkeys(locking.LEVELS, 1)
1594
    self.share_locks = _ShareAll()
1588 1595

  
1589 1596
  def DeclareLocks(self, level):
1590 1597
    if level == locking.LEVEL_NODE:
......
2867 2874
  REQ_BGL = False
2868 2875

  
2869 2876
  def ExpandNames(self):
2870
    self.share_locks = dict.fromkeys(locking.LEVELS, 1)
2877
    self.share_locks = _ShareAll()
2871 2878
    self.needed_locks = {
2872 2879
      locking.LEVEL_NODEGROUP: locking.ALL_SET,
2873 2880
      }
......
2890 2897
    # Raises errors.OpPrereqError on its own if group can't be found
2891 2898
    self.group_uuid = self.cfg.LookupNodeGroup(self.op.group_name)
2892 2899

  
2893
    self.share_locks = dict.fromkeys(locking.LEVELS, 1)
2900
    self.share_locks = _ShareAll()
2894 2901
    self.needed_locks = {
2895 2902
      locking.LEVEL_INSTANCE: [],
2896 2903
      locking.LEVEL_NODEGROUP: [],
......
3037 3044
        locking.LEVEL_NODE: locking.ALL_SET,
3038 3045
        locking.LEVEL_INSTANCE: locking.ALL_SET,
3039 3046
        }
3040
    self.share_locks = dict.fromkeys(locking.LEVELS, 1)
3047
    self.share_locks = _ShareAll()
3041 3048

  
3042 3049
  def DeclareLocks(self, level):
3043 3050
    if level == locking.LEVEL_NODE and self.wanted_names is not None:
......
6778 6785
  def ExpandNames(self):
6779 6786
    self.op.node_name = _ExpandNodeName(self.cfg, self.op.node_name)
6780 6787

  
6781
    self.share_locks = dict.fromkeys(locking.LEVELS, 1)
6788
    self.share_locks = _ShareAll()
6782 6789
    self.needed_locks = {
6783 6790
      locking.LEVEL_NODE: [self.op.node_name],
6784 6791
      }
......
9904 9911
                                   errors.ECODE_INVAL)
9905 9912

  
9906 9913
    # Declare locks
9907
    self.share_locks = dict.fromkeys(locking.LEVELS, 1)
9914
    self.share_locks = _ShareAll()
9908 9915
    self.needed_locks = {
9909 9916
      locking.LEVEL_INSTANCE: [],
9910 9917
      locking.LEVEL_NODEGROUP: [],
......
10230 10237
      self.wanted_names = None
10231 10238

  
10232 10239
    if self.op.use_locking:
10233
      self.share_locks = dict.fromkeys(locking.LEVELS, 1)
10240
      self.share_locks = _ShareAll()
10234 10241

  
10235 10242
      if self.wanted_names is None:
10236 10243
        self.needed_locks[locking.LEVEL_INSTANCE] = locking.ALL_SET
......
10238 10245
        self.needed_locks[locking.LEVEL_INSTANCE] = self.wanted_names
10239 10246

  
10240 10247
      self.needed_locks[locking.LEVEL_NODE] = []
10241
      self.share_locks = dict.fromkeys(locking.LEVELS, 1)
10242 10248
      self.recalculate_locks[locking.LEVEL_NODE] = constants.LOCKS_REPLACE
10243 10249

  
10244 10250
  def DeclareLocks(self, level):
......
12015 12021
                                 " opcode nor as a cluster-wide default",
12016 12022
                                 errors.ECODE_INVAL)
12017 12023

  
12018
    self.share_locks = dict.fromkeys(locking.LEVELS, 1)
12024
    self.share_locks = _ShareAll()
12019 12025
    self.needed_locks = {
12020 12026
      locking.LEVEL_INSTANCE: [],
12021 12027
      locking.LEVEL_NODEGROUP: [],
......
12207 12213
    TagsLU.ExpandNames(self)
12208 12214

  
12209 12215
    # Share locks as this is only a read operation
12210
    self.share_locks = dict.fromkeys(locking.LEVELS, 1)
12216
    self.share_locks = _ShareAll()
12211 12217

  
12212 12218
  def Exec(self, feedback_fn):
12213 12219
    """Returns the tag list.

Also available in: Unified diff