merging bugfixes from trunk
[sfa.git] / sfa / plc / network.py
index 1210b72..94f6e04 100644 (file)
@@ -115,6 +115,7 @@ class Slice:
         self.network = network
         self.id = slice['slice_id']
         self.name = slice['name']
+        self.peer_id = slice['peer_id']
         self.node_ids = set(slice['node_ids'])
         self.slice_tag_ids = slice['slice_tag_ids']
     
@@ -295,7 +296,7 @@ A Network is a compound object consisting of:
 * a dictionary mapping interface IDs to Iface objects
 """
 class Network:
-    def __init__(self, api, type = "PlanetLab"):
+    def __init__(self, api, type = "SFA"):
         self.api = api
         self.type = type
         self.sites = self.get_sites(api)
@@ -420,6 +421,15 @@ class Network:
             message = str(sys.exc_info()[1])
             raise InvalidRSpec(message)
 
+        # Filter out stuff that's not for us
+        rspec = tree.getroot()
+        for network in rspec.iterfind("./network"):
+            if network.get("name") != self.api.hrn:
+                rspec.remove(network)
+        for request in rspec.iterfind("./request"):
+            if request.get("name") != self.api.hrn:
+                rspec.remove(request)
+
         if schema:
             # Validate the incoming request against the RelaxNG schema
             relaxng_doc = etree.parse(schema)
@@ -430,10 +440,9 @@ class Network:
                 message = "%s (line %s)" % (error.message, error.line)
                 raise InvalidRSpec(message)
 
-        rspec = tree.getroot()
         self.rspec = rspec
 
-        defaults = rspec.find("./network/sliver_defaults")
+        defaults = rspec.find(".//sliver_defaults")
         self.__process_attributes(defaults)
 
         # Find slivers under node elements