3 from sfa.util.xrn import urn_to_hrn
4 from sfa.util.method import Method
5 from sfa.util.sfatablesRuntime import run_sfatables
6 from sfa.util.faults import SfaInvalidArgument
7 from sfa.util.sfalogging import logger
9 from sfa.trust.credential import Credential
11 from sfa.storage.parameter import Parameter, Mixed
14 class Describe(Method):
16 Retrieve a manifest RSpec describing the resources contained by the
17 named entities, e.g. a single slice or a set of the slivers in a
18 slice. This listing and description should be sufficiently
19 descriptive to allow experimenters to use the resources.
20 @param credential list
21 @param options dictionary
24 interfaces = ['aggregate']
26 Parameter(type([str]), "List of URNs"),
27 Mixed(Parameter(str, "Credential string"),
28 Parameter(type([str]), "List of credentials")),
29 Parameter(dict, "Options")
31 returns = Parameter(str, "List of resources")
33 def call(self, urns, creds, options):
34 logger.info("interface: %s\tmethod-name: %s" %
35 (self.api.interface, self.name))
37 # client must specify a version
38 if not options.get('geni_rspec_version'):
39 if options.get('rspec_version'):
40 options['geni_rspec_version'] = options['rspec_version']
42 raise SfaInvalidArgument(
43 'Must specify an rspec version option. geni_rspec_version cannot be null')
44 valid_creds = self.api.auth.checkCredentialsSpeaksFor(
45 creds, 'listnodes', urns,
46 check_sliver_callback=self.api.driver.check_sliver_credentials,
49 # get hrn of the original caller
50 origin_hrn = options.get('origin_hrn', None)
52 origin_hrn = Credential(
53 cred=valid_creds[0]).get_gid_caller().get_hrn()
54 desc = self.api.manager.Describe(self.api, creds, urns, options)
56 # filter rspec through sfatables
57 if self.api.interface in ['aggregate']:
58 chain_name = 'OUTGOING'
60 "ListResources: sfatables on chain %s" % chain_name)
61 desc['geni_rspec'] = run_sfatables(
62 chain_name, '', origin_hrn, desc['geni_rspec'])
64 if 'geni_compressed' in options and options['geni_compressed'] == True:
65 desc['geni_rspec'] = zlib.compress(
66 desc['geni_rspec']).encode('base64')