more consistency between API method names and corresponding manager implementation
Thierry Parmentelat [Thu, 17 Nov 2011 12:21:52 +0000 (13:21 +0100)]
16 files changed:
sfa/managers/aggregate_manager.py
sfa/managers/component_manager_pl.py
sfa/managers/registry_manager.py
sfa/managers/slice_manager.py
sfa/methods/CreateGid.py
sfa/methods/GetCredential.py
sfa/methods/GetSelfCredential.py
sfa/methods/GetTicket.py
sfa/methods/List.py
sfa/methods/Register.py
sfa/methods/Remove.py
sfa/methods/Resolve.py
sfa/methods/Update.py
sfa/methods/get_key.py
sfa/server/sfa_component_setup.py
tests/testInterfaces.py

index 30ebd92..1b069f7 100644 (file)
@@ -323,7 +323,7 @@ class AggregateManager:
         return rspec
     
     
-    def get_ticket(self, api, xrn, creds, rspec, users):
+    def GetTicket(self, api, xrn, creds, rspec, users):
     
         (slice_hrn, _) = urn_to_hrn(xrn)
         slices = Slices(api)
@@ -341,7 +341,7 @@ class AggregateManager:
         for tmp_record in records:
             if tmp_record['type'] == 'slice' and \
                not tmp_record['peer_authority']:
-    #Error (E0602, get_ticket): Undefined variable 'SliceRecord'
+    #Error (E0602, GetTicket): Undefined variable 'SliceRecord'
                 record = SliceRecord(dict=tmp_record)
         if not record:
             raise RecordNotFound(slice_hrn)
index 164b2d6..6992971 100644 (file)
@@ -17,7 +17,7 @@ def init_server():
     except:
         # our keypair may be old, try refreshing
         sfa_component_setup.get_node_key()
-        sfa_component_setup.get_credential(force=True)
+        sfa_component_setup.GetCredential(force=True)
         sfa_component_setup.get_trusted_certs()
 
 def SliverStatus(api, slice_xrn, creds):
index 56062b9..27b50c4 100644 (file)
@@ -29,7 +29,7 @@ class RegistryManager:
                              'urn':xrn.get_urn(),
                              'peers':peers})
     
-    def get_credential(self, api, xrn, type, is_self=False):
+    def GetCredential(self, api, xrn, type, is_self=False):
         # convert xrn to hrn     
         if type:
             hrn = urn_to_hrn(xrn)[0]
@@ -89,7 +89,7 @@ class RegistryManager:
         return new_cred.save_to_string(save_parents=True)
     
     
-    def resolve(self, api, xrns, type=None, full=True):
+    def Resolve(self, api, xrns, type=None, full=True):
     
         # load all known registry names into a prefix tree and attempt to find
         # the longest matching prefix
@@ -147,7 +147,7 @@ class RegistryManager:
     
         return records
     
-    def list(self, api, xrn, origin_hrn=None):
+    def List(self, api, xrn, origin_hrn=None):
         hrn, type = urn_to_hrn(xrn)
         # load all know registry names into a prefix tree and attempt to find
         # the longest matching prefix
@@ -182,7 +182,7 @@ class RegistryManager:
         return records
     
     
-    def create_gid(self, api, xrn, cert):
+    def CreateGid(self, api, xrn, cert):
         # get the authority
         authority = Xrn(xrn=xrn).get_authority_hrn()
         auth_info = api.auth.get_auth_info(authority)
@@ -194,7 +194,7 @@ class RegistryManager:
         gid = api.auth.hierarchy.create_gid(xrn, create_uuid(), pkey) 
         return gid.save_to_string(save_parents=True)
         
-    def register(self, api, record):
+    def Register(self, api, record):
     
         hrn, type = record['hrn'], record['type']
         urn = hrn_to_urn(hrn,type)
@@ -302,7 +302,7 @@ class RegistryManager:
     
         return record.get_gid_object().save_to_string(save_parents=True)
     
-    def update(self, api, record_dict):
+    def Update(self, api, record_dict):
         new_record = SfaRecord(dict = record_dict)
         type = new_record['type']
         hrn = new_record['hrn']
@@ -388,7 +388,7 @@ class RegistryManager:
         return 1 
     
     # expecting an Xrn instance
-    def remove(self, api, xrn, origin_hrn=None):
+    def Remove(self, api, xrn, origin_hrn=None):
     
         table = SfaTable()
         filter = {'hrn': xrn.get_hrn()}
index 9565577..50edb9a 100644 (file)
@@ -419,7 +419,7 @@ class SliceManager:
         return slices
     
     
