Avoid macsuck generated SQL bug when cleaning NULL VLAN
This commit is contained in:
@@ -9,6 +9,7 @@
|
|||||||
|
|
||||||
* Update NodeWireless entries which match both MAC and SSID found, only
|
* Update NodeWireless entries which match both MAC and SSID found, only
|
||||||
* Fix SSL-proxy behaviour by using only path+query in links (W. Gould)
|
* Fix SSL-proxy behaviour by using only path+query in links (W. Gould)
|
||||||
|
* Avoid macsuck generated SQL bug when cleaning NULL VLAN (W. Gould)
|
||||||
|
|
||||||
2.017000 - 2013-09-23
|
2.017000 - 2013-09-23
|
||||||
|
|
||||||
|
|||||||
@@ -130,8 +130,7 @@ sub store_node {
|
|||||||
my $nodes = schema('netdisco')->resultset('Node');
|
my $nodes = schema('netdisco')->resultset('Node');
|
||||||
|
|
||||||
# TODO: probably needs changing if we're to support VTP domains
|
# TODO: probably needs changing if we're to support VTP domains
|
||||||
my $old = $nodes->search(
|
my $old = $nodes->search({
|
||||||
{
|
|
||||||
mac => $mac,
|
mac => $mac,
|
||||||
vlan => $vlan,
|
vlan => $vlan,
|
||||||
-bool => 'active',
|
-bool => 'active',
|
||||||
@@ -146,37 +145,33 @@ sub store_node {
|
|||||||
my $old_count = scalar $old->search(undef,
|
my $old_count = scalar $old->search(undef,
|
||||||
{
|
{
|
||||||
columns => [qw/switch vlan port mac/],
|
columns => [qw/switch vlan port mac/],
|
||||||
order_by => [qw/switch vlan port mac/],
|
|
||||||
for => 'update',
|
for => 'update',
|
||||||
})->all;
|
})->all;
|
||||||
|
|
||||||
$old->update({ active => \'false' });
|
$old->update({ active => \'false' });
|
||||||
|
|
||||||
my $new = $nodes->search(
|
my $new = $nodes->search({
|
||||||
{
|
|
||||||
'me.switch' => $ip,
|
'me.switch' => $ip,
|
||||||
'me.port' => $port,
|
'me.port' => $port,
|
||||||
'me.mac' => $mac,
|
'me.mac' => $mac,
|
||||||
},
|
|
||||||
{
|
|
||||||
order_by => [qw/switch vlan port mac/],
|
|
||||||
for => 'update',
|
|
||||||
});
|
});
|
||||||
|
|
||||||
# lock rows
|
|
||||||
$new->search({vlan => [$vlan, 0, undef]})->first;
|
|
||||||
|
|
||||||
# upgrade old schema
|
|
||||||
$new->search({vlan => [0, undef]})->delete();
|
|
||||||
|
|
||||||
# new data
|
# new data
|
||||||
$new->update_or_create({
|
$new->update_or_create(
|
||||||
|
{
|
||||||
vlan => $vlan,
|
vlan => $vlan,
|
||||||
active => \'true',
|
active => \'true',
|
||||||
oui => substr($mac,0,8),
|
oui => substr($mac,0,8),
|
||||||
time_last => \$now,
|
time_last => \$now,
|
||||||
($old_count ? (time_recent => \$now) : ()),
|
($old_count ? (time_recent => \$now) : ()),
|
||||||
});
|
},
|
||||||
|
{ for => 'update' }
|
||||||
|
);
|
||||||
|
|
||||||
|
# upgrade old schema
|
||||||
|
# an entry for this MAC existed in old schema with vlan => null
|
||||||
|
# which now has either vlan number or 0
|
||||||
|
$new->search({vlan => undef})->delete({only_nodes => 1});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -100,6 +100,10 @@ sub delete {
|
|||||||
# avoid letting DBIC delete nodes
|
# avoid letting DBIC delete nodes
|
||||||
return 0E0;
|
return 0E0;
|
||||||
}
|
}
|
||||||
|
elsif (exists $opts->{only_nodes} and $opts->{only_nodes}) {
|
||||||
|
# now let DBIC do its thing
|
||||||
|
return $self->next::method();
|
||||||
|
}
|
||||||
elsif (exists $opts->{keep_nodes} and $opts->{keep_nodes}) {
|
elsif (exists $opts->{keep_nodes} and $opts->{keep_nodes}) {
|
||||||
# avoid letting DBIC delete nodes
|
# avoid letting DBIC delete nodes
|
||||||
return 0E0;
|
return 0E0;
|
||||||
|
|||||||
Reference in New Issue
Block a user