1 #
2 # CDDL HEADER START
3 #
4 # The contents of this file are subject to the terms of the
5 # Common Development and Distribution License (the "License").
6 # You may not use this file except in compliance with the License.
7 #
8 # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 # or http://www.opensolaris.org/os/licensing.
10 # See the License for the specific language governing permissions
11 # and limitations under the License.
12 #
13 # When distributing Covered Code, include this CDDL HEADER in each
14 # file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 # If applicable, add the following below this CDDL HEADER, with the
16 # fields enclosed by brackets "[]" replaced with your own identifying
17 # information: Portions Copyright [yyyy] [name of copyright owner]
18 #
19 # CDDL HEADER END
20 #
21
22 #
23 # Copyright 2009 Sun Microsystems, Inc. All rights reserved.
24 # Use is subject to license terms.
25 #
26 # Topspin Communications Systems, Inc.
27 #
28
29 #
30 # NAME br_port_offline.exp
31 #
32 # DESCRIPTION
33 # The Expect script will send commands to the Infiniband
34 # switch to offline a given port.
35 #
36
37 set force_conservative 0 ;# set to 1 to force conservative mode even if
38 ;# script wasn't run conservatively originally
39 if {$force_conservative} {
40 set send_slow {1 .1}
41 proc send {ignore arg} {
42 sleep .1
43 exp_send -s -- $arg
44 }
45 }
46
47 set timeout -1
48 set switch_ip [lindex ${argv} 0]
49 set switch_adm [lindex ${argv} 1]
50 set switch_pass [lindex ${argv} 2]
51 set port_num [lindex ${argv} 3]
52 spawn telnet $switch_ip
53 expect {
54 "Escape*" { exp_continue }
55 "*Login: " {
56 send -- "$switch_adm\r"
57 exp_continue
58 }
59 "Password: " {
60 send -- "$switch_pass\r"
61 }
62 }
63
64 expect "Topspin*>"
65 send -- "enable\r"
66 expect "Topspin*#";
67 send -- "config\r"
68 expect "Topspin*#";
69 send -- "int ib $port_num\r"
70 expect "Topspin*#";
71 send -- "shutdown\r"
72 expect "Topspin*#";
73 send -- "exit all\r"
74 expect "Topspin*>"
75 send -- "exit\r"
76 expect eof
77 # Exiting out of Expect script.