# step methods must take (self) and return a boolean (options is a member of the class)
def standby(minutes, dry_run):
# step methods must take (self) and return a boolean (options is a member of the class)
def standby(minutes, dry_run):
ref_name = method.__name__.replace('_ignore', '').replace('force_', '')
ref_method = TestPlc.__dict__[ref_name]
result = ref_method(self)
ref_name = method.__name__.replace('_ignore', '').replace('force_', '')
ref_method = TestPlc.__dict__[ref_name]
result = ref_method(self)
'populate', SEP,
'nodestate_show','nodestate_safeboot','nodestate_boot', SEP,
'qemu_list_all', 'qemu_list_mine', 'qemu_kill_all', 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,
+ 'sfa_install_core', 'sfa_install_sfatables', 'sfa_install_plc', 'sfa_install_client', SEPSFA,
'sfa_plcclean', 'sfa_dbclean', 'sfa_stop','sfa_uninstall', 'sfi_clean', SEPSFA,
'sfa_get_expires', SEPSFA,
'plc_db_dump' , 'plc_db_restore', SEP,
'sfa_plcclean', 'sfa_dbclean', 'sfa_stop','sfa_uninstall', 'sfi_clean', SEPSFA,
'sfa_get_expires', SEPSFA,
'plc_db_dump' , 'plc_db_restore', SEP,
- cached = file(has_sfa_cache_filename).read() == "yes"
- utils.header("build provides SFA (cached):%s" % cached)
+ with open(has_sfa_cache_filename) as cache:
+ cached = cache.read() == "yes"
+ utils.header("build provides SFA (cached):{}".format(cached))
return cached
# warning, we're now building 'sface' so let's be a bit more picky
# full builds are expected to return with 0 here
utils.header("Checking if build provides SFA package...")
return cached
# warning, we're now building 'sface' so let's be a bit more picky
# full builds are expected to return with 0 here
utils.header("Checking if build provides SFA package...")
TestPlc.default_steps.remove(step)
def __init__(self, plc_spec, options):
TestPlc.default_steps.remove(step)
def __init__(self, plc_spec, options):
- self.url = "https://%s:443/PLCAPI/" % plc_spec['vserverip']
- self.apiserver = TestApiserver(self.url, options.dry_run)
+ self.url = "https://{}:443/PLCAPI/".format(plc_spec['vserverip'])
+ self.apiserver = TestApiserver(self.url, options.dry_run)
(self.ssh_node_boot_timeout, self.ssh_node_boot_silent) = plc_spec['ssh_node_boot_timers']
(self.ssh_node_debug_timeout, self.ssh_node_debug_silent) = plc_spec['ssh_node_debug_timers']
(self.ssh_node_boot_timeout, self.ssh_node_boot_silent) = plc_spec['ssh_node_boot_timers']
(self.ssh_node_debug_timeout, self.ssh_node_debug_silent) = plc_spec['ssh_node_debug_timers']
# define the API methods on this object through xmlrpc
# would help, but not strictly necessary
def connect(self):
# define the API methods on this object through xmlrpc
# would help, but not strictly necessary
def connect(self):
def actual_command_in_guest(self,command, backslash=False):
raw1 = self.host_to_guest(command)
def actual_command_in_guest(self,command, backslash=False):
raw1 = self.host_to_guest(command)
def host_to_guest(self, command):
vservername = self.vservername
personality = self.options.personality
def host_to_guest(self, command):
vservername = self.vservername
personality = self.options.personality
def yum_check_installed(self, rpms):
if isinstance(rpms, list):
rpms=" ".join(rpms)
def yum_check_installed(self, rpms):
if isinstance(rpms, list):
rpms=" ".join(rpms)
# does a yum install in the vs, ignore yum retcod, check with rpm
def yum_install(self, rpms):
if isinstance(rpms, list):
rpms=" ".join(rpms)
# does a yum install in the vs, ignore yum retcod, check with rpm
def yum_install(self, rpms):
if isinstance(rpms, list):
rpms=" ".join(rpms)
# yum-complete-transaction comes with yum-utils, that is in vtest.pkgs
self.run_in_guest("yum-complete-transaction -y")
return self.yum_check_installed(rpms)
def auth_root(self):
# yum-complete-transaction comes with yum-utils, that is in vtest.pkgs
self.run_in_guest("yum-complete-transaction -y")
return self.yum_check_installed(rpms)
def auth_root(self):
- return {'Username' : self.plc_spec['settings']['PLC_ROOT_USER'],
- 'AuthMethod' : 'password',
- 'AuthString' : self.plc_spec['settings']['PLC_ROOT_PASSWORD'],
+ return {'Username' : self.plc_spec['settings']['PLC_ROOT_USER'],
+ 'AuthMethod' : 'password',
+ 'AuthString' : self.plc_spec['settings']['PLC_ROOT_PASSWORD'],
def locate_node(self, nodename):
for site in self.plc_spec['sites']:
for node in site['nodes']:
if node['name'] == nodename:
return site, node
def locate_node(self, nodename):
for site in self.plc_spec['sites']:
for node in site['nodes']:
if node['name'] == nodename:
return site, node
def locate_hostname(self, hostname):
for site in self.plc_spec['sites']:
for node in site['nodes']:
if node['node_fields']['hostname'] == hostname:
return(site, node)
def locate_hostname(self, hostname):
for site in self.plc_spec['sites']:
for node in site['nodes']:
if node['node_fields']['hostname'] == hostname:
return(site, node)
def locate_key(self, key_name):
for key in self.plc_spec['keys']:
if key['key_name'] == key_name:
return key
def locate_key(self, key_name):
for key in self.plc_spec['keys']:
if key['key_name'] == key_name:
return key
def locate_private_key_from_key_names(self, key_names):
# locate the first avail. key
def locate_private_key_from_key_names(self, key_names):
# locate the first avail. key
# transform into a dict { 'host_box' -> [ test_node .. ] }
result = {}
for (box,node) in tuples:
# transform into a dict { 'host_box' -> [ test_node .. ] }
result = {}
for (box,node) in tuples:
- for box,nodes in self.get_BoxNodes().iteritems():
- print box,":"," + ".join( [ node.name() for node in nodes ] )
+ for box,nodes in self.get_BoxNodes().items():
+ print(box,":"," + ".join( [ node.name() for node in nodes ] ))
return True
# make this a valid step
def qemu_kill_all(self):
'kill all qemu instances on the qemu boxes involved by this setup'
# this is the brute force version, kill all qemus on that host box
return True
# make this a valid step
def qemu_kill_all(self):
'kill all qemu instances on the qemu boxes involved by this setup'
# this is the brute force version, kill all qemus on that host box
# pass the first nodename, as we don't push template-qemu on testboxes
nodedir = nodes[0].nodedir()
TestBoxQemu(box, self.options.buildname).qemu_kill_all(nodedir)
# pass the first nodename, as we don't push template-qemu on testboxes
nodedir = nodes[0].nodedir()
TestBoxQemu(box, self.options.buildname).qemu_kill_all(nodedir)
# this is the brute force version, kill all qemus on that host box
TestBoxQemu(box, self.options.buildname).qemu_list_all()
return True
# this is the brute force version, kill all qemus on that host box
TestBoxQemu(box, self.options.buildname).qemu_list_all()
return True
# kill only the qemus related to this test
def qemu_list_mine(self):
'list qemu instances for our nodes'
# kill only the qemus related to this test
def qemu_list_mine(self):
'list qemu instances for our nodes'
# kill only the qemus related to this test
def qemu_clean_mine(self):
'cleanup (rm -rf) qemu instances for our nodes'
# kill only the qemus related to this test
def qemu_clean_mine(self):
'cleanup (rm -rf) qemu instances for our nodes'
# kill only the right qemus
def qemu_kill_mine(self):
'kill the qemu instances for our nodes'
# kill only the right qemus
def qemu_kill_mine(self):
'kill the qemu instances for our nodes'
"print cut'n paste-able stuff to export env variables to your shell"
# guess local domain from hostname
if TestPlc.exported_id > 1:
"print cut'n paste-able stuff to export env variables to your shell"
# guess local domain from hostname
if TestPlc.exported_id > 1:
- fqdn = "%s.%s" % (self.plc_spec['host_box'], domain)
- print "export BUILD=%s" % self.options.buildname
- print "export PLCHOSTLXC=%s" % fqdn
- print "export GUESTNAME=%s" % self.plc_spec['vservername']
+ fqdn = "{}.{}".format(self.plc_spec['host_box'], domain)
+ print("export BUILD={}".format(self.options.buildname))
+ print("export PLCHOSTLXC={}".format(fqdn))
+ print("export GUESTNAME={}".format(self.plc_spec['vservername']))
# find hostname of first node
hostname, qemubox = self.all_node_infos()[0]
# find hostname of first node
hostname, qemubox = self.all_node_infos()[0]
- print "export KVMHOST=%s.%s" % (qemubox, domain)
- print "export NODE=%s" % (hostname)
+ print("export KVMHOST={}.{}".format(qemubox, domain))
+ print("export NODE={}".format(hostname))
return True
# entry point
always_display_keys=['PLC_WWW_HOST', 'nodes', 'sites']
def show_pass(self, passno):
return True
# entry point
always_display_keys=['PLC_WWW_HOST', 'nodes', 'sites']
def show_pass(self, passno):
self.display_key_spec(key)
elif passno == 1:
if key not in ['sites', 'initscripts', 'slices', 'keys']:
self.display_key_spec(key)
elif passno == 1:
if key not in ['sites', 'initscripts', 'slices', 'keys']:
- print '+ ', key, ':', val
+ print('+ ', key, ':', val)
- print '+ ======== site', site['site_fields']['name']
- for k,v in site.iteritems():
+ print('+ ======== site', site['site_fields']['name'])
+ for k,v in site.items():
- print '+ ======== slice', slice['slice_fields']['name']
- for k,v in slice.iteritems():
+ print('+ ======== slice', slice['slice_fields']['name'])
+ for k,v in slice.items():
- print '+ fields',':',
- print 'max_nodes=',v['max_nodes'],
- print ''
+ print('+ fields',':', end=' ')
+ print('max_nodes=',v['max_nodes'], end=' ')
+ print('')
- print "+ node=%s host_box=%s" % (node['name'],node['host_box']),
- print "hostname=", node['node_fields']['hostname'],
- print "ip=", node['interface_fields']['ip']
+ print("+ node={} host_box={}".format(node['name'], node['host_box']), end=' ')
+ print("hostname=", node['node_fields']['hostname'], end=' ')
+ print("ip=", node['interface_fields']['ip'])
- print '+\tvserver address = root@%s:/vservers/%s' % (plc_spec['host_box'], plc_spec['vservername'])
- print '+\tIP = %s/%s' % (plc_spec['settings']['PLC_API_HOST'], plc_spec['vserverip'])
+ print('+\tvserver address = root@{}:/vservers/{}'.format(plc_spec['host_box'], plc_spec['vservername']))
+ print('+\tIP = {}/{}'.format(plc_spec['settings']['PLC_API_HOST'], plc_spec['vserverip']))
for site_spec in plc_spec['sites']:
for node_spec in site_spec['nodes']:
TestPlc.display_mapping_node(node_spec)
@staticmethod
def display_mapping_node(node_spec):
for site_spec in plc_spec['sites']:
for node_spec in site_spec['nodes']:
TestPlc.display_mapping_node(node_spec)
@staticmethod
def display_mapping_node(node_spec):
- print '+ NODE %s' % (node_spec['name'])
- print '+\tqemu box %s' % node_spec['host_box']
- print '+\thostname=%s' % node_spec['node_fields']['hostname']
+ print('+ NODE {}'.format(node_spec['name']))
+ print('+\tqemu box {}'.format(node_spec['host_box']))
+ print('+\thostname={}'.format(node_spec['node_fields']['hostname']))
# write a timestamp in /vservers/<>.timestamp
# cannot be inside the vserver, that causes vserver .. build to cough
# write a timestamp in /vservers/<>.timestamp
# cannot be inside the vserver, that causes vserver .. build to cough
# a first approx. is to store the timestamp close to the VM root like vs does
stamp_path = self.vm_timestamp_path()
stamp_dir = os.path.dirname(stamp_path)
# a first approx. is to store the timestamp close to the VM root like vs does
stamp_path = self.vm_timestamp_path()
stamp_dir = os.path.dirname(stamp_path)
- utils.system(self.test_ssh.actual_command("mkdir -p %s" % stamp_dir))
- return utils.system(self.test_ssh.actual_command("echo %d > %s" % (now, stamp_path))) == 0
+ utils.system(self.test_ssh.actual_command("mkdir -p {}".format(stamp_dir)))
+ return utils.system(self.test_ssh.actual_command("echo {:d} > {}".format(now, stamp_path))) == 0
# this is called inconditionnally at the beginning of the test sequence
# just in case this is a rerun, so if the vm is not running it's fine
def plcvm_delete(self):
"vserver delete the test myplc"
stamp_path = self.vm_timestamp_path()
# this is called inconditionnally at the beginning of the test sequence
# just in case this is a rerun, so if the vm is not running it's fine
def plcvm_delete(self):
"vserver delete the test myplc"
stamp_path = self.vm_timestamp_path()
- self.run_in_host("rm -f %s" % stamp_path)
- self.run_in_host("virsh -c lxc:// destroy %s" % self.vservername)
- self.run_in_host("virsh -c lxc:// undefine %s" % self.vservername)
- self.run_in_host("rm -fr /vservers/%s" % self.vservername)
+ self.run_in_host("rm -f {}".format(stamp_path))
+ self.run_in_host("virsh -c lxc:// destroy {}".format(self.vservername))
+ self.run_in_host("virsh -c lxc:// undefine {}".format(self.vservername))
+ self.run_in_host("rm -fr /vservers/{}".format(self.vservername))
# invoke initvm (drop support for vs)
script = "lbuild-initvm.sh"
script_options = ""
# pass the vbuild-nightly options to [lv]test-initvm
# invoke initvm (drop support for vs)
script = "lbuild-initvm.sh"
script_options = ""
# pass the vbuild-nightly options to [lv]test-initvm
- script_options += " -p %s" % self.options.personality
- script_options += " -d %s" % self.options.pldistro
- script_options += " -f %s" % self.options.fcdistro
- script_options += " -r %s" % repo_url
+ script_options += " -p {}".format(self.options.personality)
+ script_options += " -d {}".format(self.options.pldistro)
+ script_options += " -f {}".format(self.options.fcdistro)
+ script_options += " -r {}".format(repo_url)
- print "Cannot reverse lookup %s" % self.vserverip
- print "This is considered fatal, as this might pollute the test results"
+ print("Cannot reverse lookup {}".format(self.vserverip))
+ print("This is considered fatal, as this might pollute the test results")
- raise Exception, "Unsupported personality %r"%self.options.personality
- nodefamily = "%s-%s-%s" % (self.options.pldistro, self.options.fcdistro, arch)
+ raise Exception("Unsupported personality {}".format(self.options.personality))
+ nodefamily = "{}-{}-{}".format(self.options.pldistro, self.options.fcdistro, arch)
- pkgs_list.append("noderepo-%s" % nodefamily)
- pkgs_list.append("nodeimage-%s-plain" % nodefamily)
+ pkgs_list.append("noderepo-{}".format(nodefamily))
+ pkgs_list.append("nodeimage-{}-plain".format(nodefamily))
- for (var,value) in self.plc_spec['settings'].iteritems():
- fileconf.write('e %s\n%s\n'%(var,value))
+ for (var,value) in self.plc_spec['settings'].items():
+ fileconf.write('e {}\n{}\n'.format(var, value))
- utils.system('cat %s' % tmpname)
- self.run_in_guest_piped('cat %s' % tmpname, 'plc-config-tty')
- utils.system('rm %s' % tmpname)
+ utils.system('cat {}'.format(tmpname))
+ self.run_in_guest_piped('cat {}'.format(tmpname), 'plc-config-tty')
+ utils.system('rm {}'.format(tmpname))
def start_stop_service(self, service, start_or_stop):
"utility to start/stop a service with the special trick for f14"
if self.options.fcdistro != 'f14':
def start_stop_service(self, service, start_or_stop):
"utility to start/stop a service with the special trick for f14"
if self.options.fcdistro != 'f14':
else:
# patch /sbin/service so it does not reset environment
self.run_in_guest('sed -i -e \\"s,env -i,env,\\" /sbin/service')
# this is because our own scripts in turn call service
else:
# patch /sbin/service so it does not reset environment
self.run_in_guest('sed -i -e \\"s,env -i,env,\\" /sbin/service')
# this is because our own scripts in turn call service
- return self.run_in_guest("SYSTEMCTL_SKIP_REDIRECT=true service %s %s" % \
- (service, start_or_stop)) == 0
+ return self.run_in_guest("SYSTEMCTL_SKIP_REDIRECT=true service {} {}"\
+ .format(service, start_or_stop)) == 0
- src = "%(vm_root)s/etc/planetlab/%(prefix)s.%(ext)s" % locals()
- dst = "keys/%(vservername)s-debug.%(ext)s" % locals()
+ src = "{vm_root}/etc/planetlab/{prefix}.{ext}".format(**locals())
+ dst = "keys/{vservername}-debug.{ext}".format(**locals())
for site_spec in self.plc_spec['sites']:
test_site = TestSite(self,site_spec)
if (action != "add"):
for site_spec in self.plc_spec['sites']:
test_site = TestSite(self,site_spec)
if (action != "add"):
test_site.create_site()
test_site.create_users()
return True
def delete_all_sites(self):
"Delete all sites in PLC, and related objects"
test_site.create_site()
test_site.create_users()
return True
def delete_all_sites(self):
"Delete all sites in PLC, and related objects"
sites = self.apiserver.GetSites(self.auth_root(), {}, ['site_id','login_base'])
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['settings']['PLC_SLICE_PREFIX']:
continue
site_id = site['site_id']
sites = self.apiserver.GetSites(self.auth_root(), {}, ['site_id','login_base'])
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['settings']['PLC_SLICE_PREFIX']:
continue
site_id = site['site_id']
for site_spec in self.plc_spec['sites']:
test_site = TestSite(self, site_spec)
if action != "add":
for site_spec in self.plc_spec['sites']:
test_site = TestSite(self, site_spec)
if action != "add":
for node_spec in site_spec['nodes']:
test_node = TestNode(self, test_site, node_spec)
for node_spec in site_spec['nodes']:
test_node = TestNode(self, test_site, node_spec)
"create leases (on reservable nodes only, use e.g. run -c default -c resa)"
now = int(time.time())
grain = self.apiserver.GetLeaseGranularity(self.auth_root())
"create leases (on reservable nodes only, use e.g. run -c default -c resa)"
now = int(time.time())
grain = self.apiserver.GetLeaseGranularity(self.auth_root())
- print 'API answered grain=', grain
- start = (now/grain)*grain
+ print('API answered grain=', grain)
+ start = (now//grain)*grain
lease_addition = self.apiserver.AddLeases(self.auth_root(), nodes, lease_spec['slice'],
lease_spec['t_from'],lease_spec['t_until'])
if lease_addition['errors']:
lease_addition = self.apiserver.AddLeases(self.auth_root(), nodes, lease_spec['slice'],
lease_spec['t_from'],lease_spec['t_until'])
if lease_addition['errors']:
- utils.header('Leases on nodes %r for %s from %d (%s) until %d (%s)' % \
- (nodes, lease_spec['slice'],
- lease_spec['t_from'], TestPlc.timestamp_printable(lease_spec['t_from']),
- lease_spec['t_until'], TestPlc.timestamp_printable(lease_spec['t_until'])))
+ utils.header('Leases on nodes {} for {} from {:d} ({}) until {:d} ({})'\
+ .format(nodes, lease_spec['slice'],
+ lease_spec['t_from'], TestPlc.timestamp_printable(lease_spec['t_from']),
+ lease_spec['t_until'], TestPlc.timestamp_printable(lease_spec['t_until'])))
return ok
def delete_leases(self):
"remove all leases in the myplc side"
lease_ids = [ l['lease_id'] for l in self.apiserver.GetLeases(self.auth_root())]
return ok
def delete_leases(self):
"remove all leases in the myplc side"
lease_ids = [ l['lease_id'] for l in self.apiserver.GetLeases(self.auth_root())]
- utils.header("%s %s from %s until %s" % \
- (l['hostname'], l['name'],
- TestPlc.timestamp_printable(l['t_from']),
- TestPlc.timestamp_printable(l['t_until'])))
+ utils.header("{} {} from {} until {}"\
+ .format(l['hostname'], l['name'],
+ TestPlc.timestamp_printable(l['t_from']),
+ TestPlc.timestamp_printable(l['t_until'])))
test_site = TestSite(self,site_spec)
for node_spec in site_spec['nodes']:
test_node = TestNode(self, test_site, node_spec)
test_site = TestSite(self,site_spec)
for node_spec in site_spec['nodes']:
test_node = TestNode(self, test_site, node_spec)
- print 'nodegroups:', 'dealing with nodegroup',\
- nodegroupname, 'on nodes', group_nodes
+ print('nodegroups:', 'dealing with nodegroup',\
+ nodegroupname, 'on nodes', group_nodes)
# first, check if the nodetagtype is here
tag_types = self.apiserver.GetTagTypes(auth, {'tagname':nodegroupname})
if tag_types:
# first, check if the nodetagtype is here
tag_types = self.apiserver.GetTagTypes(auth, {'tagname':nodegroupname})
if tag_types:
else:
tag_type_id = self.apiserver.AddTagType(auth,
{'tagname' : nodegroupname,
else:
tag_type_id = self.apiserver.AddTagType(auth,
{'tagname' : nodegroupname,
- print 'located tag (type)', nodegroupname, 'as', tag_type_id
+ print('located tag (type)', nodegroupname, 'as', tag_type_id)
# create nodegroup
nodegroups = self.apiserver.GetNodeGroups(auth, {'groupname' : nodegroupname})
if not nodegroups:
self.apiserver.AddNodeGroup(auth, nodegroupname, tag_type_id, 'yes')
# create nodegroup
nodegroups = self.apiserver.GetNodeGroups(auth, {'groupname' : nodegroupname})
if not nodegroups:
self.apiserver.AddNodeGroup(auth, nodegroupname, tag_type_id, 'yes')
- print 'created nodegroup', nodegroupname, \
- 'from tagname', nodegroupname, 'and value', 'yes'
+ print('created nodegroup', nodegroupname, \
+ 'from tagname', nodegroupname, 'and value', 'yes')
# set node tag on all nodes, value='yes'
for nodename in group_nodes:
try:
self.apiserver.AddNodeTag(auth, nodename, nodegroupname, "yes")
except:
traceback.print_exc()
# set node tag on all nodes, value='yes'
for nodename in group_nodes:
try:
self.apiserver.AddNodeTag(auth, nodename, nodegroupname, "yes")
except:
traceback.print_exc()
- print 'node', nodename, 'seems to already have tag', nodegroupname
+ print('node', nodename, 'seems to already have tag', nodegroupname)
- print 'Mismatch node tag on node',nodename,'got',expect_yes
+ print('Mismatch node tag on node',nodename,'got',expect_yes)
- print 'Cannot find tag', nodegroupname, 'on node', nodename
+ print('Cannot find tag', nodegroupname, 'on node', nodename)
def nodes_check_boot_state(self, target_boot_state, timeout_minutes,
silent_minutes, period_seconds = 15):
if self.options.dry_run:
def nodes_check_boot_state(self, target_boot_state, timeout_minutes,
silent_minutes, period_seconds = 15):
if self.options.dry_run:
- print "node %s in state %s - expected %s" %\
- (self.hostname, self.last_boot_state, target_boot_state)
+ print("node {} in state {} - expected {}"\
+ .format(self.hostname, self.last_boot_state, target_boot_state))
timeout = timedelta(minutes=timeout_minutes)
graceout = timedelta(minutes=silent_minutes)
period = timedelta(seconds=period_seconds)
# the nodes that haven't checked yet - start with a full list and shrink over time
timeout = timedelta(minutes=timeout_minutes)
graceout = timedelta(minutes=silent_minutes)
period = timedelta(seconds=period_seconds)
# the nodes that haven't checked yet - start with a full list and shrink over time
tasks = [ CompleterTaskBootState(self,hostname) \
for (hostname,_) in self.all_node_infos() ]
message = 'check_boot_state={}'.format(target_boot_state)
tasks = [ CompleterTaskBootState(self,hostname) \
for (hostname,_) in self.all_node_infos() ]
message = 'check_boot_state={}'.format(target_boot_state)
return utils.system(command, silent=silent) == 0
def failure_epilogue(self):
return utils.system(command, silent=silent) == 0
def failure_epilogue(self):
- local_key = "keys/key_admin.rsa"
- utils.header("checking ssh access to nodes (expected in %s mode)" % message)
+ local_key = "keys/key_admin.rsa"
+ utils.header("checking ssh access to nodes (expected in {} mode)".format(message))
node_infos = self.all_node_infos()
tasks = [ CompleterTaskNodeSsh(nodename, qemuname, local_key,
boot_state=message, dry_run=self.options.dry_run) \
node_infos = self.all_node_infos()
tasks = [ CompleterTaskNodeSsh(nodename, qemuname, local_key,
boot_state=message, dry_run=self.options.dry_run) \
- print "initscript stamp %s not found in sliver %s"%\
- (self.stamp, self.test_sliver.name())
+ print("initscript stamp {} not found in sliver {}"\
+ .format(self.stamp, self.test_sliver.name()))
continue
stamp = slice_spec['initscriptstamp']
slicename = slice_spec['slice_fields']['name']
for nodename in slice_spec['nodenames']:
continue
stamp = slice_spec['initscriptstamp']
slicename = slice_spec['slice_fields']['name']
for nodename in slice_spec['nodenames']:
- print 'nodename', nodename, 'slicename', slicename, 'stamp', stamp
+ print('nodename', nodename, 'slicename', slicename, 'stamp', stamp)
site,node = self.locate_node(nodename)
# xxx - passing the wrong site - probably harmless
test_site = TestSite(self, site)
site,node = self.locate_node(nodename)
# xxx - passing the wrong site - probably harmless
test_site = TestSite(self, site)
tasks.append(CompleterTaskInitscript(test_sliver, stamp))
return Completer(tasks, message='check_initscripts').\
run (timedelta(minutes=5), timedelta(minutes=4), timedelta(seconds=10))
tasks.append(CompleterTaskInitscript(test_sliver, stamp))
return Completer(tasks, message='check_initscripts').\
run (timedelta(minutes=5), timedelta(minutes=4), timedelta(seconds=10))
def check_initscripts(self):
"check that the initscripts have triggered"
return self.do_check_initscripts()
def check_initscripts(self):
"check that the initscripts have triggered"
return self.do_check_initscripts()
"delete initscripts with PLCAPI"
for initscript in self.plc_spec['initscripts']:
initscript_name = initscript['initscript_fields']['name']
"delete initscripts with PLCAPI"
for initscript in self.plc_spec['initscripts']:
initscript_name = initscript['initscript_fields']['name']
def _speed_up_slices(self, p, r):
# create the template on the server-side
def _speed_up_slices(self, p, r):
# create the template on the server-side
self.test_ssh.copy_abs(template, remote)
# Add a conf file
if not self.apiserver.GetConfFiles(self.auth_root(),
self.test_ssh.copy_abs(template, remote)
# Add a conf file
if not self.apiserver.GetConfFiles(self.auth_root(),
def debug_nodemanager(self):
"sets verbose mode for nodemanager, and speeds up cycle even more (needs speed_up_slices first)"
def debug_nodemanager(self):
"sets verbose mode for nodemanager, and speeds up cycle even more (needs speed_up_slices first)"
with open(template,"w") as template_file:
template_file.write('OPTIONS="-p 10 -r 6 -v -d"\n')
in_vm = "/var/www/html/PlanetLabConf/nodemanager"
with open(template,"w") as template_file:
template_file.write('OPTIONS="-p 10 -r 6 -v -d"\n')
in_vm = "/var/www/html/PlanetLabConf/nodemanager"
# locate the TestSliver instances involved, and cache them in the spec instance
spec['s_sliver'] = self.locate_sliver_obj_cross(spec['server_node'], spec['server_slice'], other_plcs)
spec['c_sliver'] = self.locate_sliver_obj_cross(spec['client_node'], spec['client_slice'], other_plcs)
# locate the TestSliver instances involved, and cache them in the spec instance
spec['s_sliver'] = self.locate_sliver_obj_cross(spec['server_node'], spec['server_slice'], other_plcs)
spec['c_sliver'] = self.locate_sliver_obj_cross(spec['client_node'], spec['client_slice'], other_plcs)
- message = "Will check TCP between s=%s and c=%s" % \
- (spec['s_sliver'].name(), spec['c_sliver'].name())
+ message = "Will check TCP between s={} and c={}"\
+ .format(spec['s_sliver'].name(), spec['c_sliver'].name())
utils.header(message)
# we need to check network presence in both slivers, but also
# avoid to insert a sliver several times
utils.header(message)
# we need to check network presence in both slivers, but also
# avoid to insert a sliver several times
"runs PLCAPI stress test, that checks Add/Update/Delete on all types - preserves contents"
# install the stress-test in the plc image
location = "/usr/share/plc_api/plcsh_stress_test.py"
"runs PLCAPI stress test, that checks Add/Update/Delete on all types - preserves contents"
# install the stress-test in the plc image
location = "/usr/share/plc_api/plcsh_stress_test.py"
utils.header("********** Regular yum failed - special workaround in place, 2nd chance")
code, cached_rpm_path = \
utils.output_of(self.actual_command_in_guest('find /var/cache/yum -name sfa-client\*.rpm'))
utils.header("********** Regular yum failed - special workaround in place, 2nd chance")
code, cached_rpm_path = \
utils.output_of(self.actual_command_in_guest('find /var/cache/yum -name sfa-client\*.rpm'))
return self.yum_check_installed("sfa-client")
def sfa_dbclean(self):
"thoroughly wipes off the SFA database"
return self.run_in_guest("sfaadmin reg nuke") == 0 or \
self.run_in_guest("sfa-nuke.py") == 0 or \
return self.yum_check_installed("sfa-client")
def sfa_dbclean(self):
"thoroughly wipes off the SFA database"
return self.run_in_guest("sfaadmin reg nuke") == 0 or \
self.run_in_guest("sfa-nuke.py") == 0 or \
for spec_name in ['pi_spec','user_spec']:
user_spec = auth_sfa_spec[spec_name]
for spec_name in ['pi_spec','user_spec']:
user_spec = auth_sfa_spec[spec_name]
self.apiserver.DeletePerson(self.auth_root(),username)
except:
# this in fact is expected as sites delete their members
self.apiserver.DeletePerson(self.auth_root(),username)
except:
# this in fact is expected as sites delete their members
def confsubdir(self, dirname, clean, dry_run=False):
def confsubdir(self, dirname, clean, dry_run=False):
return subdirname
def conffile_clean(self, filename):
filename=self.conffile(filename)
return subdirname
def conffile_clean(self, filename):
filename=self.conffile(filename)
###
def sfa_configure(self):
"run sfa-config-tty"
tmpname = self.conffile("sfa-config-tty")
with open(tmpname,'w') as fileconf:
###
def sfa_configure(self):
"run sfa-config-tty"
tmpname = self.conffile("sfa-config-tty")
with open(tmpname,'w') as fileconf:
- for (var,value) in self.plc_spec['sfa']['settings'].iteritems():
- fileconf.write('e %s\n%s\n'%(var,value))
+ for (var,value) in self.plc_spec['sfa']['settings'].items():
+ fileconf.write('e {}\n{}\n'.format(var, value))
- utils.system('cat %s' % tmpname)
- self.run_in_guest_piped('cat %s' % tmpname, 'sfa-config-tty')
+ utils.system('cat {}'.format(tmpname))
+ self.run_in_guest_piped('cat {}'.format(tmpname), 'sfa-config-tty')
- return '<aggregate addr="%s" hrn="%s" port="%r"/>' % \
- (self.vserverip, self.plc_spec['sfa']['settings']['SFA_REGISTRY_ROOT_AUTH'], port)
+ return '<aggregate addr="{}" hrn="{}" port="{}"/>'\
+ .format(self.vserverip, self.plc_spec['sfa']['settings']['SFA_REGISTRY_ROOT_AUTH'], port)
- return '<registry addr="%s" hrn="%s" port="12345"/>' % \
- (self.vserverip, self.plc_spec['sfa']['settings']['SFA_REGISTRY_ROOT_AUTH'])
+ return '<registry addr="{}" hrn="{}" port="12345"/>'\
+ .format(self.vserverip, self.plc_spec['sfa']['settings']['SFA_REGISTRY_ROOT_AUTH'])
return True
agg_fname = self.conffile("agg.xml")
with open(agg_fname,"w") as out:
return True
agg_fname = self.conffile("agg.xml")
with open(agg_fname,"w") as out:
- out.write("<aggregates>%s</aggregates>\n" % \
- " ".join([ plc.aggregate_xml_line() for plc in other_plcs ]))
- utils.header("(Over)wrote %s" % agg_fname)
+ out.write("<aggregates>{}</aggregates>\n"\
+ .format(" ".join([ plc.aggregate_xml_line() for plc in other_plcs ])))
+ utils.header("(Over)wrote {}".format(agg_fname))
reg_fname=self.conffile("reg.xml")
with open(reg_fname,"w") as out:
reg_fname=self.conffile("reg.xml")
with open(reg_fname,"w") as out:
- out.write("<registries>%s</registries>\n" % \
- " ".join([ plc.registry_xml_line() for plc in other_plcs ]))
- utils.header("(Over)wrote %s" % reg_fname)
+ out.write("<registries>{}</registries>\n"\
+ .format(" ".join([ plc.registry_xml_line() for plc in other_plcs ])))
+ utils.header("(Over)wrote {}".format(reg_fname))
for slice_spec in self.plc_spec['sfa']['auth_sfa_specs']:
test_slice = TestAuthSfa(self, slice_spec)
dir_basename = os.path.basename(test_slice.sfi_path())
for slice_spec in self.plc_spec['sfa']['auth_sfa_specs']:
test_slice = TestAuthSfa(self, slice_spec)
dir_basename = os.path.basename(test_slice.sfi_path())
clean=True, dry_run=self.options.dry_run)
test_slice.sfi_configure(dir_name)
# push into the remote /root/sfi area
location = test_slice.sfi_path()
clean=True, dry_run=self.options.dry_run)
test_slice.sfi_configure(dir_name)
# push into the remote /root/sfi area
location = test_slice.sfi_path()
self.test_ssh.mkdir(remote, abs=True)
# need to strip last level or remote otherwise we get an extra dir level
self.test_ssh.copy_abs(dir_name, os.path.dirname(remote), recursive=True)
self.test_ssh.mkdir(remote, abs=True)
# need to strip last level or remote otherwise we get an extra dir level
self.test_ssh.copy_abs(dir_name, os.path.dirname(remote), recursive=True)
for slice_spec in self.plc_spec['sfa']['auth_sfa_specs']:
test_slice = TestAuthSfa(self, slice_spec)
in_vm = test_slice.sfi_path()
for slice_spec in self.plc_spec['sfa']['auth_sfa_specs']:
test_slice = TestAuthSfa(self, slice_spec)
in_vm = test_slice.sfi_path()
"creates random entries in the PLCAPI"
# install the stress-test in the plc image
location = "/usr/share/plc_api/plcsh_stress_test.py"
"creates random entries in the PLCAPI"
# install the stress-test in the plc image
location = "/usr/share/plc_api/plcsh_stress_test.py"
self.test_ssh.copy_abs("plcsh_stress_test.py", remote)
command = location
command += " -- --preserve --short-names"
self.test_ssh.copy_abs("plcsh_stress_test.py", remote)
command = location
command += " -- --preserve --short-names"
# (3) get the nodes /var/log and store is as logs/node.var-log.<node>/*
# (4) as far as possible get the slice's /var/log as logs/sliver.var-log.<sliver>/*
# (1.a)
# (3) get the nodes /var/log and store is as logs/node.var-log.<node>/*
# (4) as far as possible get the slice's /var/log as logs/sliver.var-log.<sliver>/*
# (1.a)
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)
test_node.gather_qemu_logs()
# (3)
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)
test_node.gather_qemu_logs()
# (3)
self.gather_slivers_var_logs()
return True
def gather_slivers_var_logs(self):
for test_sliver in self.all_sliver_objs():
remote = test_sliver.tar_var_logs()
self.gather_slivers_var_logs()
return True
def gather_slivers_var_logs(self):
for test_sliver in self.all_sliver_objs():
remote = test_sliver.tar_var_logs()
- utils.system("mkdir -p logs/sliver.var-log.%s" % test_sliver.name())
- command = remote + " | tar -C logs/sliver.var-log.%s -xf -" % test_sliver.name()
+ utils.system("mkdir -p logs/sliver.var-log.{}".format(test_sliver.name()))
+ command = remote + " | tar -C logs/sliver.var-log.{} -xf -".format(test_sliver.name())
test_node = TestNode(self, test_site, node_spec)
test_ssh = TestSsh(test_node.name(), key="keys/key_admin.rsa")
command = test_ssh.actual_command("tar -C /var/log -cf - .")
test_node = TestNode(self, test_site, node_spec)
test_ssh = TestSsh(test_node.name(), key="keys/key_admin.rsa")
command = test_ssh.actual_command("tar -C /var/log -cf - .")
- command = command + "| tar -C logs/node.var-log.%s -xf -" % test_node.name()
- utils.system("mkdir -p logs/node.var-log.%s" % test_node.name())
+ command = command + "| tar -C logs/node.var-log.{} -xf -".format(test_node.name())
+ utils.system("mkdir -p logs/node.var-log.{}".format(test_node.name()))
def plc_db_dump(self):
'dump the planetlab5 DB in /root in the PLC - filename has time'
dump=self.dbfile("planetab5")
self.run_in_guest('pg_dump -U pgsqluser planetlab5 -f '+ dump)
def plc_db_dump(self):
'dump the planetlab5 DB in /root in the PLC - filename has time'
dump=self.dbfile("planetab5")
self.run_in_guest('pg_dump -U pgsqluser planetlab5 -f '+ dump)