From: Tony Mack Date: Tue, 3 Aug 2010 21:13:46 +0000 (+0000) Subject: create_slice is deprecated and is being replaced by CreateSliver. create_slice just... X-Git-Tag: sfa-1.0-0~111 X-Git-Url: http://git.onelab.eu/?a=commitdiff_plain;h=b85d1d7908a12ae054f4d3042d7c8dadf16327db;p=sfa.git create_slice is deprecated and is being replaced by CreateSliver. create_slice just forwards the request to CreateSliver --- diff --git a/sfa/methods/CreateSliver.py b/sfa/methods/CreateSliver.py index 4f580138..bcca6b35 100644 --- a/sfa/methods/CreateSliver.py +++ b/sfa/methods/CreateSliver.py @@ -1,8 +1,8 @@ from sfa.util.faults import * from sfa.util.namespace import * from sfa.util.method import Method -from sfa.util.parameter import Parameter -from sfatables.runtime import SFATablesRules +from sfa.util.parameter import Parameter, Mixed +from sfa.util.sfatablesRuntime import run_sfatables import sys from sfa.trust.credential import Credential from sfa.util.sfalogging import logger @@ -19,24 +19,16 @@ class CreateSliver(Method): @param rspec (string) rspec to allocate """ - interfaces = ['geni_am'] + interfaces = ['aggregate', 'slicemgr', 'geni_am'] accepts = [ Parameter(str, "Slice URN"), - Parameter(type([str]), "List of credentials"), + Mixed(Parameter(str, "Credential string"), + Parameter(type([str]), "List of credentials")), Parameter(str, "RSpec"), Parameter(type([]), "List of user information") ] returns = Parameter(str, "Allocated RSpec") - def __run_sfatables(self, manager, rules, hrn, origin_hrn, rspec): - if rules.sorted_rule_list: - contexts = rules.contexts - request_context = manager.fetch_context(hrn, origin_hrn, contexts) - rules.set_context(request_context) - newrspec = rules.apply(rspec) - else: - newrspec = rspec - return newrspec def call(self, slice_xrn, creds, rspec, users): @@ -45,22 +37,20 @@ class CreateSliver(Method): self.api.logger.info("interface: %s\ttarget-hrn: %s\tmethod-name: %s"%(self.api.interface, hrn, self.name)) # Find the valid credentials - ValidCreds = self.api.auth.checkCredentials(creds, 'createsliver', hrn) - origin_hrn = Credential(string=ValidCreds[0]).get_gid_caller().get_hrn() - - 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]) - rspec = self.__run_sfatables(manager, SFATablesRules('INCOMING'), - hrn, origin_hrn, rspec) - - - allocated = manager.CreateSliver(self.api, slice_xrn, ValidCreds, rspec, users) - if allocated: - return rspec + valid_creds = self.api.auth.checkCredentials(creds, 'createsliver', hrn) + origin_hrn = Credential(string=valid_creds[0]).get_gid_caller().get_hrn() + + manager = self.api.get_interface_manager() + + # flter rspec through sfatables + if self.api.interface in ['aggregate', 'geni_am']: + chain_name = 'OUTGOING' + elif self.api.interface in ['slicemgr']: + chain_name = 'FORWARD-OUTGOING' + rspec = run_sfatables(chain_name, hrn, origin_hrn, rspec) + allocated = manager.create_slice(self.api, slice_xrn, valid_creds, rspec, users) + if allocated: + return rspec return '' diff --git a/sfa/methods/create_slice.py b/sfa/methods/create_slice.py index a55b96e2..e7dc1119 100644 --- a/sfa/methods/create_slice.py +++ b/sfa/methods/create_slice.py @@ -5,14 +5,11 @@ 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.plc.slices import Slices -from sfa.util.config import Config -from sfa.trust.credential import Credential -from sfatables.runtime import SFATablesRules +from sfa.methods.CreateSliver import CreateSliver -class create_slice(Method): +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 @@ -32,45 +29,7 @@ class create_slice(Method): ] returns = Parameter(int, "1 if successful") - - def __run_sfatables(self, manager, rules, hrn, origin_hrn, rspec): - if rules.sorted_rule_list: - contexts = rules.contexts - request_context = manager.fetch_context(hrn, origin_hrn, contexts) - rules.set_context(request_context) - newrspec = rules.apply(rspec) - else: - newrspec = rspec - return newrspec - def call(self, cred, xrn, requested_rspec, origin_hrn=None): - hrn, type = urn_to_hrn(xrn) - user_cred = Credential(string=cred) - #log the call - if not origin_hrn: - origin_hrn = user_cred.get_gid_caller().get_hrn() - self.api.logger.info("interface: %s\tcaller-hrn: %s\ttarget-hrn: %s\tmethod-name: %s"%(self.api.interface, origin_hrn, hrn, self.name)) - - # validate the credential - self.api.auth.check(cred, 'createslice', hrn) - - manager_base = 'sfa.managers' - if self.api.interface in ['aggregate']: - mgr_type = self.api.config.SFA_AGGREGATE_TYPE - manager_module = manager_base + ".aggregate_manager_%s" % mgr_type - manager = __import__(manager_module, fromlist=[manager_base]) - rspec = self.__run_sfatables(manager, - SFATablesRules('INCOMING'), - hrn, origin_hrn, requested_rspec) - manager.create_slice(self.api, xrn, rspec) - elif self.api.interface in ['slicemgr']: - mgr_type = self.api.config.SFA_SM_TYPE - manager_module = manager_base + ".slice_manager_%s" % mgr_type - manager = __import__(manager_module, fromlist=[manager_base]) - rspec = self.__run_sfatables(manager, - SFATablesRules('FORWARD-INCOMING'), - hrn, origin_hrn, requested_rspec) - manager.create_slice(self.api, xrn, rspec, origin_hrn) - return 1 + return CreateSliver.call(self, xrn, cred, requested_rspec, [])