missing methods in __init__
authorThierry Parmentelat <thierry.parmentelat@sophia.inria.fr>
Wed, 6 Oct 2010 07:54:43 +0000 (09:54 +0200)
committerThierry Parmentelat <thierry.parmentelat@sophia.inria.fr>
Wed, 6 Oct 2010 07:54:43 +0000 (09:54 +0200)
arguments to Get(Self)Credential (from get_credential, need to swap hrn and type)
renamed RightList into just Rights

13 files changed:
sfa/client/sfi.py
sfa/managers/registry_manager_pl.py
sfa/methods/GetCredential.py
sfa/methods/GetSelfCredential.py
sfa/methods/__init__.py
sfa/plc/api-dev.py
sfa/plc/api.py
sfa/server/sfa_component_setup.py
sfa/trust/auth.py
sfa/trust/credential.py
sfa/trust/credential_legacy.py
sfa/trust/hierarchy.py
sfa/trust/rights.py

index d25c172..52f0b67 100755 (executable)
@@ -433,11 +433,11 @@ class Sfi:
                 if user_name.count(".") > 0:
                     user_name = user_name.replace(".", '_')
                     self.user = self.authority + "." + user_name
-                cred_str = self.registry.get_self_credential(cert_string, "user", hrn)
+                cred_str = self.registry.GetSelfCredential(cert_string, hrn, "user")
             else:
                 # bootstrap slice credential from user credential
                 user_cred = self.get_user_cred().save_to_string(save_parents=True)
-                cred_str = self.registry.get_credential(user_cred, type, hrn)
+                cred_str = self.registry.GetCredential(user_cred, hrn, type)
             
             if not cred_str:
                 self.logger.critical("Failed to get %s credential" % type)
index 1636eda..f5f4b48 100644 (file)
@@ -9,6 +9,7 @@ from sfa.util.namespace import *
 from sfa.trust.credential import *
 from sfa.trust.certificate import *
 from sfa.util.faults import *
+from sfa.trust.gid import create_uuid
 
 def get_version(api):
     version = {}
index 3acc3b1..9bd5cd1 100644 (file)
@@ -1,6 +1,4 @@
-### $Id: get_credential.py 17576 2010-04-05 20:56:15Z tmack $
-### $URL: https://svn.planet-lab.org/svn/sfa/trunk/sfa/methods/get_credential.py $
-
+#
 from sfa.trust.credential import *
 from sfa.trust.rights import *
 from sfa.util.faults import *
@@ -12,7 +10,7 @@ from sfa.trust.credential import Credential
 class GetCredential(Method):
     """
     Retrive a credential for an object
-    If cred == None then the behavior reverts to get_self_credential
+    If cred == None then the behavior reverts to GetSelfCredential
 
     @param hrn human readable name of object (hrn or urn)
     @param cred credential object specifying rights of the caller
index 6bdc63d..fa8c3a1 100644 (file)
@@ -1,5 +1,3 @@
-### $Id: get_credential.py 15321 2009-10-15 05:01:21Z tmack $
-### $URL: https://svn.planet-lab.org/svn/sfa/trunk/sfa/methods/get_credential.py $
 
 from sfa.trust.credential import *
 from sfa.trust.rights import *
@@ -33,7 +31,7 @@ class GetSelfCredential(Method):
 
     def call(self, cert, xrn, type):
         """
-        get_self_credential a degenerate version of get_credential used by a client
+        GetSelfCredential a degenerate version of GetCredential used by a client
         to get his initial credential when de doesnt have one. This is the same as
         get_credetial(..., cred = None, ...)
 
index fa26aa0..7c5ecf5 100644 (file)
@@ -1,4 +1,7 @@
 all = """
+GetCredential
+GetSelfCredential
+GetGids
 get_aggregates
 get_key
 get_registries
index 41ae35c..4a6d7a2 100644 (file)
@@ -360,9 +360,9 @@ class SfaAPI(BaseAPI):
             registry = registries[self.hrn]
             cert_string=self.cert.save_to_string(save_parents=True)
             # get self credential
-            self_cred = registry.get_self_credential(cert_string, type, self.hrn)
+            self_cred = registry.GetSelfCredential(cert_string, self.hrn, type)
             # get credential
-            cred = registry.get_credential(self_cred, type, self.hrn)
+            cred = registry.GetCredential(self_cred, type, self.hrn)
             
             # save cred to file
             Credential(string=cred).save_to_file(cred_filename, save_parents=True)
index 6da1188..8707405 100644 (file)
@@ -162,9 +162,9 @@ class SfaAPI(BaseAPI):
             registry = registries[self.hrn]
             cert_string=self.cert.save_to_string(save_parents=True)
             # get self credential
-            self_cred = registry.get_self_credential(cert_string, type, self.hrn)
+            self_cred = registry.GetSelfCredential(cert_string, self.hrn, type)
             # get credential
-            cred = registry.get_credential(self_cred, type, self.hrn)
+            cred = registry.GetCredential(self_cred, self.hrn, type)
             
             # save cred to file
             Credential(string=cred).save_to_file(cred_filename, save_parents=True)
@@ -654,7 +654,7 @@ class ComponentAPI(BaseAPI):
             # get credential from registry
             cert_str = Certificate(filename=cert_filename).save_to_string(save_parents=True)
             registry = self.get_registry()
-            cred = registry.get_self_credential(cert_str, 'node', hrn)
+            cred = registry.GetSelfCredential(cert_str, hrn, 'node')
             Credential(string=cred).save_to_file(credfile, save_parents=True)            
 
             return cred
@@ -670,7 +670,7 @@ class ComponentAPI(BaseAPI):
                 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
         self.get_node_key()
         self.getCredential()
index 628ae7a..db1c965 100755 (executable)
@@ -146,7 +146,7 @@ def get_credential(registry=None, force=False, verbose=False):
         registry = get_server(url=registry, keyfile=keyfile, certfile=certfile)
         cert = Certificate(filename=certfile)
         cert_str = cert.save_to_string(save_parents=True)
-        cred = registry.GetSelfCredential(cert_str, hrn, 'node')    
+        cred = registry.GetSelfCredential(cert_str, 'node', hrn)
         Credential(string=cred).save_to_file(credfile, save_parents=True)
     
     return cred
index 9cb905d..b596d8d 100644 (file)
@@ -237,7 +237,7 @@ class Auth:
         verify_cancreate_credential()
         """
 
