Changeset 305 for trunk/klask
- Timestamp:
- Oct 11, 2017, 10:19:45 PM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/klask
r304 r305 7 7 use strict; 8 8 use warnings; 9 use version; our $VERSION = qv('0.7. 0');9 use version; our $VERSION = qv('0.7.1'); 10 10 11 11 use Readonly; … … 91 91 'vlan-getname' => \&cmd_vlan_getname, 92 92 'vlan-list' => \&cmd_vlan_list, 93 'host-setlocation' => \&cmd_host_setlocation, 93 94 'rebootsw' => \&cmd_rebootsw, 94 95 ); … … 2187 2188 2188 2189 #--------------------------------------------------------------- 2190 sub cmd_host_setlocation { 2191 @ARGV = @_; 2192 2193 my ($verbose, $force); 2194 GetOptions( 2195 'verbose|v' => \$verbose, 2196 'force|f' => \$force, 2197 ); 2198 2199 my $switch_name = shift @ARGV || q{}; 2200 my $switch_location = shift @ARGV || q{}; 2201 2202 if ($switch_name eq q{} or $switch_location eq q{}) { 2203 die "Usage: klask host-setlocation SWITCH_NAME LOCATION\n"; 2204 } 2205 2206 for my $sw_name (split /,/, $switch_name) { 2207 if (not defined $SWITCH_DB{$sw_name}) { 2208 die "Switch $sw_name must be defined in klask configuration file\n"; 2209 } 2210 2211 my $oid_search = $OID_NUMBER{'sysLocation'}; 2212 2213 my $sw = $SWITCH_DB{$sw_name}; 2214 my ($session, $error) = Net::SNMP->session(snmp_get_rwsession($sw)); 2215 print "$error \n" if $error; 2216 2217 my $result = $session->set_request( 2218 -varbindlist => [$oid_search, OCTET_STRING, $switch_location], 2219 ); 2220 print $session->error()."\n" if $session->error_status(); 2221 2222 $session->close; 2223 } 2224 return; 2225 } 2226 2227 #--------------------------------------------------------------- 2189 2228 # not finish - do not use 2190 2229 sub cmd_port_setvlan {
Note: See TracChangeset
for help on using the changeset viewer.