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,6 +16,8 @@ register_worker({ phase => 'main', driver => 'snmp' }, sub {
|
|||||||
my ($job, $workerconf) = @_;
|
my ($job, $workerconf) = @_;
|
||||||
my ($device, $data) = map {$job->$_} qw/device extra/;
|
my ($device, $data) = map {$job->$_} qw/device extra/;
|
||||||
|
|
||||||
|
# update pseudo devices directly in database
|
||||||
|
unless ($device->is_pseudo()) {
|
||||||
# snmp connect using rw community
|
# snmp connect using rw community
|
||||||
my $snmp = App::Netdisco::Transport::SNMP->writer_for($device)
|
my $snmp = App::Netdisco::Transport::SNMP->writer_for($device)
|
||||||
or return Status->defer("failed to connect to $device to update contact");
|
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) {
|
if ($new_data ne $data) {
|
||||||
return Status->error("verify of contact failed on $device: $new_data");
|
return Status->error("verify of contact failed on $device: $new_data");
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
# update netdisco DB
|
# update netdisco DB
|
||||||
$device->update({contact => $data});
|
$device->update({contact => $data});
|
||||||
|
|||||||
@@ -16,6 +16,8 @@ register_worker({ phase => 'main', driver => 'snmp' }, sub {
|
|||||||
my ($job, $workerconf) = @_;
|
my ($job, $workerconf) = @_;
|
||||||
my ($device, $data) = map {$job->$_} qw/device extra/;
|
my ($device, $data) = map {$job->$_} qw/device extra/;
|
||||||
|
|
||||||
|
# update pseudo devices directly in database
|
||||||
|
unless ($device->is_pseudo()) {
|
||||||
# snmp connect using rw community
|
# snmp connect using rw community
|
||||||
my $snmp = App::Netdisco::Transport::SNMP->writer_for($device)
|
my $snmp = App::Netdisco::Transport::SNMP->writer_for($device)
|
||||||
or return Status->defer("failed to connect to $device to update location");
|
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) {
|
if ($new_data ne $data) {
|
||||||
return Status->error("verify of location failed on $device: $new_data");
|
return Status->error("verify of location failed on $device: $new_data");
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
# update netdisco DB
|
# update netdisco DB
|
||||||
$device->update({location => $data});
|
$device->update({location => $data});
|
||||||
|
|||||||
@@ -24,6 +24,8 @@ register_worker({ phase => 'main', driver => 'snmp' }, sub {
|
|||||||
my ($job, $workerconf) = @_;
|
my ($job, $workerconf) = @_;
|
||||||
my ($device, $pn, $data) = map {$job->$_} qw/device port extra/;
|
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
|
# snmp connect using rw community
|
||||||
my $snmp = App::Netdisco::Transport::SNMP->writer_for($device)
|
my $snmp = App::Netdisco::Transport::SNMP->writer_for($device)
|
||||||
or return Status->defer("failed to connect to $device to update alias");
|
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) {
|
if (ref {} ne ref $state or $state->{$iid} ne $data) {
|
||||||
return Status->error("Verify of [$pn] alias failed on $device");
|
return Status->error("Verify of [$pn] alias failed on $device");
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
# update netdisco DB
|
# update netdisco DB
|
||||||
vars->{'port'}->update({name => $data});
|
vars->{'port'}->update({name => $data});
|
||||||
|
|||||||
Reference in New Issue
Block a user