Package ganeti :: Module ovf :: Class OVFReader
[hide private]
[frames] | no frames]

Class OVFReader

source code


Reader class for OVF files.

Instance Methods [hide private]
 
__init__(self, input_path)
Initialiaze the reader - load the .ovf file to XML parser.
source code
list
_GetAttributes(self, path, attribute)
Get specified attribute from all nodes accessible using given path.
source code
ET.ElementTree or None
_GetElementMatchingAttr(self, path, match_attr)
Searches for element on a path that matches certain attribute value.
source code
ET.ElementTree or None
_GetElementMatchingText(self, path, match_text)
Searches for element on a path that matches certain text value.
source code
 
VerifyManifest(self)
Verifies manifest for the OVF package, if one is given.
source code
string
GetInstanceName(self)
Provides information about instance name.
source code
string or None
GetDiskTemplate(self)
Returns disk template from .ovf file
source code
dict
GetHypervisorData(self)
Provides hypervisor information - hypervisor name and options.
source code
dict
GetOSData(self)
Provides operating system information - os name and options.
source code
dict
GetBackendData(self)
Provides backend information - vcpus, memory, auto balancing options.
source code
string or None
GetTagsData(self)
Provides tags information for instance.
source code
string
GetVersionData(self)
Provides version number read from .ovf file
source code
dict
GetNetworkData(self)
Provides data about the network in the OVF instance.
source code
list
GetDisksNames(self)
Provides list of file names for the disks used by the instance.
source code

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Static Methods [hide private]
dict
_GetDictParameters(root, schema)
Reads text in all children and creates the dictionary from the contents.
source code
Instance Variables [hide private]
list files_list
list of files in the OVF package
string input_dir
directory in which the .ovf file resides
string schema_name
name of the .ovf file
ET.ElementTree tree
XML tree of the .ovf file
Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, input_path)
(Constructor)

source code 

Initialiaze the reader - load the .ovf file to XML parser.

It is assumed that names of manifesto (.mf), certificate (.cert) and ovf files are the same. In order to account any other files as part of the ovf package, they have to be explicitly mentioned in the Resources section of the .ovf file.

Parameters:
  • input_path (string) - absolute path to the .ovf file
Raises:
  • errors.OpPrereqError - when .ovf file is not a proper XML file or some of the files mentioned in Resources section do not exist
Overrides: object.__init__

_GetAttributes(self, path, attribute)

source code 

Get specified attribute from all nodes accessible using given path.

Function follows the path from root node to the desired tags using path, then reads the apropriate attribute values.

Parameters:
  • path (string) - path of nodes to visit
  • attribute (string) - attribute for which we gather the information
Returns: list
for each accessible tag with the attribute value set, value of the attribute

_GetElementMatchingAttr(self, path, match_attr)

source code 

Searches for element on a path that matches certain attribute value.

Function follows the path from root node to the desired tags using path, then searches for the first one matching the attribute value.

Parameters:
  • path (string) - path of nodes to visit
  • match_attr (tuple) - pair (attribute, value) for which we search
Returns: ET.ElementTree or None
first element matching match_attr or None if nothing matches

_GetElementMatchingText(self, path, match_text)

source code 

Searches for element on a path that matches certain text value.

Function follows the path from root node to the desired tags using path, then searches for the first one matching the text value.

Parameters:
  • path (string) - path of nodes to visit
  • match_text (tuple) - pair (node, text) for which we search
Returns: ET.ElementTree or None
first element matching match_text or None if nothing matches

_GetDictParameters(root, schema)
Static Method

source code 

Reads text in all children and creates the dictionary from the contents.

Parameters:
  • root (ET.ElementTree or None) - father of the nodes we want to collect data about
  • schema (string) - schema name to be removed from the tag
Returns: dict
dictionary containing tags and their text contents, tags have their schema fragment removed or empty dictionary, when root is None

VerifyManifest(self)

source code 

Verifies manifest for the OVF package, if one is given.

Raises:

GetInstanceName(self)

source code 

Provides information about instance name.

Returns: string
instance name string

GetDiskTemplate(self)

source code 

Returns disk template from .ovf file

Returns: string or None
name of the template

GetHypervisorData(self)

source code 

Provides hypervisor information - hypervisor name and options.

Returns: dict
dictionary containing name of the used hypervisor and all the specified options

GetOSData(self)

source code 

Provides operating system information - os name and options.

Returns: dict
dictionary containing name and options for the chosen OS

GetBackendData(self)

source code 

Provides backend information - vcpus, memory, auto balancing options.

Returns: dict
dictionary containing options for vcpus, memory and auto balance settings

GetTagsData(self)

source code 

Provides tags information for instance.

Returns: string or None
string of comma-separated tags for the instance

GetVersionData(self)

source code 

Provides version number read from .ovf file

Returns: string
string containing the version number

GetNetworkData(self)

source code 

Provides data about the network in the OVF instance.

The method gathers the data about networks used by OVF instance. It assumes that 'name' tag means something - in essence, if it contains one of the words 'bridged' or 'routed' then that will be the mode of this network in Ganeti. The information about the network can be either in GanetiSection or VirtualHardwareSection.

Returns: dict
dictionary containing all the network information

GetDisksNames(self)

source code 

Provides list of file names for the disks used by the instance.

Returns: list
list of file names, as referenced in .ovf file