-    def get_ticket(self, api, xrn, creds, rspec, users):
+    def GetTicket(self, api, xrn, creds, rspec, users):
         slice_hrn, type = urn_to_hrn(xrn)
         # get the netspecs contained within the clients rspec
         aggregate_rspecs = {}
index 74ce9de..db69acd 100644 (file)
@@ -43,4 +43,4 @@ class CreateGid(Method):
         origin_hrn = Credential(string=valid_creds[0]).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, xrn, self.name))
 
-        return self.api.manager.create_gid(self.api, xrn, cert)
+        return self.api.manager.CreateGid(self.api, xrn, cert)
index b645cd4..d966dd3 100644 (file)
@@ -42,5 +42,5 @@ class GetCredential(Method):
         origin_hrn = Credential(string=valid_creds[0]).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, hrn, self.name))        
 
-        return self.api.manager.get_credential(self.api, xrn, type)
+        return self.api.manager.GetCredential(self.api, xrn, type)
 
index 37f2e7b..7076e92 100644 (file)
@@ -71,4 +71,4 @@ class GetSelfCredential(Method):
                     self.api.logger.debug("ConnectionKeyGIDMismatch, %s filename: %s"%(name,obj.filename))
             raise ConnectionKeyGIDMismatch(gid.get_subject())
         
-        return self.api.manager.get_credential(self.api, xrn, type, is_self=True)
+        return self.api.manager.GetCredential(self.api, xrn, type, is_self=True)
index c21ce16..174bd4c 100644 (file)
@@ -51,5 +51,5 @@ class GetTicket(Method):
         rspec = run_sfatables(chain_name, hrn, origin_hrn, rspec)
         
         # remove nodes that are not available at this interface from the rspec
-        return self.api.manager.get_ticket(self.api, xrn, creds, rspec, users)
+        return self.api.manager.GetTicket(self.api, xrn, creds, rspec, users)
         
index ccd66b4..55dd7dd 100644 (file)
@@ -31,4 +31,4 @@ class List(Method):
         origin_hrn = Credential(string=valid_creds[0]).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, hrn, self.name))
        
-        return self.api.manager.list(self.api, xrn) 
+        return self.api.manager.List(self.api, xrn) 
index 92f230a..2d9cbfd 100644 (file)
@@ -36,4 +36,4 @@ class Register(Method):
         origin_hrn = Credential(string=valid_creds[0]).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, hrn, self.name))
         
-        return self.api.manager.register(self.api, record)
+        return self.api.manager.Register(self.api, record)
index 98ef38b..1804fd9 100644 (file)
@@ -39,4 +39,4 @@ class Remove(Method):
         self.api.logger.info("interface: %s\tmethod-name: %s\tcaller-hrn: %s\ttarget-urn: %s"%(
                 self.api.interface, self.name, origin_hrn, xrn.get_urn()))
 
-        return self.api.manager.remove(self.api, xrn) 
+        return self.api.manager.Remove(self.api, xrn) 
index 6277e1b..094500f 100644 (file)
@@ -40,5 +40,5 @@ class Resolve(Method):
         self.api.logger.info("interface: %s\tcaller-hrn: %s\ttarget-hrn: %s\tmethod-name: %s"%(self.api.interface, origin_hrn, hrns, self.name))
  
         # send the call to the right manager
-        return self.api.manager.resolve(self.api, xrns, type)
+        return self.api.manager.Resolve(self.api, xrns, type)
             
index a90a44e..7643302 100644 (file)
@@ -35,5 +35,5 @@ class Update(Method):
         origin_hrn = Credential(string=valid_creds[0]).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, hrn, self.name))
        
-        return self.api.manager.update(self.api, record_dict)
+        return self.api.manager.Update(self.api, record_dict)
 
index 638332e..1195d53 100644 (file)
@@ -22,7 +22,7 @@ class get_key(Method):
     returns = Parameter(int, "1 if successful, faults otherwise")
     
     def call(self):
-        # verify that the callers's ip address exist in the db and is an inteface
+        # verify that the callers's ip address exist in the db and is an interface
         # for a node in the db
         (ip, port) = self.api.remote_addr
         interfaces = self.api.driver.GetInterfaces({'ip': ip}, ['node_id'])
index 16f358e..ed1ee30 100755 (executable)
@@ -78,9 +78,9 @@ def clean_key_cred():
             os.unlink(f)
    
     # install the new key pair
-    # get_credential will take care of generating the new keypair
+    # GetCredential will take care of generating the new keypair
     # and credential 
