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())
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
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()
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)
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, [])
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()
self.plshell.AddPersonToSlice,
self.plshell.DeletePersonFromSlice)
elif record.type == "authority":
- # TODO
+ # xxx TODO
pass
pass
class ExceptionUnmarshaller(xmlrpclib.Unmarshaller):
- def close(self):\r
- try:\r
- return xmlrpclib.Unmarshaller.close(self)\r
- except xmlrpclib.Fault, e:\r
+ def close(self):
+ try:
+ return xmlrpclib.Unmarshaller.close(self)
+ except xmlrpclib.Fault, e:
raise ServerException(e.faultString)
##
class GeniTransport(xmlrpclib.Transport):
key_file = None
cert_file = None
- def make_connection(self, host):\r
- # create a HTTPS connection object from a host descriptor\r
- # host may be a string, or a (host, x509-dict) tuple\r
- import httplib\r
- host, extra_headers, x509 = self.get_host_info(host)\r
- try:\r
- HTTPS = httplib.HTTPS()\r
- except AttributeError:\r
- raise NotImplementedError(\r
- "your version of httplib doesn't support HTTPS"\r
- )\r
- else:\r
- return httplib.HTTPS(host, None, key_file=self.key_file, cert_file=self.cert_file) #**(x509 or {}))\r
-\r
- def getparser(self):\r
- unmarshaller = ExceptionUnmarshaller()\r
- parser = xmlrpclib.ExpatParser(unmarshaller)\r
- return parser, unmarshaller\r
-\r
-##\r
-# The GeniClient class provides stubs for executing Geni operations. A given\r
-# client object connects to one server. To connect to multiple servers, create\r
-# multiple GeniClient objects.\r
-#\r
-# The Geni protocol uses an HTTPS connection, and the client's side of the\r
-# connection uses his private key. Generally, this private key must match the\r
-# public key that is containing in the GID that the client is providing for\r
-# those functions that take a GID.\r
-\r
+ 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.
# 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\r
-# name. For example, planetlab.us.arizona.bakers.\r
-#\r
-# PUBLIC_KEY is the public key of the principal identified by the UUID/HRN.\r
-# It is a Keypair object as defined in the cert.py module.\r
-#\r
+# 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.
#
f.close()
return dict
- ##\r
- # Replace the GID with a new one. The file specified by gid_filename is\r
- # overwritten with the new GID object\r
- #\r
- # @param gid object containing new GID\r
+ ##
+ # 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
-##\r
-# The Hierarchy class is responsible for managing the tree of authorities.\r
-# Each authority is a node in the tree and exists as an AuthInfo object.\r
-#\r
-# The tree is stored on disk in a hierarchical manner than reflects the\r
-# structure of the tree. Each authority is a subdirectory, and each subdirectory\r
-# contains the GID, pkey, and dbinfo files for that authority (as well as\r
-# subdirectories for each sub-authority)\r
+##
+# 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():
##
# create the directory to hold the files
try:
- os.makedirs(directory)\r
- # if the path already exists then pass\r
- except OSError, (errno, strerr):\r
- if errno == 17:\r
+ os.makedirs(directory)
+ # if the path already exists then pass
+ except OSError, (errno, strerr):
+ if errno == 17:
pass
if os.path.exists(privkey_filename):
dbinfo = get_default_dbinfo()
dbinfo_file = file(dbinfo_filename, "w")
- dbinfo_file.write(str(dbinfo))\r
+ dbinfo_file.write(str(dbinfo))
dbinfo_file.close()
##
# create the directory to hold the files
try:
- os.makedirs(self.basedir)\r
- # if the path already exists then pass\r
- except OSError, (errno, strerr):\r
- if errno == 17:\r
+ os.makedirs(self.basedir)
+ # if the path already exists then pass
+ except OSError, (errno, strerr):
+ if errno == 17:
pass
def add_gid(self, gid):