attributes = []
nodes_with_slivers = self.get_nodes_with_slivers()
for default_attribute in self.get_default_sliver_attributes(network):
+ attribute = default_attribute.copy()
attribute['node_id'] = None
attributes.append(attribute)
for node in nodes_with_slivers:
sliver_attributes = self.get_sliver_attributes(nodename, network)
for sliver_attribute in sliver_attributes:
sliver_attribute['node_id'] = nodename
- attributes.append(attribute)
+ attributes.append(sliver_attribute)
return attributes
SFAv1Sliver.add_sliver_attribute(sliver, name, value)
else:
# should this be an assert / raise an exception?
- print "WARNING: failed to find component_id", component_id
+ logger.error("WARNING: failed to find component_id %s" % component_id)
def get_sliver_attributes(self, component_id, network=None):
nodes = self.get_nodes({'component_id': '*%s*' % component_id})
if network:
defaults = self.xml.xpath("//network[@name='%s']/sliver_defaults" % network)
else:
- defaults = self.xml.xpath("//sliver_defaults" % network)
- if not defaults :
- network_tag = self.xml.xpath("//network[@name='%s']" % network)
+ defaults = self.xml.xpath("//sliver_defaults")
+ if not defaults:
+ if network:
+ network_tag = self.xml.xpath("//network[@name='%s']" % network)
+ else:
+ network_tag = self.xml.xpath("//network")
if isinstance(network_tag, list):
network_tag = network_tag[0]
defaults = network_tag.add_element('sliver_defaults')
Merge contents for specified rspec with current rspec
"""
+ if not in_rspec:
+ return
+
from sfa.rspecs.rspec import RSpec
if isinstance(in_rspec, RSpec):
rspec = in_rspec