X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=sfa%2Fmethods%2FCreateSliver.py;h=b28d1a536bf95969d018966515100fff72839bfc;hb=02a4a59a4a49183ec8c631cc03243b97f4602d50;hp=218986eb946957fead78da4ccffd74b795e32932;hpb=904c314440f4f0bd3f5c6c767fd7293f4887815b;p=sfa.git diff --git a/sfa/methods/CreateSliver.py b/sfa/methods/CreateSliver.py index 218986eb..b28d1a53 100644 --- a/sfa/methods/CreateSliver.py +++ b/sfa/methods/CreateSliver.py @@ -1,9 +1,10 @@ -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): @@ -29,11 +30,11 @@ class CreateSliver(Method): ] returns = Parameter(str, "Allocated RSpec") - def call(self, slice_xrn, creds, rspec, users, options={}): + 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() @@ -51,8 +52,7 @@ class CreateSliver(Method): self.api.logger.debug("CreateSliver: sfatables on chain %s"%chain_name) rspec = run_sfatables(chain_name, hrn, origin_hrn, rspec) slivers = RSpec(rspec).version.get_nodes_with_slivers() - if slivers: - result = self.api.manager.CreateSliver(self.api, slice_xrn, creds, rspec, users, options) - else: - result = rspec + 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