mirror of
https://github.com/xen-project/xen.git
synced 2026-10-29 10:40:03 +01:00
[XEND] Updates to SR and VDI implementations
* Moved xenapi transport util method, stringify to xen.util.xmlrpclib2 * XenVDI now preserves configuration to an XML-ish file * Update Xen API's class names to be all lowercase * Update get_by_label to get_by_name_label and return sets as the API expects. * Add support for VBD creation with a VDI reference. Signed-off-by: Alastair Tse <atse@xensource.com>
This commit is contained in:
1 parent
2556368450
commit
76b24ff4e2
8 files changed
+474
-115
No files matched your search
@@ -21,8 +21,9 @@ An enhanced XML-RPC client/server interface for Python.
|
||||
"""
|
||||
|
||||
import string
|
||||
import types
|
||||
import fcntl
|
||||
from types import *
|
||||
|
||||
|
||||
from httplib import HTTPConnection, HTTP
|
||||
from SimpleXMLRPCServer import SimpleXMLRPCServer, SimpleXMLRPCRequestHandler
|
||||
@@ -39,6 +40,23 @@ except ImportError:
|
||||
# package.
|
||||
ssh_enabled = False
|
||||
|
||||
#
|
||||
# Convert all integers to strings as described in the Xen API
|
||||
#
|
||||
|
||||
|
||||
def stringify(value):
|
||||
if isinstance(value, IntType) and not isinstance(value, BooleanType):
|
||||
return str(value)
|
||||
elif isinstance(value, DictType):
|
||||
for k, v in value.items():
|
||||
value[k] = stringify(v)
|
||||
return value
|
||||
elif isinstance(value, (TupleType, ListType)):
|
||||
return [stringify(v) for v in value]
|
||||
else:
|
||||
return value
|
||||
|
||||
|
||||
# A new ServerProxy that also supports httpu urls. An http URL comes in the
|
||||
# form:
|
||||
@@ -91,8 +109,7 @@ class UnixTransport(xmlrpclib.Transport):
|
||||
|
||||
# See _marshalled_dispatch below.
|
||||
def conv_string(x):
|
||||
if (isinstance(x, types.StringType) or
|
||||
isinstance(x, unicode)):
|
||||
if isinstance(x, StringTypes):
|
||||
s = string.replace(x, "'", r"\047")
|
||||
exec "s = '" + s + "'"
|
||||
return s
|
||||
@@ -169,8 +186,7 @@ class TCPXMLRPCServer(SocketServer.ThreadingMixIn, SimpleXMLRPCServer):
|
||||
# to transmit the string using Python encoding.
|
||||
# Thanks to David Mertz <mertz@gnosis.cx> for the trick (buried
|
||||
# in xml_pickle.py).
|
||||
if (isinstance(response, types.StringType) or
|
||||
isinstance(response, unicode)):
|
||||
if isinstance(response, StringTypes):
|
||||
response = repr(response)[1:-1]
|
||||
|
||||
response = (response,)
|
||||
|
||||