admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 1 | #!/usr/bin/env python |
kelvin-onlab | b87672e | 2015-01-16 10:58:34 -0800 | [diff] [blame] | 2 | """ |
| 3 | Created on 26-Oct-2012 |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 4 | |
kelvin-onlab | b87672e | 2015-01-16 10:58:34 -0800 | [diff] [blame] | 5 | author:: Anil Kumar ( anilkumar.s@paxterrasolutions.com ) |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 6 | |
| 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-onlab | b87672e | 2015-01-16 10:58:34 -0800 | [diff] [blame] | 10 | ( at your option ) any later version. |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 11 | |
| 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-onlab | b87672e | 2015-01-16 10:58:34 -0800 | [diff] [blame] | 18 | along with TestON. If not, see <http://www.gnu.org/licenses/>. |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 19 | |
| 20 | |
kelvin-onlab | b87672e | 2015-01-16 10:58:34 -0800 | [diff] [blame] | 21 | """ |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 22 | from drivers.common.clidriver import CLI |
| 23 | |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 24 | |
kelvin-onlab | b87672e | 2015-01-16 10:58:34 -0800 | [diff] [blame] | 25 | class RemoteTestBedDriver( CLI ): |
| 26 | # The common functions for emulator included in RemoteTestBedDriver |
| 27 | |
| 28 | def __init__( self ): |
| 29 | super( CLI, self ).__init__() |
| 30 | |
| 31 | def connect( self, **connectargs ): |
| 32 | for key in connectargs: |
| 33 | vars( self )[ 'vm_' + key ] = connectargs[ key ] |
| 34 | |
| 35 | remote_user_name = main.componentDictionary[ |
| 36 | self.name ][ 'remote_user_name' ] |
| 37 | remote_ip_address = main.componentDictionary[ |
| 38 | self.name ][ 'remote_ip_address' ] |
| 39 | remote_port = main.componentDictionary[ self.name ][ 'remote_port' ] |
| 40 | remote_pwd = main.componentDictionary[ self.name ][ 'remote_pwd' ] |
| 41 | |
| 42 | self.handle = super( |
| 43 | RemoteTestBedDriver, |
| 44 | self ).connect( |
| 45 | user_name=remote_user_name, |
| 46 | ip_address=remote_ip_address, |
| 47 | port=remote_port, |
| 48 | pwd=remote_pwd ) |
| 49 | |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 50 | if self.handle: |
kelvin-onlab | b87672e | 2015-01-16 10:58:34 -0800 | [diff] [blame] | 51 | self.execute( cmd="\n", prompt="\$|>|#", timeout=10 ) |
| 52 | self.execute( cmd="SET CYGWIN=notty", prompt="\$|>|#", timeout=10 ) |
| 53 | self.execute( cmd="\n", prompt="\$|>|#", timeout=10 ) |
| 54 | main.log.info( |
| 55 | "ssh " + |
| 56 | self.vm_user_name + |
| 57 | '@' + |
| 58 | self.vm_ip_address ) |
| 59 | self.execute( |
| 60 | cmd="ssh " + |
| 61 | self.vm_user_name + |
| 62 | '@' + |
| 63 | self.vm_ip_address, |
| 64 | prompt="(.*)", |
| 65 | timeout=10 ) |
| 66 | self.execute( cmd="\n", prompt="assword:", timeout=10 ) |
| 67 | self.execute( cmd=self.vm_pwd, prompt="\$", timeout=10 ) |
| 68 | |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 69 | return self.handle |
kelvin-onlab | b87672e | 2015-01-16 10:58:34 -0800 | [diff] [blame] | 70 | else: |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 71 | return main.FALSE |