allow setting some speudo device info (#572)
* allow port name to be changed on pseudo devices, was once added in commit 1f020e07ee
* also allow this for location and contact
This commit is contained in:
@@ -16,22 +16,25 @@ register_worker({ phase => 'main', driver => 'snmp' }, sub {
|
||||
my ($job, $workerconf) = @_;
|
||||
my ($device, $data) = map {$job->$_} qw/device extra/;
|
||||
|
||||
# snmp connect using rw community
|
||||
my $snmp = App::Netdisco::Transport::SNMP->writer_for($device)
|
||||
or return Status->defer("failed to connect to $device to update location");
|
||||
# update pseudo devices directly in database
|
||||
unless ($device->is_pseudo()) {
|
||||
# snmp connect using rw community
|
||||
my $snmp = App::Netdisco::Transport::SNMP->writer_for($device)
|
||||
or return Status->defer("failed to connect to $device to update location");
|
||||
|
||||
my $rv = $snmp->set_location($data);
|
||||
my $rv = $snmp->set_location($data);
|
||||
|
||||
if (!defined $rv) {
|
||||
return Status->error(
|
||||
"failed to set location on $device: ". ($snmp->error || ''));
|
||||
}
|
||||
if (!defined $rv) {
|
||||
return Status->error(
|
||||
"failed to set location on $device: ". ($snmp->error || ''));
|
||||
}
|
||||
|
||||
# confirm the set happened
|
||||
$snmp->clear_cache;
|
||||
my $new_data = ($snmp->location || '');
|
||||
if ($new_data ne $data) {
|
||||
return Status->error("verify of location failed on $device: $new_data");
|
||||
# confirm the set happened
|
||||
$snmp->clear_cache;
|
||||
my $new_data = ($snmp->location || '');
|
||||
if ($new_data ne $data) {
|
||||
return Status->error("verify of location failed on $device: $new_data");
|
||||
}
|
||||
}
|
||||
|
||||
# update netdisco DB
|
||||
|
||||
Reference in New Issue
Block a user