XenAPI 24.19.2__tar.gz → 24.20.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: XenAPI
3
- Version: 24.19.2
3
+ Version: 24.20.0
4
4
  Summary: XenAPI SDK, for communication with XenServer.
5
5
  Home-page: https://xapi-project.github.io/
6
6
  Author: Xapi project developers and maintainers
@@ -124,7 +124,13 @@ class UDSTransport(xmlrpclib.Transport):
124
124
  self.add_extra_header(k, v)
125
125
  def make_connection(self, host):
126
126
  self.with_tracecontext()
127
- return UDSHTTPConnection(host)
127
+
128
+ # compatibility with parent xmlrpclib.Transport HTTP/1.1 support
129
+ if self._connection and host == self._connection[0]:
130
+ return self._connection[1]
131
+
132
+ self._connection = host, UDSHTTPConnection(host)
133
+ return self._connection[1]
128
134
 
129
135
  def notimplemented(name, *args, **kwargs):
130
136
  raise NotImplementedError("XMLRPC proxies do not support python magic methods", name, *args, **kwargs)
@@ -144,6 +150,11 @@ class Session(xmlrpclib.ServerProxy):
144
150
  def __init__(self, uri, transport=None, encoding=None, verbose=0,
145
151
  allow_none=1, ignore_ssl=False):
146
152
 
153
+ if sys.version_info[0] > 2:
154
+ # this changed to be a 'bool' in Python3
155
+ verbose = bool(verbose)
156
+ allow_none = bool(allow_none)
157
+
147
158
  # Fix for CA-172901 (+ Python 2.4 compatibility)
148
159
  # Fix for context=ctx ( < Python 2.7.9 compatibility)
149
160
  if not (sys.version_info[0] <= 2 and sys.version_info[1] <= 7 and sys.version_info[2] <= 9 ) \
@@ -159,7 +170,7 @@ class Session(xmlrpclib.ServerProxy):
159
170
  self._session = None
160
171
  self.last_login_method = None
161
172
  self.last_login_params = None
162
- self.API_version = API_VERSION_1_1
173
+ self._API_version = API_VERSION_1_1
163
174
 
164
175
 
165
176
  def xenapi_request(self, methodname, params):
@@ -196,24 +207,32 @@ class Session(xmlrpclib.ServerProxy):
196
207
  self._session = result
197
208
  self.last_login_method = method
198
209
  self.last_login_params = params
199
- self.API_version = self._get_api_version()
210
+
211
+ # This was initialized to 1.1 in the constructor.
212
+ # Now that we are logged in, the next time API_version() is run
213
+ # it can fetch the real version.
214
+ # However nothing in this script actually needs that, so don't call it immediately.
215
+ self._API_version = None
200
216
  except socket.error as e:
201
- if e.errno == socket.errno.ETIMEDOUT:
217
+ # pytype false positive: there is a socket.errno in both py2 and py3
218
+ if e.errno == socket.errno.ETIMEDOUT: # pytype: disable=module-attr
202
219
  raise xmlrpclib.Fault(504, 'The connection timed out')
203
- else:
204
- raise e
220
+ raise e
205
221
 
206
222
  def _logout(self):
207
223
  try:
208
224
  if self.last_login_method.startswith("slave_local"):
225
+ # Proxied function, pytype can't see it
226
+ # pytype: disable=attribute-error
209
227
  return _parse_result(self.session.local_logout(self._session))
228
+ # pytype: enable=attribute-error
210
229
  else:
211
230
  return _parse_result(self.session.logout(self._session))
212
231
  finally:
213
232
  self._session = None
214
233
  self.last_login_method = None
215
234
  self.last_login_params = None
216
- self.API_version = API_VERSION_1_1
235
+ self._API_version = API_VERSION_1_1
217
236
 
218
237
  def _get_api_version(self):
219
238
  pool = self.xenapi.pool.get_all()[0]
@@ -222,15 +241,21 @@ class Session(xmlrpclib.ServerProxy):
222
241
  minor = self.xenapi.host.get_API_version_minor(host)
223
242
  return "%s.%s"%(major,minor)
224
243
 
244
+ @property
245
+ def API_version(self):
246
+ if not self._API_version:
247
+ self._API_version = self._get_api_version()
248
+ return self._API_version
249
+
225
250
  def __getattr__(self, name):
226
251
  if name == 'handle':
227
252
  return self._session
228
253
  elif name == 'xenapi':
229
- return _Dispatcher(self.API_version, self.xenapi_request, None)
254
+ return _Dispatcher(self.xenapi_request, None)
230
255
  elif name.startswith('login') or name.startswith('slave_local'):
231
256
  return lambda *params: self._login(name, params)
232
257
  elif name == 'logout':
233
- return _Dispatcher(self.API_version, self.xenapi_request, "logout")
258
+ return _Dispatcher(self.xenapi_request, "logout")
234
259
  elif name.startswith('__') and name.endswith('__'):
235
260
  return lambda *args, **kwargs: notimplemented(name, args, kwargs)
236
261
  else:
@@ -261,8 +286,7 @@ def _parse_result(result):
261
286
 
262
287
  # Based upon _Method from xmlrpclib.
263
288
  class _Dispatcher:
264
- def __init__(self, API_version, send, name):
265
- self.__API_version = API_version
289
+ def __init__(self, send, name):
266
290
  self.__send = send
267
291
  self.__name = name
268
292
 
@@ -274,9 +298,9 @@ class _Dispatcher:
274
298
 
275
299
  def __getattr__(self, name):
276
300
  if self.__name is None:
277
- return _Dispatcher(self.__API_version, self.__send, name)
301
+ return _Dispatcher(self.__send, name)
278
302
  else:
279
- return _Dispatcher(self.__API_version, self.__send, "%s.%s" % (self.__name, name))
303
+ return _Dispatcher(self.__send, "%s.%s" % (self.__name, name))
280
304
 
281
305
  def __call__(self, *args):
282
306
  return self.__send(self.__name, args)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: XenAPI
3
- Version: 24.19.2
3
+ Version: 24.20.0
4
4
  Summary: XenAPI SDK, for communication with XenServer.
5
5
  Home-page: https://xapi-project.github.io/
6
6
  Author: Xapi project developers and maintainers
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes