Revision 2af8b9c9

b/lib/cli.py
531 531

  
532 532
  """
533 533
  kind, name = _ExtractTagsObject(opts, args)
534
  cl = GetClient(query=True)
534
  cl = GetClient()
535 535
  result = cl.QueryTags(kind, name)
536 536
  result = list(result)
537 537
  result.sort()
......
2932 2932

  
2933 2933
  # This ensures we're running on the master daemon
2934 2934
  cl = GetClient()
2935
  # Query client
2936
  qcl = GetClient(query=True)
2937 2935

  
2938 2936
  (cluster_name, master_node) = \
2939 2937
    cl.QueryConfigValues(["cluster_name", "master_node"])
2940 2938

  
2941
  online_nodes = GetOnlineNodes([], cl=qcl)
2942
  ssh_ports = GetNodesSshPorts(online_nodes, qcl)
2939
  online_nodes = GetOnlineNodes([], cl=cl)
2940
  ssh_ports = GetNodesSshPorts(online_nodes, cl)
2943 2941

  
2944 2942
  # Don't keep a reference to the client. The master daemon will go away.
2945 2943
  del cl
2946
  del qcl
2947 2944

  
2948 2945
  assert master_node in online_nodes
2949 2946

  
......
3554 3551

  
3555 3552
  """
3556 3553
  if cl is None:
3557
    cl = GetClient(query=True)
3554
    cl = GetClient()
3558 3555

  
3559 3556
  qfilter = []
3560 3557

  
b/lib/client/gnt_backup.py
50 50

  
51 51
  qfilter = qlang.MakeSimpleFilter("node", opts.nodes)
52 52

  
53
  cl = GetClient(query=True)
53
  cl = GetClient()
