X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=sfa%2Fmethods%2FCreateSliver.py;h=b898c9d748468b4d8353dbf18a6db739a2475d9f;hb=3d51e29695f79b143974f5cf7b2e104d89626ba4;hp=d5a507ed6d73a65eedd266c4b059596b1adc713a;hpb=431a6bf78c6232a44b178e2092451e733a71bba3;p=sfa.git diff --git a/sfa/methods/CreateSliver.py b/sfa/methods/CreateSliver.py index d5a507ed..b898c9d7 100644 --- a/sfa/methods/CreateSliver.py +++ b/sfa/methods/CreateSliver.py @@ -1,9 +1,11 @@ -from sfa.util.faults import SfaInvalidArgument +from sfa.util.faults import SfaInvalidArgument, InvalidRSpec from sfa.util.xrn import urn_to_hrn from sfa.util.method import Method -from sfa.util.parameter import Parameter, Mixed from sfa.util.sfatablesRuntime import run_sfatables +import sys from sfa.trust.credential import Credential +from sfa.storage.parameter import Parameter, Mixed +from sfa.rspecs.rspec import RSpec class CreateSliver(Method): """ @@ -24,22 +26,22 @@ class CreateSliver(Method): Parameter(type([str]), "List of credentials")), Parameter(str, "RSpec"), Parameter(type([]), "List of user information"), - Parameter(str, "call_id"), + Parameter(dict, "options"), ] returns = Parameter(str, "Allocated RSpec") - def call(self, slice_xrn, creds, rspec, users, call_id=""): + def call(self, slice_xrn, creds, rspec, users, options): hrn, type = urn_to_hrn(slice_xrn) self.api.logger.info("interface: %s\ttarget-hrn: %s\tmethod-name: %s"%(self.api.interface, hrn, self.name)) - + print >>sys.stderr, " \r\n \r\n Createsliver.py call %s\ttarget-hrn: %s\tmethod-name: %s "%(self.api.interface, hrn, self.name) # Find the valid credentials valid_creds = self.api.auth.checkCredentials(creds, 'createsliver', hrn) origin_hrn = Credential(string=valid_creds[0]).get_gid_caller().get_hrn() # make sure users info is specified if not users: - msg = "'users' musst be specified and cannot be null. You may need to update your client." + msg = "'users' must be specified and cannot be null. You may need to update your client." raise SfaInvalidArgument(name='users', extra=msg) # flter rspec through sfatables @@ -49,5 +51,8 @@ class CreateSliver(Method): chain_name = 'FORWARD-INCOMING' self.api.logger.debug("CreateSliver: sfatables on chain %s"%chain_name) rspec = run_sfatables(chain_name, hrn, origin_hrn, rspec) - - return self.api.manager.CreateSliver(self.api, slice_xrn, creds, rspec, users, call_id) + slivers = RSpec(rspec).version.get_nodes_with_slivers() + if not slivers: + raise InvalidRSpec("Missing or element. Request rspec must explicitly allocate slivers") + result = self.api.manager.CreateSliver(self.api, slice_xrn, creds, rspec, users, options) + return result