def _ova_to_spec(self, filename):
<EOL>ova_extracted_dir = os.path.splitext(filename)[<NUM_LIT:0>]<EOL>if not os.path.exists(ova_extracted_dir):<EOL><INDENT>os.makedirs(ova_extracted_dir)<EOL>subprocess.check_output(<EOL>["<STR_LIT>", "<STR_LIT>", filename, "<STR_LIT>", ova_extracted_dir],<EOL>stderr=subprocess.STDOUT<EOL>)<EOL><DEDENT>ovf = glob.glob(ova_extracted_dir + "<STR_LIT>")<EOL>if len(ovf) != <NUM_LIT:1>:<EOL><INDENT>raise RuntimeError("<STR_LIT>")<EOL><DEDENT>image_file = None<EOL>memory = None<EOL>vcpus = None<EOL>with open(ovf[<NUM_LIT:0>]) as fd:<EOL><INDENT>obj = xmltodict.parse(fd.read())<EOL>hardware_items = [<EOL>section<EOL>for section in obj["<STR_LIT>"]["<STR_LIT>"]["<STR_LIT>"]<EOL>if section["<STR_LIT>"] == "<STR_LIT>"<EOL>]<EOL>if len(hardware_items) != <NUM_LIT:1>:<EOL><INDENT>raise RuntimeError("<STR_LIT>")<EOL><DEDENT>hardware_items = hardware_items[<NUM_LIT:0>]<EOL>for item in hardware_items["<STR_LIT>"]:<EOL><INDENT>CPU_RESOURCE = <NUM_LIT:3><EOL>MEMORY_RESOURCE = <NUM_LIT:4><EOL>DISK_RESOURCE = <NUM_LIT><EOL>resource_type = int(item["<STR_LIT>"])<EOL>if resource_type == CPU_RESOURCE:<EOL><INDENT>vcpus = int(item["<STR_LIT>"]) *int(item["<STR_LIT>"])<EOL><DEDENT>elif resource_type == MEMORY_RESOURCE:<EOL><INDENT>memory = int(item["<STR_LIT>"])<EOL>if item["<STR_LIT>"] != "<STR_LIT>":<EOL><INDENT>raise TypeError(<EOL>"<STR_LIT>"<EOL>)<EOL><DEDENT><DEDENT>elif resource_type == DISK_RESOURCE:<EOL><INDENT>image_file = item["<STR_LIT>"]<EOL><DEDENT><DEDENT><DEDENT>if image_file is not None:<EOL><INDENT>disk_meta = {"<STR_LIT>": "<STR_LIT>"}<EOL>disk_spec = [<EOL>{<EOL>"<STR_LIT:type>": "<STR_LIT>",<EOL>"<STR_LIT>": "<STR_LIT>",<EOL>"<STR_LIT>": "<STR_LIT>",<EOL>"<STR_LIT>": "<STR_LIT>",<EOL>"<STR_LIT:name>": os.path.basename(image_file),<EOL>"<STR_LIT:path>": ova_extracted_dir + "<STR_LIT>" + image_file,<EOL>"<STR_LIT>": disk_meta<EOL>}<EOL>]<EOL><DEDENT>return disk_spec, memory, vcpus<EOL>
Retrieve the given ova and makes a template of it.
Creates a disk from network provided ova.
Calculates the needed memory from the ovf.
The disk will be cached in the template repo

Args:
    filename(str): the url to retrive the data from

TODO:
    * Add hash checking against the server
      for faster download and latest version
    * Add config script running on host - other place
    * Add cloud init support - by using cdroms in other place
    * Handle cpu in some way - some other place need to pick it up
    * Handle the memory units properly - we just assume MegaBytes

Returns:
    list of dict: list with the disk specification
    int: VM memory, None if none defined
    int: Number of virtual cpus, None if none defined

Raises:
    RuntimeError: If the ova format is not supported
    TypeError: If the memory units in the ova are noot supported
        (currently only 'MegaBytes')