-        rl = RightList()
+        rl = Rights()
         type = record['type']
 
 
index 1c41b08..ebecedb 100644 (file)
@@ -35,15 +35,12 @@ from tempfile import mkstemp
 from xml.dom.minidom import Document, parseString
 from dateutil.parser import parse
 
+from sfa.util.faults import *
 from sfa.util.sfalogging import sfa_logger
 from sfa.trust.certificate import Keypair
 from sfa.trust.credential_legacy import CredentialLegacy
-from sfa.trust.rights import *
-from sfa.trust.gid import *
-from sfa.util.faults import *
-
-
-
+from sfa.trust.rights import Right, Rights
+from sfa.trust.gid import GID
 
 # Two years, in seconds 
 DEFAULT_CREDENTIAL_LIFETIME = 60 * 60 * 24 * 365 * 2
@@ -342,17 +339,17 @@ class Credential(object):
     ##
     # set the privileges
     #
-    # @param privs either a comma-separated list of privileges of a RightList object
+    # @param privs either a comma-separated list of privileges of a Rights object
 
     def set_privileges(self, privs):
         if isinstance(privs, str):
-            self.privileges = RightList(string = privs)
+            self.privileges = Rights(string = privs)
         else:
             self.privileges = privs
         
 
     ##
-    # return the privileges as a RightList object
+    # return the privileges as a Rights object
 
     def get_privileges(self):
         if not self.privileges:
@@ -590,7 +587,7 @@ class Credential(object):
 
         # Process privileges
         privs = cred.getElementsByTagName("privileges")[0]
-        rlist = RightList()
+        rlist = Rights()
         for priv in privs.getElementsByTagName("privilege"):
             kind = getTextNode(priv, "name")
             deleg = str2bool(getTextNode(priv, "can_delegate"))
index dc02941..b868f2d 100644 (file)
 
 import xmlrpclib
 
-from sfa.trust.certificate import Certificate
-from sfa.trust.rights import *
-from sfa.trust.gid import *
 from sfa.util.faults import *
+from sfa.trust.certificate import Certificate
+from sfa.trust.rights import Right,Rights
+from sfa.trust.gid import GID
 
 ##
 # Credential is a tuple:
@@ -110,16 +110,16 @@ class CredentialLegacy(Certificate):
     ##
     # set the privileges
     #
-    # @param privs either a comma-separated list of privileges of a RightList object
+    # @param privs either a comma-separated list of privileges of a Rights object
 
     def set_privileges(self, privs):
         if isinstance(privs, str):
-            self.privileges = RightList(string = privs)
+            self.privileges = Rights(string = privs)
         else:
             self.privileges = privs
 
     ##
-    # return the privileges as a RightList object
+    # return the privileges as a Rights object
 
     def get_privileges(self):
         if not self.privileges:
@@ -176,7 +176,7 @@ class CredentialLegacy(Certificate):
 
         privStr = dict.get("privileges", None)
         if privStr:
-            self.privileges = RightList(string = privStr)
+            self.privileges = Rights(string = privStr)
         else:
             self.privileges = None
 
index 4678964..1f8afcf 100644 (file)
@@ -206,7 +206,7 @@ class Hierarchy:
 
     def get_auth_info(self, xrn):
         hrn, type = urn_to_hrn(xrn)
-        sfa_logger.debug("Hierarchy: getting authority: " + hrn)
+        sfa_logger.debug("Hierarchy: xrn=%s, getting authority for hrn=%s"%(xrn,hrn))
         if not self.auth_exists(hrn):
             raise MissingAuthority(hrn)
 
index 59324e8..c96703b 100644 (file)
@@ -4,7 +4,7 @@
 #
 # Right - represents a single right
 #
-# RightList - represents a list of rights
+# Rights - represents a list of rights
 #
 # A right may allow several different operations. For example, the "info" right
 # allows "listslices", "listcomponentresources", etc.
@@ -42,10 +42,10 @@ privilege_table = {"authority": ["register", "remove", "update", "resolve", "lis
 # @param type the type of the object (user | sa | ma | slice | node)
 # @param name human readable name of the object (not used at this time)
 #
-# @return RightList object containing rights
+# @return Rights object containing rights
 
 def determine_rights(type, name):
-    rl = RightList()
+    rl = Rights()
 
     # rights seem to be somewhat redundant with the type of the credential.
     # For example, a "sa" credential implies the authority right, because
@@ -132,9 +132,9 @@ class Right:
         return True
 
 ##
-# A RightList object represents a list of privileges.
+# A Rights object represents a list of privileges.
 
-class RightList:
+class Rights:
     ##
     # Create a new rightlist object, containing no rights.
     #
@@ -252,10 +252,10 @@ class RightList:
     # @param type the type of the object (user | sa | ma | slice | node)
     # @param name human readable name of the object (not used at this time)
     #
-    # @return RightList object containing rights
+    # @return Rights object containing rights
 
     def determine_rights(self, type, name):
-        rl = RightList()
+        rl = Rights()
 
         # rights seem to be somewhat redundant with the type of the credential.
         # For example, a "sa" credential implies the authority right, because