self.cert = Certificate(filename=cert_file)
# Establish connection to server(s)
self.logger.info("Contacting Registry at: %s"%reg_url)
- self.registry = xmlrpcprotocol.get_server(reg_url, key_file, cert_file, self.options.debug)
+ self.registry = xmlrpcprotocol.get_server(reg_url, key_file, cert_file, self.options)
self.logger.info("Contacting Slice Manager at: %s"%sm_url)
- self.slicemgr = xmlrpcprotocol.get_server(sm_url, key_file, cert_file, self.options.debug)
+ self.slicemgr = xmlrpcprotocol.get_server(sm_url, key_file, cert_file, self.options)
return
record = records[0]
return self.get_server(record['hostname'], CM_PORT, self.key_file, \
- self.cert_file, self.options.debug)
+ self.cert_file, self.options)
- def get_server(self, host, port, keyfile, certfile, debug):
+ def get_server(self, host, port, keyfile, certfile):
"""
Return an instnace of an xmlrpc server connection
"""
url = "http://%s:%s" % (host, port)
- return xmlrpcprotocol.get_server(url, keyfile, certfile, debug)
+ return xmlrpcprotocol.get_server(url, keyfile, certfile, self.options)
def get_server_from_opts(self, opts):
"""
server = self.slicemgr
# direct connection to an aggregate
if hasattr(opts, 'aggregate') and opts.aggregate:
- server = self.get_server(opts.aggregate, opts.port, self.key_file, \
- self.cert_file, self.options.debug)
+ server = self.get_server(opts.aggregate, opts.port, self.key_file, self.cert_file)
# direct connection to the nodes component manager interface
if hasattr(opts, 'component') and opts.component:
server = self.get_component_server_from_hrn(opts.component)
class RedeemTicket(Method):
"""
- Deprecated. Use RedeemTicket instead.
@param cred credential string specifying the rights of the caller
@param ticket
-## Please use make index to update this file
all = """
-create_slice
-delete_slice
get_aggregates
-get_credential
-get_gids
get_key
get_registries
-get_resources
-get_self_credential
-get_slices
-get_ticket
get_trusted_certs
-list
List
-redeem_ticket
RedeemTicket
-register
Register
register_peer_object
-remove
Remove
reset_slice
-resolve
Resolve
-start_slice
-stop_slice
-update
Update
remove_peer_object
GetTicket
+++ /dev/null
-### $Id$
-### $URL$
-
-from sfa.util.faults import *
-from sfa.util.namespace import *
-from sfa.util.method import Method
-from sfa.util.parameter import Parameter, Mixed
-from sfa.methods.CreateSliver import CreateSliver
-
-class create_slice(CreateSliver):
- """
- Deprecated. Use CreateSliver instead.
- Instantiate the specified slice according to whats defined in the specified rspec
-
- @param cred credential string specifying the rights of the caller
- @param hrn human readable name of slice to instantiate (hrn or xrn)
- @param rspec resource specification
- @return 1 is successful, faults otherwise
- """
-
- interfaces = ['aggregate', 'slicemgr']
-
- accepts = [
- Parameter(str, "Credential string"),
- Parameter(str, "Human readable name of slice to instantiate (hrn or xrn)"),
- Parameter(str, "Resource specification"),
- Mixed(Parameter(str, "Human readable name of the original caller"),
- Parameter(None, "Origin hrn not specified"))
- ]
-
- returns = Parameter(int, "1 if successful")
-
- def call(self, cred, xrn, requested_rspec, origin_hrn=None):
-
- return CreateSliver.call(self, xrn, cred, requested_rspec, [])
+++ /dev/null
-### $Id$
-### $URL$
-
-from sfa.util.faults import *
-from sfa.util.namespace import *
-from sfa.util.method import Method
-from sfa.util.parameter import Parameter, Mixed
-from sfa.methods.DeleteSliver import DeleteSliver
-
-class delete_slice(DeleteSliver):
- """
- Deprecated. Use delete instead.
-
- Remove the slice from all nodes.
-
- @param cred credential string specifying the rights of the caller
- @param xrn human readable name specifying the slice to delete (hrn or urn)
- @return 1 if successful, faults otherwise
- """
-
- interfaces = ['aggregate', 'slicemgr', 'component']
-
- accepts = [
- Parameter(str, "Credential string"),
- Parameter(str, "Human readable name of slice to delete (hrn or urn)"),
- Mixed(Parameter(str, "Human readable name of the original caller"),
- Parameter(None, "Origin hrn not specified"))
- ]
-
- returns = Parameter(int, "1 if successful")
-
- def call(self, cred, xrn, origin_hrn=None):
-
- return DeleteSliver.call(self, xrn, cred)
+++ /dev/null
-### $Id$
-### $URL$
-
-from sfa.trust.credential import *
-from sfa.trust.rights import *
-from sfa.util.faults import *
-from sfa.util.namespace import *
-from sfa.util.method import Method
-from sfa.util.parameter import Parameter, Mixed
-from sfa.methods.GetCredential import GetCredential
-
-class get_credential(GetCredential):
- """
- Deprecated. Use GetCredential instead.
-
- Retrive a credential for an object
- If cred == Nonee then the behavior reverts to get_self_credential
-
- @param cred credential object specifying rights of the caller
- @param type type of object (user | slice | sa | ma | node)
- @param hrn human readable name of object (hrn or urn)
-
- @return the string representation of a credential object
- """
-
- interfaces = ['registry']
-
- accepts = [
- Mixed(Parameter(str, "credential"),
- Parameter(None, "No credential")),
- Parameter(str, "Human readable name (hrn or urn)")
- ]
-
- returns = Parameter(str, "String representation of a credential object")
-
- def call(self, cred, type, xrn, origin_hrn=None):
- return GetCredential.call(self, cred, xrn, type)
+++ /dev/null
-from sfa.util.faults import *
-from sfa.util.method import Method
-from sfa.util.parameter import Parameter, Mixed
-from sfa.methods.GetGids import GetGids
-
-class get_gids(GetGids):
- """
- Deprecated. Use GetGids instead.
-
- Get a list of record information (hrn, gid and type) for
- the specified hrns.
-
- @param cred credential string
- @param cert certificate string
- @return
- """
-
- interfaces = ['registry']
-
- accepts = [
- Parameter(str, "Certificate string"),
- Mixed(Parameter(str, "Human readable name (hrn or xrn)"),
- Parameter(type([str]), "List of Human readable names (hrn or xrn)"))
- ]
-
- returns = [Parameter(dict, "Dictionary of gids keyed on hrn")]
-
- def call(self, cred, xrns):
-
- return GetGids.call(self, xrns, cred)
+++ /dev/null
-### $Id$
-### $URL$
-
-from sfa.util.faults import *
-from sfa.util.method import Method
-from sfa.util.parameter import Parameter, Mixed
-from sfa.methods.ListResources import ListResources
-# RSpecManager_pl is not used. This line is a check that ensures that everything is in place for the import to work.
-import sfa.rspecs.aggregates.rspec_manager_pl
-
-class get_resources(ListResources):
- """
- Deprecated. Use ListResources instead.
-
- Get an resource specification (rspec). The rspec may describe the resources
- available at an authority or the resources being used by a slice.
-
- @param cred credential string specifying the rights of the caller
- @param hrn human readable name of the slice we are interesed in or None
- for an authority.
- """
-
- interfaces = ['aggregate', 'slicemgr']
-
- accepts = [
- Parameter(str, "Credential string"),
- Mixed(Parameter(str, "Human readable name (hrn or urn)"),
- Parameter(None, "hrn not specified")),
- Mixed(Parameter(str, "Human readable name of the original caller"),
- Parameter(None, "Origin hrn not specified"))
- ]
-
- returns = Parameter(str, "String representatin of an rspec")
-
- def call(self, cred, xrn=None, origin_hrn=None):
- options = {'geni_slice_urn': xrn,
- 'origin_hrn': origin_hrn
- }
-
- return ListResources.call(self, cred, options)
+++ /dev/null
-### $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 *
-from sfa.util.faults import *
-from sfa.util.namespace import *
-from sfa.util.method import Method
-from sfa.util.parameter import Parameter, Mixed
-from sfa.util.record import SfaRecord
-from sfa.methods.GetSelfCredential import GetSelfCredential
-
-class get_self_credential(GetSelfCredential):
- """
- Deprecated. Use GetSelfCredential instead.
-
- Retrive a credential for an object
- @param cert certificate string
- @param type type of object (user | slice | sa | ma | node)
- @param hrn human readable name of object (hrn or urn)
-
- @return the string representation of a credential object
- """
-
- interfaces = ['registry']
-
- accepts = [
- Parameter(str, "Human readable name (hrn or urn)"),
- Parameter(str, "certificate"),
- Mixed(Parameter(str, "Request hash"),
- Parameter(None, "Request hash not specified"))
- ]
-
- returns = Parameter(str, "String representation of a credential object")
-
- def call(self, cert, type, xrn, origin_hrn=None):
- """
- get_self_credential a degenerate version of get_credential used by a client
- to get his initial credential when de doesnt have one. This is the same as
- get_credetial(..., cred = None, ...)
-
- The registry ensures that the client is the principal that is named by
- (type, name) by comparing the public key in the record's GID to the
- private key used to encrypt the client side of the HTTPS connection. Thus
- it is impossible for one principal to retrive another principal's
- credential without having the appropriate private key.
-
- @param type type of object (user | slice | sa | ma | node)
- @param hrn human readable name of authority to list
- @return string representation of a credential object
- """
- return GetSelfCredential.call(self, cert, xrn, type)
+++ /dev/null
-### $Id$
-### $URL$
-
-from sfa.util.faults import *
-from sfa.util.method import Method
-from sfa.util.parameter import Parameter, Mixed
-from sfa.methods.ListSlices import ListSlices
-
-class get_slices(ListSlices):
- """
- Deprecated. Use ListSlices instead.
- Get a list of instantiated slices at this authority.
-
- @param cred credential string specifying the rights of the caller
- @return list of human readable slice names (hrn).
- """
-
- interfaces = ['aggregate', 'slicemgr', 'component']
-
- accepts = [
- Parameter(str, "Credential string"),
- Mixed(Parameter(str, "Human readable name of the original caller"),
- Parameter(None, "Origin hrn not specified"))
- ]
-
- returns = [Parameter(str, "Human readable slice name (hrn)")]
-
- def call(self, cred, origin_hrn=None):
-
- return ListSlices.call(self, cred)
+++ /dev/null
-### $Id$
-### $URL$
-import time
-from sfa.util.faults import *
-from sfa.util.namespace import *
-from sfa.util.method import Method
-from sfa.util.parameter import Parameter, Mixed
-from sfa.methods.GetTicket import GetTicket
-
-class get_ticket(GetTicket):
- """
- Deprecated. Use GetTicket instead.
-
- Retrieve a ticket. This operation is currently implemented on PLC
- only (see SFA, engineering decisions); it is not implemented on
- components.
-
- The ticket is filled in with information from the PLC database. This
- information includes resources, and attributes such as user keys and
- initscripts.
-
- @param cred credential string
- @param name name of the slice to retrieve a ticket for (hrn or urn)
- @param rspec resource specification dictionary
-
- @return the string representation of a ticket object
- """
-
- interfaces = ['aggregate', 'slicemgr']
-
- accepts = [
- Parameter(str, "Credential string"),
- Parameter(str, "Human readable name of slice to retrive a ticket for (hrn or urn)"),
- Parameter(str, "Resource specification (rspec)"),
- Mixed(Parameter(str, "Human readable name of the original caller"),
- Parameter(None, "Origin hrn not specified"))
- ]
-
- returns = Parameter(str, "String represeneation of a ticket object")
-
- def call(self, cred, xrn, rspec, origin_hrn=None):
-
- return GetTicket.call(self, xrn, cred, rspec, None)
+++ /dev/null
-### $Id$
-### $URL$
-
-from sfa.util.faults import *
-from sfa.util.namespace import *
-from sfa.util.method import Method
-from sfa.util.parameter import Parameter, Mixed
-from sfa.util.record import SfaRecord
-from sfa.methods.List import List
-
-class list(List):
- """
- Deprecated. Use List instead.
-
- List the records in an authority.
-
- @param cred credential string specifying the rights of the caller
- @param hrn human readable name of authority to list (hrn or urn)
- @return list of record dictionaries
- """
- interfaces = ['registry']
-
- accepts = [
- Parameter(str, "Credential string"),
- Parameter(str, "Human readable name (hrn or urn)"),
- Mixed(Parameter(str, "Human readable name of the original caller"),
- Parameter(None, "Origin hrn not specified"))
- ]
-
- returns = [SfaRecord]
-
- def call(self, cred, xrn, origin_hrn=None):
-
- return List.call(self, xrn, cred)
+++ /dev/null
-### $Id: reset_slice.py 15428 2009-10-23 15:28:03Z tmack $
-### $URL: https://svn.planet-lab.org/svn/sfa/trunk/sfacomponent/methods/reset_slice.py $
-import xmlrpclib
-from sfa.util.faults import *
-from sfa.util.method import Method
-from sfa.util.parameter import Parameter, Mixed
-from sfa.methods.RedeemTicket import RedeemTicket
-
-class redeem_ticket(RedeemTicket):
- """
- Deprecated. Use RedeemTicket instead.
-
- Redeem a approved set of resource allocations (ticket).
-
- @param cred credential string specifying the rights of the caller
- @param ticket
- @return 1 is successful, faults otherwise
- """
-
- interfaces = ['component']
-
- accepts = [
- Parameter(str, "Credential string representation of SFA credential"),
- Parameter(str, "Ticket string representation of SFA ticket")
- ]
-
- returns = [Parameter(int, "1 if successful")]
-
- def call(self, cred, ticket):
-
- return RedeemTicket.call(self, ticket, cred)
+++ /dev/null
-### $Id$
-### $URL$
-
-from sfa.trust.certificate import Keypair, convert_public_key
-from sfa.trust.gid import *
-from sfa.util.faults import *
-from sfa.util.method import Method
-from sfa.util.parameter import Parameter, Mixed
-from sfa.methods.Register import Register
-
-class register(Register):
- """
- Deprecated. Used Register instead.
-
- Register an object with the registry. In addition to being stored in the
- SFA database, the appropriate records will also be created in the
- PLC databases
-
- @param cred credential string
- @param record_dict dictionary containing record fields
-
- @return gid string representation
- """
-
- interfaces = ['registry']
-
- accepts = [
- Parameter(str, "Credential string"),
- Parameter(dict, "Record dictionary containing record fields")
- ]
-
- returns = Parameter(int, "String representation of gid object")
-
- def call(self, cred, record, origin_hrn=None):
-
- return Register.call(self, record, cred)
+++ /dev/null
-### $Id$
-### $URL$
-
-from sfa.util.faults import *
-from sfa.util.namespace import *
-from sfa.util.method import Method
-from sfa.util.parameter import Parameter, Mixed
-from sfa.methods.Remove import Remove
-
-class remove(Remove):
- """
- Deprecated. Use Remove instead.
-
- Remove an object from the registry. If the object represents a PLC object,
- then the PLC records will also be removed.
-
- @param cred credential string
- @param type record type
- @param xrn human readable name of record to remove (hrn or urn)
-
- @return 1 if successful, faults otherwise
- """
-
- interfaces = ['registry']
-
- accepts = [
- Parameter(str, "Credential string"),
- Parameter(str, "Record type"),
- Parameter(str, "Human readable name of slice to instantiate (hrn or urn)"),
- Mixed(Parameter(str, "Human readable name of the original caller"),
- Parameter(None, "Origin hrn not specified"))
- ]
-
- returns = Parameter(int, "1 if successful")
-
- def call(self, cred, type, xrn, origin_hrn=None):
-
- return Remove.call(self, xrn, cred, type)
+++ /dev/null
-### $Id$
-### $URL$
-import traceback
-import types
-from sfa.util.faults import *
-from sfa.util.namespace import *
-from sfa.util.method import Method
-from sfa.util.parameter import Parameter, Mixed
-from sfa.util.record import SfaRecord
-from sfa.methods.Resolve import Resolve
-
-class resolve(Resolve):
- """
- Deprecated. Use Resolve instead
- Resolve a record.
-
- @param cred credential string authorizing the caller
- @param hrn human readable name to resolve (hrn or urn)
- @return a list of record dictionaries or empty list
- """
-
- interfaces = ['registry']
-
- accepts = [
- Parameter(str, "Credential string"),
- Mixed(Parameter(str, "Human readable name (hrn or urn)"),
- Parameter(list, "List of Human readable names ([hrn])"))
- ]
-
- returns = [SfaRecord]
-
- def call(self, cred, xrns, origin_hrn=None):
- return Resolve.call(self, xrns, cred)
-
-
-
+++ /dev/null
-### $Id$
-### $URL$
-
-from sfa.util.faults import *
-from sfa.util.namespace import *
-from sfa.util.method import Method
-from sfa.util.parameter import Parameter, Mixed
-from sfa.methods.Start import Start
-
-class start_slice(Start):
- """
- Deprecated. Use Start instead
-
- Start the specified slice
-
- @param cred credential string specifying the rights of the caller
- @param hrn human readable name of slice to instantiate (urn or hrn)
- @return 1 is successful, faults otherwise
- """
-
- interfaces = ['aggregate', 'slicemgr', 'component']
-
- accepts = [
- Parameter(str, "Credential string"),
- Parameter(str, "Human readable name of slice to instantiate (urn or hrn)"),
- Mixed(Parameter(str, "Human readable name of the original caller"),
- Parameter(None, "Origin hrn not specified"))
- ]
-
- returns = [Parameter(int, "1 if successful")]
-
- def call(self, cred, xrn, origin_hrn=None):
-
- return Start.call(self, xrn, cred)
+++ /dev/null
-### $Id$
-### $URL$
-
-from sfa.util.faults import *
-from sfa.util.namespace import *
-from sfa.util.method import Method
-from sfa.util.parameter import Parameter, Mixed
-from sfa.methods.Stop import Stop
-
-class stop_slice(Stop):
- """
- Deprecated. Use Stop instead
- Stop the specified slice
-
- @param cred credential string specifying the rights of the caller
- @param xrn human readable name of slice to instantiate (hrn or urn)
- @return 1 is successful, faults otherwise
- """
-
- interfaces = ['aggregate', 'slicemgr', 'component']
-
- accepts = [
- Parameter(str, "Credential string"),
- Parameter(str, "Human readable name of slice to instantiate (hrn or urn)"),
- Mixed(Parameter(str, "Human readable name of the original caller"),
- Parameter(None, "Origin hrn not specified"))
- ]
-
- returns = Parameter(int, "1 if successful")
-
- def call(self, cred, xrn, origin_hrn=None):
-
- return Stop.call(self, xrn, cred)
+++ /dev/null
-### $Id$
-### $URL$
-
-import time
-from sfa.util.faults import *
-from sfa.util.method import Method
-from sfa.util.parameter import Parameter, Mixed
-from sfa.methods.Update import Update
-
-class update(Update):
- """
- Deprecated. Use Update instead.
-
- Update an object in the registry. Currently, this only updates the
- PLC information associated with the record. The SFA fields (name, type,
- GID) are fixed.
-
- @param cred credential string specifying rights of the caller
- @param record a record dictionary to be updated
-
- @return 1 if successful, faults otherwise
- """
-
- interfaces = ['registry']
-
- accepts = [
- Parameter(str, "Credential string"),
- Parameter(dict, "Record dictionary to be updated"),
- Mixed(Parameter(str, "Human readable name of the original caller"),
- Parameter(None, "Origin hrn not specified"))
- ]
-
- returns = Parameter(int, "1 if successful")
-
- def call(self, cred, record_dict, origin_hrn=None):
-
- return Update.call(self, record_dict, cred)
-
--- /dev/null
+tags:
+ etags *.py
+++ /dev/null
-##
-# This module implements the client-side of the SFA API. Stubs are provided
-# that convert the supplied parameters to the necessary format and send them
-# via XMLRPC to an SFA Server.
-#
-# TODO: Investigate ways to combine this with existing PLC API?
-##
-
-### $Id$
-### $URL$
-
-from sfa.trust.certificate import *
-from sfa.trust.gid import *
-from sfa.trust.credential import *
-from sfa.util.record import *
-from sfa.util.sfaticket import SfaTicket
-
-##
-# The GeniClient class provides stubs for executing SFA operations. A given
-# client object connects to one server. To connect to multiple servers, create
-# multiple GeniClient objects.
-#
-# The SFA 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.
- #
- # @param url is the url of the server
- # @param key_file = private key file of client
- # @param cert_file = x.509 cert containing the client's public key. This
- # could be a GID certificate, or any x.509 cert.
- # @param protocol The ORPC protocol to use. Can be "soap" or "xmlrpc"
-
- def __init__(self, url, key_file, cert_file, protocol="xmlrpc"):
- self.url = url
- self.key_file = key_file
- self.cert_file = cert_file
- self.key = Keypair(filename = self.key_file)
-
-
- if (protocol=="xmlrpc"):
- import xmlrpcprotocol
- self.server = xmlrpcprotocol.get_server(self.url, self.key_file, self.cert_file)
- elif (protocol=="soap"):
- import soapprotocol
- self.server = soapprotocol.get_server(self.url, self.key_file, self.cert_file)
- else:
- raise Exception("Attempted use of undefined protocol %s"%protocol)
-
-
- # -------------------------------------------------------------------------
- # Registry Interface
- # -------------------------------------------------------------------------
-
- ##
- # Create a new GID. For MAs and SAs that are physically located on the
- # registry, this allows a owner/operator/PI to create a new GID and have it
- # signed by his respective authority.
- #
- # @param cred credential of caller
- # @param name hrn for new GID
- # @param uuid unique identifier for new GID
- # @param pkey_string public-key string (TODO: why is this a string and not a keypair object?)
- #
- # @return a GID object
-
- def create_gid(self, cred, name, uuid, pkey_string):
- gid_str = self.server.create_gid(cred.save_to_string(save_parents=True), name, uuid, pkey_string)
- return GID(string=gid_str)
-
- ##
- # Retrieve the GID for an object. This function looks up a record in the
- # registry and returns the GID of the record if it exists.
- # TODO: Is this function needed? It's a shortcut for Resolve()
- #
- # @param name hrn to look up
- #
- # @return a GID object
-
- #def get_gid(self, name):
- # gid_str_list = self.server.get_gid(name)
- # gid_list = []
- # for str in gid_str_list:
- # gid_list.append(GID(string=str))
- # return gid_list
-
-
- def get_gid(self, cert, hrn, type, request_hash):
- cert_string = cert.save_to_string(save_parents=True)
- gid_str = self.server.get_gid(cert_string, hrn, type, request_hash)
- return GID(string=gid_str)
- ##
- # Get_self_credential a degenerate version of get_credential used by a
- # client to get his initial credential when he doesn't have one. This is
- # the same as get_credential(..., cred=None,...).
- #
- # The registry ensures that the client is the principal that is named by
- # (type, name) by comparing the public key in the record's GID to the
- # private key used to encrypt the client-side of the HTTPS connection. Thus
- # it is impossible for one principal to retrieve another principal's
- # credential without having the appropriate private key.
- #
- # @param type type of object (user | slice | sa | ma | node
- # @param name human readable name of object
- #
- # @return a credential object
-
- def get_self_credential(self, type, name):
- cred_str = self.server.get_self_credential(type, name)
- return Credential(string = cred_str)
-
- ##
- # Retrieve a credential for an object.
- #
- # If cred==None, then the behavior reverts to get_self_credential()
- #
- # @param cred credential object specifying rights of the caller
- # @param type type of object (user | slice | sa | ma | node)
- # @param name human readable name of object
- #
- # @return a credental object
-
- def get_credential(self, cred, type, name):
- if cred:
- cred = cred.save_to_string(save_parents=True)
- cred_str = self.server.get_credential(cred, type, name)
- return Credential(string = cred_str)
-
- ##
- # List the records in an authority. The objectGID in the supplied credential
- # should name the authority that will be listed.
- #
- # @param cred credential object specifying rights of the caller
- #
- # @return list of record objects
-
- def list(self, cred, auth_hrn, caller_cred=None):
- result_dict_list = self.server.list(cred.save_to_string(save_parents=True), auth_hrn, caller_cred)
- result_rec_list = []
- for dict in result_dict_list:
- result_rec_list.append(SfaRecord(dict=dict))
- return result_rec_list
-
- ##
- # Register an object with the registry. In addition to being stored in the
- # SFA database, the appropriate records will also be created in the
- # PLC databases.
- #
- #
- #
- # @param cred credential object specifying rights of the caller
- # @param record to register
- #
- # @return GID object for the newly-registered record
-
- def register(self, cred, record, caller_cred=None):
- gid_str = self.server.register(cred.save_to_string(save_parents=True), record.as_dict(), caller_cred)
- return GID(string = gid_str)
-
-
- ##
- # Register a peer object with the registry.
- #
- #
- # @param cred credential object specifying rights of the caller
- # @param record to register
- #
- # @return GID object for the newly-registered record
-
- def register_peer_object(self, cred, record, caller_cred=None):
- return self.server.register_peer_object(cred.save_to_string(save_parents=True), record, caller_cred)
-
- ##
- # Remove an object from the registry. If the object represents a PLC object,
- # then the PLC records will also be removed.
- #
- # @param cred credential object specifying rights of the caller
- # @param type
- # @param hrn
-
- def remove(self, cred, type, hrn, caller_cred=None):
- return self.server.remove(cred.save_to_string(save_parents=True), type, hrn, caller_cred)
-
- ##
- # Remove a peer object from the registry. If the object represents a PLC object,
- # then the PLC records will also be removed.
- #
- # @param cred credential object specifying rights of the caller
- # @param type
- # @param hrn
-
- def remove_peer_object(self, cred, record, caller_cred=None):
- result = self.server.remove_peer_object(cred.save_to_string(save_parents=True), record, caller_cred)
- return result
-
- ##
- # Resolve an object in the registry. A given HRN may have multiple records
- # associated with it, and therefore multiple records may be returned. The
- # caller should check the type fields of the records to find the one that
- # he is interested in.
- #
- # @param cred credential object specifying rights of the caller
- # @param name human readable name of object
-
- def resolve(self, cred, name, caller_cred=None):
- result_dict_list = self.server.resolve(cred.save_to_string(save_parents=True), name, caller_cred)
- result_rec_list = []
- for dict in result_dict_list:
- if dict['type'] in ['authority']:
- result_rec_list.append(AuthorityRecord(dict=dict))
- elif dict['type'] in ['node']:
- result_rec_list.append(NodeRecord(dict=dict))
- elif dict['type'] in ['slice']:
- result_rec_list.append(SliceRecord(dict=dict))
- elif dict['type'] in ['user']:
- result_rec_list.append(UserRecord(dict=dict))
- else:
- result_rec_list.append(SfaRecord(dict=dict))
- return result_rec_list
-
- ##
- # Update an object in the registry. Currently, this only updates the
- # PLC information associated with the record. The SFA fields (name, type,
- # GID) are fixed.
- #
- #
- #
- # @param cred credential object specifying rights of the caller
- # @param record a record object to be updated
-
- def update(self, cred, record, caller_cred=None):
- result = self.server.update(cred.save_to_string(save_parents=True), record.as_dict(), caller_cred)
- return result
-
-
- #-------------------------------------------------------------------------
- # Aggregate Interface
- #-------------------------------------------------------------------------
-
- ## list resources
- #
- # @param cred a credential
- # @param hrn slice hrn
-
- def get_resources(self, cred, hrn=None, caller_cred=None):
- result = self.server.get_resources(cred.save_to_string(save_parents=True), hrn, caller_cred)
- return result
-
- def get_aggregates(self, cred, hrn=None):
- result = self.server.get_aggregates(cred.save_to_string(save_parents=True), hrn)
- return result
-
- def get_registries(self, cred, hrn=None):
- result = self.server.get_registries(cred.save_to_string(save_parents=True), hrn)
- return result
-
- ## get policy
- #
- # @param cred a credential
-
- def get_policy(self, cred):
- result = self.server.get_policy(cred.save_to_string(save_parents=True))
- return result
-
- ## create slice
- #
- # @param cred a credential
- # @param rspec resource specification defining how to instantiate the slice
-
- def create_slice(self, cred, hrn, rspec, caller_cred=None):
- result = self.server.create_slice(cred.save_to_string(save_parents=True), hrn, rspec, caller_cred)
- return result
-
-
- ## delete slice
- #
- # @param cred a credential
- # @param hrn slice to delete
- def delete_slice(self, cred, hrn, caller_cred=None):
- result = self.server.delete_slice(cred.save_to_string(save_parents=True), hrn, caller_cred)
- return result
-
- # ------------------------------------------------------------------------
- # Slice Interface
- # ------------------------------------------------------------------------
-
- ##
- # Start a slice.
- #
- # @param cred a credential identifying the caller (callerGID) and the slice
- # (objectGID)
-
- def start_slice(self, cred, hrn):
- result = self.server.start_slice(cred.save_to_string(save_parents=True), hrn)
- return result
-
- ##
- # Stop a slice.
- #
- # @param cred a credential identifying the caller (callerGID) and the slice
- # (objectGID)
-
- def stop_slice(self, cred, hrn):
- result = self.server.stop_slice(cred.save_to_string(save_parents=True), hrn)
- return result
-
- ##
- # Reset a slice.
- #
- # @param cred a credential identifying the caller (callerGID) and the slice
- # (objectGID)
-
- def reset_slice(self, cred, hrn):
- result = self.server.reset_slice(cred.save_to_string(save_parents=True), hrn)
- return result
-
- ##
- # Delete a slice.
- #
- # @param cred a credential identifying the caller (callerGID) and the slice
- # (objectGID)
-
- def delete_slice(self, cred, hrn, caller_cred=None):
- result = self.server.delete_slice(cred.save_to_string(save_parents=True), hrn, caller_cred)
- return result
-
- ##
- # List the slices on a component.
- #
- # @param cred credential object that authorizes the caller
- #
- # @return a list of slice names
-
- def get_slices(self, cred):
- result = self.server.get_slices(cred.save_to_string(save_parents=True))
- return result
-
- ##
- # Retrieve a ticket. This operation is currently implemented on the
- # registry (see SFA, engineering decisions), and is not implemented on
- # components.
- #
- # The ticket is filled in with information from the PLC database. This
- # information includes resources, and attributes such as user keys and
- # initscripts.
- #
- # @param cred credential object
- # @param name name of the slice to retrieve a ticket for
- # @param rspec resource specification dictionary
- #
- # @return a ticket object
-
- def get_ticket(self, cred, name, rspec):
- ticket_str = self.server.get_ticket(cred.save_to_string(save_parents=True), name, rspec)
- ticket = SfaTicket(string=ticket_str)
- return ticket
-
- ##
- # Redeem a ticket. This operation is currently implemented on the
- # component.
- #
- # The ticket is submitted to the node manager, and the slice is instantiated
- # or updated as appropriate.
- #
- # TODO: This operation should return a sliver credential and indicate
- # whether or not the component will accept only sliver credentials, or
- # will accept both sliver and slice credentials.
- #
- # @param ticket a ticket object containing the ticket
-
- def redeem_ticket(self, ticket):
- result = self.server.redeem_ticket(ticket.save_to_string(save_parents=True))
- return result
-
-
- def remove_remote_object(self, cred, hrn, record):
- result = self.server.remove_remote_object(cred.save_to_string(save_parents=True), hrn, record)
- return result
# remove any escaped no alpah numeric characters
#hrn = re.sub('\\\[^a-zA-Z0-9]', '', hrn)
# remove any escaped '.' (i.e. '\.')
- hrn.replace('\\.', '')
+ hrn = hrn.replace('\\.', '')
parts = hrn.split(".")
return parts[-2] + "_" + parts[-1]
# assuming hrn is the hrn of an authority, return the plc authority name
def hrn_to_pl_authname(hrn):
# remove any escaped '.' (i.e. '\.')
- hrn.replace('\\.', '')
+ hrn = hrn.replace('\\.', '')
parts = hrn.split(".")
return parts[-1]
# assuming hrn is the hrn of an authority, return the plc login_base
def hrn_to_pl_login_base(hrn):
# remove any escaped '.' (i.e. '\.')
- hrn.replace('\\.', '')
+ hrn = hrn.replace('\\.', '')
return hrn_to_pl_authname(hrn)
def hostname_to_hrn(auth_hrn, login_base, hostname):
parser = xmlrpclib.ExpatParser(unmarshaller)
return parser, unmarshaller
-def get_server(url, key_file, cert_file, debug=False):
+class XMLRPCServerProxy(xmlrpclib.ServerProxy):
+ def __init__(self, url, transport, allow_none=True, options=None):
+ self.options = options
+ verbose = False
+ if self.options and self.options.debug:
+ verbose = True
+ xmlrpclib.ServerProxy.__init__(self, url, transport, allow_none=allow_none, verbose=verbose)
+
+ def __getattr__(self, attr):
+ if self.options and self.options.verbose:
+ print "Calling xml-rpc method:", attr
+ return xmlrpclib.ServerProxy.__getattr__(self, attr)
+
+
+def get_server(url, key_file, cert_file, options=None):
transport = XMLRPCTransport()
transport.key_file = key_file
transport.cert_file = cert_file
- return xmlrpclib.ServerProxy(url, transport, allow_none=True, verbose=debug)
+ return XMLRPCServerProxy(url, transport, allow_none=True, options=options)