54 54

  
55 55
  return GenericList(constants.QR_EXPORT, selected_fields, None, opts.units,
56 56
                     opts.separator, not opts.no_headers,
......
67 67
  @return: the desired exit code
68 68

  
69 69
  """
70
  cl = GetClient(query=True)
70
  cl = GetClient()
71 71

  
72 72
  return GenericListFields(constants.QR_EXPORT, args, opts.separator,
73 73
                           not opts.no_headers, cl=cl)
b/lib/client/gnt_cluster.py
412 412
  @return: the desired exit code
413 413

  
414 414
  """
415
  cl = GetClient(query=True)
415
  cl = GetClient()
416 416
  result = cl.QueryClusterInfo()
417 417
  ToStdout("Software version: %s", result["software_version"])
418 418
  ToStdout("Internode protocol: %s", result["protocol_version"])
......
468 468
  @return: the desired exit code
469 469

  
470 470
  """
471
  cl = GetClient(query=True)
471
  cl = GetClient()
472 472
  result = cl.QueryClusterInfo()
473 473

  
474 474
  if result["tags"]:
......
579 579
                               errors.ECODE_INVAL)
580 580

  
581 581
  cl = GetClient()
582
  qcl = GetClient(query=True)
582
  qcl = GetClient()
583 583
  try:
584 584
    cluster_name = cl.QueryConfigValues(["cluster_name"])[0]
585 585

  
......
610 610

  
611 611
  """
612 612
  cl = GetClient()
613
  qcl = GetClient(query=True)
613
  qcl = GetClient()
614 614

  
615 615
  command = " ".join(args)
616 616

  
......
1566 1566

  
1567 1567
  if qcl is None:
1568 1568
    # Query client
1569
    qcl = GetClient(query=True)
1569
    qcl = GetClient()
1570 1570

  
1571 1571
  if opts.groups:
1572 1572
    node_query_list = \
......
1633 1633
  Currently it works only for ipolicy specs.
1634 1634

  
1635 1635
  """
1636
  cl = GetClient(query=True)
1636
  cl = GetClient()
1637 1637
  result = cl.QueryClusterInfo()
1638 1638
  ToStdout(_GetCreateCommand(result))
1639 1639

  
b/lib/client/gnt_group.py
122 122
    "ndparams": (_FmtDict, False),
123 123
    }
124 124

  
125
  cl = GetClient(query=True)
125
  cl = GetClient()
126 126

  
127 127
  return GenericList(constants.QR_GROUP, desired_fields, args, None,
128 128
                     opts.separator, not opts.no_headers,
......
140 140
  @return: the desired exit code
141 141

  
142 142
  """
143
  cl = GetClient(query=True)
143
  cl = GetClient()
144 144

  
145 145
  return GenericListFields(constants.QR_GROUP, args, opts.separator,
146 146
                           not opts.no_headers, cl=cl)
......
278 278
  """Shows info about node group.
279 279

  
280 280
  """
281
  cl = GetClient(query=True)
281
  cl = GetClient()
282 282
  selected_fields = ["name",
283 283
                     "ndparams", "custom_ndparams",
284 284
                     "diskparams", "custom_diskparams",
......
307 307
  Currently it works only for ipolicy specs.
308 308

  
309 309
  """
310
  cl = GetClient(query=True)
310
  cl = GetClient()
311 311
  selected_fields = ["name"]
312 312
  if opts.include_defaults:
313 313
    selected_fields += ["ipolicy"]
b/lib/client/gnt_instance.py
95 95
  # pylint: disable=W0142
96 96

  
97 97
  if client is None:
98
    client = GetClient(query=True)
98
    client = GetClient()
99 99
  if mode == _EXPAND_CLUSTER:
100 100
    if names:
101 101
      raise errors.OpPrereqError("Cluster filter mode takes no arguments",
......
182 182
    if opts.multi_mode is None:
183 183
      opts.multi_mode = _EXPAND_INSTANCES
184 184
    cl = GetClient()
185
    qcl = GetClient(query=True)
186
    inames = _ExpandMultiNames(opts.multi_mode, args, client=qcl)
185
    inames = _ExpandMultiNames(opts.multi_mode, args, client=cl)
187 186
    if not inames:
188 187
      if opts.multi_mode == _EXPAND_CLUSTER:
189 188
        ToStdout("Cluster is empty, no instances to shutdown")
......
224 223
                                                      for item in value),
225 224
                               False))
226 225

  
227
  cl = GetClient(query=True)
226
  cl = GetClient()
228 227

  
229 228
  return GenericList(constants.QR_INSTANCE, selected_fields, args, opts.units,
230 229
                     opts.separator, not opts.no_headers,
......
422 421
  instance_name = args[0]
423 422
  force = opts.force
424 423
  cl = GetClient()
425
  qcl = GetClient(query=True)
426 424

  
427 425
  if not force:
428
    _EnsureInstancesExist(qcl, [instance_name])
426
    _EnsureInstancesExist(cl, [instance_name])
429 427

  
430 428
    usertext = ("This will remove the volumes of the instance %s"
431 429
                " (including mirrors), thus removing all the data"
......
855 853
  instance_name = args[0]
856 854

  
857 855
  cl = GetClient()
858
  qcl = GetClient(query=True)
859 856
  try:
860 857
    cluster_name = cl.QueryConfigValues(["cluster_name"])[0]
861 858
    ((console_data, oper_state), ) = \
862
      qcl.QueryInstances([instance_name], ["console", "oper_state"], False)
859
      cl.QueryInstances([instance_name], ["console", "oper_state"], False)
863 860
  finally:
864 861
    # Ensure client connection is closed while external commands are run
865 862
    cl.Close()
866
    qcl.Close()
867 863

  
868 864
  del cl
869
  del qcl
870 865

  
871 866
  if not console_data:
872 867
    if oper_state:
b/lib/client/gnt_job.py
109 109

  
110 110
  qfilter = qlang.MakeSimpleFilter("status", opts.status_filter)
111 111

  
112
  cl = GetClient(query=True)
112
  cl = GetClient()
113 113

  
114 114
  return GenericList(constants.QR_JOB, selected_fields, args, None,
115 115
                     opts.separator, not opts.no_headers,
......
128 128
  @return: the desired exit code
129 129

  
130 130
  """
131
  cl = GetClient(query=True)
131
  cl = GetClient()
132 132

  
133 133
  return GenericListFields(constants.QR_JOB, args, opts.separator,
134 134
                           not opts.no_headers, cl=cl)
......
303 303
    ]
304 304

  
305 305
  qfilter = qlang.MakeSimpleFilter("id", _ParseJobIds(args))
306
  cl = GetClient(query=True)
306
  cl = GetClient()
307 307
  result = cl.Query(constants.QR_JOB, selected_fields, qfilter).data
308 308

  
309 309
  first = True
b/lib/client/gnt_network.py
111 111

  
112 112
  """
113 113
  cl = GetClient()
114
  qcl = GetClient(query=True)
115 114

  
116 115
  (network, mode, link) = args[:3]
117
  groups = _GetDefaultGroups(qcl, args[3:])
116
  groups = _GetDefaultGroups(cl, args[3:])
118 117

  
119 118
  # TODO: Change logic to support "--submit"
120 119
  for group in groups:
......
137 136

  
138 137
  """
139 138
  cl = GetClient()
140
  qcl = GetClient(query=True)
141 139

  
142 140
  (network, ) = args[:1]
143
  groups = _GetDefaultGroups(qcl, args[1:])
141
  groups = _GetDefaultGroups(cl, args[1:])
144 142

  
145 143
  # TODO: Change logic to support "--submit"
146 144
  for group in groups:
......
169 167
    "tags": (",".join, False),
170 168
    }
