(*) slice atttribute types get cached
[plcapi.git] / PLC / Peers.py
index 8be0521..684361f 100644 (file)
@@ -3,7 +3,6 @@
 # 
 
 import re
-
 from types import StringTypes
 
 from PLC.Faults import *
@@ -11,6 +10,9 @@ from PLC.Parameter import Parameter
 from PLC.Filter import Filter
 from PLC.Table import Row, Table
 
+from PLC.Nodes import Nodes,Node
+from PLC.Slices import Slices,Slice
+
 class Peer (Row):
     """
     Stores the list of peering PLCs in the peers table. 
@@ -24,7 +26,8 @@ class Peer (Row):
        'peername' : Parameter (str, "Peer name"),
        'peer_url' : Parameter (str, "Peer API url"),
        'person_id' : Parameter (int, "Person_id of the account storing credentials - temporary"),
-       'node_ids' : Parameter ([int], "This peer's nodes ids")
+       'node_ids' : Parameter ([int], "This peer's nodes ids"),
+       'slice_ids' : Parameter ([int], "This peer's slices ids"),
        }
 
     def validate_peer_url (self, url):
@@ -43,6 +46,11 @@ class Peer (Row):
        
        assert 'peer_id' in self
 
+        # remove nodes depending on this peer
+        for foreign_node in Nodes (self.api, self['node_ids']):
+            foreign_node.delete(commit)
+
+        # remove the peer
        self['deleted'] = True
        self.sync(commit)