From: Tony Mack Date: Thu, 30 Jun 2011 00:13:59 +0000 (-0400) Subject: implement get_slice_attributes() X-Git-Tag: sfa-1.0-27~57 X-Git-Url: http://git.onelab.eu/?a=commitdiff_plain;h=411ea93c242f33a690dec4f48721abf3a1fe3953;p=sfa.git implement get_slice_attributes() --- diff --git a/sfa/rspecs/sfa_rspec.py b/sfa/rspecs/sfa_rspec.py index ad87d7ce..20a2a784 100755 --- a/sfa/rspecs/sfa_rspec.py +++ b/sfa/rspecs/sfa_rspec.py @@ -87,7 +87,9 @@ class SfaRSpec(RSpec): if network: defaults = self.xml.xpath("//network[@name='%s']/sliver_defaults" % network) else: - defaults = self.xml.xpath("//network/sliver_defaults" % network) + defaults = self.xml.xpath("//sliver_defaults") + if isinstance(defaults, list) and defaults: + defaults = defaults[0] return self.attributes_list(defaults) def get_sliver_attributes(self, hostname, network=None): @@ -97,7 +99,17 @@ class SfaRSpec(RSpec): def get_slice_attributes(self, network=None): # TODO: FINISH - return [] + slice_attributes = [] + nodes_with_slivers = self.get_nodes_with_slivers(network) + for default_attribute in self.get_default_sliver_attributes(network): + attribute = {'name': str(default_attribute[0]), 'value': str(default_attribute[1]), 'node_id': None} + slice_attributes.append(attribute) + for node in nodes_with_slivers: + sliver_attributes = self.get_sliver_attributes(node, network) + for sliver_attribute in sliver_attributes: + attribute = {'name': str(sliver_attribute[0]), 'value': str(sliver_attribute[1]), 'node_id': node} + slice_attributes.append(attribute) + return slice_attributes def get_site_nodes(self, siteid, network=None): if network: