blob: eaeacd92bb345e432c6963a47334cf7763d51232 [file] [log] [blame]
adminbae64d82013-08-01 10:50:15 -07001#!/usr/bin/env python
kelvin-onlabb87672e2015-01-16 10:58:34 -08002"""
3Created on 26-Oct-2012
adminbae64d82013-08-01 10:50:15 -07004
kelvin-onlabb87672e2015-01-16 10:58:34 -08005author:: Anil Kumar ( anilkumar.s@paxterrasolutions.com )
adminbae64d82013-08-01 10:50:15 -07006
7 TestON is free software: you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation, either version 2 of the License, or
kelvin-onlabb87672e2015-01-16 10:58:34 -080010 ( at your option ) any later version.
adminbae64d82013-08-01 10:50:15 -070011
12 TestON is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
kelvin-onlabb87672e2015-01-16 10:58:34 -080018 along with TestON. If not, see <http://www.gnu.org/licenses/>.
adminbae64d82013-08-01 10:50:15 -070019
20
kelvin-onlabb87672e2015-01-16 10:58:34 -080021"""
adminbae64d82013-08-01 10:50:15 -070022import time
23import pexpect
kelvin-onlabb87672e2015-01-16 10:58:34 -080024import struct
25import fcntl
26import os
adminbae64d82013-08-01 10:50:15 -070027import sys
kelvin-onlabb87672e2015-01-16 10:58:34 -080028import signal
29import sys
30sys.path.append( "../" )
adminbae64d82013-08-01 10:50:15 -070031from drivers.common.clidriver import CLI
32
adminbae64d82013-08-01 10:50:15 -070033
kelvin-onlabb87672e2015-01-16 10:58:34 -080034class RemoteTestBedDriver( CLI ):
35 # The common functions for emulator included in RemoteTestBedDriver
36
37 def __init__( self ):
38 super( CLI, self ).__init__()
39
40 def connect( self, **connectargs ):
41 for key in connectargs:
42 vars( self )[ 'vm_' + key ] = connectargs[ key ]
43
44 remote_user_name = main.componentDictionary[
45 self.name ][ 'remote_user_name' ]
46 remote_ip_address = main.componentDictionary[
47 self.name ][ 'remote_ip_address' ]
48 remote_port = main.componentDictionary[ self.name ][ 'remote_port' ]
49 remote_pwd = main.componentDictionary[ self.name ][ 'remote_pwd' ]
50
51 self.handle = super(
52 RemoteTestBedDriver,
53 self ).connect(
54 user_name=remote_user_name,
55 ip_address=remote_ip_address,
56 port=remote_port,
57 pwd=remote_pwd )
58
adminbae64d82013-08-01 10:50:15 -070059 if self.handle:
kelvin-onlabb87672e2015-01-16 10:58:34 -080060 self.execute( cmd="\n", prompt="\$|>|#", timeout=10 )
61 self.execute( cmd="SET CYGWIN=notty", prompt="\$|>|#", timeout=10 )
62 self.execute( cmd="\n", prompt="\$|>|#", timeout=10 )
63 main.log.info(
64 "ssh " +
65 self.vm_user_name +
66 '@' +
67 self.vm_ip_address )
68 self.execute(
69 cmd="ssh " +
70 self.vm_user_name +
71 '@' +
72 self.vm_ip_address,
73 prompt="(.*)",
74 timeout=10 )
75 self.execute( cmd="\n", prompt="assword:", timeout=10 )
76 self.execute( cmd=self.vm_pwd, prompt="\$", timeout=10 )
77
adminbae64d82013-08-01 10:50:15 -070078 return self.handle
kelvin-onlabb87672e2015-01-16 10:58:34 -080079 else:
adminbae64d82013-08-01 10:50:15 -070080 return main.FALSE