171 169

  
172
  cl = GetClient(query=True)
170
  cl = GetClient()
173 171
  return GenericList(constants.QR_NETWORK, desired_fields, args, None,
174 172
                     opts.separator, not opts.no_headers,
175 173
                     verbose=opts.verbose, format_override=fmtoverride,
......
186 184
  @return: the desired exit code
187 185

  
188 186
  """
189
  cl = GetClient(query=True)
187
  cl = GetClient()
190 188

  
191 189
  return GenericListFields(constants.QR_NETWORK, args, opts.separator,
192 190
                           not opts.no_headers, cl=cl)
......
203 201
  @return: the desired exit code
204 202

  
205 203
  """
206
  cl = GetClient(query=True)
204
  cl = GetClient()
207 205
  result = cl.QueryNetworks(fields=["name", "network", "gateway",
208 206
                                    "network6", "gateway6",
209 207
                                    "mac_prefix",
b/lib/client/gnt_node.py
233 233

  
234 234
  """
235 235
  cl = GetClient()
236
  query_cl = GetClient(query=True)
237 236
  node = netutils.GetHostname(name=args[0]).name
238 237
  readd = opts.readd
239 238

  
......
242 241
  try:
243 242
    # Passing [] to QueryGroups means query the default group:
244 243
    node_groups = [opts.nodegroup] if opts.nodegroup is not None else []
245
    output = query_cl.QueryGroups(names=node_groups, fields=["ndp/ssh_port"],
246
                                  use_locking=False)
244
    output = cl.QueryGroups(names=node_groups, fields=["ndp/ssh_port"],
245
                            use_locking=False)
247 246
    (ssh_port, ) = output[0]
248 247
  except (errors.OpPrereqError, errors.OpExecError):
249 248
    pass
250 249

  
251 250
  try:
252
    output = query_cl.QueryNodes(names=[node],
253
                                 fields=["name", "sip", "master",
254
                                         "ndp/ssh_port"],
255
                                 use_locking=False)
251
    output = cl.QueryNodes(names=[node],
252
                           fields=["name", "sip", "master",
253
                                   "ndp/ssh_port"],
254
                           use_locking=False)
256 255
    node_exists, sip, is_master, ssh_port = output[0]
257 256
  except (errors.OpPrereqError, errors.OpExecError):
258 257
    node_exists = ""
......
320 319
  fmtoverride = dict.fromkeys(["pinst_list", "sinst_list", "tags"],
321 320
                              (",".join, False))
322 321

  
323
  cl = GetClient(query=True)
322
  cl = GetClient()
324 323

  
325 324
  return GenericList(constants.QR_NODE, selected_fields, args, opts.units,
326 325
                     opts.separator, not opts.no_headers,
......
338 337
  @return: the desired exit code
339 338

  
340 339
  """
341
  cl = GetClient(query=True)
340
  cl = GetClient()
342 341

  
343 342
  return GenericListFields(constants.QR_NODE, args, opts.separator,
344 343
                           not opts.no_headers, cl=cl)
......
381 380

  
382 381
  cl = GetClient()
383 382

  
384
  qcl = GetClient(query=True)
383
  qcl = GetClient()
385 384
  result = qcl.QueryNodes(names=args, fields=fields, use_locking=False)
386 385
  qcl.Close()
387 386

  
......
440 439

  
441 440
  # these fields are static data anyway, so it doesn't matter, but
442 441
  # locking=True should be safer
443
  qcl = GetClient(query=True)
442
  qcl = GetClient()
444 443
  result = qcl.QueryNodes(names=args, fields=selected_fields,
445 444
                          use_locking=False)
446 445
  qcl.Close()
......
482 481
  force = opts.force
483 482
  selected_fields = ["name", "pinst_list"]
484 483

  
485
  qcl = GetClient(query=True)
484
  qcl = GetClient()
486 485
  result = qcl.QueryNodes(names=args, fields=selected_fields, use_locking=False)
487 486
  qcl.Close()
488 487
  ((node, pinst), ) = result
......
578 577
  @return: the desired exit code
579 578

  
580 579
  """
581
  cl = GetClient(query=True)
580
  cl = GetClient()
582 581
  result = cl.QueryNodes(fields=["name", "pip", "sip",
583 582
                                 "pinst_list", "sinst_list",
584 583
                                 "master_candidate", "drained", "offline",
b/lib/rapi/rlib2.py
225 225
    """Returns cluster information.
226 226

  
227 227
    """
228
    client = self.GetClient(query=True)
228
    client = self.GetClient()
229 229
    return client.QueryClusterInfo()
230 230

  
231 231

  
......
296 296
    @return: a dictionary with jobs id and uri.
297 297

  
298 298
    """
299
    client = self.GetClient(query=True)
299
    client = self.GetClient()
300 300

  
301 301
    if self.useBulk():
302 302
      bulkdata = client.QueryJobs(None, J_FIELDS_BULK)
......
325 325

  
326 326
    """
327 327
    job_id = self.items[0]
328
    result = self.GetClient(query=True).QueryJobs([job_id, ], J_FIELDS)[0]
328
    result = self.GetClient().QueryJobs([job_id, ], J_FIELDS)[0]
329 329
    if result is None:
330 330
      raise http.HttpNotFound()
331 331
    return baserlib.MapFields(J_FIELDS, result)
......
397 397
    """Returns a list of all nodes.
398 398

  
399 399
    """
400
    client = self.GetClient(query=True)
400
    client = self.GetClient()
401 401

  
402 402
    if self.useBulk():
403 403
      bulkdata = client.QueryNodes([], N_FIELDS, False)
......
419 419

  
420 420
    """
421 421
    node_name = self.items[0]
422
    client = self.GetClient(query=True)
422
    client = self.GetClient()
423 423

  
424 424
    result = baserlib.HandleItemQueryErrors(client.QueryNodes,
425 425
                                            names=[node_name], fields=N_FIELDS,
......
457 457

  
458 458
    """
459 459
    node_name = self.items[0]
460
    client = self.GetClient(query=True)
460
    client = self.GetClient()
461 461
    result = client.QueryNodes(names=[node_name], fields=["role"],
462 462
                               use_locking=self.useLocking())
463 463

  
......
673 673
    """Returns a list of all networks.
674 674

  
675 675
    """
676
    client = self.GetClient(query=True)
676
    client = self.GetClient()
677 677

  
678 678
    if self.useBulk():
679 679
      bulkdata = client.QueryNetworks([], NET_FIELDS, False)
......
696 696

  
697 697
    """
698 698
    network_name = self.items[0]
699
    client = self.GetClient(query=True)
699
    client = self.GetClient()
700 700

  
701 701
    result = baserlib.HandleItemQueryErrors(client.QueryNetworks,
702 702
                                            names=[network_name],
......
789 789
    """Returns a list of all node groups.
790 790

  
791 791
    """
792
    client = self.GetClient(query=True)
792
    client = self.GetClient()
793 793

  
794 794
    if self.useBulk():
795 795
      bulkdata = client.QueryGroups([], G_FIELDS, False)
......
812 812

  
813 813
    """
814 814
    group_name = self.items[0]
815
    client = self.GetClient(query=True)
815
    client = self.GetClient()
816 816

  
817 817
    result = baserlib.HandleItemQueryErrors(client.QueryGroups,
818 818
                                            names=[group_name], fields=G_FIELDS,
......
917 917
    """Returns a list of all available instances.
918 918

  
919 919
    """
920
    client = self.GetClient(query=True)
920
    client = self.GetClient()
921 921

  
922 922
    use_locking = self.useLocking()
923 923
    if self.useBulk():
......
998 998
    """Send information about an instance.
999 999

  
1000 1000
    """
1001
    client = self.GetClient(query=True)
1001
    client = self.GetClient()
1002 1002
    instance_name = self.items[0]
1003 1003

  
1004 1004
    result = baserlib.HandleItemQueryErrors(client.QueryInstances,
......
1384 1384

  
1385 1385
    """
1386 1386
    instance_name = self.items[0]
1387
    client = self.GetClient(query=True)
1387
    client = self.GetClient()
1388 1388

  
1389 1389
    ((console, oper_state), ) = \
1390 1390
        client.QueryInstances([instance_name], ["console", "oper_state"], False)
......
1529 1529
      if not self.name:
1530 1530
        raise http.HttpBadRequest("Missing name on tag request")
1531 1531

  
1532
      cl = self.GetClient(query=True)
1532
      cl = self.GetClient()
1533 1533
      tags = list(cl.QueryTags(kind, self.name))
1534 1534

  
1535 1535
    elif kind == constants.TAG_CLUSTER:
b/lib/server/masterd.py
363 363
      elif what == constants.QR_JOB:
364 364
        return queue.QueryJobs(fields, qfilter)
365 365
      elif what in constants.QR_VIA_LUXI:
366
        luxi_client = runtime.GetClient(query=True)
366
        luxi_client = runtime.GetClient()
367 367
        result = luxi_client.Query(what, fields, qfilter).ToDict()
368 368
      else:
369 369
        raise errors.OpPrereqError("Resource type '%s' unknown" % what,
b/lib/tools/burnin.py
549 549
    else:
550 550
      names = []
551 551
    try:
552
      qcl = GetClient(query=True)
552
      qcl = GetClient()
553 553
      result = qcl.QueryNodes(names, ["name", "offline", "drained"], False)
554 554
    except errors.GenericError, err:
555 555
      err_code, msg = cli.FormatError(err)
......
753 753
                 islice(cycle(self.nodes), 2, None),
754 754
                 self.instances)
755 755

  
756
    qcl = GetClient(query=True)
756
    qcl = GetClient()
757 757
    for pnode, snode, enode, instance in mytor:
758 758
      Log("instance %s", instance, indent=1)
759 759
      # read the full name of the instance

Also available in: Unified diff