+ # trash the slice altogether
+ def delete_slice(self):
+ auth = self.owner_auth()
+ slice_name = self.slice_name()
+ utils.header("Deleting slice %s"%slice_name)
+ self.test_plc.apiserver.DeleteSlice(auth,slice_name)
+
+ # keep the slice alive and just delete nodes
+ def delete_nodes (self):
+ auth = self.owner_auth()
+ slice_name = self.slice_name()
+ print 'retrieving slice %s'%slice_name
+ slice=self.test_plc.apiserver.GetSlices(auth,slice_name)[0]
+ node_ids=slice['node_ids']
+ utils.header ("Deleting %d nodes from slice %s"%\
+ (len(node_ids),slice_name))
+ self.test_plc.apiserver.DeleteSliceFromNodes (auth,slice_name, node_ids)
+
+ def locate_private_key(self):
+ key_names=[]
+ for username in self.slice_spec['usernames']:
+ user_spec=self.test_site.locate_user(username)
+ key_names += user_spec['key_names']
+ return self.test_plc.locate_private_key_from_key_names (key_names)
+
+ # to be used through TestPlc.slice_mapper_tasks
+ # i.e. returns a list of CompleterTasks that are merged into the same Completer run
+ # to avoid waiting for as many slices as the Plc has
+ # also the __doc__ lines are used for the TestPlc methods, e.g. just 'ssh_slice'
+ def ssh_slice__tasks (self, options, *args, **kwds):
+ "tries to ssh-enter the slice with the user key, to check for slice creation"
+ return self.ssh_tasks(options, expected=True, *args, **kwds)
+
+ # when we expect the slice is not reachable
+ def ssh_slice_off__tasks (self, options, *args, **kwds):
+ "tries to ssh-enter the slice with the user key, expecting it to be unreachable"
+ return self.ssh_tasks(options, expected=False, *args, **kwds)
+
+ def ssh_tasks(self,options, expected=True, command=None):
+# timeout_minutes=20,silent_minutes=10,period_seconds=15):
+# timeout = timedelta(minutes=timeout_minutes)
+# graceout = timedelta(minutes=silent_minutes)
+# period = timedelta(seconds=period_seconds)
+ if not command:
+ command="echo hostname ; hostname; echo id; id; echo uname -a ; uname -a"
+ # locate a key
+ private_key=self.locate_private_key()
+ if not private_key :
+ utils.header("WARNING: Cannot find a valid key for slice %s"%self.name())
+ return False
+
+ # convert nodenames to real hostnames
+ if expected: msg="ssh slice access enabled"
+ else: msg="ssh slice access disabled"
+ utils.header("checking for %s -- slice %s"%(msg,self.name()))
+
+ tasks=[]
+ slicename=self.name()
+ dry_run = getattr(options,'dry_run',False)