call_id = options.get('call_id')
if Callids().already_handled(call_id): return True
return self.driver.renew(xrns, expiration_time, options)
+
+ def PerformOperationalAction(self, api, xrns, action, options={}):
+ call_id = options.get('call_id')
+ if Callids().already_handled(call_id): return True
+ return self.driver.performOperationalAction(xrns, action, options)
+
+ def Shutdown(self, api, xrn, options={}):
+ call_id = options.get('call_id')
+ if Callids().already_handled(call_id): return True
+ return self.driver.shutdown(xrn, options)
def GetTicket(self, api, xrn, creds, rspec, users, options):
from sfa.storage.parameter import Parameter
+from sfa.trust.credential import Credential
+from sfa.util.method import Method
-from sfa.methods.Stop import Stop
-
-class Shutdown(Stop):
+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.
]
returns = Parameter(bool, "Success or Failure")
- def call(self, slice_xrn, creds):
+ def call(self, xrn, creds):
+
+ valid_creds = self.api.auth.checkCredentials(creds, 'stopslice', xrn)
+ #log the call
+ origin_hrn = Credential(string=valid_creds[0]).get_gid_caller().get_hrn()
+ self.api.logger.info("interface: %s\tcaller-hrn: %s\ttarget-hrn: %s\tmethod-name: %s"%(self.api.interface, origin_hrn, xrn, self.name))
- return Stop.call(self, slice_xrn, creds)
+ return self.api.manager.Shutdown(self.api, xrn, creds)
return True
def perform_operational_action (self, urns, action, options):
- tenant_name = OSXrn(xrn=slice_hrn, type='slice').get_tenant_name()
- name = OSXrn(xrn=slice_urn).name
- aggregate = OSAggregate(self)
- return aggregate.stop_instances(name, tenant_name)
-
+ pass
+
+ def shutdown(self, xrn, options):
+ xrn = OSXrn(xrn=xrn, type='slice')
+ tenant_name = xrn.get_tenant_name()
+ name = xrn.get_slicename()
+ self.driver.shell.nova_manager.connect(tenant=tenant_name)
+ instances = self.driver.shell.nova_manager.servers.findall(name=name)
+ for instance in instances:
+ self.driver.shell.nova_manager.servers.shutdown(instance)
+ return True
+
# xxx this code is quite old and has not run for ages
# it is obviously totally broken and needs a rewrite
def get_ticket (self, slice_urn, slice_hrn, creds, rspec_string, options):
except:
return False
- # remove the 'enabled' tag
- def start_slice (self, slice_urn, slice_hrn, creds):
- slicename = hrn_to_pl_slicename(slice_hrn)
- slices = self.shell.GetSlices({'name': slicename}, ['slice_id'])
- if not slices:
- raise RecordNotFound(slice_hrn)
- slice_id = slices[0]['slice_id']
- slice_tags = self.shell.GetSliceTags({'slice_id': slice_id, 'tagname': 'enabled'}, ['slice_tag_id'])
- # just remove the tag if it exists
- if slice_tags:
- self.shell.DeleteSliceTag(slice_tags[0]['slice_tag_id'])
- return 1
-
# set the 'enabled' tag to 0
- def stop_slice (self, slice_urn, slice_hrn, creds):
- slicename = hrn_to_pl_slicename(slice_hrn)
+ def shutdown (self, xrn, options):
+ xrn = PlXrn(xrn=xrn, type='slice')
+ slicename = xrn.pl_slicename()
slices = self.shell.GetSlices({'name': slicename}, ['slice_id'])
if not slices:
raise RecordNotFound(slice_hrn)
self.shell.UpdateSliceTag(tag_id, '0')
return 1
- def reset_slice (self, slice_urn, slice_hrn, creds):
- raise SfaNotImplemented ("reset_slice not available at this interface")
-
# xxx this code is quite old and has not run for ages
# it is obviously totally broken and needs a rewrite
def get_ticket (self, slice_urn, slice_hrn, creds, rspec_string, options):