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 |
Jeremy Ronquillo | 4d5f1d0 | 2017-10-13 20:23:57 +0000 | [diff] [blame] | 4 | Copyright 2012 Open Networking Foundation (ONF) |
Jeremy Songster | ae01bba | 2016-07-11 15:39:17 -0700 | [diff] [blame] | 5 | |
| 6 | Please refer questions to either the onos test mailing list at <onos-test@onosproject.org>, |
| 7 | the System Testing Plans and Results wiki page at <https://wiki.onosproject.org/x/voMg>, |
| 8 | or the System Testing Guide page at <https://wiki.onosproject.org/x/WYQg> |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 9 | |
kelvin-onlab | b87672e | 2015-01-16 10:58:34 -0800 | [diff] [blame] | 10 | author:: Anil Kumar ( anilkumar.s@paxterrasolutions.com ) |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 11 | |
| 12 | TestON is free software: you can redistribute it and/or modify |
| 13 | it under the terms of the GNU General Public License as published by |
| 14 | the Free Software Foundation, either version 2 of the License, or |
kelvin-onlab | b87672e | 2015-01-16 10:58:34 -0800 | [diff] [blame] | 15 | ( at your option ) any later version. |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 16 | |
| 17 | TestON is distributed in the hope that it will be useful, |
| 18 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 19 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 20 | GNU General Public License for more details. |
| 21 | |
| 22 | You should have received a copy of the GNU General Public License |
kelvin-onlab | b87672e | 2015-01-16 10:58:34 -0800 | [diff] [blame] | 23 | along with TestON. If not, see <http://www.gnu.org/licenses/>. |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 24 | |
| 25 | |
kelvin-onlab | b87672e | 2015-01-16 10:58:34 -0800 | [diff] [blame] | 26 | """ |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 27 | from drivers.common.clidriver import CLI |
| 28 | |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 29 | |
kelvin-onlab | b87672e | 2015-01-16 10:58:34 -0800 | [diff] [blame] | 30 | class RemoteTestBedDriver( CLI ): |
| 31 | # The common functions for emulator included in RemoteTestBedDriver |
| 32 | |
| 33 | def __init__( self ): |
Devin Lim | dc78e20 | 2017-06-09 18:30:07 -0700 | [diff] [blame] | 34 | super( RemoteTestBedDriver, self ).__init__() |
kelvin-onlab | b87672e | 2015-01-16 10:58:34 -0800 | [diff] [blame] | 35 | |
| 36 | def connect( self, **connectargs ): |
| 37 | for key in connectargs: |
| 38 | vars( self )[ 'vm_' + key ] = connectargs[ key ] |
| 39 | |
| 40 | remote_user_name = main.componentDictionary[ |
| 41 | self.name ][ 'remote_user_name' ] |
| 42 | remote_ip_address = main.componentDictionary[ |
| 43 | self.name ][ 'remote_ip_address' ] |
| 44 | remote_port = main.componentDictionary[ self.name ][ 'remote_port' ] |
| 45 | remote_pwd = main.componentDictionary[ self.name ][ 'remote_pwd' ] |
| 46 | |
| 47 | self.handle = super( |
| 48 | RemoteTestBedDriver, |
| 49 | self ).connect( |
| 50 | user_name=remote_user_name, |
| 51 | ip_address=remote_ip_address, |
| 52 | port=remote_port, |
| 53 | pwd=remote_pwd ) |
| 54 | |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 55 | if self.handle: |
Devin Lim | dc78e20 | 2017-06-09 18:30:07 -0700 | [diff] [blame] | 56 | self.execute( cmd="\n", prompt=self.prompt, timeout=10 ) |
| 57 | self.execute( cmd="SET CYGWIN=notty", prompt=self.prompt, timeout=10 ) |
| 58 | self.execute( cmd="\n", prompt=self.prompt, timeout=10 ) |
kelvin-onlab | b87672e | 2015-01-16 10:58:34 -0800 | [diff] [blame] | 59 | main.log.info( |
| 60 | "ssh " + |
| 61 | self.vm_user_name + |
| 62 | '@' + |
| 63 | self.vm_ip_address ) |
| 64 | self.execute( |
| 65 | cmd="ssh " + |
| 66 | self.vm_user_name + |
| 67 | '@' + |
| 68 | self.vm_ip_address, |
| 69 | prompt="(.*)", |
| 70 | timeout=10 ) |
Devin Lim | dc78e20 | 2017-06-09 18:30:07 -0700 | [diff] [blame] | 71 | self.execute( cmd="\n", prompt="password:", timeout=10 ) |
| 72 | self.execute( cmd=self.vm_pwd, prompt=self.prompt, timeout=10 ) |
kelvin-onlab | b87672e | 2015-01-16 10:58:34 -0800 | [diff] [blame] | 73 | |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 74 | return self.handle |
kelvin-onlab | b87672e | 2015-01-16 10:58:34 -0800 | [diff] [blame] | 75 | else: |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 76 | return main.FALSE |