From: Thierry Parmentelat Date: Wed, 6 Oct 2010 07:54:43 +0000 (+0200) Subject: missing methods in __init__ X-Git-Tag: sfa-1.0-2~8^2~4 X-Git-Url: http://git.onelab.eu/?p=sfa.git;a=commitdiff_plain;h=9887cc98e96651bc4dd1a1999f299800c187b520 missing methods in __init__ arguments to Get(Self)Credential (from get_credential, need to swap hrn and type) renamed RightList into just Rights --- diff --git a/sfa/client/sfi.py b/sfa/client/sfi.py index d25c172d..52f0b671 100755 --- a/sfa/client/sfi.py +++ b/sfa/client/sfi.py @@ -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) diff --git a/sfa/managers/registry_manager_pl.py b/sfa/managers/registry_manager_pl.py index 1636eda3..f5f4b48f 100644 --- a/sfa/managers/registry_manager_pl.py +++ b/sfa/managers/registry_manager_pl.py @@ -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 = {} diff --git a/sfa/methods/GetCredential.py b/sfa/methods/GetCredential.py index 3acc3b12..9bd5cd14 100644 --- a/sfa/methods/GetCredential.py +++ b/sfa/methods/GetCredential.py @@ -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 diff --git a/sfa/methods/GetSelfCredential.py b/sfa/methods/GetSelfCredential.py index 6bdc63d1..fa8c3a1a 100644 --- a/sfa/methods/GetSelfCredential.py +++ b/sfa/methods/GetSelfCredential.py @@ -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, ...) diff --git a/sfa/methods/__init__.py b/sfa/methods/__init__.py index fa26aa04..7c5ecf5a 100644 --- a/sfa/methods/__init__.py +++ b/sfa/methods/__init__.py @@ -1,4 +1,7 @@ all = """ +GetCredential +GetSelfCredential +GetGids get_aggregates get_key get_registries diff --git a/sfa/plc/api-dev.py b/sfa/plc/api-dev.py index 41ae35c7..4a6d7a20 100644 --- a/sfa/plc/api-dev.py +++ b/sfa/plc/api-dev.py @@ -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) diff --git a/sfa/plc/api.py b/sfa/plc/api.py index 6da11882..8707405a 100644 --- a/sfa/plc/api.py +++ b/sfa/plc/api.py @@ -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() diff --git a/sfa/server/sfa_component_setup.py b/sfa/server/sfa_component_setup.py index 628ae7a8..db1c965d 100755 --- a/sfa/server/sfa_component_setup.py +++ b/sfa/server/sfa_component_setup.py @@ -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 diff --git a/sfa/trust/auth.py b/sfa/trust/auth.py index 9cb905d1..b596d8d4 100644 --- a/sfa/trust/auth.py +++ b/sfa/trust/auth.py @@ -237,7 +237,7 @@ class Auth: verify_cancreate_credential() """ - rl = RightList() + rl = Rights() type = record['type'] diff --git a/sfa/trust/credential.py b/sfa/trust/credential.py index 1c41b089..ebecedb0 100644 --- a/sfa/trust/credential.py +++ b/sfa/trust/credential.py @@ -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")) diff --git a/sfa/trust/credential_legacy.py b/sfa/trust/credential_legacy.py index dc02941d..b868f2da 100644 --- a/sfa/trust/credential_legacy.py +++ b/sfa/trust/credential_legacy.py @@ -10,10 +10,10 @@ 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 diff --git a/sfa/trust/hierarchy.py b/sfa/trust/hierarchy.py index 46789641..1f8afcf0 100644 --- a/sfa/trust/hierarchy.py +++ b/sfa/trust/hierarchy.py @@ -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) diff --git a/sfa/trust/rights.py b/sfa/trust/rights.py index 59324e8d..c96703b4 100644 --- a/sfa/trust/rights.py +++ b/sfa/trust/rights.py @@ -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