def retrieveResults(self, dest_path): if not self.node_ip: self.log.error('Attempting to retrieve results for %s but no node IP address'%self) return constants.NO_IP try: code, stdout, stderr = utils.execute_command( 'ssh -q -o BatchMode=yes -o UserKnownHostsFile=/dev/null' ' -o StrictHostKeyChecking=no -i %s %s@%s cat result.txt' % ( Configuration().NODE_KEY, Configuration().NODE_USERNAME, self.node_ip), silent=True, return_streams=True ) self.log.info('Result: %s (Err: %s)'%(stdout, stderr)) self.log.info('Downloading logs for %s'%self) utils.copy_logs( [ '/home/jenkins/workspace/testing/logs/*', '/home/jenkins/run_test*', '/etc/nova/*', '/etc/swift/*', '/etc/cinder/*', '/etc/keystone/*', ], dest_path, self.node_ip, Configuration().NODE_USERNAME, Configuration().NODE_KEY, upload=False ) self.log.info('Downloading dom0 logs for %s'%self) utils.copy_dom0_logs( self.node_ip, Configuration().NODE_USERNAME, Configuration().NODE_KEY, dest_path ) if code != 0: # This node is broken somehow... Mark it as aborted if self.result and self.result.startswith('Aborted: '): return self.result return constants.NORESULT return stdout.splitlines()[0] except Exception, e: self.log.exception(e) return constants.COPYFAIL
def test_copying(self, executor_cls): xecutor = executor_cls.return_value = executor.FakeExecutor() expected_execution = executor.FakeExecutor() this_host = localhost.Localhost() n = node.Node({ 'node_username': '******', 'node_host': 'ip', 'node_keyfile': 'key'}) expected_execution.pipe_run( n.command_to_get_dom0_files_as_tgz_to_stdout( '/var/log/messages* /var/log/SMlog* /var/log/xensource* /opt/nodepool-scripts/*.log'), this_host.commands_to_extract_stdout_tgz_to('target')) utils.copy_dom0_logs('ip', 'user', 'key', 'target') self.assertEquals( expected_execution.executed_commands, xecutor.executed_commands)
def test_copying(self, executor_cls): xecutor = executor_cls.return_value = executor.FakeExecutor() expected_execution = executor.FakeExecutor() this_host = localhost.Localhost() n = node.Node({ 'node_username': '******', 'node_host': 'ip', 'node_keyfile': 'key' }) expected_execution.pipe_run( n.command_to_get_dom0_files_as_tgz_to_stdout( '/var/log/messages* /var/log/SMlog* /var/log/xensource* /opt/nodepool-scripts/*.log' ), this_host.commands_to_extract_stdout_tgz_to('target')) utils.copy_dom0_logs('ip', 'user', 'key', 'target') self.assertEquals(expected_execution.executed_commands, xecutor.executed_commands)