admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 1 | #!/usr/bin/env python |
kelvin-onlab | 66bccb7 | 2015-01-16 14:52:12 -0800 | [diff] [blame] | 2 | """ |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 3 | Created on 12-Feb-2013 |
| 4 | |
kelvin-onlab | 66bccb7 | 2015-01-16 14:52:12 -0800 | [diff] [blame] | 5 | author:: Anil Kumar ( anilkumar.s@paxterrasolutions.com ) |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 6 | |
| 7 | |
| 8 | TestON is free software: you can redistribute it and/or modify |
| 9 | it under the terms of the GNU General Public License as published by |
| 10 | the Free Software Foundation, either version 2 of the License, or |
kelvin-onlab | 66bccb7 | 2015-01-16 14:52:12 -0800 | [diff] [blame] | 11 | ( at your option ) any later version. |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 12 | |
| 13 | TestON is distributed in the hope that it will be useful, |
| 14 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 16 | GNU General Public License for more details. |
| 17 | |
| 18 | You should have received a copy of the GNU General Public License |
kelvin-onlab | 66bccb7 | 2015-01-16 14:52:12 -0800 | [diff] [blame] | 19 | along with TestON. If not, see <http://www.gnu.org/licenses/>. |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 20 | |
| 21 | |
| 22 | RemoteVMDriver is the basic driver which will handle the Mininet functions |
kelvin-onlab | 66bccb7 | 2015-01-16 14:52:12 -0800 | [diff] [blame] | 23 | """ |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 24 | from drivers.common.cli.remotetestbeddriver import RemoteTestBedDriver |
| 25 | |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 26 | |
kelvin-onlab | 66bccb7 | 2015-01-16 14:52:12 -0800 | [diff] [blame] | 27 | class RemotePoxDriver( RemoteTestBedDriver ): |
| 28 | |
| 29 | """ |
| 30 | RemoteVMDriver is the basic driver which will handle the Mininet functions |
| 31 | """ |
| 32 | def __init__( self ): |
| 33 | super( RemoteTestBedDriver, self ).__init__() |
| 34 | |
| 35 | def connect( self, **connectargs ): |
| 36 | for key in connectargs: |
| 37 | vars( self )[ key ] = connectargs[ key ] |
| 38 | |
| 39 | self.name = self.options[ 'name' ] |
| 40 | |
| 41 | self.handle = super( |
| 42 | RemotePoxDriver, |
| 43 | self ).connect( |
| 44 | user_name=self.user_name, |
| 45 | ip_address=self.ip_address, |
| 46 | port=self.port, |
| 47 | pwd=self.pwd ) |
| 48 | if self.handle: |
| 49 | main.log.info( self.name + " connected successfully " ) |
| 50 | |
| 51 | self.execute( |
| 52 | cmd="cd " + |
| 53 | self.options[ 'pox_lib_location' ], |
| 54 | prompt="/pox\$", |
| 55 | timeout=120 ) |
| 56 | self.execute( |
| 57 | cmd='./pox.py samples.of_tutorial', |
| 58 | prompt="DEBUG:", |
| 59 | timeout=120 ) |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 60 | return self.handle |
| 61 | return main.TRUE |
kelvin-onlab | 66bccb7 | 2015-01-16 14:52:12 -0800 | [diff] [blame] | 62 | |
| 63 | def disconnect( self, handle ): |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 64 | if self.handle: |
kelvin-onlab | 66bccb7 | 2015-01-16 14:52:12 -0800 | [diff] [blame] | 65 | self.execute( cmd="exit()", prompt="/pox\$", timeout=120 ) |
| 66 | else: |
| 67 | main.log.error( "Connection failed to the host" ) |