From 713d58df0baa1f9739eec9bfa30ceb41d7149e23 Mon Sep 17 00:00:00 2001 From: Thierry Parmentelat Date: Tue, 29 May 2018 09:31:25 +0200 Subject: [PATCH] rough cleanup of the slicemanager business --- config/default_config.xml | 38 -- config/gen-sfa-cm-config.py | 2 - config/sfa_component_config | 22 +- sfa/client/sfaadmin.py | 15 +- sfa/client/sfascan.py | 8 +- sfa/generic/__init__.py | 6 +- sfa/generic/architecture.txt | 6 +- sfa/generic/dummy.py | 4 - sfa/generic/iotlab.py | 4 - sfa/generic/pl.py | 4 - sfa/generic/teagle.py | 4 - sfa/generic/void.py | 6 - sfa/importer/__init__.py | 21 - sfa/managers/slice_manager.py | 591 ------------------------ sfa/methods/Allocate.py | 4 +- sfa/methods/Delete.py | 2 +- sfa/methods/Describe.py | 4 +- sfa/methods/GetVersion.py | 2 +- sfa/methods/ListResources.py | 4 +- sfa/methods/PerformOperationalAction.py | 2 +- sfa/methods/Provision.py | 2 +- sfa/methods/Renew.py | 2 +- sfa/methods/Shutdown.py | 2 +- sfa/methods/Status.py | 2 +- sfa/methods/get_trusted_certs.py | 2 +- sfa/server/sfa-start.py | 8 - sfa/server/sfaapi.py | 4 +- sfa/server/slicemgr.py | 19 - tests/testInterfaces.py | 79 ++-- wsdl/sfa2wsdl.py | 49 +- 30 files changed, 82 insertions(+), 836 deletions(-) delete mode 100644 sfa/managers/slice_manager.py delete mode 100644 sfa/server/slicemgr.py diff --git a/config/default_config.xml b/config/default_config.xml index 0c7c526c..edeec256 100644 --- a/config/default_config.xml +++ b/config/default_config.xml @@ -109,44 +109,6 @@ Thierry Parmentelat - - - Slice Manager - The settings that affect the slice manager that will run - as part of this SFA instance. - - - - Enable Slice Manager - false - Allows this local SFA instance to run as a - slice manager. Warning, this feature is not really supported - any longer. - - - - Hostname - localhost - The hostname where the slice manager is expected to - be found. - - - - Port number - 12347 - The port where the slice manager is to be found. - - - - Cache advertisement rspec - false - Enable caching of the global advertisement, as - returned by ListResources without a slice argument. - - - - - Aggregate diff --git a/config/gen-sfa-cm-config.py b/config/gen-sfa-cm-config.py index 62f72ded..eca98355 100755 --- a/config/gen-sfa-cm-config.py +++ b/config/gen-sfa-cm-config.py @@ -12,7 +12,6 @@ default_host = socket.gethostbyname(socket.gethostname()) all_vars = ['SFA_CONFIG_DIR', 'SFA_DATA_DIR', 'SFA_INTERFACE_HRN', 'SFA_CM_SLICE_PREFIX', 'SFA_REGISTRY_HOST', 'SFA_REGISTRY_PORT', 'SFA_AGGREGATE_HOST', 'SFA_AGGREGATE_PORT', - 'SFA_SM_HOST', 'SFA_SM_PORT', 'SFA_CM_ENABLED', 'SFA_CM_HOST', 'SFA_CM_PORT', 'SFA_CM_TYPE', 'SFA_CM_SLICE_PREFIX', 'SFA_API_LOGLEVEL'] @@ -28,7 +27,6 @@ defaults = { host_defaults = { 'SFA_REGISTRY_HOST': default_host, 'SFA_AGGREGATE_HOST': default_host, - 'SFA_SM_HOST': default_host, } const_dict = {} diff --git a/config/sfa_component_config b/config/sfa_component_config index 39580155..dec159af 100644 --- a/config/sfa_component_config +++ b/config/sfa_component_config @@ -3,7 +3,7 @@ # HRN # Human readable name for this interface -SFA_INTERFACE_HRN="plc" +SFA_INTERFACE_HRN="plc" # loglevel # How deep are we logging (0|1|2) @@ -13,7 +13,7 @@ SFA_API_LOGLEVEL=1 # Registry Configuration # # Enabled -# Enable the registry interface +# Enable the registry interface SFA_REGISTRY_ENABLED=0 # Root Auth @@ -22,7 +22,7 @@ SFA_REGISTRY_ROOT_AUTH="plc" # Level1 Auth # The hrn of the registry's level1 auth (sub authority) -# The full name of this interface (only secify if this +# The full name of this interface (only secify if this # interface is a sub authority) # xxx could be determined from hrn above SFA_REGISTRY_LEVEL1_AUTH="" @@ -54,21 +54,6 @@ SFA_AGGREGATE_HOST="localhost" ## SFA aggregate server port SFA_AGGREGATE_PORT=12346 -## ============================================================== -# Slice Manager Configuration -# -# Enabled -# Enable the slice manager -SFA_SM_ENABLED=0 - -# Host -## The fully qualified hostname or IP address of the slice manager server -SFA_SM_HOST="localhost" - -# Port -# SFA slice manager server port -SFA_SM_PORT=12347 - ## =============================================================== # Component Manager Configuration # @@ -95,4 +80,3 @@ SFA_CONFIG_DIR="/etc/sfa" # Directory internal data gets stored SFA_DATA_DIR="/var/lib/sfa" - diff --git a/sfa/client/sfaadmin.py b/sfa/client/sfaadmin.py index 2ef48099..95e139f7 100755 --- a/sfa/client/sfaadmin.py +++ b/sfa/client/sfaadmin.py @@ -504,18 +504,13 @@ class AggregateCommands(Commands): self.api.manager.Delete(self.api, [xrn], [], {}) -class SliceManagerCommands(AggregateCommands): - - def __init__(self, *args, **kwds): - self.api = Generic.the_flavour().make_api(interface='slicemgr') - - class SfaAdmin: - CATEGORIES = {'certificate': CertCommands, - 'registry': RegistryCommands, - 'aggregate': AggregateCommands, - 'slicemgr': SliceManagerCommands} + CATEGORIES = { + 'certificate': CertCommands, + 'registry': RegistryCommands, + 'aggregate': AggregateCommands, + } # returns (name,class) or (None,None) def find_category(self, input): diff --git a/sfa/client/sfascan.py b/sfa/client/sfascan.py index ce9717c3..8869ae59 100644 --- a/sfa/client/sfascan.py +++ b/sfa/client/sfascan.py @@ -224,9 +224,9 @@ class Interface: # default is for when we can't determine the type of the service # typically the server is down, or we can't authenticate, or it's too old # code - shapes = {"registry": "diamond", "slicemgr": "ellipse", + shapes = {"registry": "diamond", "aggregate": "box", 'default': 'plaintext'} - abbrevs = {"registry": "REG", "slicemgr": "SA", + abbrevs = {"registry": "REG", "aggregate": "AM", 'default': '[unknown interface]'} # return a dictionary that translates into the node's attr @@ -265,8 +265,8 @@ class Interface: shape = Interface.shapes['default'] layout['shape'] = shape # fill color to outline wrongly configured or unreachable bodies - # as of sfa-2.0 registry doesn't have 'sfa' not 'geni_api', but have peers - # slicemgr and aggregate have 'geni_api' and 'sfa' + # as of sfa-2.0 registry doesn't have 'sfa' not 'geni_api', + # but have peer aggregates have 'geni_api' and 'sfa' if 'geni_api' not in version and 'peers' not in version: layout['style'] = 'filled' layout['fillcolor'] = 'gray' diff --git a/sfa/generic/__init__.py b/sfa/generic/__init__.py index 2f7137f7..1a2778d0 100644 --- a/sfa/generic/__init__.py +++ b/sfa/generic/__init__.py @@ -6,7 +6,7 @@ from sfa.managers.managerwrapper import ManagerWrapper # a bundle is the combination of # (*) an api that reacts on the incoming requests to trigger the API methods # (*) a manager that implements the function of the service, -# either aggregate, registry, or slicemgr +# either aggregate or registry # (*) a driver that controls the underlying testbed # # @@ -58,8 +58,6 @@ class Generic: def registry_class(self): pass - def slicemgr_class(self): pass - def aggregate_class(self): pass def component_class(self): pass @@ -86,7 +84,7 @@ class Generic: def make_manager(self, interface): """ - interface expected in ['registry', 'aggregate', 'slicemgr', 'component'] + interface expected in ['registry', 'aggregate', 'component'] flavour is e.g. 'pl' or 'max' or whatever """ flavour = self.flavour diff --git a/sfa/generic/architecture.txt b/sfa/generic/architecture.txt index fe793bff..66ac3c37 100644 --- a/sfa/generic/architecture.txt +++ b/sfa/generic/architecture.txt @@ -3,7 +3,7 @@ We identify 3 layers in the server-side aspects: . api: this object reacts to an incoming SFA request . manager: this implements a given interface, either registry, -aggregate, or slicemgr +or aggregate . driver: this object is in charge of actually talking to the underlying testbed @@ -19,7 +19,7 @@ configurable in a flavour (e.g. sfa.generic.pl.py) * a call to make_api will then create the 3 elements with the following layout: -api.manager +api.manager api.driver driver.api @@ -36,5 +36,3 @@ with the arguments passed as arguments to the constructor ------ more in sfa/generic/__init__.py - - diff --git a/sfa/generic/dummy.py b/sfa/generic/dummy.py index 1d5a3f28..82f40ea9 100644 --- a/sfa/generic/dummy.py +++ b/sfa/generic/dummy.py @@ -18,10 +18,6 @@ class dummy (Generic): import sfa.managers.registry_manager return sfa.managers.registry_manager.RegistryManager - def slicemgr_manager_class(self): - import sfa.managers.slice_manager - return sfa.managers.slice_manager.SliceManager - def aggregate_manager_class(self): import sfa.managers.aggregate_manager return sfa.managers.aggregate_manager.AggregateManager diff --git a/sfa/generic/iotlab.py b/sfa/generic/iotlab.py index 818e01ef..e9422b67 100644 --- a/sfa/generic/iotlab.py +++ b/sfa/generic/iotlab.py @@ -19,10 +19,6 @@ class iotlab (Generic): import sfa.managers.registry_manager return sfa.managers.registry_manager.RegistryManager - def slicemgr_manager_class(self): - import sfa.managers.slice_manager - return sfa.managers.slice_manager.SliceManager - def aggregate_manager_class(self): import sfa.managers.aggregate_manager return sfa.managers.aggregate_manager.AggregateManager diff --git a/sfa/generic/pl.py b/sfa/generic/pl.py index cbeabd11..0e7fba95 100644 --- a/sfa/generic/pl.py +++ b/sfa/generic/pl.py @@ -18,10 +18,6 @@ class pl (Generic): import sfa.managers.registry_manager return sfa.managers.registry_manager.RegistryManager - def slicemgr_manager_class(self): - import sfa.managers.slice_manager - return sfa.managers.slice_manager.SliceManager - def aggregate_manager_class(self): import sfa.managers.aggregate_manager return sfa.managers.aggregate_manager.AggregateManager diff --git a/sfa/generic/teagle.py b/sfa/generic/teagle.py index a4ec66ad..0612e7c1 100644 --- a/sfa/generic/teagle.py +++ b/sfa/generic/teagle.py @@ -18,10 +18,6 @@ class teagle (Generic): import sfa.managers.registry_manager return sfa.managers.registry_manager.RegistryManager - def slicemgr_manager_class(self): - import sfa.managers.slice_manager - return sfa.managers.slice_manager.SliceManager - def aggregate_manager_class(self): import sfa.managers.aggregate_manager return sfa.managers.aggregate_manager.AggregateManager diff --git a/sfa/generic/void.py b/sfa/generic/void.py index bbd5deaf..0033f42b 100644 --- a/sfa/generic/void.py +++ b/sfa/generic/void.py @@ -23,12 +23,6 @@ class void (Generic): import sfa.managers.registry_manager return sfa.managers.registry_manager.RegistryManager - def slicemgr_manager_class(self): - import sfa.managers.slice_manager - return sfa.managers.slice_manager.SliceManager - # most likely you'll want to turn OFF the aggregate in sfa-config-tty - # SFA_AGGREGATE_ENABLED=false - def aggregate_manager_class(self): import sfa.managers.aggregate_manager return sfa.managers.aggregate_manager.AggregateManager diff --git a/sfa/importer/__init__.py b/sfa/importer/__init__.py index 46a69f10..babfc04f 100644 --- a/sfa/importer/__init__.py +++ b/sfa/importer/__init__.py @@ -74,27 +74,6 @@ class Importer: self.logger.info( "SfaImporter: imported authority (parent) %s " % auth_record) - def create_sm_client_record(self): - """ - Create a user record for the Slicemanager service. - """ - hrn = self.interface_hrn + '.slicemanager' # pylint: disable=e1101 - urn = hrn_to_urn(hrn, 'user') - if not self.auth_hierarchy.auth_exists(urn): - self.logger.info("SfaImporter: creating Slice Manager user") - self.auth_hierarchy.create_auth(urn) - - if self.record_exists('user', hrn): - return - auth_info = self.auth_hierarchy.get_auth_info(hrn) - user_record = RegUser(hrn=hrn, gid=auth_info.get_gid_object(), - authority=get_authority(hrn)) - user_record.just_created() - global_dbsession.add(user_record) - global_dbsession.commit() - self.logger.info( - "SfaImporter: importing user (slicemanager) %s " % user_record) - def create_interface_records(self): """ Create a record for each SFA interface diff --git a/sfa/managers/slice_manager.py b/sfa/managers/slice_manager.py deleted file mode 100644 index a6af10b3..00000000 --- a/sfa/managers/slice_manager.py +++ /dev/null @@ -1,591 +0,0 @@ -# pylint: disable=c0111, c0103 - -import sys -import time -import traceback -from copy import copy - -from sfa.trust.credential import Credential - -from sfa.util.sfalogging import logger -from sfa.util.xrn import Xrn, urn_to_hrn -from sfa.util.version import version_core -from sfa.util.callids import Callids -from sfa.util.cache import Cache - -from sfa.client.multiclient import MultiClient - -from sfa.rspecs.version_manager import VersionManager -from sfa.rspecs.rspec import RSpec - -from sfa.client.return_value import ReturnValue - - -class SliceManager: - - # the cache instance is a class member so it survives across incoming - # requests - cache = None - - def __init__(self, config): - self.cache = None - if config.SFA_SM_CACHING: - if SliceManager.cache is None: - SliceManager.cache = Cache() - self.cache = SliceManager.cache - - def GetVersion(self, api, options): - # peers explicitly in aggregates.xml - peers = {peername: interface.get_url() - for (peername, interface) in api.aggregates.iteritems() - if peername != api.hrn} - version_manager = VersionManager() - ad_rspec_versions = [] - request_rspec_versions = [] - cred_types = [{'geni_type': 'geni_sfa', - 'geni_version': str(i)} for i in range(4)[-2:]] - for rspec_version in version_manager.versions: - if rspec_version.content_type in ['*', 'ad']: - ad_rspec_versions.append(rspec_version.to_dict()) - if rspec_version.content_type in ['*', 'request']: - request_rspec_versions.append(rspec_version.to_dict()) - xrn = Xrn(api.hrn, 'authority+sm') - version_more = { - 'interface': 'slicemgr', - 'sfa': 2, - 'geni_api': 3, - 'geni_api_versions': - {'3': 'https://%s:%s' - % (api.config.SFA_SM_HOST, api.config.SFA_SM_PORT)}, - 'hrn': xrn.get_hrn(), - 'urn': xrn.get_urn(), - 'peers': peers, - # Accept operations that act on as subset of slivers in a given - # state. - 'geni_single_allocation': 0, - # Multiple slivers can exist and be incrementally added, including - # those which connect or overlap in some way. - 'geni_allocate': 'geni_many', - 'geni_credential_types': cred_types, - } - sm_version = version_core(version_more) - # local aggregate if present needs to have localhost resolved - if api.hrn in api.aggregates: - local_am_url = api.aggregates[api.hrn].get_url() - sm_version['peers'][api.hrn] = local_am_url.replace( - 'localhost', sm_version['hostname']) - return sm_version - - def drop_slicemgr_stats(self, rspec): - try: - stats_elements = rspec.xml.xpath('//statistics') - for node in stats_elements: - node.getparent().remove(node) - except Exception as e: - logger.warning("drop_slicemgr_stats failed: %s " % (str(e))) - - def add_slicemgr_stat(self, rspec, callname, aggname, - elapsed, status, exc_info=None): - try: - stats_tags = rspec.xml.xpath('//statistics[@call="%s"]' % callname) - if stats_tags: - stats_tag = stats_tags[0] - else: - stats_tag = rspec.xml.root.add_element( - "statistics", call=callname) - - stat_tag = stats_tag.add_element( - "aggregate", name=str(aggname), - elapsed=str(elapsed), status=str(status)) - - if exc_info: - exc_tag = stat_tag.add_element( - "exc_info", name=str(exc_info[1])) - - # formats the traceback as a set of xml elements - tb = traceback.extract_tb(exc_info[2]) - for item in tb: - exc_frame = exc_tag.add_element( - "tb_frame", filename=str(item[0]), - line=str(item[1]), func=str(item[2]), code=str(item[3])) - - except Exception as e: - logger.warning("add_slicemgr_stat failed on %s: %s" % - (aggname, str(e))) - - def ListResources(self, api, creds, options): - call_id = options.get('call_id') - if Callids().already_handled(call_id): - return "" - - version_manager = VersionManager() - - def _ListResources(aggregate, server, credential, options): - forward_options = copy(options) - tStart = time.time() - try: - version = api.get_cached_server_version(server) - # force ProtoGENI aggregates to give us a v2 RSpec - forward_options['geni_rspec_version'] = options.get( - 'geni_rspec_version') - result = server.ListResources(credential, forward_options) - return {"aggregate": aggregate, "result": result, - "elapsed": time.time() - tStart, "status": "success"} - except Exception as e: - logger.log_exc("ListResources failed at %s" % (server.url)) - return {"aggregate": aggregate, "elapsed": time.time() - tStart, - "status": "exception", "exc_info": sys.exc_info()} - - # get slice's hrn from options - xrn = options.get('geni_slice_urn', '') - (hrn, type) = urn_to_hrn(xrn) - if 'geni_compressed' in options: - del(options['geni_compressed']) - - # get the rspec's return format from options - rspec_version = version_manager.get_version( - options.get('geni_rspec_version')) - version_string = "rspec_%s" % (rspec_version) - - # look in cache first - cached_requested = options.get('cached', True) - if not xrn and self.cache and cached_requested: - rspec = self.cache.get(version_string) - if rspec: - logger.debug( - "SliceManager.ListResources returns cached advertisement") - return rspec - - # get the callers hrn - valid_cred = api.auth.checkCredentials(creds, 'listnodes', hrn)[0] - caller_hrn = Credential(cred=valid_cred).get_gid_caller().get_hrn() - - # attempt to use delegated credential first - cred = api.getDelegatedCredential(creds) - if not cred: - cred = api.getCredential() - multiclient = MultiClient() - for aggregate in api.aggregates: - # prevent infinite loop. Dont send request back to caller - # unless the caller is the aggregate's SM - if caller_hrn == aggregate and aggregate != api.hrn: - continue - - # get the rspec from the aggregate - interface = api.aggregates[aggregate] - server = api.server_proxy(interface, cred) - multiclient.run(_ListResources, aggregate, server, [cred], options) - - results = multiclient.get_results() - rspec_version = version_manager.get_version( - options.get('geni_rspec_version')) - if xrn: - result_version = version_manager._get_version( - rspec_version.type, rspec_version.version, 'manifest') - else: - result_version = version_manager._get_version( - rspec_version.type, rspec_version.version, 'ad') - rspec = RSpec(version=result_version) - for result in results: - self.add_slicemgr_stat( - rspec, "ListResources", result["aggregate"], result["elapsed"], - result["status"], result.get("exc_info", None)) - if result["status"] == "success": - res = result['result']['value'] - try: - rspec.version.merge(ReturnValue.get_value(res)) - except Exception: - logger.log_exc( - "SM.ListResources: Failed to merge aggregate rspec") - - # cache the result - if self.cache and not xrn: - logger.debug("SliceManager.ListResources caches advertisement") - self.cache.add(version_string, rspec.toxml()) - - return rspec.toxml() - - def Allocate(self, api, xrn, creds, rspec_str, expiration, options): - call_id = options.get('call_id') - if Callids().already_handled(call_id): - return "" - - version_manager = VersionManager() - - def _Allocate(aggregate, server, xrn, credential, rspec, options): - tStart = time.time() - try: - # Need to call GetVersion at an aggregate to determine the supported - # rspec type/format beofre calling CreateSliver at an Aggregate. - #server_version = api.get_cached_server_version(server) - # if 'sfa' not in server_version and 'geni_api' in server_version: - # sfa aggregtes support both sfa and pg rspecs, no need to convert - # if aggregate supports sfa rspecs. otherwise convert to pg rspec - #rspec = RSpec(RSpecConverter.to_pg_rspec(rspec, 'request')) - #filter = {'component_manager_id': server_version['urn']} - # rspec.filter(filter) - #rspec = rspec.toxml() - result = server.Allocate(xrn, credential, rspec, options) - return {"aggregate": aggregate, "result": result, - "elapsed": time.time() - tStart, "status": "success"} - except: - logger.log_exc( - 'Something wrong in _Allocate with URL %s' % server.url) - return {"aggregate": aggregate, "elapsed": time.time() - tStart, - "status": "exception", "exc_info": sys.exc_info()} - - # Validate the RSpec against PlanetLab's schema --disabled for now - # The schema used here needs to aggregate the PL and VINI schemas - # schema = "/var/www/html/schemas/pl.rng" - rspec = RSpec(rspec_str) - # schema = None - # if schema: - # rspec.validate(schema) - - # if there is a section, the aggregates don't care about it, - # so delete it. - self.drop_slicemgr_stats(rspec) - - # attempt to use delegated credential first - cred = api.getDelegatedCredential(creds) - if not cred: - cred = api.getCredential() - - # get the callers hrn - hrn, type = urn_to_hrn(xrn) - valid_cred = api.auth.checkCredentials(creds, 'createsliver', hrn)[0] - caller_hrn = Credential(cred=valid_cred).get_gid_caller().get_hrn() - multiclient = MultiClient() - for aggregate in api.aggregates: - # prevent infinite loop. Dont send request back to caller - # unless the caller is the aggregate's SM - if caller_hrn == aggregate and aggregate != api.hrn: - continue - interface = api.aggregates[aggregate] - server = api.server_proxy(interface, cred) - # Just send entire RSpec to each aggregate - multiclient.run(_Allocate, aggregate, server, xrn, - [cred], rspec.toxml(), options) - - results = multiclient.get_results() - manifest_version = version_manager._get_version( - rspec.version.type, rspec.version.version, 'manifest') - result_rspec = RSpec(version=manifest_version) - geni_urn = None - geni_slivers = [] - - for result in results: - self.add_slicemgr_stat( - result_rspec, "Allocate", result["aggregate"], result["elapsed"], - result["status"], result.get("exc_info", None)) - if result["status"] == "success": - try: - res = result['result']['value'] - geni_urn = res['geni_urn'] - result_rspec.version.merge( - ReturnValue.get_value(res['geni_rspec'])) - geni_slivers.extend(res['geni_slivers']) - except Exception: - logger.log_exc( - "SM.Allocate: Failed to merge aggregate rspec") - return { - 'geni_urn': geni_urn, - 'geni_rspec': result_rspec.toxml(), - 'geni_slivers': geni_slivers - } - - def Provision(self, api, xrn, creds, options): - call_id = options.get('call_id') - if Callids().already_handled(call_id): - return "" - - version_manager = VersionManager() - - def _Provision(aggregate, server, xrn, credential, options): - tStart = time.time() - try: - # Need to call GetVersion at an aggregate to determine the supported - # rspec type/format before calling CreateSliver at an - # Aggregate. - server_version = api.get_cached_server_version(server) - result = server.Provision(xrn, credential, options) - return {"aggregate": aggregate, "result": result, - "elapsed": time.time() - tStart, "status": "success"} - except Exception: - logger.log_exc( - 'Something wrong in _Allocate with URL %s' % server.url) - return {"aggregate": aggregate, "elapsed": time.time() - tStart, - "status": "exception", "exc_info": sys.exc_info()} - - # attempt to use delegated credential first - cred = api.getDelegatedCredential(creds) - if not cred: - cred = api.getCredential() - - # get the callers hrn - valid_cred = api.auth.checkCredentials(creds, 'createsliver', xrn)[0] - caller_hrn = Credential(cred=valid_cred).get_gid_caller().get_hrn() - multiclient = MultiClient() - for aggregate in api.aggregates: - # prevent infinite loop. Dont send request back to caller - # unless the caller is the aggregate's SM - if caller_hrn == aggregate and aggregate != api.hrn: - continue - interface = api.aggregates[aggregate] - server = api.server_proxy(interface, cred) - # Just send entire RSpec to each aggregate - multiclient.run(_Provision, aggregate, - server, xrn, [cred], options) - - results = multiclient.get_results() - manifest_version = version_manager._get_version( - 'GENI', '3', 'manifest') - result_rspec = RSpec(version=manifest_version) - geni_slivers = [] - geni_urn = None - for result in results: - self.add_slicemgr_stat( - result_rspec, "Provision", result["aggregate"], result["elapsed"], - result["status"], result.get("exc_info", None)) - if result["status"] == "success": - try: - res = result['result']['value'] - geni_urn = res['geni_urn'] - result_rspec.version.merge( - ReturnValue.get_value(res['geni_rspec'])) - geni_slivers.extend(res['geni_slivers']) - except: - logger.log_exc( - "SM.Provision: Failed to merge aggregate rspec") - return { - 'geni_urn': geni_urn, - 'geni_rspec': result_rspec.toxml(), - 'geni_slivers': geni_slivers - } - - def Renew(self, api, xrn, creds, expiration_time, options): - call_id = options.get('call_id') - if Callids().already_handled(call_id): - return True - - def _Renew(aggregate, server, xrn, creds, expiration_time, options): - try: - result = server.Renew(xrn, creds, expiration_time, options) - if type(result) != dict: - result = {'code': {'geni_code': 0}, 'value': result} - result['aggregate'] = aggregate - return result - except: - logger.log_exc( - 'Something wrong in _Renew with URL %s' % server.url) - return {'aggregate': aggregate, 'exc_info': traceback.format_exc(), - 'code': {'geni_code': -1}, - 'value': False, 'output': ""} - - # get the callers hrn - valid_cred = api.auth.checkCredentials(creds, 'renewsliver', xrn)[0] - caller_hrn = Credential(cred=valid_cred).get_gid_caller().get_hrn() - - # attempt to use delegated credential first - cred = api.getDelegatedCredential(creds) - if not cred: - cred = api.getCredential(minimumExpiration=31 * 86400) - multiclient = MultiClient() - for aggregate in api.aggregates: - # prevent infinite loop. Dont send request back to caller - # unless the caller is the aggregate's SM - if caller_hrn == aggregate and aggregate != api.hrn: - continue - interface = api.aggregates[aggregate] - server = api.server_proxy(interface, cred) - multiclient.run(_Renew, aggregate, server, xrn, - [cred], expiration_time, options) - - results = multiclient.get_results() - - geni_code = 0 - geni_output = ",".join([x.get('output', "") for x in results]) - geni_value = reduce(lambda x, y: x and y, - [result.get('value', False) for result in results], - True) - for agg_result in results: - agg_geni_code = agg_result['code'].get('geni_code', 0) - if agg_geni_code: - geni_code = agg_geni_code - - results = {'aggregates': results, 'code': { - 'geni_code': geni_code}, 'value': geni_value, 'output': geni_output} - - return results - - def Delete(self, api, xrn, creds, options): - call_id = options.get('call_id') - if Callids().already_handled(call_id): - return "" - - def _Delete(server, xrn, creds, options): - return server.Delete(xrn, creds, options) - - (hrn, type) = urn_to_hrn(xrn[0]) - # get the callers hrn - valid_cred = api.auth.checkCredentials(creds, 'deletesliver', hrn)[0] - caller_hrn = Credential(cred=valid_cred).get_gid_caller().get_hrn() - - # attempt to use delegated credential first - cred = api.getDelegatedCredential(creds) - if not cred: - cred = api.getCredential() - multiclient = MultiClient() - for aggregate in api.aggregates: - # prevent infinite loop. Dont send request back to caller - # unless the caller is the aggregate's SM - if caller_hrn == aggregate and aggregate != api.hrn: - continue - interface = api.aggregates[aggregate] - server = api.server_proxy(interface, cred) - multiclient.run(_Delete, server, xrn, [cred], options) - - results = [] - for result in multiclient.get_results(): - results += ReturnValue.get_value(result) - return results - - # first draft at a merging SliverStatus - def Status(self, api, slice_xrn, creds, options): - def _Status(server, xrn, creds, options): - return server.Status(xrn, creds, options) - - call_id = options.get('call_id') - if Callids().already_handled(call_id): - return {} - # attempt to use delegated credential first - cred = api.getDelegatedCredential(creds) - if not cred: - cred = api.getCredential() - multiclient = MultiClient() - for aggregate in api.aggregates: - interface = api.aggregates[aggregate] - server = api.server_proxy(interface, cred) - multiclient.run(_Status, server, slice_xrn, [cred], options) - results = [ReturnValue.get_value(result) - for result in multiclient.get_results()] - - # get rid of any void result - e.g. when call_id was hit, where by - # convention we return {} - results = [ - result for result in results if result and result['geni_slivers']] - - # do not try to combine if there's no result - if not results: - return {} - - # otherwise let's merge stuff - geni_slivers = [] - geni_urn = None - for result in results: - try: - geni_urn = result['geni_urn'] - geni_slivers.extend(result['geni_slivers']) - except Exception: - logger.log_exc( - "SM.Provision: Failed to merge aggregate rspec") - return { - 'geni_urn': geni_urn, - 'geni_slivers': geni_slivers - } - - def Describe(self, api, creds, xrns, options): - def _Describe(server, xrn, creds, options): - return server.Describe(xrn, creds, options) - - call_id = options.get('call_id') - if Callids().already_handled(call_id): - return {} - # attempt to use delegated credential first - cred = api.getDelegatedCredential(creds) - if not cred: - cred = api.getCredential() - multiclient = MultiClient() - for aggregate in api.aggregates: - interface = api.aggregates[aggregate] - server = api.server_proxy(interface, cred) - multiclient.run(_Describe, server, xrns, [cred], options) - results = [ReturnValue.get_value(result) - for result in multiclient.get_results()] - - # get rid of any void result - e.g. when call_id was hit, where by - # convention we return {} - results = [ - result for result in results if result and result.get('geni_urn')] - - # do not try to combine if there's no result - if not results: - return {} - - # otherwise let's merge stuff - version_manager = VersionManager() - manifest_version = version_manager._get_version( - 'GENI', '3', 'manifest') - result_rspec = RSpec(version=manifest_version) - geni_slivers = [] - geni_urn = None - for result in results: - try: - geni_urn = result['geni_urn'] - result_rspec.version.merge( - ReturnValue.get_value(result['geni_rspec'])) - geni_slivers.extend(result['geni_slivers']) - except Exception: - logger.log_exc( - "SM.Provision: Failed to merge aggregate rspec") - return { - 'geni_urn': geni_urn, - 'geni_rspec': result_rspec.toxml(), - 'geni_slivers': geni_slivers - } - - def PerformOperationalAction(self, api, xrn, creds, action, options): - # get the callers hrn - valid_cred = api.auth.checkCredentials(creds, 'createsliver', xrn)[0] - caller_hrn = Credential(cred=valid_cred).get_gid_caller().get_hrn() - - # attempt to use delegated credential first - cred = api.getDelegatedCredential(creds) - if not cred: - cred = api.getCredential() - multiclient = MultiClient() - for aggregate in api.aggregates: - # prevent infinite loop. Dont send request back to caller - # unless the caller is the aggregate's SM - if caller_hrn == aggregate and aggregate != api.hrn: - continue - interface = api.aggregates[aggregate] - server = api.server_proxy(interface, cred) - multiclient.run(server.PerformOperationalAction, - xrn, [cred], action, options) - multiclient.get_results() - return 1 - - def Shutdown(self, api, xrn, creds, options=None): - if options is None: - options = {} - xrn = Xrn(xrn) - # get the callers hrn - valid_cred = api.auth.checkCredentials(creds, 'stopslice', xrn.hrn)[0] - caller_hrn = Credential(cred=valid_cred).get_gid_caller().get_hrn() - - # attempt to use delegated credential first - cred = api.getDelegatedCredential(creds) - if not cred: - cred = api.getCredential() - multiclient = MultiClient() - for aggregate in api.aggregates: - # prevent infinite loop. Dont send request back to caller - # unless the caller is the aggregate's SM - if caller_hrn == aggregate and aggregate != api.hrn: - continue - interface = api.aggregates[aggregate] - server = api.server_proxy(interface, cred) - multiclient.run(server.Shutdown, xrn.urn, cred) - multiclient.get_results() - return 1 diff --git a/sfa/methods/Allocate.py b/sfa/methods/Allocate.py index cd3d889d..fb5771a4 100644 --- a/sfa/methods/Allocate.py +++ b/sfa/methods/Allocate.py @@ -45,7 +45,7 @@ class Allocate(Method): See also http://svn.planet-lab.org/wiki/SFASliceTags """ - interfaces = ['aggregate', 'slicemgr'] + interfaces = ['aggregate'] accepts = [ Parameter(str, "Slice URN"), Parameter(type([dict]), "List of credentials"), @@ -78,8 +78,6 @@ class Allocate(Method): # flter rspec through sfatables if self.api.interface in ['aggregate']: chain_name = 'INCOMING' - elif self.api.interface in ['slicemgr']: - chain_name = 'FORWARD-INCOMING' logger.debug("Allocate: sfatables on chain %s" % chain_name) actual_caller_hrn = the_credential.actual_caller_hrn() logger.info("interface: %s\tcaller-hrn: %s\ttarget-hrn: %s\tmethod-name: %s" % diff --git a/sfa/methods/Delete.py b/sfa/methods/Delete.py index 74442ce4..5c913ed7 100644 --- a/sfa/methods/Delete.py +++ b/sfa/methods/Delete.py @@ -16,7 +16,7 @@ class Delete(Method): @return 1 is successful, faults otherwise """ - interfaces = ['aggregate', 'slicemgr', 'component'] + interfaces = ['aggregate', 'component'] accepts = [ Parameter( diff --git a/sfa/methods/Describe.py b/sfa/methods/Describe.py index b04b3a6e..44ccf6bf 100644 --- a/sfa/methods/Describe.py +++ b/sfa/methods/Describe.py @@ -21,7 +21,7 @@ class Describe(Method): @param options dictionary @return dict """ - interfaces = ['aggregate', 'slicemgr'] + interfaces = ['aggregate'] accepts = [ Parameter(type([str]), "List of URNs"), Mixed(Parameter(str, "Credential string"), @@ -56,8 +56,6 @@ class Describe(Method): # filter rspec through sfatables if self.api.interface in ['aggregate']: chain_name = 'OUTGOING' - elif self.api.interface in ['slicemgr']: - chain_name = 'FORWARD-OUTGOING' logger.debug( "ListResources: sfatables on chain %s" % chain_name) desc['geni_rspec'] = run_sfatables( diff --git a/sfa/methods/GetVersion.py b/sfa/methods/GetVersion.py index 01136ccf..4da1e97d 100644 --- a/sfa/methods/GetVersion.py +++ b/sfa/methods/GetVersion.py @@ -9,7 +9,7 @@ class GetVersion(Method): Returns this GENI Aggregate Manager's Version Information @return version """ - interfaces = ['registry', 'aggregate', 'slicemgr', 'component'] + interfaces = ['registry', 'aggregate', 'component'] accepts = [ Parameter(dict, "Options") ] diff --git a/sfa/methods/ListResources.py b/sfa/methods/ListResources.py index 2ae119a7..f719a801 100644 --- a/sfa/methods/ListResources.py +++ b/sfa/methods/ListResources.py @@ -18,7 +18,7 @@ class ListResources(Method): @param options dictionary @return string """ - interfaces = ['aggregate', 'slicemgr'] + interfaces = ['aggregate'] accepts = [ Mixed(Parameter(str, "Credential string"), Parameter(type([str]), "List of credentials")), @@ -52,8 +52,6 @@ class ListResources(Method): # filter rspec through sfatables if self.api.interface in ['aggregate']: chain_name = 'OUTGOING' - elif self.api.interface in ['slicemgr']: - chain_name = 'FORWARD-OUTGOING' logger.debug( "ListResources: sfatables on chain %s" % chain_name) filtered_rspec = run_sfatables(chain_name, '', origin_hrn, rspec) diff --git a/sfa/methods/PerformOperationalAction.py b/sfa/methods/PerformOperationalAction.py index 57d8db91..0d33b0c3 100644 --- a/sfa/methods/PerformOperationalAction.py +++ b/sfa/methods/PerformOperationalAction.py @@ -23,7 +23,7 @@ class PerformOperationalAction(Method): @param options (dict) options """ - interfaces = ['aggregate', 'slicemgr'] + interfaces = ['aggregate'] accepts = [ Parameter(type([str]), "URNs"), Parameter(type([dict]), "Credentials"), diff --git a/sfa/methods/Provision.py b/sfa/methods/Provision.py index f9f71e41..6652a139 100644 --- a/sfa/methods/Provision.py +++ b/sfa/methods/Provision.py @@ -25,7 +25,7 @@ class Provision(Method): @param options (dict) options """ - interfaces = ['aggregate', 'slicemgr'] + interfaces = ['aggregate'] accepts = [ Parameter(type([str]), "URNs"), Parameter(type([dict]), "Credentials"), diff --git a/sfa/methods/Renew.py b/sfa/methods/Renew.py index 3cbb9293..48f1a44a 100644 --- a/sfa/methods/Renew.py +++ b/sfa/methods/Renew.py @@ -21,7 +21,7 @@ class Renew(Method): @param expiration_time (string) requested time of expiration @param options (dict) options """ - interfaces = ['aggregate', 'slicemgr'] + interfaces = ['aggregate'] accepts = [ Parameter(type([str]), "Slice URN"), Parameter(type([str]), "List of credentials"), diff --git a/sfa/methods/Shutdown.py b/sfa/methods/Shutdown.py index a1acf9a8..c4452151 100644 --- a/sfa/methods/Shutdown.py +++ b/sfa/methods/Shutdown.py @@ -12,7 +12,7 @@ class Shutdown(Method): @param slice_urn (string) URN of slice to renew @param credentials ([string]) of credentials """ - interfaces = ['aggregate', 'slicemgr'] + interfaces = ['aggregate'] accepts = [ Parameter(str, "Slice URN"), Parameter(type([dict]), "Credentials"), diff --git a/sfa/methods/Status.py b/sfa/methods/Status.py index 577d1b7d..98aa321e 100644 --- a/sfa/methods/Status.py +++ b/sfa/methods/Status.py @@ -12,7 +12,7 @@ class Status(Method): @param slice_urn (string) URN of slice to allocate to """ - interfaces = ['aggregate', 'slicemgr', 'component'] + interfaces = ['aggregate', 'component'] accepts = [ Parameter(type([str]), "Slice or sliver URNs"), Parameter(type([dict]), "credentials"), diff --git a/sfa/methods/get_trusted_certs.py b/sfa/methods/get_trusted_certs.py index 3cfc51d7..1b26d468 100644 --- a/sfa/methods/get_trusted_certs.py +++ b/sfa/methods/get_trusted_certs.py @@ -13,7 +13,7 @@ class get_trusted_certs(Method): @return list of gid strings """ - interfaces = ['registry', 'aggregate', 'slicemgr'] + interfaces = ['registry', 'aggregate'] accepts = [ Mixed(Parameter(str, "Credential string"), diff --git a/sfa/server/sfa-start.py b/sfa/server/sfa-start.py index 5b386c02..bd412857 100755 --- a/sfa/server/sfa-start.py +++ b/sfa/server/sfa-start.py @@ -186,8 +186,6 @@ def main(): parser = OptionParser(usage="sfa-start.py [options]") parser.add_option("-r", "--registry", dest="registry", action="store_true", help="run registry server", default=False) - parser.add_option("-s", "--slicemgr", dest="sm", action="store_true", - help="run slice manager", default=False) parser.add_option("-a", "--aggregate", dest="am", action="store_true", help="run aggregate manager", default=False) parser.add_option("-c", "--component", dest="cm", action="store_true", @@ -231,12 +229,6 @@ def main(): server_key_file, server_cert_file) a.start() - # start slice manager - if (options.sm): - from sfa.server.slicemgr import SliceMgr - s = SliceMgr("", config.SFA_SM_PORT, server_key_file, server_cert_file) - s.start() - if (options.cm): from sfa.server.component import Component c = Component("", config.component_port, diff --git a/sfa/server/sfaapi.py b/sfa/server/sfaapi.py index 231fdeb2..71aadfa7 100644 --- a/sfa/server/sfaapi.py +++ b/sfa/server/sfaapi.py @@ -28,7 +28,7 @@ class SfaApi(XmlrpcApi): augmented with the local cryptographic material and hrn It also has the notion of its own interface (a string describing - whether we run a registry, aggregate or slicemgr) and has + whether we run a registry, or aggregate) and has the notion of neighbour sfa services as defined in /etc/sfa/{aggregates,registries}.xml @@ -266,6 +266,6 @@ class SfaApi(XmlrpcApi): response """ # as of dec 13 2011 we only support API v2 - if self.interface.lower() in ['aggregate', 'slicemgr']: + if self.interface.lower() in ['aggregate']: result = self.prepare_response_am(result) return XmlrpcApi.prepare_response(self, result, method) diff --git a/sfa/server/slicemgr.py b/sfa/server/slicemgr.py deleted file mode 100644 index 280c2a06..00000000 --- a/sfa/server/slicemgr.py +++ /dev/null @@ -1,19 +0,0 @@ -import os -import sys -import datetime -import time -from sfa.server.sfaserver import SfaServer - - -class SliceMgr(SfaServer): - - ## - # Create a new slice manager 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, config="/etc/sfa/sfa_config"): - SfaServer.__init__(self, ip, port, key_file, cert_file, 'slicemgr') diff --git a/tests/testInterfaces.py b/tests/testInterfaces.py index a51799b8..3eddf77b 100755 --- a/tests/testInterfaces.py +++ b/tests/testInterfaces.py @@ -26,7 +26,7 @@ class Client: key = None cert = None credential = None - type = None + type = None def __init__(self, options): try: self.config = config = Config(options.config_file) except: @@ -41,7 +41,7 @@ class Client: self.cert.set_pubkey(self.key) self.cert.set_issuer(self.key, self.config.SFI_USER) self.cert.sign() - self.cert.save_to_file(cert_file) + self.cert.save_to_file(cert_file) SFI_AGGREGATE = config.SFI_SM.replace('12347', '12346') SFI_CM = 'http://' + options.cm_host + ':12346' self.registry = SfaServerProxy(config.SFI_REGISTRY, key_file, cert_file) @@ -53,9 +53,9 @@ class Client: # test from components persepctive self.type = 'user' self.credential = self.GetCredential(self.hrn) - + def GetCredential(self, hrn = None, type = 'user'): - if not hrn: hrn = self.hrn + if not hrn: hrn = self.hrn if hrn == self.hrn: cert = self.cert.save_to_string(save_parents=True) request_hash = self.key.compute_hash([cert, 'user', hrn]) @@ -64,14 +64,14 @@ class Client: else: if not self.credential: self.credential = self.GetCredential(self.hrn, 'user') - return self.registry.GetCredential(self.credential, type, hrn) + return self.registry.GetCredential(self.credential, type, hrn) class BasicTestCase(unittest.TestCase): def __init__(self, testname, client, test_slice=None): unittest.TestCase.__init__(self, testname) self.client = client self.slice = test_slice - + def setUp(self): self.registry = self.client.registry self.aggregate = self.client.aggregate @@ -79,8 +79,8 @@ class BasicTestCase(unittest.TestCase): self.cm = self.client.cm self.credential = self.client.credential self.hrn = self.client.hrn - self.type = self.client.type - + self.type = self.client.type + # Registry tests class RegistryTest(BasicTestCase): @@ -122,22 +122,22 @@ class RegistryTest(BasicTestCase): try: self.registry.Remove(auth_cred, record['type'], record['hrn']) except: pass - + def testRegisterPeerObject(self): assert True - + def testUpdate(self): authority = get_authority(self.hrn) auth_cred = self.client.GetCredential(authority, 'authority') records = self.registry.Resolve(self.credential, self.hrn) if not records: assert False record = records[0] - self.registry.update(auth_cred, record) + self.registry.update(auth_cred, record) def testResolve(self): authority = get_authority(self.hrn) self.registry.Resolve(self.credential, self.hrn) - + def testRemove(self): authority = get_authority(self.hrn) auth_cred = self.client.GetCredential(authority, 'authority') @@ -149,26 +149,26 @@ class RegistryTest(BasicTestCase): try: self.registry.Resolve(self.credential, record['hrn']) assert False - except: + except: assert True - + def testRemovePeerObject(self): assert True def testList(self): authority = get_authority(self.client.hrn) self.registry.List(self.credential, authority) - + def testGetRegistries(self): self.registry.get_registries(self.credential) - + def testGetAggregates(self): self.registry.get_aggregates(self.credential) def testGetTrustedCerts(self): # this should fail unless we are a node callable = self.registry.get_trusted_certs - server_exception = False + server_exception = False try: callable(self.credential) except ServerException: @@ -176,12 +176,12 @@ class RegistryTest(BasicTestCase): finally: if self.type in ['user'] and not server_exception: assert False - + class AggregateTest(BasicTestCase): def setUp(self): BasicTestCase.setUp(self) - + def testGetSlices(self): self.aggregate.ListSlices(self.credential) @@ -195,7 +195,7 @@ class AggregateTest(BasicTestCase): RSpec(xml=slice_rspec) def testCreateSlice(self): - # get availabel resources + # get availabel resources rspec = self.aggregate.get_resources(self.credential) slice_credential = self.client.GetCredential(self.slice['hrn'], 'slice') self.aggregate.CreateSliver(slice_credential, self.slice['hrn'], rspec) @@ -209,17 +209,7 @@ class AggregateTest(BasicTestCase): rspec = self.aggregate.get_resources(self.credential) ticket = self.aggregate.GetTicket(slice_credential, self.slice['hrn'], rspec) # will raise an exception if the ticket inst valid - SfaTicket(string=ticket) - -class SlicemgrTest(AggregateTest): - def setUp(self): - AggregateTest.setUp(self) - - # force calls to go through slice manager - self.aggregate = self.sm - - # get the slice credential - + SfaTicket(string=ticket) class ComponentTest(BasicTestCase): def setUp(self): @@ -258,13 +248,13 @@ def CreateSliver(client): 'type': 'slice', 'researcher': [client.hrn]} client.registry.Register(auth_cred, slice_record) return slice_record - + def DeleteSliver(client, slice): authority = get_authority(client.hrn) auth_cred = client.GetCredential(authority, 'authority') if slice: client.registry.Remove(auth_cred, 'slice', slice['hrn']) - + if __name__ == '__main__': args = sys.argv @@ -278,42 +268,35 @@ if __name__ == '__main__': default=False, help='run registry tests') parser.add_option('-a', '--aggregate', dest='aggregate', action='store_true', default=False, help='run aggregate tests') - parser.add_option('-s', '--slicemgr', dest='slicemgr', action='store_true', - default=False, help='run slicemgr tests') parser.add_option('-c', '--component', dest='component', action='store_true', default=False, help='run component tests') - parser.add_option('-d', '--cm_host', dest='cm_host', default=default_cm, + parser.add_option('-d', '--cm_host', dest='cm_host', default=default_cm, help='dns name of component to test. default is %s' % default_cm) parser.add_option('-A', '--all', dest='all', action='store_true', default=False, help='run component tests') - + options, args = parser.parse_args() suite = unittest.TestSuite() client = Client(options) test_slice = {} - + # create the test slice if necessary - if options.all or options.slicemgr or options.aggregate \ - or options.component: + if options.all or options.aggregate or options.component: test_slice = CreateSliver(client) if options.registry or options.all: for name in test_names(RegistryTest): suite.addTest(RegistryTest(name, client)) - if options.aggregate or options.all: + if options.aggregate or options.all: for name in test_names(AggregateTest): suite.addTest(AggregateTest(name, client, test_slice)) - if options.slicemgr or options.all: - for name in test_names(SlicemgrTest): - suite.addTest(SlicemgrTest(name, client, test_slice)) - - if options.component or options.all: + if options.component or options.all: for name in test_names(ComponentTest): suite.addTest(ComponentTest(name, client, test_slice)) - - # run tests + + # run tests unittest.TextTestRunner(verbosity=2).run(suite) # remove teset slice diff --git a/wsdl/sfa2wsdl.py b/wsdl/sfa2wsdl.py index 2eb9463c..6da341d8 100755 --- a/wsdl/sfa2wsdl.py +++ b/wsdl/sfa2wsdl.py @@ -43,17 +43,15 @@ class WSDLGen: self.interface_options = interface_options def interface_name (self): - if self.interface_options.aggregate and \ - self.interface_options.slicemgr and \ - self.interface_options.registry: + if (self.interface_options.aggregate and + self.interface_options.registry): return "complete" if self.interface_options.aggregate: return "aggregate" - elif self.interface_options.slicemgr: return "slicemgr" elif self.interface_options.registry: return "registry" elif self.interface_options.component: return "component" else: return "unknown" - def filter_argname(self,argname): + def filter_argname(self, argname): if (not self.interface_options.lite or (argname!="cred")): if (argname.find('(') != -1): # The name has documentation in it :-/ @@ -98,7 +96,7 @@ class WSDLGen: min_args = 0 else: min_args = 1 - + self.num_types += 1 type_name = "Type%d"%self.num_types complex_type = types_section.appendChild(self.types.createElement("xsd:complexType")) @@ -115,7 +113,7 @@ class WSDLGen: elif (isinstance(arg, Parameter)): return (self.name_simple_type(arg.type)) elif type(arg) in ( ListType , TupleType ): - inner_type = self.name_complex_type(arg[0]) + inner_type = self.name_complex_type(arg[0]) self.num_types=self.num_types+1 type_name = "Type%d"%self.num_types complex_type = types_section.appendChild(self.types.createElement("xsd:complexType")) @@ -137,14 +135,14 @@ class WSDLGen: type_name = self.filter_argname(type_name) complex_type.setAttribute("name", type_name) complex_content = complex_type.appendChild(self.types.createElement("xsd:sequence")) - + for k in arg.fields: - inner_type = self.name_complex_type(arg.fields[k]) + inner_type = self.name_complex_type(arg.fields[k]) element=complex_content.appendChild(self.types.createElement("xsd:element")) element.setAttribute("name",k) element.setAttribute("type",inner_type) - return "xsdl:%s"%type_name + return "xsdl:%s"%type_name else: return (self.name_simple_type(arg)) @@ -185,7 +183,7 @@ class WSDLGen: #print "\n".join(lines) #print - + in_el = self.wsdl.lastChild.appendChild(self.wsdl.createElement("message")) in_el.setAttribute("name", method + "_in") @@ -205,8 +203,8 @@ class WSDLGen: arg_part = in_el.appendChild(self.wsdl.createElement("part")) arg_part.setAttribute("name", argname) arg_part.setAttribute("type", self.param_type(argtype)) - - # Return type + + # Return type return_type = function.returns out_el = self.wsdl.lastChild.appendChild(self.wsdl.createElement("message")) out_el.setAttribute("name", method + "_out") @@ -218,7 +216,7 @@ class WSDLGen: port_el = self.wsdl.lastChild.appendChild(self.wsdl.createElement("portType")) port_el.setAttribute("name", method + "_port") - + op_el = port_el.appendChild(self.wsdl.createElement("operation")) op_el.setAttribute("name", method) inp_el=self.wsdl.createElement("input") @@ -235,31 +233,31 @@ class WSDLGen: bind_el = self.wsdl.lastChild.appendChild(self.wsdl.createElement("binding")) bind_el.setAttribute("name", method + "_binding") bind_el.setAttribute("type", "tns:" + method + "_port") - + soap_bind = bind_el.appendChild(self.wsdl.createElement("soap:binding")) soap_bind.setAttribute("style", "rpc") soap_bind.setAttribute("transport","http://schemas.xmlsoap.org/soap/http") - + wsdl_op = bind_el.appendChild(self.wsdl.createElement("operation")) wsdl_op.setAttribute("name", method) wsdl_op.appendChild(self.wsdl.createElement("soap:operation")).setAttribute("soapAction", "urn:" + method) - + wsdl_input = wsdl_op.appendChild(self.wsdl.createElement("input")) input_soap_body = wsdl_input.appendChild(self.wsdl.createElement("soap:body")) input_soap_body.setAttribute("use", "encoded") input_soap_body.setAttribute("namespace", "urn:" + method) input_soap_body.setAttribute("encodingStyle","http://schemas.xmlsoap.org/soap/encoding/") - + wsdl_output = wsdl_op.appendChild(self.wsdl.createElement("output")) output_soap_body = wsdl_output.appendChild(self.wsdl.createElement("soap:body")) output_soap_body.setAttribute("use", "encoded") output_soap_body.setAttribute("namespace", "urn:" + method) output_soap_body.setAttribute("encodingStyle","http://schemas.xmlsoap.org/soap/encoding/") - + def add_wsdl_services(self): for service in self.services.keys(): @@ -291,9 +289,9 @@ class WSDLGen: xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"/> """ % (self.interface_name(),plc_ns,plc_ns,plc_ns) - + self.wsdl = xml.dom.minidom.parseString(wsdl_text_header) - + def compute_wsdl_definitions_and_types(self): wsdl_text_header = """ @@ -313,7 +311,7 @@ class WSDLGen: """ % (self.interface_name(),plc_ns, plc_ns, plc_ns, plc_ns) self.types = xml.dom.minidom.parseString(wsdl_text_header) - + def add_wsdl_types(self): wsdl_types = self.wsdl.importNode(self.types.getElementsByTagName("types")[0], True) @@ -334,11 +332,8 @@ class WSDLGen: def main(): parser = OptionParser() - parser.add_option("-r", "--registry", dest="registry", action="store_true", + parser.add_option("-r", "--registry", dest="registry", action="store_true", help="Generate registry.wsdl", metavar="FILE") - parser.add_option("-s", "--slice-manager", - action="store_true", dest="slicemgr", - help="Generate sm.wsdl") parser.add_option("-a", "--aggregate", action="store_true", dest="aggregate", help="Generate am.wsdl") parser.add_option("-c", "--component", action="store_true", dest="component", @@ -352,7 +347,7 @@ def main(): gen = WSDLGen(interface_options) gen.generate_wsdl() gen.pretty_print() - + if __name__ == "__main__": main() -- 2.43.0