bug fixes for port up/down setting

This commit is contained in:
Oliver Gorwits
2012-12-09 19:07:35 +00:00
parent a046fabe9d
commit 704f0fc8e9
3 changed files with 8 additions and 8 deletions

View File

@@ -7,7 +7,7 @@ use Netdisco::Daemon::Actions::Util ':all';
use namespace::clean; use namespace::clean;
use Moo::Role; use Moo::Role;
sub portcontrol { sub set_portcontrol {
my ($self, $job) = @_; my ($self, $job) = @_;
my $ip = $job->device; my $ip = $job->device;
@@ -25,7 +25,7 @@ sub portcontrol {
my $info = snmp_connect($ip) my $info = snmp_connect($ip)
or return error("Failed to connect to device [$ip] to control port"); or return error("Failed to connect to device [$ip] to control port");
my $iid = get_iid($port) my $iid = get_iid($info, $port)
or return error("Failed to get port ID for [$pn] from [$ip]"); or return error("Failed to get port ID for [$pn] from [$ip]");
my $rv = $info->set_i_up_admin(lc($dir), $iid); my $rv = $info->set_i_up_admin(lc($dir), $iid);
@@ -36,14 +36,14 @@ sub portcontrol {
# confirm the set happened # confirm the set happened
$info->clear_cache; $info->clear_cache;
my $state = ($info->i_up_admin($iid) || ''); my $state = ($info->i_up_admin($iid) || '');
if ($state ne $dir) { if (ref {} ne ref $state or $state->{$iid} ne $dir) {
return error("Verify of [$pn] port status failed on [$ip]: $state"); return error("Verify of [$pn] port status failed on [$ip]");
} }
# update netdisco DB # update netdisco DB
$port->device->update({up_admin => $state}); $port->update({up_admin => $dir});
return done("Updated [$pn] port status on [$ip] to [$state]"); return done("Updated [$pn] port status on [$ip] to [$dir]");
} }
1; 1;

View File

@@ -55,7 +55,7 @@ sub get_port {
$device = get_device($device) $device = get_device($device)
if not ref $device; if not ref $device;
my $port = schema('Netdisco')->resultset('DevicePort') my $port = schema('netdisco')->resultset('DevicePort')
->find({ip => $device->ip, port => $portname}); ->find({ip => $device->ip, port => $portname});
return $port; return $port;

View File

@@ -53,7 +53,7 @@ sub port_reconfig_check {
my $ip = $port->ip; my $ip = $port->ip;
my $name = $port->port; my $name = $port->port;
my $has_phone = has_phone($port); my $has_phone = port_has_phone($port);
my $is_vlan = is_vlan_interface($port); my $is_vlan = is_vlan_interface($port);
# uplink check # uplink check