@@ -96,6 +96,23 @@ END
return $flags;
}
+sub modify_flag ($$$$) {
+ my ($hd, $ho, $flag, $set) = @_;
+ my $rmq = $dbh_tests->prepare(<<END);
+ DELETE FROM hostflags WHERE hostname=? AND hostflag=?
+END
+ my $addq = $dbh_tests->prepare(<<END);
+ INSERT INTO hostflags (hostname,hostflag) VALUES (?,?)
+END
+
+ modify_host($hd, $ho, sub {
+ $rmq->execute($ho->{Name}, $flag);
+ if ($set) {
+ $addq->execute($ho->{Name}, $flag);
+ }
+ });
+}
+
sub get_arch_platforms ($$$) {
my ($hd, $blessing, $arch, $suite) = @_;
@@ -72,6 +72,13 @@ sub get_flags ($$) { #method
return $flags;
}
+sub modify_flag ($$$$) {
+ my ($hd, $ho, $flag, $set) = @_;
+
+ die
+ "Cannot modify flags in standalone mode for $ho->{Name} $flag set: $set\n";
+}
+
sub get_arch_platforms ($$$) {
my ($hd, $blessing, $arch, $suite) = @_;
@@ -84,7 +84,7 @@ BEGIN {
get_target_property get_host_native_linux_console
hostnamepath hostnamepath_list set_runtime_hostflag
power_state power_cycle power_reboot_attempts
- serial_fetch_logs set_host_property
+ serial_fetch_logs set_host_property modify_host_flag
propname_massage propname_check
hostprop_putative_record
@@ -1411,6 +1411,12 @@ sub hostprop_putative_record ($$$) {
store_runvar("hostprop/$ho->{Ident}/$prop", $val);
}
+sub modify_host_flag ($$$) {
+ my ($ho, $flag, $set) = @_;
+
+ $mhostdb->modify_flag($ho, $flag, $set);
+}
+
sub get_target_property ($$;$);
sub get_target_property ($$;$) {
my ($ho, $prop, $defval) = @_;
Add a generic function to perform database changes related to a host flag and add a wrapper to TestSupport. Signed-off-by: Roger Pau Monné <roger.pau@citrix.com> --- Changes since v4: - Move addition of hostflag_putative_record to a different patch. - Introduce a single helper in TestSupport: modify_host_flag. Changes since v3: - Introduce modify_flag instead of {set/remove}_flag. - Introduce a generic modify_host helper. - Split from patch 1. --- Requested on IRC: 17:08:58 Diziet royger: I think your ts-examine-hostprops-save hunk in 2/ belongs in 1/ ? (Or in a separate 1.5/ along with hostflag_putative_record.) --- Osstest/HostDB/Executive.pm | 17 +++++++++++++++++ Osstest/HostDB/Static.pm | 7 +++++++ Osstest/TestSupport.pm | 8 +++++++- 3 files changed, 31 insertions(+), 1 deletion(-)