Top

ovirtsdk4.writer module

Classes

class Writer

This is the base class for all the writers of the SDK. It contains the utility methods used by all of them.

Ancestors (in MRO)

Static methods

def render_boolean(

value)

Converts the given boolean value to a string.

def render_date(

value)

Converts the given date value to a string.

def render_decimal(

value)

Converts the given decimal value to a string.

def render_integer(

value)

Converts the given integer value to a string.

def write_boolean(

writer, name, value)

Writes an element with the given name and boolean value.

def write_date(

writer, name, value)

Writes an element with the given name and date value.

def write_decimal(

writer, name, value)

Writes an element with the given name and decimal value.

def write_integer(

writer, name, value)

Writes an element with the given name and integer value.

def write_string(

writer, name, value)

Writes an element with the given name and string value.

Methods

def __init__(

self)

def register(

cls, typ, writer)

Registers a write method.

typ

The type.

writer

The reference to the method that writes the XML object corresponding to the type.

def write(

cls, obj, target=None, root=None, indent=False)

Writes one object, determining the writer method to use based on the type. For example, if the type of the object is Vm then it will write the vm tag, with its contents.

obj

The object to write.

target

The XML writer where the output will be written. If this parameter isn’t given, or if the value is None the method will return a string containing the XML document.

root

The name of the root tag of the generated XML document. This isn’t needed when writing single objects, as the tag is calculated from the type of the object. For example, if the object isa virtual machine then the tag will be vm. But when writing lists of objects the it is needed, because the list may be empty, or have different types of objects. In this case, for lists, if it isn’t provided an exception will be raised.

indent

Indicates if the output should be indented, for easier reading by humans.