Home | Trees | Indices | Help |
|
---|
|
1 #/usr/bin/env python 2 """ 3 Created on 26-Nov-2012 4 5 author:: Raghav Kashyap( raghavkashyap@paxterrasolutions.com ) 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 11 ( at your option ) any later version. 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 19 along with TestON. If not, see <http://www.gnu.org/licenses/>. 20 21 22 23 DPCTL driver class provides the basic functions of DPCTL controller 24 """ 25 import sys 26 from drivers.common.cli.toolsdriver import Tools 27 2830 31 """ 32 DpctlCliDriver driver class provides the basic functions of DPCTL controller 33 """300 301 if __name__ != "__main__": 302 import sys 303 sys.modules[ __name__ ] = DpctlCliDriver() 30435 super( DpctlCliDriver, self ).__init__() 36 self.handle = self 37 self.wrapped = sys.modules[ __name__ ]3840 41 for key in connectargs: 42 vars( self )[ key ] = connectargs[ key ] 43 44 self.name = self.options[ 'name' ] 45 46 self.handle = super( 47 DpctlCliDriver, self ).connect( user_name=self.user_name, 48 ip_address=self.ip_address, 49 port=None, 50 pwd=self.pwd ) 51 if self.handle: 52 main.log.info( "Connected to the host" ) 53 return main.TRUE 54 else: 55 main.log.error( 56 "Connection failed to the host " + 57 self.user_name + 58 "@" + 59 self.ip_address ) 60 return main.FALSE6163 """ 64 addFlow create a new flow entry into flow table using "dpctl" 65 """ 66 args = utilities.parse_args( [ 67 "TCPIP", 68 "TCPPORT", 69 "INPORT", 70 "ACTION", 71 "TIMEOUT" ], 72 **flowParameters ) 73 74 cmd = "dpctl add-flow tcp:" 75 tcpIP = args[ "TCPIP" ] if args[ "TCPIP" ] is not None else "127.0.0.1" 76 tcpPort = args[ "TCPPORT" ] if args[ 77 "TCPPORT" ] is not None else "6634" 78 timeOut = args[ "TIMEOUT" ] if args[ "TIMEOUT" ] is not None else 120 79 cmd = cmd + tcpIP + ":" + tcpPort + " in_port=" + \ 80 str( args[ "INPORT" ] ) + ",idle_timeout=" + str( 81 args[ "TIMEOUT" ] ) + ",actions=" + args[ "ACTION" ] 82 response = self.execute( cmd=cmd, prompt="\~\$", timeout=60 ) 83 if utilities.assert_matches( expect="openflow", actual=response, onpass="Flow Added Successfully", onfail="Adding Flow Failed!!!" ): 84 return main.TRUE 85 else: 86 return main.FALSE8789 """ 90 showFlow dumps the flow entries of flow table using "dpctl" 91 """ 92 args = utilities.parse_args( [ "TCPIP", "TCPPORT" ], **flowParameters ) 93 tcpIP = args[ "TCPIP" ] if args[ "TCPIP" ] is not None else "127.0.0.1" 94 tcpPort = args[ "TCPPORT" ] if args[ 95 "TCPPORT" ] is not None else "6634" 96 command = "dpctl show tcp:" + str( tcpIP ) + ":" + str( tcpPort ) 97 response = self.execute( 98 cmd=command, 99 prompt="get_config_reply", 100 timeout=240 ) 101 if utilities.assert_matches( expect='features_reply', actual=response, onpass="Show flow executed", onfail="Show flow execution Failed" ): 102 main.last_result = main.TRUE 103 return main.TRUE 104 else: 105 main.last_result = main.FALSE 106 return main.FALSE107109 """ 110 dumpFlow gives installed flow information 111 """ 112 args = utilities.parse_args( [ "TCPIP", "TCPPORT" ], **flowParameters ) 113 tcpIP = args[ "TCPIP" ] if args[ "TCPIP" ] is not None else "127.0.0.1" 114 tcpPort = args[ "TCPPORT" ] if args[ 115 "TCPPORT" ] is not None else "6634" 116 command = "dpctl dump-flows tcp:" + str( tcpIP ) + ":" + str( tcpPort ) 117 response = self.execute( cmd=command, prompt="type=", timeout=240 ) 118 if utilities.assert_matches( expect='stats_reply', actual=response, onpass="Dump flow executed", onfail="Dump flow execution Failed" ): 119 main.last_result = main.TRUE 120 return main.TRUE 121 else: 122 main.last_result = main.FALSE 123 return main.FALSE124126 """ 127 dumpTables gives statistics for each of the flow tables used by datapath switch. 128 """ 129 args = utilities.parse_args( [ "TCPIP", "TCPPORT" ], **flowParameters ) 130 tcpIP = args[ "TCPIP" ] if args[ "TCPIP" ] is not None else "127.0.0.1" 131 tcpPort = args[ "TCPPORT" ] if args[ 132 "TCPPORT" ] is not None else "6634" 133 command = "dpctl dump-tables tcp:" + \ 134 str( tcpIP ) + ":" + str( tcpPort ) 135 response = self.execute( cmd=command, prompt="matched", timeout=240 ) 136 if utilities.assert_matches( expect='lookup=3', actual=response, onpass="Dump Tables executed", onfail="Dump Tables execution Failed" ): 137 main.last_result = main.TRUE 138 return main.TRUE 139 else: 140 main.last_result = main.FALSE 141 return main.FALSE142144 """ 145 dumpPorts gives ports information 146 """ 147 args = utilities.parse_args( [ "TCPIP", "TCPPORT" ], **flowParameters ) 148 tcpIP = args[ "TCPIP" ] if args[ "TCPIP" ] is not None else "127.0.0.1" 149 tcpPort = args[ "TCPPORT" ] if args[ 150 "TCPPORT" ] is not None else "6634" 151 command = "dpctl dump-ports tcp:" + str( tcpIP ) + ":" + str( tcpPort ) 152 response = self.execute( cmd=command, prompt="rx pkts", timeout=240 ) 153 if utilities.assert_matches( expect='ports', actual=response, onpass="Dump Ports executed", onfail="Dump Ports execution Failed" ): 154 main.last_result = main.TRUE 155 return main.TRUE 156 else: 157 main.last_result = main.FALSE 158 return main.FALSE159161 """ 162 dumpAggregate gives installed flow information.ggregate statistics for flows in datapath WITCH's tables that match flows. 163 If flows is omitted, the statistics are aggregated across all flows in the datapath's flow tables 164 """ 165 args = utilities.parse_args( 166 [ "TCPIP", "TCPPORT", "FLOW" ], **flowParameters ) 167 tcpIP = args[ "TCPIP" ] if args[ "TCPIP" ] is not None else "127.0.0.1" 168 tcpPort = args[ "TCPPORT" ] if args[ 169 "TCPPORT" ] is not None else "6634" 170 flow = args[ "FLOW" ] if args[ "FLOW" ] is not None else "" 171 command = "dpctl dump-aggregate tcp:" + \ 172 str( tcpIP ) + ":" + str( tcpPort ) + " " + str( flow ) 173 response = self.execute( 174 cmd=command, 175 prompt="flow_count=", 176 timeout=240 ) 177 if utilities.assert_matches( expect='stats_reply', actual=response, onpass="Dump Aggregate executed", onfail="Dump Aggregate execution Failed" ): 178 main.last_result = main.TRUE 179 return main.TRUE 180 else: 181 main.last_result = main.FALSE 182 return main.FALSE183185 """ 186 delFlow Deletes entries from the datapath switch's tables that match flow 187 """ 188 args = utilities.parse_args( 189 [ "TCPIP", "TCPPORT", "FLOW" ], **flowParameters ) 190 tcpIP = args[ "TCPIP" ] if args[ "TCPIP" ] is not None else "127.0.0.1" 191 tcpPort = args[ "TCPPORT" ] if args[ 192 "TCPPORT" ] is not None else "6634" 193 flow = args[ "FLOW" ] if args[ "FLOW" ] is not None else "" 194 command = "dpctl del-flows tcp:" + \ 195 str( tcpIP ) + ":" + str( tcpPort ) + " " + str( flow ) 196 response = self.execute( 197 cmd=command, 198 prompt="ETH-Tutorial", 199 timeout=240 ) 200 if utilities.assert_matches( expect='@', actual=response, onpass="Delete flow executed", onfail="Delete flow execution Failed" ): 201 main.last_result = main.TRUE 202 return main.TRUE 203 else: 204 main.last_result = main.FALSE 205 return main.FALSE206208 """ 209 show gives information on datapath switch including information on its flow tables and ports. 210 """ 211 args = utilities.parse_args( [ "TCPIP", "TCPPORT" ], **flowParameters ) 212 tcpIP = args[ "TCPIP" ] if args[ "TCPIP" ] is not None else "127.0.0.1" 213 tcpPort = args[ "TCPPORT" ] if args[ 214 "TCPPORT" ] is not None else "6634" 215 command = "dpctl show tcp:" + str( tcpIP ) + ":" + str( tcpPort ) 216 response = self.execute( 217 cmd=command, 218 prompt="miss_send_len=", 219 timeout=240 ) 220 if utilities.assert_matches( expect='get_config_reply', actual=response, onpass="show command executed", onfail="show command execution Failed" ): 221 main.last_result = main.TRUE 222 return main.TRUE 223 else: 224 main.last_result = main.FALSE 225 return main.FALSE226228 """ 229 showStatus gives a series of key-value pairs that report the status of switch. 230 If key is specified, only the key-value pairs whose key names begin with key are printed. 231 """ 232 args = utilities.parse_args( 233 [ "TCPIP", "TCPPORT", "KEY" ], **flowParameters ) 234 tcpIP = args[ "TCPIP" ] if args[ "TCPIP" ] is not None else "127.0.0.1" 235 tcpPort = args[ "TCPPORT" ] if args[ 236 "TCPPORT" ] is not None else "6634" 237 key = args[ "KEY" ] if args[ "KEY" ] is not None else "" 238 command = "dpctl status tcp:" + \ 239 str( tcpIP ) + ":" + str( tcpPort ) + " " + key 240 response = self.execute( cmd=command, prompt="(.*)", timeout=240 ) 241 if utilities.assert_matches( expect='(.*)', actual=response, onpass="show command executed", onfail="show command execution Failed" ): 242 main.last_result = main.TRUE 243 return main.TRUE 244 else: 245 main.last_result = main.FALSE 246 return main.FALSE247249 """ 250 desc_set Sets the switch description ( as returned in ofp_desc_stats ) to string ( max length is DESC_STR_LEN ) 251 """ 252 args = utilities.parse_args( [ 253 "TCPIP", 254 "TCPPORT", 255 "STRING" ], 256 **flowParameters ) 257 258 tcpIP = args[ "TCPIP" ] if args[ "TCPIP" ] is not None else "127.0.0.1" 259 tcpPort = args[ "TCPPORT" ] if args[ 260 "TCPPORT" ] is not None else "6634" 261 string = " " + args[ "STRING" ] if args[ 262 "STRING" ] is not None else " DESC_STR_LEN" 263 command = "dpctl desc tcp:" + \ 264 str( tcpIP ) + ":" + str( tcpPort ) + str( string ) 265 response = self.execute( 266 cmd=command, 267 prompt="ETH-Tutorial", 268 timeout=240 ) 269 if utilities.assert_matches( expect='@', actual=response, onpass="desc command executed", onfail="desc command execution Failed" ): 270 main.last_result = main.TRUE 271 return main.TRUE 272 else: 273 main.last_result = main.FALSE 274 return main.FALSE275277 """ 278 dumpDesc Sets the switch description ( as returned in ofp_desc_stats ) to string ( max length is DESC_STR_LEN ) 279 """ 280 args = utilities.parse_args( [ 281 "TCPIP", 282 "TCPPORT", 283 "STRING" ], 284 **flowParameters ) 285 286 tcpIP = args[ "TCPIP" ] if args[ "TCPIP" ] is not None else "127.0.0.1" 287 tcpPort = args[ "TCPPORT" ] if args[ 288 "TCPPORT" ] is not None else "6634" 289 command = "dpctl dump-desc tcp:" + str( tcpIP ) + ":" + str( tcpPort ) 290 response = self.execute( 291 cmd=command, 292 prompt="Serial Num:", 293 timeout=240 ) 294 if utilities.assert_matches( expect='stats_reply', actual=response, onpass="desc command executed", onfail="desc command execution Failed" ): 295 main.last_result = main.TRUE 296 return main.TRUE 297 else: 298 main.last_result = main.FALSE 299 return main.FALSE
Home | Trees | Indices | Help |
|
---|
Generated by Epydoc 3.0.1 on Mon Aug 10 11:12:35 2015 | http://epydoc.sourceforge.net |