From 5d0b517fc331d9ac063ab0777081feb6345368da Mon Sep 17 00:00:00 2001 From: Josh Karlin Date: Tue, 20 Apr 2010 15:35:18 +0000 Subject: [PATCH] Added resolve/shutdown files --- sfa/methods/Resolve.py | 42 +++++++++++++++++++++++++++++++++++ sfa/methods/Shutdown.py | 49 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 91 insertions(+) create mode 100644 sfa/methods/Resolve.py create mode 100644 sfa/methods/Shutdown.py diff --git a/sfa/methods/Resolve.py b/sfa/methods/Resolve.py new file mode 100644 index 00000000..b694bc8a --- /dev/null +++ b/sfa/methods/Resolve.py @@ -0,0 +1,42 @@ +from sfa.util.faults import * +from sfa.util.namespace import * +from sfa.util.method import Method +from sfa.util.parameter import Parameter + + +class Resolve(Method): + """ + Lookup a URN and return information about the corresponding object. + @param slice_urn (string) URN of slice to renew + @param credentials ([string]) of credentials + + """ + interfaces = ['registry'] + accepts = [ + Parameter(str, "URN"), + Parameter(type([str]), "List of credentials"), + ] + returns = Parameter(bool, "Success or Failure") + + def call(self, xrn, creds): + for cred in creds: + try: + self.api.auth.check(cred, 'resolve') + found = True + break + except: + continue + + if not found: + raise InsufficientRights('Resolve: Credentials either did not verify, were no longer valid, or did not have appropriate privileges') + + + manager_base = 'sfa.managers' + + if self.api.interface in ['registry']: + mgr_type = self.api.config.SFA_REGISTRY_TYPE + manager_module = manager_base + ".registry_manager_%s" % mgr_type + manager = __import__(manager_module, fromlist=[manager_base]) + return manager.Resolve(self.api, xrn, creds) + + return {} \ No newline at end of file diff --git a/sfa/methods/Shutdown.py b/sfa/methods/Shutdown.py new file mode 100644 index 00000000..4445ae2f --- /dev/null +++ b/sfa/methods/Shutdown.py @@ -0,0 +1,49 @@ +from sfa.util.faults import * +from sfa.util.namespace import * +from sfa.util.method import Method +from sfa.util.parameter import Parameter + + +class Shutdown(Method): + """ + Perform an emergency shut down of a sliver. This operation is intended for administrative use. + The sliver is shut down but remains available for further forensics. + + @param slice_urn (string) URN of slice to renew + @param credentials ([string]) of credentials + """ + interfaces = ['geni_am'] + accepts = [ + Parameter(str, "Slice URN"), + Parameter(type([str]), "List of credentials"), + ] + returns = Parameter(bool, "Success or Failure") + + def call(self, slice_xrn, creds, expiration_time): + hrn, type = urn_to_hrn(slice_xrn) + + self.api.logger.info("interface: %s\ttarget-hrn: %s\tcaller-creds: %s\tmethod-name: %s"%(self.api.interface, hrn, creds, self.name)) + + # Validate that at least one of the credentials is good enough + found = False + for cred in creds: + try: + self.api.auth.check(cred, 'shutdown') + found = True + break + except: + continue + + if not found: + raise InsufficientRights('Shutdown: Credentials either did not verify, were no longer valid, or did not have appropriate privileges') + + manager_base = 'sfa.managers' + + if self.api.interface in ['geni_am']: + mgr_type = self.api.config.SFA_GENI_AGGREGATE_TYPE + manager_module = manager_base + ".geni_am_%s" % mgr_type + manager = __import__(manager_module, fromlist=[manager_base]) + return manager.Shutdown(self.api, slice_xrn, creds) + + return '' + -- 2.47.0