cleaning unneeded registry methods {register,remove}_peer_object (and camlcase)
authorThierry Parmentelat <thierry.parmentelat@sophia.inria.fr>
Thu, 17 Nov 2011 16:11:41 +0000 (17:11 +0100)
committerThierry Parmentelat <thierry.parmentelat@sophia.inria.fr>
Thu, 17 Nov 2011 16:11:41 +0000 (17:11 +0100)
and get_{aggregates,registries}

sfa/managers/registry_manager.py
sfa/methods/RegisterPeerObject.py [deleted file]
sfa/methods/RemovePeerObject.py [deleted file]
sfa/methods/get_aggregates.py [deleted file]
sfa/methods/get_registries.py [deleted file]
sfa/methods/register_peer_object.py [deleted file]
sfa/methods/remove_peer_object.py [deleted file]

index 27b50c4..941e4b0 100644 (file)
@@ -435,9 +435,3 @@ class RegistryManager:
         table.remove(record)
     
         return 1
-    
-    def remove_peer_object(self, api, record, origin_hrn=None):
-        pass
-    
-    def register_peer_object(self, api, record, origin_hrn=None):
-        pass
diff --git a/sfa/methods/RegisterPeerObject.py b/sfa/methods/RegisterPeerObject.py
deleted file mode 100644 (file)
index 2eec2f5..0000000
+++ /dev/null
@@ -1,64 +0,0 @@
-from sfa.util.faults import SfaInvalidArgument
-from sfa.util.xrn import get_authority
-from sfa.util.method import Method
-from sfa.util.parameter import Parameter, Mixed
-from sfa.util.record import SfaRecord
-from sfa.util.table import SfaTable
-from sfa.trust.credential import Credential
-
-class RegisterPeerObject(Method):
-    """
-    Register a peer object with the registry. In addition to being stored in the
-    SFA database, the appropriate records will also be created in the
-    PLC databases
-    
-    @param cred credential string
-    @param record_dict dictionary containing record fields
-    @return gid string representation
-    """
-
-    interfaces = ['registry']
-    
-    accepts = [
-        Parameter(str, "Credential string"),
-        Parameter(dict, "Record dictionary containing record fields"),
-        Mixed(Parameter(str, "Human readable name of the original caller"),
-              Parameter(None, "Origin hrn not specified"))
-        ]
-
-    returns = Parameter(int, "1 if successful")
-    
-    def call(self, cred, record_dict, origin_hrn=None):
-        user_cred = Credential(string=cred)
-
-        #log the call
-        if not origin_hrn:
-            origin_hrn = user_cred.get_gid_caller().get_hrn()    
-        self.api.logger.info("interface: %s\tcaller-hrn: %s\ttarget-hrn: %s\tmethod-name: %s"%(self.api.interface, origin_hrn, None, self.name))
-
-        # validate the cred
-        self.api.auth.check(cred, "register")
-
-        # make sure this is a peer record
-        if 'peer_authority' not in record_dict or \
-           not record_dict['peer_authority']: 
-            raise SfaInvalidArgument, "peer_authority must be specified" 
-
-        record = SfaRecord(dict = record_dict)
-        type, hrn, peer_authority = record['type'], record['hrn'], record['peer_authority']
-        record['authority'] = get_authority(record['hrn'])
-        # verify permissions
-        self.api.auth.verify_cred_is_me(cred)
-
-        # check if record already exists
-        table = SfaTable()
-        existing_records = table.find({'type': type, 'hrn': hrn, 'peer_authority': peer_authority})
-        if existing_records:
-            for existing_record in existing_records:
-                if existing_record['pointer'] != record['pointer']:
-                    record['record_id'] = existing_record['record_id']
-                    table.update(record)
-        else:
-            record_id = table.insert(record)
-        return 1
diff --git a/sfa/methods/RemovePeerObject.py b/sfa/methods/RemovePeerObject.py
deleted file mode 100644 (file)
index c831924..0000000
+++ /dev/null
@@ -1,99 +0,0 @@
-from sfa.util.faults import UnknownSfaType, SfaInvalidArgument
-from sfa.util.method import Method
-from sfa.util.parameter import Parameter, Mixed
-from sfa.util.table import SfaTable
-from sfa.trust.credential import Credential
-
-class RemovePeerObject(Method):
-    """
-    Remove an peer object from the PLC records of a local aggregate. 
-    This method will be called by registry.remove() while removing 
-    a record from the local aggreage's PLCDB and sfa table. This 
-    method need not be directly called by end-user.
-    
-    @param cred credential string
-    @param record record as stored in the local registry
-
-    @return 1 if successful, faults otherwise 
-    """
-
-    interfaces = ['registry']
-    
-    accepts = [
-        Parameter(str, "Credential string"),
-        Parameter(dict, "Record dictionary"),
-        Mixed(Parameter(str, "Human readable name of the original caller"),
-              Parameter(None, "Origin hrn not specified"))
-        ]
-
-    returns = Parameter(int, "1 if successful")
-    
-    def call(self, cred, record, origin_hrn=None):
-        user_cred = Credential(string=cred)
-
-        #log the call
-        if not origin_hrn:
-            origin_hrn = user_cred.get_gid_caller().get_hrn()
-        self.api.logger.info("interface: %s\tcaller-hrn: %s\ttarget-hrn: %s\tmethod-name: %s"%(self.api.interface, origin_hrn, record['hrn'], self.name))
-
-        self.api.auth.check(cred, "remove")
-
-        # Only allow the local interface or record owner to delete peer_records 
-        try: self.api.auth.verify_object_permission(record['hrn'])
-        except: self.api.auth.verify_cred_is_me(cred)
-        
-        table = SfaTable()
-        hrn, type = record['hrn'], record['type']
-        records = table.find({'hrn': hrn, 'type': type })
-        for record in records:
-            if record['peer_authority']:
-                self.remove_plc_record(record)
-                table.remove(record)
-            
-        return 1
-
-    def remove_plc_record(self, record):
-        type = record['type']        
-        if type == "user":
-            persons = self.api.driver.GetPersons({'person_id' : record['pointer']})
-            if not persons:
-                return 1
-            person = persons[0]
-            if person['peer_id']:
-                peer = self.get_peer_name(person['peer_id']) 
-                self.api.driver.UnBindObjectFromPeer('person', person['person_id'], peer)
-            self.api.driver.DeletePerson(person['person_id'])
-           
-        elif type == "slice":
-            slices=self.api.driver.GetSlices({'slice_id' : record['pointer']})
-            if not slices:
-                return 1
-            slice=slices[0]
-            if slice['peer_id']:
-                peer = self.get_peer_name(slice['peer_id']) 
-                self.api.driver.UnBindObjectFromPeer('slice', slice['slice_id'], peer)
-            self.api.driver.DeleteSlice(slice['slice_id'])
-        elif type == "authority":
-            sites=self.api.driver.GetSites({'site_id' : record['pointer']})
-            if not sites:
-                return 1
-            site=sites[0]
-            if site['peer_id']:
-                peer = self.get_peer_name(site['peer_id']) 
-                self.api.driver.UnBindObjectFromPeer('site', site['site_id'], peer)
-            self.api.driver.DeleteSite(site['site_id'])
-           
-        else:
-            raise UnknownSfaType(type)
-
-        return 1
-
-    def get_peer_name(self, peer_id):
-        peers = self.api.driver.GetPeers([peer_id], ['peername', 'shortname', 'hrn_root'])
-        if not peers:
-            raise SfaInvalidArgument, "No such peer"
-        peer = peers[0]
-        return peer['shortname'] 
-
-
-
diff --git a/sfa/methods/get_aggregates.py b/sfa/methods/get_aggregates.py
deleted file mode 100644 (file)
index 23c8d60..0000000
+++ /dev/null
@@ -1,31 +0,0 @@
-from sfa.util.xrn import urn_to_hrn
-from sfa.util.method import Method
-from sfa.util.parameter import Parameter, Mixed
-from sfa.server.aggregate import Aggregates
-
-class get_aggregates(Method):
-    """
-    Get a list of connection information for all known aggregates.      
-
-    @param cred credential string specifying the rights of the caller
-    @param a Human readable name (hrn or urn), or list of hrns or None
-    @return list of dictionaries with aggregate information.  
-    """
-
-    interfaces = ['registry', 'aggregate', 'slicemgr']
-    
-    accepts = [
-        Parameter(str, "Credential string"),
-        Mixed(Parameter(str, "Human readable name (hrn or urn)"),
-              Parameter(None, "hrn not specified"))
-        ]
-
-    returns = [Parameter(dict, "Aggregate interface information")]
-    
-    def call(self, cred, xrn = None):
-        hrn, type = urn_to_hrn(xrn)
-        self.api.auth.check(cred, 'list')
-        aggregates = Aggregates(self.api).interfaces.values()
-        if hrn:
-            aggregates = [agg for agg in aggregates if agg['hrn'] == hrn]
-        return aggregates
diff --git a/sfa/methods/get_registries.py b/sfa/methods/get_registries.py
deleted file mode 100644 (file)
index 65d9444..0000000
+++ /dev/null
@@ -1,31 +0,0 @@
-from sfa.util.xrn import urn_to_hrn
-from sfa.util.method import Method
-from sfa.util.parameter import Parameter, Mixed
-from sfa.server.registry import Registries
-
-class get_registries(Method):
-    """
-    Get a list of connection information for all known registries.      
-
-    @param cred credential string specifying the rights of the caller
-    @param a Human readable name (hrn or urn), or list of names or None
-    @return list of dictionaries with aggregate information.  
-    """
-
-    interfaces = ['registry', 'aggregate', 'slicemgr']
-    
-    accepts = [
-        Parameter(str, "Credential string"),
-        Mixed(Parameter(str, "Human readable name (hrn or urn)"),
-              Parameter(None, "hrn not specified"))
-        ]
-
-    returns = [Parameter(dict, "Registry interface information")]
-    
-    def call(self, cred, xrn = None):
-        hrn, type = urn_to_hrn(xrn)
-        self.api.auth.check(cred, 'list')
-        registries = Registries(self.api).values()
-        if hrn:
-            registries = [reg for reg in registries if reg['hrn'] == hrn] 
-        return registries
diff --git a/sfa/methods/register_peer_object.py b/sfa/methods/register_peer_object.py
deleted file mode 100644 (file)
index 42ef240..0000000
+++ /dev/null
@@ -1,65 +0,0 @@
-
-from sfa.util.faults import SfaInvalidArgument
-from sfa.util.xrn import get_authority
-from sfa.util.method import Method
-from sfa.util.parameter import Parameter, Mixed
-from sfa.util.record import SfaRecord
-from sfa.util.table import SfaTable
-from sfa.trust.credential import Credential
-
-class register_peer_object(Method):
-    """
-    Register a peer object with the registry. In addition to being stored in the
-    SFA database, the appropriate records will also be created in the
-    PLC databases
-    
-    @param cred credential string
-    @param record_dict dictionary containing record fields
-    @return gid string representation
-    """
-
-    interfaces = ['registry']
-    
-    accepts = [
-        Parameter(str, "Credential string"),
-        Parameter(dict, "Record dictionary containing record fields"),
-        Mixed(Parameter(str, "Human readable name of the original caller"),
-              Parameter(None, "Origin hrn not specified"))
-        ]
-
-    returns = Parameter(int, "1 if successful")
-    
-    def call(self, cred, record_dict, origin_hrn=None):
-        user_cred = Credential(string=cred)
-
-        #log the call
-        if not origin_hrn:
-            origin_hrn = user_cred.get_gid_caller().get_hrn()    
-        self.api.logger.info("interface: %s\tcaller-hrn: %s\ttarget-hrn: %s\tmethod-name: %s"%(self.api.interface, origin_hrn, None, self.name))
-
-        # validate the cred
-        self.api.auth.check(cred, "register")
-
-        # make sure this is a peer record
-        if 'peer_authority' not in record_dict or \
-           not record_dict['peer_authority']: 
-            raise SfaInvalidArgument, "peer_authority must be specified" 
-
-        record = SfaRecord(dict = record_dict)
-        type, hrn, peer_authority = record['type'], record['hrn'], record['peer_authority']
-        record['authority'] = get_authority(record['hrn'])
-        # verify permissions
-        self.api.auth.verify_cred_is_me(cred)
-
-        # check if record already exists
-        table = SfaTable()
-        existing_records = table.find({'type': type, 'hrn': hrn, 'peer_authority': peer_authority})
-        if existing_records:
-            for existing_record in existing_records:
-                if existing_record['pointer'] != record['pointer']:
-                    record['record_id'] = existing_record['record_id']
-                    table.update(record)
-        else:
-            record_id = table.insert(record)
-        return 1
diff --git a/sfa/methods/remove_peer_object.py b/sfa/methods/remove_peer_object.py
deleted file mode 100644 (file)
index 465ed05..0000000
+++ /dev/null
@@ -1,99 +0,0 @@
-from sfa.util.faults import UnknownSfaType, SfaInvalidArgument
-from sfa.util.method import Method
-from sfa.util.parameter import Parameter, Mixed
-from sfa.util.table import SfaTable
-from sfa.trust.credential import Credential
-
-class remove_peer_object(Method):
-    """
-    Remove a peer object from the PLC records of a local aggregate. 
-    This method will be called by registry.remove() while removing 
-    a record from the local aggreage's PLCDB and sfa table. This 
-    method need not be directly called by end-user.
-    
-    @param cred credential string
-    @param record record as stored in the local registry
-
-    @return 1 if successful, faults otherwise 
-    """
-
-    interfaces = ['registry']
-    
-    accepts = [
-        Parameter(str, "Credential string"),
-        Parameter(dict, "Record dictionary"),
-        Mixed(Parameter(str, "Human readable name of the original caller"),
-              Parameter(None, "Origin hrn not specified"))
-        ]
-
-    returns = Parameter(int, "1 if successful")
-    
-    def call(self, cred, record, origin_hrn=None):
-        user_cred = Credential(string=cred)
-
-        #log the call
-        if not origin_hrn:
-            origin_hrn = user_cred.get_gid_caller().get_hrn()
-        self.api.logger.info("interface: %s\tcaller-hrn: %s\ttarget-hrn: %s\tmethod-name: %s"%(self.api.interface, origin_hrn, record['hrn'], self.name))
-
-        self.api.auth.check(cred, "remove")
-
-        # Only allow the local interface or record owner to delete peer_records 
-        try: self.api.auth.verify_object_permission(record['hrn'])
-        except: self.api.auth.verify_cred_is_me(cred)
-        
-        table = SfaTable()
-        hrn, type = record['hrn'], record['type']
-        records = table.find({'hrn': hrn, 'type': type })
-        for record in records:
-            if record['peer_authority']:
-                self.remove_plc_record(record)
-                table.remove(record)
-            
-        return 1
-
-    def remove_plc_record(self, record):
-        type = record['type']        
-        if type == "user":
-            persons = self.api.driver.GetPersons({'person_id' : record['pointer']})
-            if not persons:
-                return 1
-            person = persons[0]
-            if person['peer_id']:
-                peer = self.get_peer_name(person['peer_id']) 
-                self.api.driver.UnBindObjectFromPeer('person', person['person_id'], peer)
-            self.api.driver.DeletePerson(person['person_id'])
-           
-        elif type == "slice":
-            slices=self.api.driver.GetSlices({'slice_id' : record['pointer']})
-            if not slices:
-                return 1
-            slice=slices[0]
-            if slice['peer_id']:
-                peer = self.get_peer_name(slice['peer_id']) 
-                self.api.driver.UnBindObjectFromPeer('slice', slice['slice_id'], peer)
-            self.api.driver.DeleteSlice(slice['slice_id'])
-        elif type == "authority":
-            sites=self.api.driver.GetSites({'site_id' : record['pointer']})
-            if not sites:
-                return 1
-            site=sites[0]
-            if site['peer_id']:
-                peer = self.get_peer_name(site['peer_id']) 
-                self.api.driver.UnBindObjectFromPeer('site', site['site_id'], peer)
-            self.api.driver.DeleteSite(site['site_id'])
-           
-        else:
-            raise UnknownSfaType(type)
-
-        return 1
-
-    def get_peer_name(self, peer_id):
-        peers = self.api.driver.GetPeers([peer_id], ['peername', 'shortname', 'hrn_root'])
-        if not peers:
-            raise SfaInvalidArgument, "No such peer"
-        peer = peers[0]
-        return peer['shortname'] 
-
-
-