X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=sfa%2Fmethods%2FCreateSliver.py;h=fb1a292051d4e9d037b51e3921b9cf92a33bc479;hb=cf630d87d633f3861e3ac8a50433fa29ca46a74e;hp=0c729b945bbf475002ec2d7bb2c2acf67e8bf2ac;hpb=06b330f0ee047bdb107e43e82b1d7356c876bc15;p=sfa.git diff --git a/sfa/methods/CreateSliver.py b/sfa/methods/CreateSliver.py index 0c729b94..fb1a2920 100644 --- a/sfa/methods/CreateSliver.py +++ b/sfa/methods/CreateSliver.py @@ -1,10 +1,14 @@ -from sfa.util.faults import * +from sfa.util.faults import SfaInvalidArgument 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 + from sfa.trust.credential import Credential +from sfa.storage.parameter import Parameter, Mixed + +from sfa.rspecs.rspec import RSpec + class CreateSliver(Method): """ Allocate resources to a slice. This operation is expected to @@ -23,11 +27,12 @@ class CreateSliver(Method): Mixed(Parameter(str, "Credential string"), Parameter(type([str]), "List of credentials")), Parameter(str, "RSpec"), - Parameter(type([]), "List of user information") + Parameter(type([]), "List of user information"), + Parameter(dict, "options"), ] returns = Parameter(str, "Allocated RSpec") - def call(self, slice_xrn, creds, rspec, users): + 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)) @@ -36,14 +41,21 @@ class CreateSliver(Method): 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() - + # 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." + raise SfaInvalidArgument(name='users', extra=msg) + # flter rspec through sfatables if self.api.interface in ['aggregate']: chain_name = 'INCOMING' elif self.api.interface in ['slicemgr']: chain_name = 'FORWARD-INCOMING' + self.api.logger.debug("CreateSliver: sfatables on chain %s"%chain_name) rspec = run_sfatables(chain_name, hrn, origin_hrn, rspec) - allocated = manager.create_slice(self.api, slice_xrn, creds, rspec, users) - - return 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 + return result