Commit 8455af9c by tarokkk

adding deserializers to VM classes

parent 25b22a1e
......@@ -68,6 +68,12 @@ class VMInstance:
self.seclabel_type = seclabel_type
self.seclabel_mode = seclabel_mode
@classmethod
def deserialize(cls, desc):
desc['disk_list'] = [VMDisk.deserialize(d) for d in desc['disk_list']]
desc['network_list'] = [VMNetwork.deserialize(n) for n in desc['network_list']]
return cls(**desc)
def build_xml(self):
'''Return the root Element Tree object
'''
......@@ -160,6 +166,10 @@ class VMDisk:
self.driver_cache = driver_cache
self.target_device = target_device
@classmethod
def deserialize(cls, desc):
return cls(**desc)
def build_xml(self):
xml_top = ET.Element('disk',
attrib={'type': self.disk_type,
......@@ -234,6 +244,10 @@ class VMNetwork:
self.vlan = vlan
self.managed = managed
@classmethod
def deserialize(cls, desc):
return cls(**desc)
# XML dump
def build_xml(self):
xml_top = ET.Element('interface', attrib={'type': self.network_type})
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment