fix minor issue with locking rows for macsuck update

This commit is contained in:
Oliver Gorwits
2013-10-19 19:07:47 +01:00
parent 4b6e216674
commit 0fcd558c45

View File

@@ -129,6 +129,7 @@ field of the database record. If not provided, it defauls to C<now()>.
sub store_node { sub store_node {
my ($ip, $vlan, $port, $mac, $now) = @_; my ($ip, $vlan, $port, $mac, $now) = @_;
$now ||= 'now()'; $now ||= 'now()';
$vlan ||= 0;
schema('netdisco')->txn_do(sub { schema('netdisco')->txn_do(sub {
my $nodes = schema('netdisco')->resultset('Node'); my $nodes = schema('netdisco')->resultset('Node');
@@ -157,13 +158,13 @@ sub store_node {
my $new = $nodes->search({ my $new = $nodes->search({
'me.switch' => $ip, 'me.switch' => $ip,
'me.port' => $port, 'me.port' => $port,
'me.vlan' => $vlan,
'me.mac' => $mac, 'me.mac' => $mac,
}); });
# new data # new data
$new->update_or_create( $new->update_or_create(
{ {
vlan => $vlan,
active => \'true', active => \'true',
oui => substr($mac,0,8), oui => substr($mac,0,8),
time_last => \$now, time_last => \$now,