From 1f020e07ee0da9bb3a6deacbf690f0ec515d0e49 Mon Sep 17 00:00:00 2001 From: Oliver Gorwits Date: Sat, 1 Oct 2016 16:45:31 +0100 Subject: [PATCH] allow port name to be changed on pseudo devices --- .../Daemon/Worker/Interactive/PortActions.pm | 36 ++++++++++--------- 1 file changed, 19 insertions(+), 17 deletions(-) diff --git a/Netdisco/lib/App/Netdisco/Daemon/Worker/Interactive/PortActions.pm b/Netdisco/lib/App/Netdisco/Daemon/Worker/Interactive/PortActions.pm index 81a0a02c..a5362505 100644 --- a/Netdisco/lib/App/Netdisco/Daemon/Worker/Interactive/PortActions.pm +++ b/Netdisco/lib/App/Netdisco/Daemon/Worker/Interactive/PortActions.pm @@ -71,27 +71,29 @@ sub _set_port_generic { my $port = get_port($ip, $pn) or return job_error("Unknown port name [$pn] on device [$ip]"); - # snmp connect using rw community - my $info = snmp_connect_rw($ip) - or return job_error("Failed to connect to device [$ip] to control port"); + if ($device->vendor ne 'netdisco') { + # snmp connect using rw community + my $info = snmp_connect_rw($ip) + or return job_error("Failed to connect to device [$ip] to control port"); - my $iid = get_iid($info, $port) - or return job_error("Failed to get port ID for [$pn] from [$ip]"); + my $iid = get_iid($info, $port) + or return job_error("Failed to get port ID for [$pn] from [$ip]"); - my $method = 'set_i_'. $slot; - my $rv = $info->$method($data, $iid); + my $method = 'set_i_'. $slot; + my $rv = $info->$method($data, $iid); - if (!defined $rv) { - return job_error(sprintf 'Failed to set [%s] %s to [%s] on [%s]: %s', - $pn, $slot, $data, $ip, ($info->error || '')); - } + if (!defined $rv) { + return job_error(sprintf 'Failed to set [%s] %s to [%s] on [%s]: %s', + $pn, $slot, $data, $ip, ($info->error || '')); + } - # confirm the set happened - $info->clear_cache; - my $check_method = 'i_'. $slot; - my $state = ($info->$check_method($iid) || ''); - if (ref {} ne ref $state or $state->{$iid} ne $data) { - return job_error("Verify of [$pn] $slot failed on [$ip]"); + # confirm the set happened + $info->clear_cache; + my $check_method = 'i_'. $slot; + my $state = ($info->$check_method($iid) || ''); + if (ref {} ne ref $state or $state->{$iid} ne $data) { + return job_error("Verify of [$pn] $slot failed on [$ip]"); + } } # update netdisco DB