Package ganeti :: Package confd :: Module client
[hide private]
[frames] | no frames]

Module client

source code

Ganeti confd client

Clients can use the confd client library to send requests to a group of master candidates running confd. The expected usage is through the asyncore framework, by sending queries, and asynchronously receiving replies through a callback.

This way the client library doesn't ever need to "wait" on a particular answer, and can proceed even if some udp packets are lost. It's up to the user to reschedule queries if they haven't received responses and they need them.

Example usage:

 client = ConfdClient(...) # includes callback specification
 req = confd_client.ConfdClientRequest(type=constants.CONFD_REQ_PING)
 client.SendRequest(req)
 # then make sure your client calls asyncore.loop() or daemon.Mainloop.Run()
 # ... wait ...
 # And your callback will be called by asyncore, when your query gets a
 # response, or when it expires.

You can use the provided ConfdFilterCallback to act as a filter, only passing "newer" answer to your callback, and filtering out outdated ones, or ones confirming what you already got.

Classes [hide private]
  ConfdAsyncUDPClient
Confd udp asyncore client
  _Request
Request status structure.
  ConfdClient
Send queries to confd, and get back answers.
  ConfdUpcallPayload
Callback argument for confd replies
  ConfdClientRequest
This is the client-side version of ConfdRequest.
  ConfdFilterCallback
Callback that calls another callback, but filters duplicate results.
  ConfdCountingCallback
Callback that calls another callback, and counts the answers
  StoreResultCallback
Callback that simply stores the most recent answer.
Functions [hide private]
 
GetConfdClient(callback)
Return a client configured using the given callback.
source code
Variables [hide private]
  UPCALL_REPLY = 1
  UPCALL_EXPIRE = 2
  CONFD_UPCALL_TYPES = frozenset([UPCALL_REPLY, UPCALL_EXPIRE,])

Imports: time, random, utils, constants, objects, serializer, daemon, errors, confd, ssconf, compat, netutils


Function Details [hide private]

GetConfdClient(callback)

source code 

Return a client configured using the given callback.

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

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