-    get_credential()
+    GetCredential()
     
              
 def get_node_key(registry=None, verbose=False):
@@ -113,7 +113,7 @@ def create_server_keypair(keyfile=None, certfile=None, hrn="component", verbose=
     cert.save_to_file(certfile, save_parents=True)       
 
 @handle_gid_mismatch_exception
-def get_credential(registry=None, force=False, verbose=False):
+def GetCredential(registry=None, force=False, verbose=False):
     config = Config()
     hierarchy = Hierarchy()
     key_dir= hierarchy.basedir
@@ -169,7 +169,7 @@ def get_trusted_certs(registry=None, verbose=False):
     node_gid = GID(filename=node_gid_file)
     hrn = node_gid.get_hrn()
     # get credential
-    cred = get_credential(registry=registry, verbose=verbose)
+    cred = GetCredential(registry=registry, verbose=verbose)
     # make sure server key cert pair exists
     create_server_keypair(keyfile=keyfile, certfile=certfile, hrn=hrn, verbose=verbose)
     registry = server_proxy(url=registry, keyfile=keyfile, certfile=certfile)
@@ -214,7 +214,7 @@ def get_gids(registry=None, verbose=False):
     hrn = node_gid.get_hrn()
     interface_hrn = config.SFA_INTERFACE_HRN
     # get credential
-    cred = get_credential(registry=registry, verbose=verbose)
+    cred = GetCredential(registry=registry, verbose=verbose)
     # make sure server key cert pair exists
     create_server_keypair(keyfile=keyfile, certfile=certfile, hrn=hrn, verbose=verbose)
     registry = server_proxy(url=registry, keyfile=keyfile, certfile=certfile)
index ce72936..fb57a71 100755 (executable)
@@ -51,9 +51,9 @@ class Client:
         # XX defaulting to user, but this should be configurable so we can
         # test from components persepctive
         self.type = 'user'
-        self.credential = self.get_credential(self.hrn)
+        self.credential = self.GetCredential(self.hrn)
         
-    def get_credential(self, hrn = None, type = 'user'):
+    def GetCredential(self, hrn = None, type = 'user'):
         if not hrn: hrn = self.hrn 
         if hrn == self.hrn:
             cert = self.cert.save_to_string(save_parents=True)
@@ -62,8 +62,8 @@ class Client:
             return credential
         else:
             if not self.credential:
-                self.credential = self.get_credential(self.hrn, 'user')
-            return self.registry.get_credential(self.credential, type, hrn)     
+                self.credential = self.GetCredential(self.hrn, 'user')
+            return self.registry.GetCredential(self.credential, type, hrn)     
 
 class BasicTestCase(unittest.TestCase):
     def __init__(self, testname, client, test_slice=None):
@@ -90,13 +90,13 @@ class RegistryTest(BasicTestCase):
         BasicTestCase.setUp(self)
 
     def testGetSelfCredential(self):
-        cred = self.client.get_credential()
+        cred = self.client.GetCredential()
         # this will raise an openssl error if the credential string isnt valid
         Credential(string=cred)
 
     def testRegister(self):
         authority = get_authority(self.hrn)
-        auth_cred = self.client.get_credential(authority, 'authority')
+        auth_cred = self.client.GetCredential(authority, 'authority')
         auth_record = {'hrn': '.'.join([authority, random_string(10).lower()]),
                        'type': 'authority'}
         node_record = {'hrn': '.'.join([authority, random_string(10)]),
@@ -113,12 +113,12 @@ class RegistryTest(BasicTestCase):
         all_records = [auth_record, node_record, slice_record, user_record]
         for record in all_records:
             try:
-                self.registry.register(auth_cred, record)
-                self.registry.resolve(self.credential, record['hrn'])
+                self.registry.Register(auth_cred, record)
+                self.registry.Resolve(self.credential, record['hrn'])
             except:
                 raise
             finally:
-                try: self.registry.remove(auth_cred, record['type'], record['hrn'])
+                try: self.registry.Remove(auth_cred, record['type'], record['hrn'])
                 except: pass
 
     
@@ -127,26 +127,26 @@ class RegistryTest(BasicTestCase):
    
     def testUpdate(self):
         authority = get_authority(self.hrn)
-        auth_cred = self.client.get_credential(authority, 'authority')
-        records = self.registry.resolve(self.credential, self.hrn)
+        auth_cred = self.client.GetCredential(authority, 'authority')
+        records = self.registry.Resolve(self.credential, self.hrn)
         if not records: assert False
         record = records[0]
         self.registry.update(auth_cred, record) 
 
     def testResolve(self):
         authority = get_authority(self.hrn)
-        self.registry.resolve(self.credential, self.hrn)
+        self.registry.Resolve(self.credential, self.hrn)
    
     def testRemove(self):
         authority = get_authority(self.hrn)
-        auth_cred = self.client.get_credential(authority, 'authority')
+        auth_cred = self.client.GetCredential(authority, 'authority')
         record = {'hrn': ".".join([authority, random_string(10)]),
                        'type': 'slice'}
-        self.registry.register(auth_cred, record)
-        self.registry.remove(auth_cred, record['type'], record['hrn'])
+        self.registry.Register(auth_cred, record)
+        self.registry.Remove(auth_cred, record['type'], record['hrn'])
         # should generate an exception
         try:
-            self.registry.resolve(self.credential,  record['hrn'])
+            self.registry.Resolve(self.credential,  record['hrn'])
             assert False
         except:       
             assert True
@@ -156,7 +156,7 @@ class RegistryTest(BasicTestCase):
 
     def testList(self):
         authority = get_authority(self.client.hrn)
-        self.registry.list(self.credential, authority)
+        self.registry.List(self.credential, authority)
              
     def testGetRegistries(self):
         self.registry.get_registries(self.credential)
@@ -196,17 +196,17 @@ class AggregateTest(BasicTestCase):
     def testCreateSlice(self):
         # get availabel resources   
         rspec = self.aggregate.get_resources(self.credential)
-        slice_credential = self.client.get_credential(self.slice['hrn'], 'slice')
+        slice_credential = self.client.GetCredential(self.slice['hrn'], 'slice')
         self.aggregate.CreateSliver(slice_credential, self.slice['hrn'], rspec)
 
     def testDeleteSlice(self):
-        slice_credential = self.client.get_credential(self.slice['hrn'], 'slice')
+        slice_credential = self.client.GetCredential(self.slice['hrn'], 'slice')
         self.aggregate.DeleteSliver(slice_credential, self.slice['hrn'],"call-id-delete-slice")
 
     def testGetTicket(self):
-        slice_credential = self.client.get_credential(self.slice['hrn'], 'slice')
+        slice_credential = self.client.GetCredential(self.slice['hrn'], 'slice')
         rspec = self.aggregate.get_resources(self.credential)
-        ticket = self.aggregate.get_ticket(slice_credential, self.slice['hrn'], rspec)
+        ticket = self.aggregate.GetTicket(slice_credential, self.slice['hrn'], rspec)
         # will raise an exception if the ticket inst valid
         SfaTicket(string=ticket)        
 
@@ -223,7 +223,7 @@ class SlicemgrTest(AggregateTest):
 class ComponentTest(BasicTestCase):
     def setUp(self):
         BasicTestCase.setUp(self)
-        self.slice_cred = self.client.get_credential(self.slice['hrn'], 'slice')
+        self.slice_cred = self.client.GetCredential(self.slice['hrn'], 'slice')
 
     def testStartSlice(self):
         self.cm.start_slice(self.slice_cred, self.slice['hrn'])
@@ -242,7 +242,7 @@ class ComponentTest(BasicTestCase):
 
     def testRedeemTicket(self):
         rspec = self.aggregate.get_resources(self.credential)
-        ticket = self.aggregate.get_ticket(slice_cred, self.slice['hrn'], rspec)
+        ticket = self.aggregate.GetTicket(slice_cred, self.slice['hrn'], rspec)
         self.cm.redeem_ticket(slice_cred, ticket)
 
 
@@ -252,17 +252,17 @@ def test_names(testcase):
 def CreateSliver(client):
     # register a slice that will be used for some test
     authority = get_authority(client.hrn)
-    auth_cred = client.get_credential(authority, 'authority')
+    auth_cred = client.GetCredential(authority, 'authority')
     slice_record = {'hrn': ".".join([authority, random_string(10)]),
                     'type': 'slice', 'researcher': [client.hrn]}
-    client.registry.register(auth_cred, slice_record)
+    client.registry.Register(auth_cred, slice_record)
     return  slice_record
  
 def DeleteSliver(client, slice):
     authority = get_authority(client.hrn)
-    auth_cred = client.get_credential(authority, 'authority')
+    auth_cred = client.GetCredential(authority, 'authority')
     if slice:
-        client.registry.remove(auth_cred, 'slice', slice['hrn'])
+        client.registry.Remove(auth_cred, 'slice', slice['hrn'])
     
 if __name__ == '__main__':