Commit c14472f9 authored by Leigh Stoller's avatar Leigh Stoller

Fixes for DeleteNodes():

* When deleting a lan can there is only one interface left, need to go
  back and delete the interface from the last node. Else its a malformed
  rpsec (which we have been ignoring), but it was passing through to the
  manifest, which made it a malformed manifest.

* But a later bug was causing that now removed interface to sneak back
  in via the old copy of the manifest in the database.

* Also fix a bug that was causing multiple versions of the site_info
  element to get inserted during an update.

* Remove code that updates the manifest in the DB, use the existing
  Aggregate->UpdateManifest() method instead.
parent e234b170
......@@ -5044,6 +5044,8 @@ sub SliverWorkAux($)
#
$inaggregate = 1;
$sliver = $nodemap{$virtual_id};
# Replace the existing rspec/manifest
$sliver->UpdateRspec($ref);
}
else {
$sliver = GeniSliver::Node->Create($slice, $owner, $node, $ref);
......@@ -5686,7 +5688,8 @@ sub SliverWorkAux($)
goto bad;
}
my $siteinfo = GeniXML::FindFirst("n:site_info", $manifest);
my $siteinfo = GeniXML::FindFirstNS("n:site_info", $manifest,
$GeniXML::SITEINFO_NS);
if (defined($siteinfo)) {
# Clean old location.
$manifest->removeChild($siteinfo);
......@@ -5726,11 +5729,9 @@ sub SliverWorkAux($)
print STDERR "GeniUsage->NewAggregate($aggregate) failed\n";
}
# This should move someplace else?
$aggregate->UpdateManifest($manifest);
# Need this below.
my $manifest_string = GeniXML::Serialize($manifest);
DBQueryWarn("replace into geni_manifests set ".
" manifest=". DBQuoteSpecial($manifest_string) . ", " .
" idx=NULL, slice_uuid='$slice_uuid', created=now()");
#
# Cache the credential for subsequent requests. See GetSliver().
......
......@@ -2398,9 +2398,10 @@ sub DeleteNodes($)
#
# Suck out nodes. Also figure out what nodes have to be removed
# from which lans.
# from which lans, and which ifaces from which nodes.
#
my %ifacestoremovefromlans = ();
my %ifacestoremovefromlans = ();
my %ifacestoremovefromnodes = ();
foreach my $noderef (GeniXML::FindNodes("n:node",
$manifest)->get_nodelist()) {
......@@ -2438,9 +2439,29 @@ sub DeleteNodes($)
my @ifaces = GeniXML::FindNodes("n:interface_ref",
$linkref)->get_nodelist();
if (@ifaces <= 1) {
# Need to find this last iface in the node and delete it
# since otherwise the rspec would be malformed.
foreach my $iref (@ifaces) {
my $client_id = GeniXML::GetInterfaceId($iref);
$ifacestoremovefromnodes{$client_id} = $client_id;
}
$manifest->removeChild($linkref);
}
}
# Purge the ifaces from nodes for links left with just one iface.
if (keys(%ifacestoremovefromnodes)) {
foreach my $noderef (GeniXML::FindNodes("n:node",
$manifest)->get_nodelist()) {
foreach my $iref (GeniXML::FindNodes("n:interface",
$noderef)->get_nodelist()) {
my $client_id = GeniXML::GetInterfaceId($iref);
if (exists($ifacestoremovefromnodes{$client_id})) {
$noderef->removeChild($iref);
}
}
}
}
my $rspecstr = GeniXML::Serialize($manifest);
print STDERR "$rspecstr\n";
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment