diff --git a/db/Experiment.pm.in b/db/Experiment.pm.in index d9683da4a43297505c04f3009c86789eb74ebe31..5c6869dbb4671de36cdba12d8547a06f72333875 100755 --- a/db/Experiment.pm.in +++ b/db/Experiment.pm.in @@ -3636,6 +3636,7 @@ sub RemovePhysicalState($;$) { my ($self, $purge) = @_; require Lan; + require Interface; # Must be a real reference. return -1 @@ -3670,6 +3671,9 @@ sub RemovePhysicalState($;$) } return -1 if (Lan->DestroyExperimentLans($self, $purge) != 0); + + return -1 + if (Interface::LogicalWire->DeleteLogicalWires($self) != 0); if (@pnodenames || @vnodenames) { my $clause1 = join(" or ", map("node_id='$_'", @pnodenames)) @@ -3712,6 +3716,7 @@ sub BackupPhysicalState($;$$) { my ($self, $directory, $regression) = @_; require Lan; + require Interface; # Must be a real reference. return -1 @@ -3755,6 +3760,9 @@ sub BackupPhysicalState($;$$) return -1 if (Lan->BackupExperimentLans($self, $pstateDir) != 0); + return -1 + if (Interface::LogicalWire->BackupLogicalWires($self, $pstateDir) != 0); + if (@pnodenames || @vnodenames) { my $clause = join(" or ", map("node_id='$_'", (@pnodenames, @vnodenames))); @@ -3823,6 +3831,7 @@ sub RestorePhysicalState($) { my ($self) = @_; require Lan; + require Interface; # Must be a real reference. return -1 @@ -3837,6 +3846,9 @@ sub RestorePhysicalState($) return -1 if (Lan->RestoreExperimentLans($self, $pstateDir) != 0); + return -1 + if (Interface::LogicalWire->RestoreLogicalWires($self, $pstateDir)); + foreach my $table (keys(%physicalTables), "vinterfaces", "interface_settings") { if (-e "$pstateDir/$table") { diff --git a/db/Interface.pm.in b/db/Interface.pm.in index f74689b6fd873de20a0f0212760b4fe58e24635f..1a2bcbc52eaa509f23d9102ba28c2ce5709d7327 100755 --- a/db/Interface.pm.in +++ b/db/Interface.pm.in @@ -1,6 +1,6 @@ #!/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 # @@ -2101,6 +2101,50 @@ sub DeleteLogicalWires($$) 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. diff --git a/protogeni/lib/GeniCM.pm.in b/protogeni/lib/GeniCM.pm.in index 029c681461f90b7b03e4cc2668e56e96290acee0..4aff142f77e614e6f9380016cbddde8378f13b43 100755 --- a/protogeni/lib/GeniCM.pm.in +++ b/protogeni/lib/GeniCM.pm.in @@ -7127,6 +7127,10 @@ sub CleanupDeadSlice($;$) 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.