Revision 5b349fd1

b/lib/confd/client.py
60 60
from ganeti import daemon # contains AsyncUDPSocket
61 61
from ganeti import errors
62 62
from ganeti import confd
63
from ganeti import ssconf
63 64

  
64 65

  
65 66
class ConfdAsyncUDPClient(daemon.AsyncUDPSocket):
......
494 495
    elif up.type == UPCALL_EXPIRE:
495 496
      self._HandleExpire(up)
496 497
    self._callback(up)
498

  
499
def GetConfdClient(callback):
500
  """Return a client configured using the given callback.
501

  
502
  This is handy to abstract the MC list and HMAC key reading.
503

  
504
  @attention: This should only be called on nodes which are part of a
505
      cluster, since it depends on a valid (ganeti) data directory;
506
      for code running outside of a cluster, you need to create the
507
      client manually
508

  
509
  """
510
  ss = ssconf.SimpleStore()
511
  mc_file = ss.KeyToFilename(constants.SS_MASTER_CANDIDATES_IPS)
512
  mc_list = utils.ReadFile(mc_file).splitlines()
513
  hmac_key = utils.ReadFile(constants.CONFD_HMAC_KEY)
514
  return ConfdClient(hmac_key, mc_list, callback)
b/tools/burnin
36 36
from ganeti import cli
37 37
from ganeti import errors
38 38
from ganeti import utils
39
from ganeti import ssconf
40 39

  
41 40
from ganeti.confd import client as confd_client
42 41

  
......
266 265
    self.hvp = self.bep = None
267 266
    self.ParseOptions()
268 267
    self.cl = cli.GetClient()
269
    self.ss = ssconf.SimpleStore()
270 268
    self.GetState()
271 269

  
272 270
  def ClearFeedbackBuf(self):
......
885 883
    """
886 884
    Log("Checking confd results")
887 885

  
888
    hmac_key = utils.ReadFile(constants.CONFD_HMAC_KEY)
889
    mc_file = self.ss.KeyToFilename(constants.SS_MASTER_CANDIDATES_IPS)
890
    mc_list = utils.ReadFile(mc_file).splitlines()
891 886
    filter_callback = confd_client.ConfdFilterCallback(self.ConfdCallback)
892 887
    counting_callback = confd_client.ConfdCountingCallback(filter_callback)
893 888
    self.confd_counting_callback = counting_callback
894 889

  
895
    self.confd_client = confd_client.ConfdClient(hmac_key, mc_list,
896
                                                 counting_callback)
890
    self.confd_client = confd_client.GetConfdClient(counting_callback)
897 891

  
898 892
    req = confd_client.ConfdClientRequest(type=constants.CONFD_REQ_PING)
899 893
    self.DoConfdRequestReply(req)

Also available in: Unified diff