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:
nick n
2019-05-02 14:19:46 +02:00
committed by Oliver Gorwits
parent 3d5525ca77
commit 3ec136aea3
3 changed files with 50 additions and 41 deletions

View File

@@ -16,6 +16,8 @@ register_worker({ phase => 'main', driver => 'snmp' }, sub {
my ($job, $workerconf) = @_;
my ($device, $data) = map {$job->$_} qw/device extra/;
# 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 contact");
@@ -33,6 +35,7 @@ register_worker({ phase => 'main', driver => 'snmp' }, sub {
if ($new_data ne $data) {
return Status->error("verify of contact failed on $device: $new_data");
}
}
# update netdisco DB
$device->update({contact => $data});

View File

@@ -16,6 +16,8 @@ register_worker({ phase => 'main', driver => 'snmp' }, sub {
my ($job, $workerconf) = @_;
my ($device, $data) = map {$job->$_} qw/device extra/;
# 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");
@@ -33,6 +35,7 @@ register_worker({ phase => 'main', driver => 'snmp' }, sub {
if ($new_data ne $data) {
return Status->error("verify of location failed on $device: $new_data");
}
}
# update netdisco DB
$device->update({location => $data});

View File

@@ -24,6 +24,8 @@ register_worker({ phase => 'main', driver => 'snmp' }, sub {
my ($job, $workerconf) = @_;
my ($device, $pn, $data) = map {$job->$_} qw/device port extra/;
# 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 alias");
@@ -44,6 +46,7 @@ register_worker({ phase => 'main', driver => 'snmp' }, sub {
if (ref {} ne ref $state or $state->{$iid} ne $data) {
return Status->error("Verify of [$pn] alias failed on $device");
}
}
# update netdisco DB
vars->{'port'}->update({name => $data});