From 84fa2b69f4cf220bf2abdb3eaf55b9d45fd1dd5b Mon Sep 17 00:00:00 2001
From: Tony Mack <tmack@paris.CS.Princeton.EDU>
Date: Mon, 20 Jun 2011 16:03:28 -0400
Subject: [PATCH] global sliver attributes should appear in the
 <sliver_defaults> tag and not under each node

---
 sfa/plc/aggregate.py    | 3 ++-
 sfa/rspecs/pg_rspec.py  | 3 +++
 sfa/rspecs/sfa_rspec.py | 5 ++---
 3 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/sfa/plc/aggregate.py b/sfa/plc/aggregate.py
index 12580b86..ae4a03bb 100644
--- a/sfa/plc/aggregate.py
+++ b/sfa/plc/aggregate.py
@@ -105,8 +105,9 @@ class Aggregate:
                     slivers.append(sliver)
                     for tag in tags:
                         # if tag isn't bound to a node then it applies to all slivers
+                        # and belongs in the <sliver_defaults> tag
                         if not tag['node_id']:
-                            sliver['tags'].append(tag)
+                            rspec.add_default_sliver_attribute(tag['tagname'], tag['value'], self.api.hrn)
                         else:
                             tag_host = self.nodes[tag['node_id']]['hostname']
                             if tag_host == sliver['hostname']:
diff --git a/sfa/rspecs/pg_rspec.py b/sfa/rspecs/pg_rspec.py
index 7c3f7601..d481eb74 100755
--- a/sfa/rspecs/pg_rspec.py
+++ b/sfa/rspecs/pg_rspec.py
@@ -136,6 +136,9 @@ class PGRSpec(RSpec):
                     node.set('sliver_id', sliver_urn)
                 etree.SubElement(node, 'sliver_type', name='plab-vnode')
 
+    def add_default_sliver_attribute(self, name, value, network=Name):
+        pass
+
     def add_interfaces(self, interfaces, no_dupes=False):
         pass
 
diff --git a/sfa/rspecs/sfa_rspec.py b/sfa/rspecs/sfa_rspec.py
index bc122004..0fce4265 100755
--- a/sfa/rspecs/sfa_rspec.py
+++ b/sfa/rspecs/sfa_rspec.py
@@ -248,9 +248,8 @@ class SfaRSpec(RSpec):
         else:
             defaults = self.xml.xpath("//sliver_defaults" % network)
         if defaults is None:
-            defaults = etree.Element("sliver_defaults")
-            network = self.xml.xpath("//network[@name='%s']" % network)
-            network.insert(0, defaults)
+            network_tag = self.xml.xpath("//network[@name='%s']" % network)
+            defaults = self.add_element('sliver_defaults', attrs={}, network_tag)
         self.add_attribute(defaults, name, value)
 
     def add_sliver_attribute(self, hostname, name, value, network=None):
-- 
2.47.0