From d640c805f02f8fda54bf14d1f99f9f3a2d8039d5 Mon Sep 17 00:00:00 2001 From: Thierry Parmentelat Date: Tue, 9 Jun 2009 14:41:12 +0000 Subject: [PATCH] dos2unix --- geni/util/api.py | 31 +++++++++---------- geni/util/geniclient.py | 66 ++++++++++++++++++++-------------------- geni/util/gid.py | 12 ++++---- geni/util/hierarchy.py | 36 +++++++++++----------- geni/util/trustedroot.py | 8 ++--- 5 files changed, 76 insertions(+), 77 deletions(-) diff --git a/geni/util/api.py b/geni/util/api.py index 228647f1..03620d14 100644 --- a/geni/util/api.py +++ b/geni/util/api.py @@ -121,8 +121,8 @@ class GeniAPI: def getPLCShell(self): self.plauth = {'Username': self.config.GENI_PLC_USER, - 'AuthMethod': 'password', - 'AuthString': self.config.GENI_PLC_PASSWORD} + 'AuthMethod': 'password', + 'AuthString': self.config.GENI_PLC_PASSWORD} try: import PLC.Shell shell = PLC.Shell.Shell(globals = globals()) @@ -133,16 +133,15 @@ class GeniAPI: plc_host = self.config.GENI_PLC_HOST plc_port = self.config.GENI_PLC_PORT plc_api_path = self.config.GENI_PLC_API_PATH - url = "https://%(plc_host)s:%(plc_port)s/%(plc_api_path)s/" % \ - locals() + url = "https://%(plc_host)s:%(plc_port)s/%(plc_api_path)s/" % locals() shell = xmlrpclib.Server(url, verbose = 0, allow_none = True) shell.AuthCheck(self.plauth) return shell def getPLCShellVersion(self): - # We need to figure out what version of PLCAPI are talking to. - # Some calls we need to make later will be different depending + # We need to figure out what version of PLCAPI we are talking to. + # Some calls we need to make later will be different depending on # the api version. try: # This is probably a bad way to determine api versions @@ -290,12 +289,12 @@ class GeniAPI: def fill_record_pl_info(self, record): """ Fill in the planetlab specific fields of a Geni record. This - involves calling the appropraite PLC method to retrie the - dtabase record for the object. + involves calling the appropriate PLC method to retrieve the + database record for the object. - PLC data is filled into the pl_fino field of the record. + PLC data is filled into the pl_info field of the record. - @param record record to fill in field (in/out param) + @param record: record to fill in field (in/out param) """ type = record.get_type() pointer = record.get_pointer() @@ -391,15 +390,15 @@ class GeniAPI: geni_info['pi'] = pis geni_info['operator'] = operators geni_info['owner'] = owners - # TODO: OrganizationName + # xxx TODO: OrganizationName elif (type == "node"): geni_info['dns'] = record.get("hostname", "") - # TODO: URI, LatLong, IP, DNS + # xxx TODO: URI, LatLong, IP, DNS elif (type == "user"): geni_info['email'] = record.get("email", "") - # TODO: PostalAddress, Phone + # xxx TODO: PostalAddress, Phone record.update(geni_info) @@ -412,7 +411,7 @@ class GeniAPI: self.fill_record_geni_info(record) def update_membership_list(self, oldRecord, record, listName, addFunc, delFunc): - # get a list of the HRNs tht are members of the old and new records^M + # get a list of the HRNs tht are members of the old and new records oldList = oldRecord.get(listName, []) newList = record.get(listName, []) @@ -434,7 +433,7 @@ class GeniAPI: userRecord = records[0] newIdList.append(userRecord.get_pointer()) - # build a list of the old person ids from the person_ids field of the + # build a list of the old person ids from the person_ids field if oldRecord: oldIdList = oldRecord.get("person_ids", []) containerId = oldRecord.get_pointer() @@ -462,7 +461,7 @@ class GeniAPI: self.plshell.AddPersonToSlice, self.plshell.DeletePersonFromSlice) elif record.type == "authority": - # TODO + # xxx TODO pass diff --git a/geni/util/geniclient.py b/geni/util/geniclient.py index 35065d58..fb969f72 100644 --- a/geni/util/geniclient.py +++ b/geni/util/geniclient.py @@ -23,10 +23,10 @@ class ServerException(Exception): pass class ExceptionUnmarshaller(xmlrpclib.Unmarshaller): - def close(self): - try: - return xmlrpclib.Unmarshaller.close(self) - except xmlrpclib.Fault, e: + def close(self): + try: + return xmlrpclib.Unmarshaller.close(self) + except xmlrpclib.Fault, e: raise ServerException(e.faultString) ## @@ -37,35 +37,35 @@ class ExceptionUnmarshaller(xmlrpclib.Unmarshaller): class GeniTransport(xmlrpclib.Transport): key_file = None cert_file = None - def make_connection(self, host): - # create a HTTPS connection object from a host descriptor - # host may be a string, or a (host, x509-dict) tuple - import httplib - host, extra_headers, x509 = self.get_host_info(host) - try: - HTTPS = httplib.HTTPS() - except AttributeError: - raise NotImplementedError( - "your version of httplib doesn't support HTTPS" - ) - else: - return httplib.HTTPS(host, None, key_file=self.key_file, cert_file=self.cert_file) #**(x509 or {})) - - def getparser(self): - unmarshaller = ExceptionUnmarshaller() - parser = xmlrpclib.ExpatParser(unmarshaller) - return parser, unmarshaller - -## -# The GeniClient class provides stubs for executing Geni operations. A given -# client object connects to one server. To connect to multiple servers, create -# multiple GeniClient objects. -# -# The Geni protocol uses an HTTPS connection, and the client's side of the -# connection uses his private key. Generally, this private key must match the -# public key that is containing in the GID that the client is providing for -# those functions that take a GID. - + def make_connection(self, host): + # create a HTTPS connection object from a host descriptor + # host may be a string, or a (host, x509-dict) tuple + import httplib + host, extra_headers, x509 = self.get_host_info(host) + try: + HTTPS = httplib.HTTPS() + except AttributeError: + raise NotImplementedError( + "your version of httplib doesn't support HTTPS" + ) + else: + return httplib.HTTPS(host, None, key_file=self.key_file, cert_file=self.cert_file) #**(x509 or {})) + + def getparser(self): + unmarshaller = ExceptionUnmarshaller() + parser = xmlrpclib.ExpatParser(unmarshaller) + return parser, unmarshaller + +## +# The GeniClient class provides stubs for executing Geni operations. A given +# client object connects to one server. To connect to multiple servers, create +# multiple GeniClient objects. +# +# The Geni protocol uses an HTTPS connection, and the client's side of the +# connection uses his private key. Generally, this private key must match the +# public key that is containing in the GID that the client is providing for +# those functions that take a GID. + class GeniClient(): ## # Create a new GeniClient object. diff --git a/geni/util/gid.py b/geni/util/gid.py index 65aff6b3..c9196056 100644 --- a/geni/util/gid.py +++ b/geni/util/gid.py @@ -20,12 +20,12 @@ def create_uuid(): # UUID is a unique identifier and is created by the python uuid module # (or the utility function create_uuid() in gid.py). # -# HRN is a human readable name. It is a dotted form similar to a backward domain -# name. For example, planetlab.us.arizona.bakers. -# -# PUBLIC_KEY is the public key of the principal identified by the UUID/HRN. -# It is a Keypair object as defined in the cert.py module. -# +# HRN is a human readable name. It is a dotted form similar to a backward domain +# name. For example, planetlab.us.arizona.bakers. +# +# PUBLIC_KEY is the public key of the principal identified by the UUID/HRN. +# It is a Keypair object as defined in the cert.py module. +# # It is expected that there is a one-to-one pairing between UUIDs and HRN, # but it is uncertain how this would be inforced or if it needs to be enforced. # diff --git a/geni/util/hierarchy.py b/geni/util/hierarchy.py index 742ab8bf..11469632 100644 --- a/geni/util/hierarchy.py +++ b/geni/util/hierarchy.py @@ -78,24 +78,24 @@ class AuthInfo(): f.close() return dict - ## - # Replace the GID with a new one. The file specified by gid_filename is - # overwritten with the new GID object - # - # @param gid object containing new GID + ## + # Replace the GID with a new one. The file specified by gid_filename is + # overwritten with the new GID object + # + # @param gid object containing new GID def update_gid_object(self, gid): gid.save_to_file(self.gid_filename) self.gid_object = gid -## -# The Hierarchy class is responsible for managing the tree of authorities. -# Each authority is a node in the tree and exists as an AuthInfo object. -# -# The tree is stored on disk in a hierarchical manner than reflects the -# structure of the tree. Each authority is a subdirectory, and each subdirectory -# contains the GID, pkey, and dbinfo files for that authority (as well as -# subdirectories for each sub-authority) +## +# The Hierarchy class is responsible for managing the tree of authorities. +# Each authority is a node in the tree and exists as an AuthInfo object. +# +# The tree is stored on disk in a hierarchical manner than reflects the +# structure of the tree. Each authority is a subdirectory, and each subdirectory +# contains the GID, pkey, and dbinfo files for that authority (as well as +# subdirectories for each sub-authority) class Hierarchy(): ## @@ -159,10 +159,10 @@ class Hierarchy(): # create the directory to hold the files try: - os.makedirs(directory) - # if the path already exists then pass - except OSError, (errno, strerr): - if errno == 17: + os.makedirs(directory) + # if the path already exists then pass + except OSError, (errno, strerr): + if errno == 17: pass if os.path.exists(privkey_filename): @@ -179,7 +179,7 @@ class Hierarchy(): dbinfo = get_default_dbinfo() dbinfo_file = file(dbinfo_filename, "w") - dbinfo_file.write(str(dbinfo)) + dbinfo_file.write(str(dbinfo)) dbinfo_file.close() ## diff --git a/geni/util/trustedroot.py b/geni/util/trustedroot.py index 67ad1292..f2ec35a1 100644 --- a/geni/util/trustedroot.py +++ b/geni/util/trustedroot.py @@ -12,10 +12,10 @@ class TrustedRootList(): # create the directory to hold the files try: - os.makedirs(self.basedir) - # if the path already exists then pass - except OSError, (errno, strerr): - if errno == 17: + os.makedirs(self.basedir) + # if the path already exists then pass + except OSError, (errno, strerr): + if errno == 17: pass def add_gid(self, gid): -- 2.43.0