- restarted=[]
- tocheck=[]
- for nodename in slice_spec['nodenames']:
- (site_spec,node_spec) = self.test_plc.locate_node(nodename)
- tocheck.append(node_spec['node_fields']['hostname'])
-
- while tocheck:
- for hostname in tocheck:
- (site_spec,node_spec) = self.test_plc.locate_hostname(hostname)
- date_test_ssh = TestSsh (hostname,key=remote_privatekey,username=self.name())
- # this can be ran locally as we have the key
- utils.header('Trying to enter into slice %s@%s'%(self.name(),hostname))
- date = date_test_ssh.run("date")
- if not date:
- utils.header("Successfuly entered slice %s on %s"%(self.name(),hostname))
- tocheck.remove(hostname)
+ nodename=slice_spec['nodenames'][0]
+ site_spec, node_spec = self.test_plc.locate_node(nodename)
+ hostname=node_spec['node_fields']['hostname']
+
+ if expected:
+ msg="{} to return TRUE from ssh".format(command)
+ else:
+ msg="{} to return FALSE from ssh".format(command)
+
+ utils.header("checking {} -- slice {} on node {}".format(msg, self.name(), hostname))
+ site_spec, node_spec = self.test_plc.locate_hostname(hostname)
+ test_ssh = TestSsh (hostname, key=private_key, username=self.name())
+ full_command = test_ssh.actual_command(command)
+ retcod = utils.system (full_command, silent=True, timeout=10)
+ if getattr(options, 'dry_run', None):
+ return True
+ if expected:
+ success = retcod==0
+ else:
+ success = retcod!=0
+ if not success:
+ utils.header ("WRONG RESULT for {}".format(msg))
+ return success
+
+ # for TestPlc.slice_mapper__tasks
+ # check that /vservers/<> is present/deleted
+ def slice_fs_present__tasks (self, options):
+ "checks that /vservers/<slicename> exists on the filesystem"
+ return self.check_rootfs_tasks(options, expected=True)
+ def slice_fs_deleted__tasks (self, options):
+ "checks that /vservers/<slicename> has been properly wiped off"
+ return self.check_rootfs_tasks (options, expected=False)
+
+ def check_rootfs_tasks (self, options, expected):
+ # use constant admin key
+ local_key = "keys/key_admin.rsa"
+ node_infos = self.test_plc.all_node_infos()
+ rootfs="/vservers/{}".format(self.name())
+ class CompleterTaskRootfs (CompleterTaskNodeSsh):
+ def __init__ (self, nodename, qemuname):
+ CompleterTaskNodeSsh.__init__(self, nodename, qemuname, local_key, expected=expected,
+ command="ls -d {}".format(rootfs))
+ def failure_epilogue (self):
+ if expected:
+ print("Could not stat {} - was expected to be present".format(rootfs))