initial checkin
[sfa.git] / sfa / methods / PerformOperationalAction.py
1 from sfa.util.faults import SfaInvalidArgument, InvalidRSpec
2 from sfa.util.xrn import urn_to_hrn
3 from sfa.util.method import Method
4 from sfa.util.sfatablesRuntime import run_sfatables
5 from sfa.trust.credential import Credential
6 from sfa.storage.parameter import Parameter, Mixed
7
8 class PerformOperationalAction(Method):
9     """
10     Request that the named geni_allocated slivers be made 
11     geni_provisioned, instantiating or otherwise realizing the 
12     resources, such that they have a valid geni_operational_status 
13     and may possibly be made geni_ready for experimenter use. This 
14     operation is synchronous, but may start a longer process, such 
15     as creating and imaging a virtual machine
16
17     @param slice urns ([string]) URNs of slivers to provision to
18     @param credentials (dict) of credentials
19     @param options (dict) options
20     
21     """
22     interfaces = ['aggregate', 'slicemgr']
23     accepts = [
24         Parameter(type([str]), "URNs"),
25         Parameter(type([dict]), "Credentials"),
26         Parameter(str, "Action"),
27         Parameter(dict, "Options"),
28         ]
29     returns = Parameter(dict, "Provisioned Resources")
30
31     def call(self, xrns, creds, action, options):
32         self.api.logger.info("interface: %s\ttarget-hrn: %s\tmethod-name: %s"%(self.api.interface, xrns, self.name))
33
34         # Find the valid credentials
35         valid_creds = self.api.auth.checkCredentials(creds, 'createsliver', xrns) 
36         result = self.api.manager.PerformOperationalAction(self.api, xrns, creds, action, options)
37         return result