class documentation

class Converter(object):

Known subclasses: ganeti.ovf.OVFExporter, ganeti.ovf.OVFImporter

View In Hierarchy

Converter class for OVF packages.

Converter is a class above both ImporterOVF and ExporterOVF. It's purpose is to provide a common interface for the two.

Method __init__ Initialize the converter.
Method Cleanup Cleans the temporary directory, if one was created.
Method Parse Parses the data and creates a structure containing all required info.
Method Save Saves the gathered configuration in an apropriate format.
Instance Variable options options parsed from the command line
Instance Variable output_dir directory to which the results of conversion shall be written
Instance Variable temp_dir temporary directory created then we deal with OVA
Instance Variable temp_file_manager container for temporary files created during conversion
Static Method _GetDiskQemuInfo Figures out some information of the disk using qemu-img.
Method _CompressDisk Performs (de)compression on the disk and returns the new path
Method _ConvertDisk Performes conversion to specified format.
Method _ReadInputData Reads the data on which the conversion will take place.
def __init__(self, input_path, options):

Initialize the converter.

Parameters
input_path:stringpath to the Converter input file
options:optparse.Valuescommand line options
Raises
errors.OpPrereqErrorif file does not exist
def Cleanup(self):

Cleans the temporary directory, if one was created.

def Parse(self):

Parses the data and creates a structure containing all required info.

def Save(self):

Saves the gathered configuration in an apropriate format.

options: optparse.Values =

options parsed from the command line

output_dir: string =

directory to which the results of conversion shall be written

temp_dir: string =

temporary directory created then we deal with OVA

temp_file_manager: utils.TemporaryFileManager =

container for temporary files created during conversion

@staticmethod
def _GetDiskQemuInfo(disk_path, regexp):

Figures out some information of the disk using qemu-img.

Parameters
disk_path:stringpath to the disk we want to know the format of
regexp:stringstring that has to be matched, it has to contain one group
Returns
stringdisk format
Raises
errors.OpPrereqErrorformat information cannot be retrieved
def _CompressDisk(self, disk_path, compression, action):

Performs (de)compression on the disk and returns the new path

Parameters
disk_path:stringpath to the disk
compression:stringcompression type
action:stringwhether the action is compression or decompression
Returns
stringnew disk path after (de)compression
Raises
errors.OpPrereqErrordisk (de)compression failed or "compression" is not supported
def _ConvertDisk(self, disk_format, disk_path):

Performes conversion to specified format.

Parameters
disk_format:stringformat to which the disk should be converted
disk_path:stringpath to the disk that should be converted
Returns
string @return path to the output diskUndocumented
Raises
errors.OpPrereqErrorconvertion of the disk failed
def _ReadInputData(self, input_path):

Reads the data on which the conversion will take place.

Parameters
input_path:stringabsolute path to the Converter input file