Revision 5eacbcae lib/cmdlib/instance_query.py

b/lib/cmdlib/instance_query.py
30 30
from ganeti import locking
31 31
from ganeti import qlang
32 32
from ganeti import query
33
from ganeti.cmdlib.base import _QueryBase, NoHooksLU
34
from ganeti.cmdlib.common import _ShareAll, _GetWantedInstances, \
35
  _CheckInstanceNodeGroups, _CheckInstancesNodeGroups, _AnnotateDiskParams
36
from ganeti.cmdlib.instance_operation import _GetInstanceConsole
37
from ganeti.cmdlib.instance_utils import _NICListToTuple
33
from ganeti.cmdlib.base import QueryBase, NoHooksLU
34
from ganeti.cmdlib.common import ShareAll, GetWantedInstances, \
35
  CheckInstanceNodeGroups, CheckInstancesNodeGroups, AnnotateDiskParams
36
from ganeti.cmdlib.instance_operation import GetInstanceConsole
37
from ganeti.cmdlib.instance_utils import NICListToTuple
38 38

  
39 39
import ganeti.masterd.instance
40 40

  
41 41

  
42
class _InstanceQuery(_QueryBase):
42
class InstanceQuery(QueryBase):
43 43
  FIELDS = query.INSTANCE_FIELDS
44 44

  
45 45
  def ExpandNames(self, lu):
46 46
    lu.needed_locks = {}
47
    lu.share_locks = _ShareAll()
47
    lu.share_locks = ShareAll()
48 48

  
49 49
    if self.names:
50
      self.wanted = _GetWantedInstances(lu, self.names)
50
      self.wanted = GetWantedInstances(lu, self.names)
51 51
    else:
52 52
      self.wanted = locking.ALL_SET
53 53

  
......
90 90

  
91 91
    # Check if node groups for locked instances are still correct
92 92
    for instance_name in owned_instances:
93
      _CheckInstanceNodeGroups(lu.cfg, instance_name, owned_groups)
93
      CheckInstanceNodeGroups(lu.cfg, instance_name, owned_groups)
94 94

  
95 95
  def _GetQueryData(self, lu):
96 96
    """Computes the list of instances and their attributes.
......
155 155
      for inst in instance_list:
156 156
        if inst.name in live_data:
157 157
          # Instance is running
158
          consinfo[inst.name] = _GetInstanceConsole(cluster, inst)
158
          consinfo[inst.name] = GetInstanceConsole(cluster, inst)
159 159
        else:
160 160
          consinfo[inst.name] = None
161 161
      assert set(consinfo.keys()) == set(instance_names)
......
194 194
  REQ_BGL = False
195 195

  
196 196
  def CheckArguments(self):
197
    self.iq = _InstanceQuery(qlang.MakeSimpleFilter("name", self.op.names),
197
    self.iq = InstanceQuery(qlang.MakeSimpleFilter("name", self.op.names),
198 198
                             self.op.output_fields, self.op.use_locking)
199 199

  
200 200
  def ExpandNames(self):
......
223 223

  
224 224
    if self.op.instances or not self.op.use_locking:
225 225
      # Expand instance names right here
226
      self.wanted_names = _GetWantedInstances(self, self.op.instances)
226
      self.wanted_names = GetWantedInstances(self, self.op.instances)
227 227
    else:
228 228
      # Will use acquired locks
229 229
      self.wanted_names = None
230 230

  
231 231
    if self.op.use_locking:
232
      self.share_locks = _ShareAll()
232
      self.share_locks = ShareAll()
233 233

  
234 234
      if self.wanted_names is None:
235 235
        self.needed_locks[locking.LEVEL_INSTANCE] = locking.ALL_SET
......
282 282
    instances = dict(self.cfg.GetMultiInstanceInfo(self.wanted_names))
283 283

  
284 284
    if self.op.use_locking:
285
      _CheckInstancesNodeGroups(self.cfg, instances, owned_groups, owned_nodes,
286
                                None)
285
      CheckInstancesNodeGroups(self.cfg, instances, owned_groups, owned_nodes,
286
                               None)
287 287
    else:
288 288
      assert not (owned_instances or owned_groups or
289 289
                  owned_nodes or owned_networks)
......
317 317
    """Compute block device status.
318 318

  
319 319
    """
320
    (anno_dev,) = _AnnotateDiskParams(instance, [dev], self.cfg)
320
    (anno_dev,) = AnnotateDiskParams(instance, [dev], self.cfg)
321 321

  
322 322
    return self._ComputeDiskStatusInner(instance, snode, anno_dev)
323 323

  
......
413 413
        "snodes_group_names": map(group2name_fn, snodes_group_uuids),
414 414
        "os": instance.os,
415 415
        # this happens to be the same format used for hooks
416
        "nics": _NICListToTuple(self, instance.nics),
416
        "nics": NICListToTuple(self, instance.nics),
417 417
        "disk_template": instance.disk_template,
418 418
        "disks": disks,
419 419
        "hypervisor": instance.hypervisor,

Also available in: Unified diff