Revision 7f28a87a
b/lib/runtime.py | ||
---|---|---|
26 | 26 |
import grp |
27 | 27 |
import pwd |
28 | 28 |
import threading |
29 |
import os |
|
30 | 29 |
import platform |
31 | 30 |
|
32 | 31 |
from ganeti import constants |
... | ... | |
242 | 241 |
return _arch |
243 | 242 |
|
244 | 243 |
|
245 |
def GetClient(query=True):
|
|
244 |
def GetClient(): |
|
246 | 245 |
"""Connects to the a luxi socket and returns a client. |
247 | 246 |
|
248 |
@type query: boolean |
|
249 |
@param query: this signifies that the client will only be |
|
250 |
used for queries; if the build-time parameter |
|
251 |
enable-split-queries is enabled, then the client will be |
|
252 |
connected to the query socket instead of the masterd socket |
|
253 |
|
|
254 | 247 |
""" |
255 |
override_socket = os.getenv(constants.LUXI_OVERRIDE, "") |
|
256 |
if override_socket: |
|
257 |
if override_socket == constants.LUXI_OVERRIDE_MASTER: |
|
258 |
address = pathutils.MASTER_SOCKET |
|
259 |
elif override_socket == constants.LUXI_OVERRIDE_QUERY: |
|
260 |
address = pathutils.QUERY_SOCKET |
|
261 |
else: |
|
262 |
address = override_socket |
|
263 |
elif query: |
|
264 |
address = pathutils.QUERY_SOCKET |
|
265 |
else: |
|
266 |
address = None |
|
267 |
# TODO: Cache object? |
|
268 | 248 |
try: |
269 |
client = luxi.Client(address=address)
|
|
249 |
client = luxi.Client(address=pathutils.QUERY_SOCKET)
|
|
270 | 250 |
except NoMasterError: |
271 | 251 |
ss = ssconf.SimpleStore() |
272 | 252 |
|
Also available in: Unified diff