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