X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=PLC%2FPeers.py;h=684361f388c418ed3c74eca934b9ee0f26c73570;hb=c0bdeb3305ebfa5c0f5613dab1a7e0adf55b6ba5;hp=1a5e6fb3e75e0520f6c8d83f3ae7ade0e1e1024e;hpb=e1a827010ec8e6e5c1e1272e22b3269108bcc9c8;p=plcapi.git diff --git a/PLC/Peers.py b/PLC/Peers.py index 1a5e6fb..684361f 100644 --- a/PLC/Peers.py +++ b/PLC/Peers.py @@ -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) @@ -51,11 +59,11 @@ class Peers (Table): Maps to the peers table in the database """ - def __init__ (self, api, peer_filter = None): - Table.__init__(self, api, Peer) + def __init__ (self, api, peer_filter = None, columns = None): + Table.__init__(self, api, Peer, columns) sql = "SELECT %s FROM view_peers WHERE deleted IS False" % \ - ", ".join(Peer.fields) + ", ".join(self.columns) if peer_filter is not None: if isinstance(peer_filter, (list, tuple, set)):