1 from sfa.util.faults import *
2 from sfa.util.namespace import *
3 from sfa.util.method import Method
4 from sfa.util.parameter import Parameter, Mixed
5 from sfa.util.sfatablesRuntime import run_sfatables
7 from sfa.trust.credential import Credential
8 from sfa.util.sfalogging import logger
10 class CreateSliver(Method):
12 Allocate resources to a slice. This operation is expected to
13 start the allocated resources asynchornously after the operation
14 has successfully completed. Callers can check on the status of
15 the resources using SliverStatus.
17 @param slice_urn (string) URN of slice to allocate to
18 @param credentials ([string]) of credentials
19 @param rspec (string) rspec to allocate
22 interfaces = ['aggregate', 'slicemgr']
24 Parameter(str, "Slice URN"),
25 Mixed(Parameter(str, "Credential string"),
26 Parameter(type([str]), "List of credentials")),
27 Parameter(str, "RSpec"),
28 Parameter(type([]), "List of user information")
30 returns = Parameter(str, "Allocated RSpec")
32 def call(self, slice_xrn, creds, rspec, users):
33 hrn, type = urn_to_hrn(slice_xrn)
35 self.api.logger.info("interface: %s\ttarget-hrn: %s\tmethod-name: %s"%(self.api.interface, hrn, self.name))
37 # Find the valid credentials
38 valid_creds = self.api.auth.checkCredentials(creds, 'createsliver', hrn)
39 origin_hrn = Credential(string=valid_creds[0]).get_gid_caller().get_hrn()
41 manager = self.api.get_interface_manager()
43 # flter rspec through sfatables
44 if self.api.interface in ['aggregate']:
45 chain_name = 'OUTGOING'
46 elif self.api.interface in ['slicemgr']:
47 chain_name = 'FORWARD-OUTGOING'
48 rspec = run_sfatables(chain_name, hrn, origin_hrn, rspec)
49 allocated = manager.create_slice(self.api, slice_xrn, creds, rspec, users)