Revision d36e433d
b/lib/luxi.py | ||
---|---|---|
30 | 30 |
""" |
31 | 31 |
|
32 | 32 |
from ganeti import constants |
33 |
from ganeti import pathutils |
|
33 | 34 |
from ganeti import objects |
34 | 35 |
import ganeti.rpc.client as cl |
35 | 36 |
from ganeti.rpc.errors import RequestError |
... | ... | |
81 | 82 |
Arguments are the same as for L{AbstractClient}. |
82 | 83 |
|
83 | 84 |
""" |
84 |
super(Client, self).__init__(address, timeouts, transport)
|
|
85 |
super(Client, self).__init__(timeouts, transport) |
|
85 | 86 |
# Override the version of the protocol: |
86 | 87 |
self.version = constants.LUXI_VERSION |
88 |
# Store the socket address |
|
89 |
if address is None: |
|
90 |
address = pathutils.QUERY_SOCKET |
|
91 |
self.address = address |
|
92 |
self._InitTransport() |
|
93 |
|
|
94 |
def _GetAddress(self): |
|
95 |
return self.address |
|
87 | 96 |
|
88 | 97 |
def SetQueueDrainFlag(self, drain_flag): |
89 | 98 |
return self.CallMethod(REQ_SET_DRAIN_FLAG, (drain_flag, )) |
b/lib/rpc/client.py | ||
---|---|---|
25 | 25 |
|
26 | 26 |
import logging |
27 | 27 |
|
28 |
from ganeti import pathutils |
|
29 | 28 |
import ganeti.rpc.transport as t |
30 | 29 |
|
31 | 30 |
from ganeti import constants |
... | ... | |
157 | 156 |
|
158 | 157 |
""" |
159 | 158 |
|
160 |
def __init__(self, address=None, timeouts=None, |
|
161 |
transport=t.Transport): |
|
159 |
def __init__(self, timeouts=None, transport=t.Transport): |
|
162 | 160 |
"""Constructor for the Client class. |
163 | 161 |
|
164 | 162 |
Arguments: |
... | ... | |
171 | 169 |
class are used. |
172 | 170 |
|
173 | 171 |
""" |
174 |
if address is None: |
|
175 |
address = pathutils.QUERY_SOCKET |
|
176 |
self.address = address |
|
177 | 172 |
self.timeouts = timeouts |
178 | 173 |
self.transport_class = transport |
179 | 174 |
self.transport = None |
180 |
self._InitTransport() |
|
181 | 175 |
# The version used in RPC communication, by default unused: |
182 | 176 |
self.version = None |
183 | 177 |
|
178 |
def _GetAddress(self): |
|
179 |
"""Returns the socket address |
|
180 |
|
|
181 |
""" |
|
182 |
raise NotImplementedError |
|
183 |
|
|
184 | 184 |
def _InitTransport(self): |
185 | 185 |
"""(Re)initialize the transport if needed. |
186 | 186 |
|
187 | 187 |
""" |
188 | 188 |
if self.transport is None: |
189 |
self.transport = self.transport_class(self.address,
|
|
189 |
self.transport = self.transport_class(self._GetAddress(),
|
|
190 | 190 |
timeouts=self.timeouts) |
191 | 191 |
|
192 | 192 |
def _CloseTransport(self): |
Also available in: Unified diff