default_steps = ['uninstall','install','install_rpm',
'configure', 'start', SEP,
- 'store_keys', 'initscripts',
+ 'store_keys', 'clear_known_hosts', 'initscripts', SEP,
'sites', 'nodes', 'slices', 'nodegroups', SEP,
'init_node','bootcd', 'configure_qemu', SEP,
'kill_all_qemus', 'start_nodes', SEP,
import utils
from TestUser import TestUser
from TestBox import TestBox
+from TestSsh import TestSsh
class TestNode:
remote_log="%s/qemu.log"%self.nodedir()
local_log="logs/%s-qemu.log"%self.name()
self.test_box().test_ssh.fetch(remote_log,local_log)
+
+ def clear_known_hosts (self):
+ TestSsh(self.name()).clear_known_hosts()
+ return True
def node_mapper (method):
def actual(self):
overall=True
+ node_method = TestNode.__dict__[method.__name__]
for site_spec in self.plc_spec['sites']:
test_site = TestSite (self,site_spec)
for node_spec in site_spec['nodes']:
test_node = TestNode (self,test_site,node_spec)
- node_method = TestNode.__dict__[method.__name__]
if not node_method(test_node): overall=False
return overall
return actual
+def slice_mapper_options (method):
+ def actual(self):
+ overall=True
+ slice_method = TestSlice.__dict__[method.__name__]
+ for slice_spec in self.plc_spec['slices']:
+ site_spec = self.locate_site (slice_spec['sitename'])
+ test_site = TestSite(self,site_spec)
+ test_slice=TestSlice(self,test_site,slice_spec)
+ if not slice_method(test_slice,self.options): overall=False
+ return overall
+ return actual
+
class TestPlc:
def __init__ (self,plc_spec,options):
utils.header('Created Slice %s'%slice['slice_fields']['name'])
return True
- def check_slices(self):
- for slice_spec in self.plc_spec['slices']:
- site_spec = self.locate_site (slice_spec['sitename'])
- test_site = TestSite(self,site_spec)
- test_slice=TestSlice(self,test_site,slice_spec)
- status=test_slice.do_check_slice(self.options)
- if (not status):
- return False
- return status
+ @slice_mapper_options
+ def check_slice(self): pass
+
+ @node_mapper
+ def clear_known_hosts (self): pass
def start_nodes (self):
utils.header("Starting nodes")
TestSite(self,site_spec).start_nodes (self.options)
return True
-
def locate_first_sliver (self):
slice_spec = self.plc_spec['slices'][0]
slicename = slice_spec['slice_fields']['name']
utils.header("Adding initscript %s in %s"%(isname,slice_name))
self.test_plc.apiserver.AddSliceAttribute(self.test_plc.auth_root(), slice_name,'initscript',isname)
-# def clear_known_hosts (self):
-# utils.header("Messing with known_hosts for slice %s"%self.name())
-# hostnames=[]
-# # scan nodenames
-# for nodename in self.slice_spec['nodenames']:
-# (site_spec,node_spec) = self.test_plc.locate_node(nodename)
-# hostnames.append(node_spec['node_fields']['hostname'])
-# self.test_plc.run_in_guest("sed -i -e /^%s/d /root/.ssh/known_hosts"%node_spec['node_fields']['hostname'])
-# #scan public key and update the known_host file in the root image
-# self.test_plc.scan_publicKeys(hostnames)
-
def locate_key(self):
# locate the first avail. key
found=False
found=True
return (found,privatekey)
- def do_check_slice(self,options,minutes=3):
-# self.clear_known_hosts()
+ def check_slice(self,options,minutes=3):
timeout = datetime.datetime.now()+datetime.timedelta(minutes=minutes)
# locate a key
command += self.key_part()
command += "%s:%s/%s %s"%(self.hostname_part(),self.buildname,remote_file,local_file)
utils.system(command)
+
+ # this is only to avoid harmless message when host cannot be identified
+ # convenience only
+ # the only place where this is needed is when tring to reach a slice in a node,
+ # which is done from the test master box
+ def clear_known_hosts (self):
+ known_hosts = "%s/.ssh/known_hosts"%os.getenv("HOME")
+ utils.header("Clearing entry for %s in %s"%(self.hostname,known_hosts))
+ utils.system("sed -i -e /^%s/d %s"%(self.hostname,known_hosts))
+