- def add_sliver_attributes(xml, attributes):
- for attribute in attributes:
- if attribute['name'] == 'initscript':
- xml.add_element('{%s}initscript' % xml.namespaces['planetlab'], name=attribute['value'])
- elif tag['tagname'] == 'flack_info':
- attrib_elem = xml.add_element('{%s}info' % self.namespaces['flack'])
- attrib_dict = eval(tag['value'])
- for (key, value) in attrib_dict.items():
- attrib_elem.set(key, value)
+ def add_sliver_attributes(xml, tags):
+ if tags is None:
+ return
+ for tag in tags:
+ tagname = tag['tagname'] if 'tagname' in tag else tag['name']
+ if tagname == 'flack_info':
+ attrib_elem = xml.add_element(
+ '{%s}info' % self.namespaces['flack'])
+ try:
+ attrib_dict = eval(tag['value'])
+ for (key, value) in list(attrib_dict.items()):
+ attrib_elem.set(key, value)
+ except Exception as e:
+ logger.warning(
+ "Could not parse dictionary in flack tag -- {}".format(e))
+ elif tagname == 'initscript':
+ xml.add_element('{%s}initscript' % xml.namespaces['planetlab'],
+ name=tag['value'])
+ else:
+ xml.add_element('{%s}attribute' % (xml.namespaces['planetlab']),
+ name=tagname,
+ value=tag['value'],
+ scope=tag.get('scope', 'unknown'),
+ )
+