4 from sfa.util.faults import *
5 from sfa.util.misc import *
6 from sfa.util.method import Method
7 from sfa.util.parameter import Parameter, Mixed
8 from sfa.trust.auth import Auth
9 from sfa.plc.slices import Slices
10 from sfa.util.config import Config
11 # RSpecManager_pl is not used. This is just to resolve issues with the dynamic __import__ that comes later.
12 import sfa.rspecs.aggregates.rspec_manager_pl
15 class create_slice(Method):
17 Instantiate the specified slice according to whats defined in the specified rspec
19 @param cred credential string specifying the rights of the caller
20 @param hrn human readable name of slice to instantiate
21 @param rspec resource specification
22 @return 1 is successful, faults otherwise
25 interfaces = ['aggregate', 'slicemgr']
28 Parameter(str, "Credential string"),
29 Parameter(str, "Human readable name of slice to instantiate"),
30 Parameter(str, "Resource specification"),
33 returns = Parameter(int, "1 if successful")
35 def call(self, cred, hrn, rspec):
36 sfa_aggregate_type = Config().get_aggregate_rspec_type()
37 self.api.auth.check(cred, 'createslice')
38 if (sfa_aggregate_type == 'pl'):
39 slices = Slices(self.api)
40 slices.create_slice(hrn, rspec)
42 # To clean up after July 21 - SB
43 rspec_manager = __import__("sfa.rspecs.aggregates.rspec_manager_"+sfa_aggregate_type, fromlist = ["sfa.rspecs.aggregates"])
44 rspec = rspec_manager.create_slice(self.api, hrn, rspec)