X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=sfa%2Fmethods%2FCreateSliver.py;h=b28d1a536bf95969d018966515100fff72839bfc;hb=02a4a59a4a49183ec8c631cc03243b97f4602d50;hp=fb1a292051d4e9d037b51e3921b9cf92a33bc479;hpb=d58bbc6238ee07a3e386b2627aa64ccb2dce352f;p=sfa.git diff --git a/sfa/methods/CreateSliver.py b/sfa/methods/CreateSliver.py index fb1a2920..b28d1a53 100644 --- a/sfa/methods/CreateSliver.py +++ b/sfa/methods/CreateSliver.py @@ -1,12 +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.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): @@ -32,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() @@ -54,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