primalmotion/Archipel — Issue #375: vmcasting fails under certain circumstances
Author: ew0x
Created: 2011-12-29 14:56:22+00:00
State: open

When decompressing an appliance, the definition gets generated from the bundled xml desc.
The parsing fails under certain circumstances, with this message in logs :

> ERROR ::2011-12-29 15:21:00::utils.py:70::TNArchipelVirtualMachine.run (dbf262ce-3227-11e1-
> b5dd-001517ba6f68@my.dummy.net/kvm2)::TNApplianceDecompresser: cannot update description because
> update_description() has returned exception: 'NoneType' object has no attribute 'getAttr'

That's due to wrong assessment while parsing the bundled xml desc file.
Here's an example :

While correcty formatted XML, the appliance decompresser code will fail parsing it:

archipelagentvmcasting/appliancedecompresser.py:

147 def update_description(self):
148 """
149 Define the uuid to write in the description file.
150 @raise Exception: Exception if description file is empty
151 @return: True in case of success
152 """
153 if not self.description_file:
154 raise Exception("Description file is empty.")
155 desc_string = self.description_file
156 xml_desc = xmpp.simplexml.NodeBuilder(data=desc_string).getDom()
157 name_node = xml_desc.getTag("name")
158 uuid_node = xml_desc.getTag("uuid")
159 disk_nodes = xml_desc.getTag("devices").getTags("disk")
160 for disk in disk_nodes:
161 source = disk.getTag("source")
162 if source is None: continue ########Extra line, quick&dirty fix
163 source_file = os.path.basename(source.getAttr("file")).replace(" .gz", "")
164 source.setAttr("file", os.path.join(self.entity.folder, source_file))

When line 162 is omitted, trying to access the "file" attribute @ line 163 obviously fails.
I've added line 162 here as a quick and dirty fix - checked, and it works so far so good.