Commit e412f7db authored by Leigh B Stoller's avatar Leigh B Stoller

Logical wires need to be part of the experiment back/restore/delete

physical state stuff, since we do call those directly on the Geni
path.
parent 80781e7c
...@@ -3636,6 +3636,7 @@ sub RemovePhysicalState($;$) ...@@ -3636,6 +3636,7 @@ sub RemovePhysicalState($;$)
{ {
my ($self, $purge) = @_; my ($self, $purge) = @_;
require Lan; require Lan;
require Interface;
# Must be a real reference. # Must be a real reference.
return -1 return -1
...@@ -3670,6 +3671,9 @@ sub RemovePhysicalState($;$) ...@@ -3670,6 +3671,9 @@ sub RemovePhysicalState($;$)
} }
return -1 return -1
if (Lan->DestroyExperimentLans($self, $purge) != 0); if (Lan->DestroyExperimentLans($self, $purge) != 0);
return -1
if (Interface::LogicalWire->DeleteLogicalWires($self) != 0);
if (@pnodenames || @vnodenames) { if (@pnodenames || @vnodenames) {
my $clause1 = join(" or ", map("node_id='$_'", @pnodenames)) my $clause1 = join(" or ", map("node_id='$_'", @pnodenames))
...@@ -3712,6 +3716,7 @@ sub BackupPhysicalState($;$$) ...@@ -3712,6 +3716,7 @@ sub BackupPhysicalState($;$$)
{ {
my ($self, $directory, $regression) = @_; my ($self, $directory, $regression) = @_;
require Lan; require Lan;
require Interface;
# Must be a real reference. # Must be a real reference.
return -1 return -1
...@@ -3755,6 +3760,9 @@ sub BackupPhysicalState($;$$) ...@@ -3755,6 +3760,9 @@ sub BackupPhysicalState($;$$)
return -1 return -1
if (Lan->BackupExperimentLans($self, $pstateDir) != 0); if (Lan->BackupExperimentLans($self, $pstateDir) != 0);
return -1
if (Interface::LogicalWire->BackupLogicalWires($self, $pstateDir) != 0);
if (@pnodenames || @vnodenames) { if (@pnodenames || @vnodenames) {
my $clause = join(" or ", map("node_id='$_'", my $clause = join(" or ", map("node_id='$_'",
(@pnodenames, @vnodenames))); (@pnodenames, @vnodenames)));
...@@ -3823,6 +3831,7 @@ sub RestorePhysicalState($) ...@@ -3823,6 +3831,7 @@ sub RestorePhysicalState($)
{ {
my ($self) = @_; my ($self) = @_;
require Lan; require Lan;
require Interface;
# Must be a real reference. # Must be a real reference.
return -1 return -1
...@@ -3837,6 +3846,9 @@ sub RestorePhysicalState($) ...@@ -3837,6 +3846,9 @@ sub RestorePhysicalState($)
return -1 return -1
if (Lan->RestoreExperimentLans($self, $pstateDir) != 0); if (Lan->RestoreExperimentLans($self, $pstateDir) != 0);
return -1
if (Interface::LogicalWire->RestoreLogicalWires($self, $pstateDir));
foreach my $table (keys(%physicalTables), foreach my $table (keys(%physicalTables),
"vinterfaces", "interface_settings") { "vinterfaces", "interface_settings") {
if (-e "$pstateDir/$table") { if (-e "$pstateDir/$table") {
......
#!/usr/bin/perl -wT #!/usr/bin/perl -wT
# #
# Copyright (c) 2005-2017 University of Utah and the Flux Group. # Copyright (c) 2005-2018 University of Utah and the Flux Group.
# #
# {{{EMULAB-LICENSE # {{{EMULAB-LICENSE
# #
...@@ -2101,6 +2101,50 @@ sub DeleteLogicalWires($$) ...@@ -2101,6 +2101,50 @@ sub DeleteLogicalWires($$)
return $errors; return $errors;
} }
#
# Backup all logical wires for an experiment, as for modify.
#
sub BackupLogicalWires($$$)
{
my ($class, $experiment, $pstatedir) = @_;
my $exptidx = $experiment->idx();
my $query_result =
DBQueryWarn("select distinct node_id1,iface1,node_id2,iface2 ".
" from logical_wires as w ".
"left join reserved as r on ".
" w.node_id1=r.node_id or w.node_id2=r.node_id ".
"where r.exptidx='$exptidx'");
return -1
if (!$query_result);
return 0
if (!$query_result->numrows);
DBQueryWarn("select distinct w.* from logical_wires as w ".
"left join reserved as r on ".
" w.node_id1=r.node_id or w.node_id2=r.node_id ".
"where r.exptidx='$exptidx' ".
"into outfile '$pstatedir/logical_wires'")
or return -1;
return 0
}
#
# Restore all logical wires for an experiment, as for modify.
#
sub RestoreLogicalWires($$$)
{
my ($class, $experiment, $pstatedir) = @_;
if (-e "$pstatedir/logical_wires") {
DBQueryWarn("load data infile '$pstatedir/logical_wires' ".
"replace into table logical_wires")
or return -1;
}
return 0;
}
############################################################################## ##############################################################################
# #
# A trivial wrapper class for interface_types. # A trivial wrapper class for interface_types.
......
...@@ -7127,6 +7127,10 @@ sub CleanupDeadSlice($;$) ...@@ -7127,6 +7127,10 @@ sub CleanupDeadSlice($;$)
return -1; return -1;
} }
} }
if (Interface::LogicalWire->DeleteLogicalWires($experiment)) {
print STDERR "Could not delete logical wires and interfaces\n";
return -1;
}
# #
# A firewalled slice gets special treatment. # A firewalled slice gets special treatment.
......
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