blob: 44951aa0702fe3cde1ff7d2942e38f9ef9ab42ab [file] [log] [blame]
adminbae64d82013-08-01 10:50:15 -07001#!/usr/bin/env python
kelvin-onlab66bccb72015-01-16 14:52:12 -08002"""
adminbae64d82013-08-01 10:50:15 -07003Created on 12-Feb-2013
4
kelvin-onlab66bccb72015-01-16 14:52:12 -08005author:: Anil Kumar ( anilkumar.s@paxterrasolutions.com )
adminbae64d82013-08-01 10:50:15 -07006
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-onlab66bccb72015-01-16 14:52:12 -080011 ( at your option ) any later version.
adminbae64d82013-08-01 10:50:15 -070012
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-onlab66bccb72015-01-16 14:52:12 -080019 along with TestON. If not, see <http://www.gnu.org/licenses/>.
adminbae64d82013-08-01 10:50:15 -070020
21
22RemoteVMDriver is the basic driver which will handle the Mininet functions
kelvin-onlab66bccb72015-01-16 14:52:12 -080023"""
adminbae64d82013-08-01 10:50:15 -070024import pexpect
25import struct
26import fcntl
27import os
28import signal
29import re
30import sys
31import time
32
kelvin-onlab66bccb72015-01-16 14:52:12 -080033sys.path.append( "../" )
adminbae64d82013-08-01 10:50:15 -070034
35from drivers.common.cli.remotetestbeddriver import RemoteTestBedDriver
36
adminbae64d82013-08-01 10:50:15 -070037
kelvin-onlab66bccb72015-01-16 14:52:12 -080038class RemotePoxDriver( RemoteTestBedDriver ):
39
40 """
41 RemoteVMDriver is the basic driver which will handle the Mininet functions
42 """
43 def __init__( self ):
44 super( RemoteTestBedDriver, self ).__init__()
45
46 def connect( self, **connectargs ):
47 for key in connectargs:
48 vars( self )[ key ] = connectargs[ key ]
49
50 self.name = self.options[ 'name' ]
51
52 self.handle = super(
53 RemotePoxDriver,
54 self ).connect(
55 user_name=self.user_name,
56 ip_address=self.ip_address,
57 port=self.port,
58 pwd=self.pwd )
59 if self.handle:
60 main.log.info( self.name + " connected successfully " )
61
62 self.execute(
63 cmd="cd " +
64 self.options[ 'pox_lib_location' ],
65 prompt="/pox\$",
66 timeout=120 )
67 self.execute(
68 cmd='./pox.py samples.of_tutorial',
69 prompt="DEBUG:",
70 timeout=120 )
adminbae64d82013-08-01 10:50:15 -070071 return self.handle
72 return main.TRUE
kelvin-onlab66bccb72015-01-16 14:52:12 -080073
74 def disconnect( self, handle ):
adminbae64d82013-08-01 10:50:15 -070075 if self.handle:
kelvin-onlab66bccb72015-01-16 14:52:12 -080076 self.execute( cmd="exit()", prompt="/pox\$", timeout=120 )
77 else:
78 main.log.error( "Connection failed to the host" )