From: Josh Karlin Date: Wed, 24 Mar 2010 21:50:02 +0000 (+0000) Subject: Added a GENI Aggregate Manager module to the mix, it handles the first call, GetVersion X-Git-Tag: geni-apiv1-totrunk~95 X-Git-Url: http://git.onelab.eu/?a=commitdiff_plain;h=c8ef1b859192507e5f1d98fbf228cc1ff43ac157;p=sfa.git Added a GENI Aggregate Manager module to the mix, it handles the first call, GetVersion --- diff --git a/config/default_config.xml b/config/default_config.xml index 02f48e3a..7e5dfdf3 100644 --- a/config/default_config.xml +++ b/config/default_config.xml @@ -121,6 +121,42 @@ $URL$ + + + + GENI Aggregate + The settings that affect the geni aggregate manager that will run + as part of this SFA instance. + + + + Enable GENI Aggregate + true + Allows this local SFA instance to run as an + GENI aggregate manager. + + + + GENI Aggregate type + pl + The type of backend server for this + aggregate. Some aggregates may not be myplc. + + + + Hostname + localhost + The hostname where the aggregate is expected to + be found. + + + + Port number + 12348 + The port where the aggregate is to be found. + + + diff --git a/sfa/client/sfi.py b/sfa/client/sfi.py index b4bedf90..30513ae6 100755 --- a/sfa/client/sfi.py +++ b/sfa/client/sfi.py @@ -121,7 +121,8 @@ def load_record_from_file(filename): class Sfi: - + + geni_am = None slicemgr = None registry = None user = None @@ -148,7 +149,9 @@ class Sfi: "reset": "name", "start": "name", "stop": "name", - "delegate": "name" + "delegate": "name", + "GetVersion": "name", + } if additional_cmdargs: @@ -201,6 +204,7 @@ class Sfi: help="delegate user credential") parser.add_option("-s", "--slice", dest="delegate_slice", help="delegate slice credential", metavar="HRN", default=None) + return parser @@ -209,6 +213,8 @@ class Sfi: # Generate command line parser parser = OptionParser(usage="sfi [options] command [command_options] [command_args]", description="Commands: gid,list,show,remove,add,update,nodes,slices,resources,create,delete,start,stop,reset") + parser.add_option("-g", "--geni_am", dest="geni_am", + help="geni am", metavar="URL", default=None) parser.add_option("-r", "--registry", dest="registry", help="root registry", metavar="URL", default=None) parser.add_option("-s", "--slicemgr", dest="sm", @@ -269,7 +275,13 @@ class Sfi: else: print "You need to set e.g. SFI_REGISTRY='http://your.registry.url:12345/' in %s"%config_file errors +=1 - + + + if (self.options.geni_am is not None): + geni_am_url = self.options.geni_am + elif hasattr(config,"SFI_GENI_AM"): + geni_am_url = config.SFI_GENI_AM + # Set user HRN if (self.options.user is not None): self.user = self.options.user @@ -304,7 +316,8 @@ class Sfi: self.cert = Certificate(filename=cert_file) # Establish connection to server(s) self.registry = xmlrpcprotocol.get_server(reg_url, key_file, cert_file) - self.slicemgr = xmlrpcprotocol.get_server(sm_url, key_file, cert_file) + self.slicemgr = xmlrpcprotocol.get_server(sm_url, key_file, cert_file) + self.geni_am = xmlrpcprotocol.get_server(geni_am_url, key_file, cert_file) return # @@ -609,7 +622,7 @@ class Sfi: print "Error: Didn't find a user record for", args[0] return - # the gid of the user who will be delegated too + # the gid of the user who will be delegated to delegee_gid = records[0].get_gid_object() delegee_hrn = delegee_gid.get_hrn() @@ -885,6 +898,13 @@ class Sfi: server = self.get_component_server_from_hrn(opts.component) slice_cred = self.get_slice_cred(args[0]).save_to_string(save_parents=True) return server.reset_slice(slice_cred, slice_hrn) + + + # GENI AM related calls + + def GetVersion(self,opts,args): + server = self.geni_am + print server.GetVersion() # # Main: parse arguments and dispatch to command diff --git a/sfa/init.d/sfa b/sfa/init.d/sfa index b3b041ca..6e81c63e 100755 --- a/sfa/init.d/sfa +++ b/sfa/init.d/sfa @@ -75,6 +75,10 @@ start() { action "SFA SliceMgr" daemon /usr/bin/sfa-server.py -s -d $OPTIONS fi + if [ "$SFA_GENI_AGGREGATE_ENABLED" ]; then + action $"SFA GENI Aggregate" daemon /usr/bin/sfa-server.py -g -d $OPTIONS + fi + RETVAL=$? [ $RETVAL -eq 0 ] && touch /var/lock/subsys/sfa diff --git a/sfa/managers/geni_am_pl.py b/sfa/managers/geni_am_pl.py new file mode 100644 index 00000000..c783bfd6 --- /dev/null +++ b/sfa/managers/geni_am_pl.py @@ -0,0 +1,26 @@ +import datetime +import time +import traceback +import sys + +from types import StringTypes +from sfa.util.namespace import * +from sfa.util.rspec import * +from sfa.util.specdict import * +from sfa.util.faults import * +from sfa.util.record import SfaRecord +from sfa.util.policy import Policy +from sfa.util.record import * +from sfa.util.sfaticket import SfaTicket +from sfa.server.registry import Registries +from sfa.util.debug import log +from sfa.plc.slices import Slices +import sfa.plc.peers as peers +from sfa.plc.api import SfaAPI +from sfa.plc.slices import * + +def GetVersion(): + version = {} + version['geni_api'] = 1 + version['geni_stitching'] = False + return version diff --git a/sfa/methods/GetVersion.py b/sfa/methods/GetVersion.py new file mode 100644 index 00000000..c5a41f60 --- /dev/null +++ b/sfa/methods/GetVersion.py @@ -0,0 +1,29 @@ +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.trust.auth import Auth +from sfa.trust.gid import GID +from sfa.trust.certificate import Certificate + +class GetVersion(Method): + """ + Returns this GENI Aggregate Manager's Version Information + @return version + """ + interfaces = ['geni_am'] + accepts = [] + returns = Parameter(dict, "Version information") + + def call(self): + self.api.logger.info("interface: %s" % (self.name)) + + manager_base = 'sfa.managers' + + if self.api.interface in ['geni_am']: + mgr_type = self.api.config.SFA_GENI_AGGREGATE_TYPE + manager_module = manager_base + ".geni_am_%s" % mgr_type + manager = __import__(manager_module, fromlist=[manager_base]) + return manager.GetVersion() + return {} + diff --git a/sfa/methods/__init__.py b/sfa/methods/__init__.py index f4c1dae1..8d2995e5 100644 --- a/sfa/methods/__init__.py +++ b/sfa/methods/__init__.py @@ -26,4 +26,5 @@ start_slice stop_slice update remove_peer_object +GetVersion """.split() diff --git a/sfa/server/geni_aggregate.py b/sfa/server/geni_aggregate.py new file mode 100644 index 00000000..8b51eab2 --- /dev/null +++ b/sfa/server/geni_aggregate.py @@ -0,0 +1,36 @@ +### $Id: aggregate.py 16477 2010-01-05 16:31:37Z thierry $ +### $URL: svn+ssh://svn.planet-lab.org/svn/sfa/branches/geni-api/sfa/server/aggregate.py $ + +import os +import sys +import datetime +import time +import xmlrpclib +from types import StringTypes, ListType + +from sfa.util.server import SfaServer +from sfa.util.storage import * +from sfa.util.faults import * +import sfa.util.xmlrpcprotocol as xmlrpcprotocol +import sfa.util.soapprotocol as soapprotocol + +# GeniLight client support is optional +try: + from egeni.geniLight_client import * +except ImportError: + GeniClientLight = None + + +class GENIAggregate(SfaServer): + + ## + # Create a new aggregate object. + # + # @param ip the ip address to listen on + # @param port the port to listen on + # @param key_file private key filename of registry + # @param cert_file certificate filename containing public key (could be a GID file) + def __init__(self, ip, port, key_file, cert_file): + SfaServer.__init__(self, ip, port, key_file, cert_file) + self.server.interface = 'geni_am' + diff --git a/sfa/server/sfa-server.py b/sfa/server/sfa-server.py index 134b44ae..35d00be4 100755 --- a/sfa/server/sfa-server.py +++ b/sfa/server/sfa-server.py @@ -34,7 +34,7 @@ registry_port=12345 aggregate_port=12346 slicemgr_port=12347 component_port=12346 - +geni_am_port=12348 import os, os.path import sys from optparse import OptionParser @@ -144,7 +144,14 @@ def init_server(options, config): try: manager = __import__(manager_module, fromlist=[manager_base]) except: manager = None if manager and hasattr(manager, 'init_server'): - manager.init_server() + manager.init_server() + if options.gam: + mgr_type = config.SFA_GENI_AGGREGATE_TYPE + manager_module = manager_base + ".geni_am_%s" % mgr_type + try: manager = __import__(manager_module, fromlist=[manager_base]) + except: manager = None + if manager and hasattr(manager, 'init_server'): + manager.init_server() def main(): @@ -165,6 +172,8 @@ def main(): help="run aggregate manager", default=False) parser.add_option("-c", "--component", dest="cm", action="store_true", help="run component server", default=False) + parser.add_option("-g", "--geniam", dest="gam", action="store_true", + help="run GENI aggregate manager", default=False) parser.add_option("-v", "--verbose", dest="verbose", action="store_true", help="verbose mode", default=False) parser.add_option("-d", "--daemon", dest="daemon", action="store_true", @@ -205,5 +214,11 @@ def main(): c = Component("", component_port, server_key_file, server_cert_file) c.start() + # start GENI aggregate manager + if (options.gam): + from sfa.server.geni_aggregate import GENIAggregate + g = GENIAggregate("", geni_am_port, server_key_file, server_cert_file) + g.start() + if __name__ == "__main__": main() diff --git a/sfa/trust/gid.py b/sfa/trust/gid.py index 051168ff..5c7b7354 100644 --- a/sfa/trust/gid.py +++ b/sfa/trust/gid.py @@ -19,7 +19,7 @@ def create_uuid(): ## # GID is a tuple: -# (uuid, hrn, public_key) +# (uuid, urn, public_key) # # UUID is a unique identifier and is created by the python uuid module # (or the utility function create_uuid() in gid.py). diff --git a/sfa/util/api.py b/sfa/util/api.py index 48af3adc..ad129de4 100644 --- a/sfa/util/api.py +++ b/sfa/util/api.py @@ -131,6 +131,7 @@ class BaseAPI: Return a new instance of the specified method. """ # Look up method + print self.methods if method not in self.methods: raise SfaInvalidAPIMethod, method diff --git a/sfa/util/config.py b/sfa/util/config.py index 923df4f4..257b0652 100644 --- a/sfa/util/config.py +++ b/sfa/util/config.py @@ -71,6 +71,9 @@ class Config: if not hasattr(self, 'SFA_CM_TYPE'): self.SFA_COMPONENT_TYPE='pl' + if not hasattr(self, 'SFA_GAM_TYPE'): + self.SFA_GAM_TYPE='pl' + # create the data directory if it doesnt exist if not os.path.isdir(self.SFA_DATA_DIR): try: