('AddSlice' , True),
('AddPersonToSlice' , True),
('AddSliceToNodes' , True),
+ ('DeleteSliceFromNodes' , True),
('AddSliceTag' , True),
('AddPerson' , True),
('UpdatePerson' , True),
('AddPersonKey' , True),
('GetPlcRelease', {'build': {'target-arch':'i386'}}),
('GetSites', []),
- ('GetSlices', [{'name':'dry_run_slice'}]),
+ ('GetSlices', [{'name':'dry_run_slice','node_ids':['dry_run']}]),
('GetLeaseGranularity', 180),
('AddLeases', True),
('GetLeases', []),
('DeleteLeases',True),
+ ('AddConfFile','True'),
('system.listMethods',[]),
]
'show', SEP,
'vs_delete','timestamp_vs','vs_create', SEP,
'plc_install', 'plc_configure', 'plc_start', SEP,
- 'keys_fetch', 'keys_store', 'keys_clear_known_hosts', SEP,
+ 'keys_fetch', 'keys_store', 'keys_clear_known_hosts', 'speed_up_slices', SEP,
'initscripts', 'sites', 'nodes', 'slices', 'nodegroups', 'leases', SEP,
'nodestate_reinstall', 'qemu_local_init','bootcd', 'qemu_local_config', SEP,
'qemu_export', 'qemu_kill_mine', 'qemu_start', 'timestamp_qemu', SEP,
'ssh_node_boot@1', 'ssh_slice', 'check_initscripts', SEP,
'ssh_slice_sfa@1', 'sfa_delete_slice@1', 'sfa_delete_user@1', SEPSFA,
'check_tcp', 'check_sys_slice', SEP,
+ 'empty_slices', 'ssh_slice_off', 'fill_slices', SEP,
'force_gather_logs', SEP,
]
other_steps = [
'delete_initscripts', 'delete_nodegroups','delete_all_sites', SEP,
'delete_sites', 'delete_nodes', 'delete_slices', 'keys_clean', SEP,
'delete_leases', 'list_leases', SEP,
- 'populate' , SEP,
+ 'populate', SEP,
'nodestate_show','nodestate_safeboot','nodestate_boot', SEP,
'qemu_list_all', 'qemu_list_mine', 'qemu_kill_all', SEP,
'sfa_install_core', 'sfa_install_sfatables', 'sfa_install_plc', 'sfa_install_client', SEPSFA,
def delete_all_sites (self):
"Delete all sites in PLC, and related objects"
print 'auth_root',self.auth_root()
- site_ids = [s['site_id'] for s in self.apiserver.GetSites(self.auth_root(), {}, ['site_id'])]
- for site_id in site_ids:
+ sites = self.apiserver.GetSites(self.auth_root(), {}, ['site_id'])
+ for site in sites:
+ # keep automatic site - otherwise we shoot in our own foot, root_auth is not valid anymore
+ if site['login_base']==self.plc_spec['PLC_SLICE_PREFIX']: continue
+ site_id=site['site_id']
print 'Deleting site_id',site_id
self.apiserver.DeleteSite(self.auth_root(),site_id)
return True
### manage slices
def slices (self):
"create slices with PLCAPI"
- return self.do_slices()
+ return self.do_slices(action="add")
def delete_slices (self):
"delete slices with PLCAPI"
- return self.do_slices("delete")
+ return self.do_slices(action="delete")
+
+ def fill_slices (self):
+ "add nodes in slices with PLCAPI"
+ return self.do_slices(action="fill")
+
+ def empty_slices (self):
+ "remove nodes from slices with PLCAPI"
+ return self.do_slices(action="empty")
def do_slices (self, action="add"):
for slice in self.plc_spec['slices']:
site_spec = self.locate_site (slice['sitename'])
test_site = TestSite(self,site_spec)
test_slice=TestSlice(self,test_site,slice)
- if action != "add":
- utils.header("Deleting slices in site %s"%test_site.name())
+ if action == "delete":
test_slice.delete_slice()
- else:
- utils.pprint("Creating slice",slice)
+ elif action=="fill":
+ test_slice.add_nodes()
+ elif action=="empty":
+ test_slice.delete_nodes()
+ else:
test_slice.create_slice()
- utils.header('Created Slice %s'%slice['slice_fields']['name'])
return True
@slice_mapper
"tries to ssh-enter the slice with the user key, to ensure slice creation"
pass
+ @slice_mapper
+ def ssh_slice_off (self):
+ "tries to ssh-enter the slice with the user key, expecting it to be unreachable"
+ pass
+
@node_mapper
def keys_clear_known_hosts (self):
"remove test nodes entries from the local known_hosts file"
pass
+ def speed_up_slices (self):
+ "tweak nodemanager settings on all nodes using a conf file"
+ # create the template on the server-side
+ template="%s.nodemanager"%self.name()
+ template_file = open (template,"w")
+ template_file.write('OPTIONS="-p 30 -r 11 -d"\n')
+ template_file.close()
+ in_vm="/var/www/html/PlanetLabConf/nodemanager"
+ remote="%s/%s"%(self.vm_root_in_host(),in_vm)
+ self.test_ssh.copy_abs(template,remote)
+ # Add a conf file
+ self.apiserver.AddConfFile (self.auth_root(),
+ {'dest':'/etc/sysconfig/nodemanager',
+ 'source':'PlanetLabConf/nodemanager',
+ 'postinstall_cmd':'service nm restart',})
+ return True
+
@node_mapper
def qemu_start (self) :
"all nodes: start the qemu instance (also runs qemu-bridge-init start)"
'SFA_DB_PASSWORD',
'SFA_DB_NAME',
'SFA_API_LOGLEVEL',
+ 'SFA_GENERIC_FLAVOUR',
+ 'SFA_AGGREGATE_ENABLED',
]:
if self.plc_spec['sfa'].has_key(var):
fileconf.write ('e %s\n%s\n'%(var,self.plc_spec['sfa'][var]))
if(slice_spec['slice_fields']['name']== slice_name):
return slice_spec
- def delete_slice(self):
+ def owner_auth(self):
owner_spec = self.test_site.locate_user(self.slice_spec['owner'])
- auth = TestUser(self,self.test_site,owner_spec).auth()
- slice_fields = self.slice_spec['slice_fields']
- slice_name = slice_fields['name']
- self.test_plc.apiserver.DeleteSlice(auth,slice_fields['name'])
- utils.header("Deleted slice %s"%slice_fields['name'])
+ return TestUser(self,self.test_site,owner_spec).auth()
-
+ def slice_name (self):
+ return self.slice_spec['slice_fields']['name']
+
+ # init slice with people, and then add nodes
def create_slice(self):
- owner_spec = self.test_site.locate_user(self.slice_spec['owner'])
- auth = TestUser(self,self.test_site,owner_spec).auth()
+ auth = self.owner_auth()
slice_fields = self.slice_spec['slice_fields']
slice_name = slice_fields['name']
-
+ utils.header("Creating slice %s"%slice_name)
self.test_plc.apiserver.AddSlice(auth,slice_fields)
for username in self.slice_spec['usernames']:
user_spec=self.test_site.locate_user(username)
test_user=TestUser(self,self.test_site,user_spec)
self.test_plc.apiserver.AddPersonToSlice(auth, test_user.name(), slice_name)
-
- hostnames=[]
- for nodename in self.slice_spec['nodenames']:
- node_spec=self.test_site.locate_node(nodename)
- test_node=TestNode(self,self.test_site,node_spec)
- hostnames += [test_node.name()]
- utils.header("Adding %r in %s"%(hostnames,slice_name))
- self.test_plc.apiserver.AddSliceToNodes(auth, slice_name, hostnames)
# add initscript code or name as appropriate
if self.slice_spec.has_key('initscriptcode'):
iscode=self.slice_spec['initscriptcode']
if self.slice_spec.has_key ('vref'):
vref_value=self.slice_spec['vref']
self.test_plc.apiserver.AddSliceTag(self.test_plc.auth_root(), slice_name,'vref',vref_value)
+
+ self.add_nodes()
+
+ # just add the nodes and handle tags
+ def add_nodes (self):
+ auth = self.owner_auth()
+ slice_name = self.slice_name()
+ hostnames=[]
+ for nodename in self.slice_spec['nodenames']:
+ node_spec=self.test_site.locate_node(nodename)
+ test_node=TestNode(self,self.test_site,node_spec)
+ hostnames += [test_node.name()]
+ utils.header("Adding %r in %s"%(hostnames,slice_name))
+ self.test_plc.apiserver.AddSliceToNodes(auth, slice_name, hostnames)
+ # trash the slice altogether
+ def delete_slice(self):
+ utils.header("Deleting slice %s"%slice_name)
+ auth = self.owner_auth()
+ slice_name = self.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_key(self):
# locate the first avail. key
found=False
found=True
return (found,privatekey)
- def ssh_slice(self,options,timeout_minutes=20,silent_minutes=10,period=15):
+
+ # trying to reach the slice through ssh - expected to answer
+ def ssh_slice (self, options, *args, **kwds):
+ return self.do_ssh_slice(options, expected=True, *args, **kwds)
+
+ # when we expect the slice is not reachable
+ def ssh_slice_off (self, options, *args, **kwds):
+ return self.do_ssh_slice(options, expected=False, *args, **kwds)
+
+ def do_ssh_slice(self,options,expected=True,timeout_minutes=20,silent_minutes=10,period=15):
timeout = datetime.datetime.now()+datetime.timedelta(minutes=timeout_minutes)
graceout = datetime.datetime.now()+datetime.timedelta(minutes=silent_minutes)
# locate a key
(site_spec,node_spec) = self.test_plc.locate_node(nodename)
tocheck.append(node_spec['node_fields']['hostname'])
- utils.header("checking ssh access into slice %s on nodes %r"%(self.name(),tocheck))
+ if expected: msg="ssh slice access enabled"
+ else: msg="ssh slice access disabled"
+
+ utils.header("checking for %s -- slice %s on nodes %r"%(msg,self.name(),tocheck))
utils.header("max timeout is %d minutes, silent for %d minutes (period is %s)"%\
(timeout_minutes,silent_minutes,period))
while tocheck:
date_test_ssh = TestSsh (hostname,key=remote_privatekey,username=self.name())
command = date_test_ssh.actual_command("echo hostname ; hostname; echo id; id; echo uname -a ; uname -a")
date = utils.system (command, silent=datetime.datetime.now() < graceout)
- if date==0:
- utils.header("Successfuly entered slice %s on %s"%(self.name(),hostname))
+ if expected: success = date==0
+ else: success = date!=0
+
+ if success:
+ utils.header("OK %s - slice=%s@%s"%(msg,self.name(),hostname))
tocheck.remove(hostname)
else:
# real nodes will have been checked once in case they're up - skip if not
return True
if datetime.datetime.now() > timeout:
for hostname in tocheck:
- utils.header("FAILURE to ssh into %s@%s"%(self.name(),hostname))
+ utils.header("FAILED %s slice=%s@%s"%(msg,self.name(),hostname))
return False
# wait for the period
time.sleep (period)