Commit 12efac17 authored by Rafael Monnerat's avatar Rafael Monnerat

slapos_cloud: Minor improvements

parent 52696697
...@@ -71,21 +71,18 @@ class SoftwareInstance(Item): ...@@ -71,21 +71,18 @@ class SoftwareInstance(Item):
def _getXmlAsDict(self, xml): def _getXmlAsDict(self, xml):
result_dict = {} result_dict = {}
if xml is None or xml == '': if xml:
return result_dict tree = etree.fromstring(xml)
for element in tree.iterfind('parameter'):
tree = etree.fromstring(xml) key = element.get('id').encode("UTF-8")
value = result_dict.get(key, None)
for element in tree.findall('parameter'): if value is not None:
key = element.get('id').encode("UTF-8") value = (value + ' ' + element.text)
value = result_dict.get(key, None) else:
if value is not None: value = element.text
value = (value + ' ' + element.text) if value is not None:
else: value = value.encode("UTF-8")
value = element.text result_dict[key] = value
if value is not None:
value = value.encode("UTF-8")
result_dict[key] = value
return result_dict return result_dict
security.declareProtected(Permissions.AccessContentsInformation, security.declareProtected(Permissions.AccessContentsInformation,
...@@ -160,6 +157,8 @@ class SoftwareInstance(Item): ...@@ -160,6 +157,8 @@ class SoftwareInstance(Item):
def _asParameterDict(self, shared_instance_sql_list=None): def _asParameterDict(self, shared_instance_sql_list=None):
portal = self.getPortalObject() portal = self.getPortalObject()
compute_partition = self.getAggregateValue(portal_type="Compute Partition") compute_partition = self.getAggregateValue(portal_type="Compute Partition")
if compute_partition is None:
raise ValueError("Instance isn't allocated to call _asParamterDict")
timestamp = int(compute_partition.getModificationDate()) timestamp = int(compute_partition.getModificationDate())
newtimestamp = int(self.getBangTimestamp(int(self.getModificationDate()))) newtimestamp = int(self.getBangTimestamp(int(self.getModificationDate())))
......
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 to comment