slivers = node.get('slivers', [])
if not slivers:
# we must still advertise the available sliver types
- slivers = Sliver({'type': 'plab-vserver'})
+ if node.get('sliver_type'):
+ slivers = Sliver({'type': node['sliver_type']})
+ else:
+ # Planet lab
+ slivers = Sliver({'type': 'plab-vserver'})
# we must also advertise the available initscripts
slivers['tags'] = []
if node.get('pl_initscripts'):
node_elem.add_instance('{%s}attribute' % xml.namespaces['planetlab'], tag, ['name', 'value'])
# add sliver tag in Request Rspec
- if rspec_content_type == "request":
- node_elem.add_instance('sliver', '', [])
+ #if rspec_content_type == "request":
+ # node_elem.add_instance('sliver', '', [])
return node_elems
@staticmethod
- def get_nodes(xml, filter={}):
+ def get_nodes(xml, filter=None):
+ if filter is None: filter={}
xpath = '//node%s | //default:node%s' % (XpathFilter.xpath(filter), XpathFilter.xpath(filter))
node_elems = xml.xpath(xpath)
return PGv2Node.get_node_objs(node_elems)
@staticmethod
- def get_nodes_with_slivers(xml, filter={}):
+ def get_nodes_with_slivers(xml, filter=None):
+ if filter is None: filter={}
xpath = '//node[count(sliver_type)>0] | //default:node[count(default:sliver_type) > 0]'
node_elems = xml.xpath(xpath)
return PGv2Node.get_node_objs(node_elems)
node['slivers'] = PGv2SliverType.get_slivers(node_elem)
# get boot state
- available_elems = node_elem.xpath('./default:available | ./available')
+ available_elems = node_elem.xpath('./default:available | ./available')
if len(available_elems) > 0 and 'now' in available_elems[0].attrib:
if available_elems[0].attrib.get('now', '').lower() == 'true':
node['boot_state'] = 'boot'
node['boot_state'] = 'disabled'
# get initscripts
- node['pl_initscripts'] = []
- initscript_elems = node_elem.xpath('./default:sliver_type/planetlab:initscript | ./sliver_type/initscript')
- if len(initscript_elems) > 0:
- for initscript_elem in initscript_elems:
- if 'name' in initscript_elem.attrib:
- node['pl_initscripts'].append(dict(initscript_elem.attrib))
+ try:
+ node['pl_initscripts'] = []
+ initscript_elems = node_elem.xpath('./default:sliver_type/planetlab:initscript | ./sliver_type/initscript')
+ if len(initscript_elems) > 0:
+ for initscript_elem in initscript_elems:
+ if 'name' in initscript_elem.attrib:
+ node['pl_initscripts'].append(dict(initscript_elem.attrib))
+ except:
+ pass
# get node tags
- tag_elems = node_elem.xpath('./planetlab:attribute | ./attribute')
- node['tags'] = []
- if len(tag_elems) > 0:
- for tag_elem in tag_elems:
- tag = dict(tag_elem.get_instance(Attribute))
- tag['tagname'] = tag.pop('name')
- node['tags'].append(tag)
+ try:
+ tag_elems = node_elem.xpath('./planetlab:attribute | ./attribute')
+ node['tags'] = []
+ if len(tag_elems) > 0:
+ for tag_elem in tag_elems:
+ tag = dict(tag_elem.get_instance(Attribute))
+ tag['tagname'] = tag.pop('name')
+ node['tags'].append(tag)
+ except:
+ pass
+
return nodes